Search in sources :

Example 6 with EntityCreative

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;
}
Also used : Entity(io.xol.chunkstories.api.entity.Entity) Player(io.xol.chunkstories.api.player.Player) EntityCreative(io.xol.chunkstories.api.entity.interfaces.EntityCreative)

Aggregations

EntityCreative (io.xol.chunkstories.api.entity.interfaces.EntityCreative)6 Location (io.xol.chunkstories.api.Location)4 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)4 Player (io.xol.chunkstories.api.player.Player)3 Entity (io.xol.chunkstories.api.entity.Entity)2 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)2 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)2 LocalPlayer (io.xol.chunkstories.api.client.LocalPlayer)1 Controller (io.xol.chunkstories.api.entity.Controller)1 HitBox (io.xol.chunkstories.api.entity.EntityLiving.HitBox)1 EntityComponentRotation (io.xol.chunkstories.api.entity.components.EntityComponentRotation)1 EntityWithSelectedItem (io.xol.chunkstories.api.entity.interfaces.EntityWithSelectedItem)1 EntityWorldModifier (io.xol.chunkstories.api.entity.interfaces.EntityWorldModifier)1 EventItemDroppedToWorld (io.xol.chunkstories.api.events.item.EventItemDroppedToWorld)1 PlayerMoveItemEvent (io.xol.chunkstories.api.events.player.PlayerMoveItemEvent)1 PlayerVoxelModificationEvent (io.xol.chunkstories.api.events.player.voxel.PlayerVoxelModificationEvent)1 CameraSetupEvent (io.xol.chunkstories.api.events.rendering.CameraSetupEvent)1 NullItemException (io.xol.chunkstories.api.exceptions.NullItemException)1 UndefinedItemTypeException (io.xol.chunkstories.api.exceptions.UndefinedItemTypeException)1 WorldException (io.xol.chunkstories.api.exceptions.world.WorldException)1