04.01.2016, 22:18
Код:
package dev.acesamp; public class Test extends Gamemode { protected static final DialogId dialogSpawn = DialogId.create(); protected void onEnable() throws Throwable { EventManager event = getEventManager(); event.registerHandler(PlayerSpawnEvent.class, (e) -> { System.out.println("Message");//This message appears two times at the same second Callbacks.onPlayerSpawn(e.getPlayer()); }); event.registerHandler(PlayerRequestSpawnEvent.class, (e) -> { Callbacks.onPlayerRequestSpawn(e.getPlayer()); e.disallow(); });} evento.registerHandler(DialogResponseEvent.class, (e) -> { Callbacks.onDialogResponse(e.getDialog(), e.getPlayer(), e.getDialogResponse(), e.getListitem(), e.getInputText()); }); } @Override protected void onDisable() throws Throwable { } }
Код:
package dev.acesamp; public class Callbacks extends Test{ public static void onPlayerSpawn(Player player){ } public static void onPlayerRequestSpawn(Player player){ Server.showSpawnMenu(player); } } public static int onDialogResponse(DialogId dialog, Player player, int response, int listitem, String inputtext){ if(dialog == dialogSpawn){ player.spawn(); } } }
Код:
package dev.acesamp; public class Server extends Test{ public static void showSpawnMenu(Player player){ dialogSpawn.show(player, DialogStyle.LIST, "Title", "Option1", "Choose", ""); } }