use of net.blay09.mods.waystones.network.message.MessageRemoveWaystone in project Waystones by blay09.
the class GuiWaystoneList method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
if (button == btnNextPage) {
pageOffset++;
updateList();
} else if (button == btnPrevPage) {
pageOffset--;
updateList();
} else if (button instanceof GuiButtonWaystoneEntry) {
NetworkHandler.channel.sendToServer(new MessageTeleportToWaystone(((GuiButtonWaystoneEntry) button).getWaystone(), warpMode, hand, fromWaystone));
mc.displayGuiScreen(null);
} else if (button instanceof GuiButtonSortWaystone) {
WaystoneEntry waystoneEntry = ((GuiButtonSortWaystone) button).getWaystone();
int index = ArrayUtils.indexOf(entries, waystoneEntry);
int sortDir = ((GuiButtonSortWaystone) button).getSortDir();
int otherIndex = index + sortDir;
if (index == -1 || otherIndex < 0 || otherIndex >= entries.length) {
return;
}
WaystoneEntry swap = entries[index];
entries[index] = entries[otherIndex];
entries[otherIndex] = swap;
NetworkHandler.channel.sendToServer(new MessageSortWaystone(index, otherIndex));
updateList();
} else if (button instanceof GuiButtonRemoveWaystone) {
WaystoneEntry waystoneEntry = ((GuiButtonRemoveWaystone) button).getWaystone();
int index = ArrayUtils.indexOf(entries, waystoneEntry);
entries = ArrayUtils.remove(entries, index);
NetworkHandler.channel.sendToServer(new MessageRemoveWaystone(index));
updateList();
}
}
use of net.blay09.mods.waystones.network.message.MessageRemoveWaystone in project Waystones by blay09.
the class HandlerRemoveWaystone method onMessage.
@Override
@Nullable
public IMessage onMessage(final MessageRemoveWaystone message, final MessageContext ctx) {
NetworkHandler.getThreadListener(ctx).addScheduledTask(() -> {
PlayerWaystoneData waystoneData = PlayerWaystoneData.fromPlayer(ctx.getServerHandler().player);
WaystoneEntry[] entries = waystoneData.getWaystones();
int index = message.getIndex();
if (index < 0 || index >= entries.length) {
return;
}
WaystoneManager.removePlayerWaystone(ctx.getServerHandler().player, entries[index]);
WaystoneManager.sendPlayerWaystones(ctx.getServerHandler().player);
});
return null;
}
Aggregations