I’m a french amator developper and I would use Sponge to developp an HungerGames plugin. I’m now working on a command to freeze players but I’m wondering how I can do that. I was thinking about use a /freeze command that send a packet to all players to interact with a client mod. Have you a better idea ?
@Listener
public void onPlayerMove(DisplaceEntityEvent.TargetPlayer e){
if(plugin.getIsFreezingPlayers() == Boolean.TRUE){
e.getTargetEntity().sendMessage(Texts.of(TextColors.BLUE, "You can't move: you have been freeze"));
e.setCancelled(true);
}
}
But it doesn’t work… Indeed, the player don’t receive the message “You can’t move: you have been freeze” and can move by the same time. What did I do wrong ?
Thank for answer. I’ll try this change.
And yes, it is register in the main class:
@Listener
public void onInit(GameInitializationEvent e){
game.getCommandDispatcher().register(this, new FreezePlayersCommand(game.getServer(), this), "freeze", "gele");
game.getEventManager().registerListeners(this, new FreezePlayerEvent(this));
}
Thanks a lot
EDIT : When I was changing, I found the real error: the /freeze command changed the isFreezingPlayers value to false, which is not right. It should change to true.
Thank for your answer. I will change this, I don’t know why I did that. But, I don’t think the gamemodes API is implemented… They are all equal to “null”…
Has your problem been solved? If so, do you mind marking this thread as solved? Also, if you’re having issues with the gamemodes API please create another thread with all the relevant information so community members can help you out
Did you check that at runtime?
Please notice that variables equal to null do not mean that they are not implemented. Most of them are null in the API but not null at runtime!