import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
/**
* Simple example of detecting if a player is in creative mode
* when they break a block.
*
* @author Mark Hughes <m@rkhugh.es>
*/
public class Example {
// REMEMBER! Always use @Root not @First for a player-specific event!
@Listener
public void onBreakBlock(ChangeBlockEvent.Break event, @Root Player player) {
// Ignore players in creative mode
if (player.gameMode().get() == GameModes.CREATIVE) return;
// do your thang here
}
}
Simple example of detecting if a player is in creative mode when they break a block.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.