Untitled
unknown
java
a year ago
2.9 kB
8
Indexable
@Override public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) { if (!channel.equals("rapidchallenge:channel")) { return; } ByteArrayDataInput in = ByteStreams.newDataInput(message); String input = in.readUTF(); String[] reading = input.split(" "); System.out.println(input); String commandString = reading[0]; BungeeCommand command = BungeeCommand.valueOf(commandString); switch (command) { case RECEIVE_START_CHALLENGE -> { if (reading.length > 2) { String uuid = reading[1]; String challengeName = reading[2]; main.getChallengeManager().StartChallenge(uuid, challengeName); } else if (reading.length > 1) { String uuid = reading[1]; main.getChallengeManager().StartChallenge(uuid); } } case RECEIVE_STOP_CHALLENGE -> main.getChallengeManager().StopChallenge(); case SEND_WIN_MESSAGE -> { if (reading.length > 1) { String uuidString = reading[1]; UUID uuid = UUID.fromString(uuidString); OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); Messenger.sendChallengeWinMessage(offlinePlayer.getName(), new ArrayList<>(Bukkit.getOnlinePlayers())); main.getChallengeManager().getActiveChallenge().AddWinner(offlinePlayer); } } } } public void StartChallenge(Player player, String arg) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); if (arg == null) { out.writeUTF(String.valueOf(BungeeCommand.SEND_START_CHALLENGE)); } else { out.writeUTF(BungeeCommand.SEND_START_CHALLENGE + " " + arg); } SendData(player, out); } public void StopChallenge(Player player) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(String.valueOf(BungeeCommand.SEND_STOP_CHALLENGE)); SendData(player, out); } public void SendWinMessageCommand(Player player) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(BungeeCommand.SEND_WIN_MESSAGE + " " + player.getUniqueId()); SendData(player, out); } private void SendData(Player player, ByteArrayDataOutput out) { player.sendPluginMessage(main, "rapidchallenge:channel", out.toByteArray()); }
Editor is loading...
Leave a Comment