use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class LogCommands method tool.
@Alias(value = "lt")
@Command(desc = "Gives you an item to check logs with.\n" + "no log-type: Shows everything\n" + "chest: Shows chest-interactions only\n" + "player: Shows player-interacions only\n" + "kills: Shows kill-interactions only\n" + "block: Shows block-changes only")
@Restricted(value = User.class, msg = "Why don't you check in your log-file? You won't need a block there!")
public void tool(User context, @Optional @Label("log-type") String logType) {
// TODO tabcompleter for logToolTypes (waiting for CE-389)
Material blockMaterial = this.matchType(logType, false);
if (blockMaterial == null) {
context.sendTranslated(NEGATIVE, "{input} is not a valid log-type. Use chest, container, player, block or kills instead!", logType);
return;
}
this.findLogTool(context, blockMaterial);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class LogCommands method block.
@Alias(value = "lb")
@Command(desc = "Gives you a block to check logs with." + "no log-type: Shows everything\n" + "chest: Shows chest-interactions only\n" + "player: Shows player-interacions only\n" + "kills: Shows kill-interactions only\n" + "block: Shows block-changes only")
@Restricted(value = User.class, msg = "Why don't you check in your log-file? You won't need a block there!")
public void block(User context, @Optional @Label("log-type") String logType) {
// TODO tabcompleter for logBlockTypes (waiting for CE-389)
Material blockMaterial = this.matchType(logType, true);
if (blockMaterial == null) {
context.sendTranslated(NEGATIVE, "{input} is not a valid log-type. Use chest, container, player, block or kills instead!", logType);
return;
}
this.findLogTool(context, blockMaterial);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class PlayerCommands method explosion.
@Command(desc = "Creates an explosion")
public void explosion(CommandSource context, @Optional Integer damage, @Named({ "player", "p" }) Player player, @Flag boolean unsafe, @Flag boolean fire, @Flag boolean blockDamage, @Flag boolean playerDamage) {
damage = damage == null ? 1 : damage;
if (damage > this.module.getConfig().command.explosion.power) {
i18n.send(context, NEGATIVE, "The power of the explosion shouldn't be greater than {integer}", this.module.getConfig().command.explosion.power);
return;
}
Location<World> loc;
if (player != null) {
if (!context.equals(player)) {
if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_OTHER.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to specify a player.");
return;
}
}
loc = player.getLocation();
} else {
if (!(context instanceof Player)) {
i18n.send(context, NEGATIVE, "This command can only be used by a player!");
return;
}
java.util.Optional<BlockRayHit<World>> end = BlockRay.from(((Player) context)).distanceLimit(module.getConfig().command.explosion.distance).stopFilter(BlockRay.onlyAirFilter()).build().end();
if (end.isPresent()) {
loc = end.get().getLocation();
} else {
throw new IllegalStateException();
}
}
if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_BLOCK_DAMAGE.getId()) && (blockDamage || unsafe)) {
i18n.send(context, NEGATIVE, "You are not allowed to break blocks");
return;
}
if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_FIRE.getId()) && (fire || unsafe)) {
i18n.send(context, NEGATIVE, "You are not allowed to set fireticks");
return;
}
if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_PLAYER_DAMAGE.getId()) && (playerDamage || unsafe)) {
i18n.send(context, NEGATIVE, "You are not allowed to damage another player");
return;
}
Explosion explosion = Explosion.builder().location(loc).canCauseFire(fire || unsafe).shouldDamageEntities(playerDamage || unsafe).shouldBreakBlocks(blockDamage || unsafe).build();
Sponge.getCauseStackManager().pushCause(context);
loc.getExtent().triggerExplosion(explosion);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class PlayerCommands method hat.
@Command(desc = "Gives a player a hat")
public void hat(CommandSource context, @Optional String item, @Named({ "player", "p" }) Player player, @Flag boolean quiet) {
ItemStack head;
if (player != null) {
if (!context.hasPermission(module.perms().COMMAND_HAT_OTHER.getId())) {
i18n.send(context, NEGATIVE, "You can't set the hat of an other player.");
return;
}
} else if (context instanceof Player) {
player = (Player) context;
} else {
i18n.send(context, NEGATIVE, "You have to specify a player!");
return;
}
if (item != null) {
if (!context.hasPermission(module.perms().COMMAND_HAT_ITEM.getId())) {
i18n.send(context, NEGATIVE, "You can only use your item in hand!");
return;
}
head = materialMatcher.itemStack(item);
if (head == null) {
i18n.send(context, NEGATIVE, "Item not found!");
return;
}
} else if (context instanceof Player) {
head = ((Player) context).getItemInHand(MAIN_HAND).orElse(null);
} else {
i18n.send(context, NEGATIVE, "Trying to be Notch? No hat for you!");
i18n.send(context, NEUTRAL, "Please specify an item!");
return;
}
if (head == null) {
i18n.send(context, NEGATIVE, "You do not have any item in your hand!");
return;
}
EquipmentType type = head.getType().getDefaultProperty(EquipmentProperty.class).map(EquipmentProperty::getValue).orElse(null);
if (type == null || type != EquipmentTypes.HEADWEAR) {
if (!context.hasPermission(module.perms().COMMAND_HAT_MORE_ARMOR.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to use other armor as headpiece");
return;
}
}
head.setQuantity(1);
if (item == null && context instanceof Player) {
ItemStack clone = head.copy();
clone.setQuantity(head.getQuantity() - 1);
((Player) context).setItemInHand(MAIN_HAND, clone);
}
if (player.getHelmet().isPresent()) {
player.getInventory().offer(player.getHelmet().get());
}
player.setHelmet(head);
if (!(quiet && context.hasPermission(module.perms().COMMAND_HAT_QUIET.getId())) && player.hasPermission(module.perms().COMMAND_HAT_NOTIFY.getId())) {
i18n.send(player, POSITIVE, "Your hat was changed");
}
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class HideCommands method listhiddens.
@Command(desc = "Lists all hidden players.")
public void listhiddens(CommandSource context) throws ExecutionException, InterruptedException {
Set<UUID> hiddens = this.module.getHiddenUsers();
if (hiddens.isEmpty()) {
i18n.send(context, NEUTRAL, "There are no hidden users!");
return;
}
i18n.send(context, POSITIVE, "The following users are hidden:");
for (UUID uuid : hiddens) {
context.sendMessage(Text.of(" - ", YELLOW, Sponge.getServer().getGameProfileManager().get(uuid).get().getName().orElse("???")));
}
}
Aggregations