- 28
- 0
Good morning. I want to create a "Queue system". So I write to get some hints about it. For example, suppose that players A and B exist, if player A executes the command "/matching join", it joins a queue; if player B executes the same command, B also joins the queue. If Player A and B are in the queue, I want the server to run "/pokebattle <PlayerA> <PlayerB>".
That way, when the command is executed, change the rating_on boolean to true, make sure the player is a bronze player, and add the player to the "B MATCHING PLAYER" list. But I question because this method is a mess.
What should I do? If you have code for a system like this, please let me know.
That way, when the command is executed, change the rating_on boolean to true, make sure the player is a bronze player, and add the player to the "B MATCHING PLAYER" list. But I question because this method is a mess.
What should I do? If you have code for a system like this, please let me know.
Java:
@SubscribeEvent
public void onLivingUpdateEvent(LivingUpdateEvent event) {
if (event.getEntity() instanceof EntityPlayer) {
if(CommandPokeBattle.rating_on == true) {
try {
if(bronze_player.contains(player)) {
B_MATCHING_PLAYER.add(player);
EntityPlayer player1 = B_MATCHING_PLAYER.get(1);
EntityPlayer player2 = B_MATCHING_PLAYER.get(2);
if(player1 != null && player2 != null) {
player.getServer().commandManager.executeCommand(player.getCommandSenderEntity(), "pokebattle " + player1.getName() + " " + player2.getName());
B_MATCHING_PLAYER.remove(player1);
B_MATCHING_PLAYER.remove(player2);
CommandPokeBattle.rating_on = false;
}
}
}
}
}
}