use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class ChatCommands method chatcolors.
@Command(desc = "Displays the colors")
public void chatcolors(CommandSource context) {
i18n.send(context, POSITIVE, "The following chat codes are available:");
Builder builder = Text.builder();
int i = 0;
for (TextColor color : Sponge.getRegistry().getAllOf(TextColor.class)) {
if (color == TextColors.NONE) {
continue;
}
if (i++ % 3 == 0) {
builder.append(Text.NEW_LINE);
}
builder.append(Text.of(" ")).append(Text.of(color, color.getName())).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(color)), ")"));
}
builder.append(Text.NEW_LINE);
builder.append(Text.of(" ")).append(Text.of(BOLD, "bold")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(BOLD)), ")"));
builder.append(Text.of(" ")).append(Text.of(ITALIC, "italic")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(ITALIC)), ")"));
builder.append(Text.of(" ")).append(Text.of(UNDERLINE, "underline")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(UNDERLINE)), ")"));
builder.append(Text.NEW_LINE);
builder.append(Text.of(" ")).append(Text.of(STRIKETHROUGH, "strikethrough")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(STRIKETHROUGH)), ")"));
builder.append(Text.of(" ")).append(Text.of(OBFUSCATED, "obfuscated")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(OBFUSCATED)), ")"));
context.sendMessage(builder.build());
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class ChatCommands method reply.
@Command(alias = "r", desc = "Replies to the last person that whispered to you.")
public void reply(CommandSource context, @Greed(INFINITE) String message) {
UUID lastWhisper;
if (context instanceof Player) {
lastWhisper = lastWhispers.get(((Player) context).getUniqueId());
} else {
lastWhisper = lastWhispers.get(consoleUUID);
}
if (lastWhisper == null) {
i18n.send(context, NEUTRAL, "No one has sent you a message that you could reply to!");
return;
}
CommandSource target;
if (lastWhisper.equals(consoleUUID)) {
target = Sponge.getServer().getConsole();
} else {
target = Sponge.getServer().getPlayer(lastWhisper).orElse(null);
}
if (!this.sendWhisperTo(target, message, context)) {
i18n.send(context, NEGATIVE, "Could not find the player to reply to. Is the player offline?");
}
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class ManagementCommands method showHelp.
@Command(name = "help", desc = "Prints out all the custom chat commands.")
public void showHelp(CommandSource context) {
List<Text> list = config.commands.entrySet().stream().map(e -> Text.of("!", e.getKey(), " -> ", e.getValue())).collect(Collectors.toList());
PaginationList pages = PaginationList.builder().contents(list).build();
pages.sendTo(context);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class InvasionCommand method invasion.
@Command(desc = "Spawns a mob next to every player on the server")
public void invasion(CommandSource context, String mob) {
EntityType entityType = em.mob(mob, context.getLocale());
if (entityType == null) {
i18n.send(context, MessageType.NEGATIVE, "EntityType {input} not found", mob);
return;
}
Sponge.getCauseStackManager().pushCause(context);
for (Player player : Sponge.getServer().getOnlinePlayers()) {
Optional<BlockRayHit<World>> end = BlockRay.from(player).stopFilter(BlockRay.onlyAirFilter()).distanceLimit(module.getConfig().command.invasion.distance).build().end();
if (end.isPresent()) {
Location<World> location = end.get().getLocation();
Entity entity = location.getExtent().createEntity(entityType, location.getPosition());
location.getExtent().spawnEntity(entity);
}
}
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class NukeCommand method nuke.
@Command(desc = "Makes a carpet of TNT fall on a player or where you're looking")
public void nuke(CommandSource context, @Optional Integer diameter, @Named({ "player", "p" }) Player player, @Named({ "height", "h" }) Integer height, @Named({ "range", "r" }) Integer range, @Flag boolean unsafe, @Flag boolean quiet) {
Location<World> location;
range = range == null ? 4 : range;
height = height == null ? 5 : height;
diameter = diameter == null ? 5 : diameter;
diameter = Math.min(10, diameter);
if (range != 4 && !context.hasPermission(module.perms().COMMAND_NUKE_CHANGE_RANGE.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to change the explosion range of the nuke carpet!");
return;
}
if (range < 0 || range > this.module.getConfig().command.nuke.maxExplosionRange) {
i18n.send(context, NEGATIVE, "The explosion range can't be less than 0 or greater than {integer}", this.module.getConfig().command.nuke.maxExplosionRange);
return;
}
if (player != null) {
if (!context.equals(player) && !context.hasPermission(module.perms().COMMAND_NUKE_OTHER.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to specify a player!");
return;
}
location = ((Player) context).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)).stopFilter(onlyAirFilter()).distanceLimit(100).build().end();
if (!end.isPresent()) {
throw new IllegalStateException();
}
location = end.get().getLocation();
}
location = this.getSpawnLocation(location, height);
Shape aShape = new Cuboid(new Vector3d(location.getX() + .5, location.getY() + .5, location.getZ() + .5), diameter, 1, diameter);
int blockAmount = this.spawnNuke(aShape, location.getExtent(), range, unsafe);
if (!quiet) {
i18n.send(context, POSITIVE, "You spawned {integer} blocks of tnt.", blockAmount);
}
}
Aggregations