use of io.xol.chunkstories.api.entity.interfaces.EntityCreative in project chunkstories by Hugobros3.
the class CreativeCommand method handleCommand.
@Override
public boolean handleCommand(CommandEmitter emitter, Command command, String[] arguments) {
if (!(emitter instanceof Player)) {
emitter.sendMessage("You need to be a player to use this command.");
return true;
}
Player player = (Player) emitter;
if (!emitter.hasPermission("self.toggleCreative")) {
emitter.sendMessage("You don't have the permission.");
return true;
}
Entity controlledEntity = player.getControlledEntity();
if (controlledEntity != null && controlledEntity instanceof EntityCreative) {
boolean state = ((EntityCreative) controlledEntity).getCreativeModeComponent().get();
state = !state;
player.sendMessage("Creative mode set to: " + state);
((EntityCreative) controlledEntity).getCreativeModeComponent().set(state);
return true;
}
emitter.sendMessage("This action doesn't apply to your current entity.");
return true;
}
Aggregations