org.spongepowered.api.text.format.TextColors Java Examples
The following examples show how to use
org.spongepowered.api.text.format.TextColors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BroadcastExecutor.java From EssentialCmds with MIT License | 6 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { String message = ctx.<String> getOne("message").get(); Text msg = TextSerializers.formattingCode('&').deserialize(message); Text broadcast = Text.of(TextColors.DARK_GRAY, "[", TextColors.DARK_RED, "Broadcast", TextColors.DARK_GRAY, "]", TextColors.GREEN, " "); Text finalBroadcast = Text.builder().append(broadcast).append(msg).build(); if ((message.contains("https://")) || (message.contains("http://"))) { Text urlBroadcast = Text.builder().append(broadcast).append(Utils.getURL(message)).build(); MessageChannel.TO_ALL.send(urlBroadcast); } else { MessageChannel.TO_ALL.send(finalBroadcast); } }
Example #2
Source File: PermsCommand.java From EagleFactions with MIT License | 6 votes |
@Override public CommandResult execute(final CommandSource source, final CommandContext context) throws CommandException { if(!(source instanceof Player)) throw new CommandException(Text.of (PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.ONLY_IN_GAME_PLAYERS_CAN_USE_THIS_COMMAND)); final Player player = (Player)source; final Optional<Faction> optionalPlayerFaction = getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId()); if(!optionalPlayerFaction.isPresent()) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_IN_FACTION_IN_ORDER_TO_USE_THIS_COMMAND)); final Faction faction = optionalPlayerFaction.get(); if(!faction.getLeader().equals(player.getUniqueId()) && !super.getPlugin().getPlayerManager().hasAdminMode(player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_THE_FACTIONS_LEADER_TO_DO_THIS)); showPerms(player, faction); return CommandResult.success(); }
Example #3
Source File: NationadminSpyExecutor.java From Nations with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (src instanceof Player) { NationMessageChannel channel = DataHandler.getSpyChannel(); if (channel.getMembers().contains(src)) { channel.removeMember(src); src.sendMessage(Text.of(TextColors.YELLOW, LanguageHandler.INFO_NATIONSPY_OFF)); } else { channel.addMember(src); src.sendMessage(Text.of(TextColors.YELLOW, LanguageHandler.INFO_NATIONSPY_ON)); } } else { src.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_NOPLAYER)); } return CommandResult.success(); }
Example #4
Source File: JaillistCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, JailPermissions.UC_JAIL_JAILLIST_BASE); List<Jail> jails = GlobalData.get(JailKeys.JAILS).get(); List<Text> texts = new ArrayList<>(); //Add entry to texts for every jail for (Jail jail : jails) { texts.add(Messages.getFormatted("jail.command.jaillist.entry", "%jail%", jail.getName(), "%description%", jail.getDescription()).toBuilder().onHover(TextActions.showText(Messages.getFormatted("jail.command.jaillist.hoverentry", "%jail%", jail.getName()))).onClick(TextActions.runCommand("/jailtp " + jail.getName())).build()); } //If empty send message if (texts.isEmpty()) { throw new ErrorMessageException(Messages.getFormatted(sender, "jail.command.jaillist.empty")); } //Sort alphabetically Collections.sort(texts); //Send page PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList paginationList = paginationService.builder().contents(texts).title(Messages.getFormatted("jail.command.jaillist.header").toBuilder().color(TextColors.DARK_GREEN).build()).build(); paginationList.sendTo(sender); return CommandResult.success(); }
Example #5
Source File: SignListener.java From UltimateCore with MIT License | 6 votes |
@Listener(order = Order.EARLY) public void onSignCreate(ChangeSignEvent event, @Root Player p) { //Sign colors List<Text> lines = event.getText().lines().get(); lines.set(0, TextUtil.replaceColors(lines.get(0), p, "uc.sign")); lines.set(1, TextUtil.replaceColors(lines.get(1), p, "uc.sign")); lines.set(2, TextUtil.replaceColors(lines.get(2), p, "uc.sign")); lines.set(3, TextUtil.replaceColors(lines.get(3), p, "uc.sign")); event.getText().setElements(lines); //Registered signs for (UCSign sign : UltimateCore.get().getSignService().get().getRegisteredSigns()) { if (event.getText().get(0).orElse(Text.of()).toPlain().equalsIgnoreCase("[" + sign.getIdentifier() + "]")) { if (!p.hasPermission(sign.getCreatePermission().get())) { Messages.send(p, "core.nopermissions"); } SignCreateEvent cevent = new SignCreateEvent(sign, event.getTargetTile().getLocation(), Cause.builder().append(UltimateCore.getContainer()).append(p).build(EventContext.builder().build())); Sponge.getEventManager().post(cevent); if (!cevent.isCancelled() && sign.onCreate(p, event)) { //Color sign event.getTargetTile().offer(Keys.SIGN_LINES, event.getText().setElement(0, Text.of(TextColors.AQUA, "[" + StringUtil.firstUpperCase(sign.getIdentifier()) + "]")).asList()); Messages.send(p, "sign.create", "%sign%", sign.getIdentifier()); } } } }
Example #6
Source File: ChatGroupTab.java From ChatUI with MIT License | 6 votes |
@Override public void draw(PlayerContext ctx, LineFactory lineFactory) { Text.Builder builder = Text.builder(); LiteralText.Builder createButton = Text.builder("[Create Group]"); if (ChatGroupTab.this.feature.canCreateGroup(ctx.getPlayer())) { createButton.onClick(Utils.execClick(view -> { ChatGroupTab.this.createGroup = !ChatGroupTab.this.createGroup; view.update(); })); createButton.color(TextColors.GREEN); if (ChatGroupTab.this.createGroup) { lineFactory.appendNewLine(Text.of("Type group name in chat:"), ctx); createButton.content("[Cancel]"); createButton.color(TextColors.RED); } } else { createButton.onHover(TextActions.showText(Text.of("You do not have permission to create groups"))); createButton.color(TextColors.GRAY); } builder.append(createButton.build()); lineFactory.appendNewLine(builder.build(), ctx); }
Example #7
Source File: AdminCommand.java From EagleFactions with MIT License | 6 votes |
@Override public CommandResult execute(final CommandSource source, final CommandContext context) throws CommandException { if (!(source instanceof Player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.ONLY_IN_GAME_PLAYERS_CAN_USE_THIS_COMMAND)); final Player player = (Player)source; if(super.getPlugin().getPlayerManager().hasAdminMode(player)) { super.getPlugin().getPlayerManager().deactivateAdminMode(player); player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.GOLD, Messages.ADMIN_MODE_HAS_BEEN_TURNED_OFF)); } else { super.getPlugin().getPlayerManager().activateAdminMode(player); player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.GOLD, Messages.ADMIN_MODE_HAS_BEEN_TURNED_ON)); } return CommandResult.success(); }
Example #8
Source File: CommandGpVersion.java From GriefPrevention with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource src, CommandContext ctx) { if (!src.hasPermission(GPPermissions.COMMAND_VERSION)) { return CommandResult.success(); } String version = GriefPreventionPlugin.IMPLEMENTATION_VERSION; if (version == null) { version = "unknown"; } final String spongePlatform = Sponge.getPlatform().getContainer(Component.IMPLEMENTATION).getName(); Text gpVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.AQUA, "GriefPrevention ", version); Text spongeVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.YELLOW, spongePlatform, " ", GriefPreventionPlugin.SPONGE_VERSION); String permissionPlugin = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getId(); String permissionVersion = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getVersion().orElse("unknown"); Text permVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.GREEN, permissionPlugin, " ", permissionVersion); src.sendMessage(Text.of(gpVersion, "\n", spongeVersion, "\n", permVersion)); return CommandResult.success(); }
Example #9
Source File: MaxPowerCommand.java From EagleFactions with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource source, CommandContext context) throws CommandException { final Player selectedPlayer = context.requireOne(Text.of("player")); final double power = context.requireOne(Text.of("power")); if (source instanceof Player) { final Player player = (Player) source; if (!super.getPlugin().getPlayerManager().hasAdminMode(player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_NEED_TO_TOGGLE_FACTION_ADMIN_MODE_TO_DO_THIS)); setMaxPower(source, selectedPlayer, (float) power); } else { setMaxPower(source, selectedPlayer, (float)power); } return CommandResult.success(); }
Example #10
Source File: ZoneExecutor.java From Nations with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { src.sendMessage(Text.of( TextColors.GOLD, ((src instanceof Player) ? "" : "\n") + "--------{ ", TextColors.YELLOW, "/zone", TextColors.GOLD, " }--------", TextColors.GOLD, "\n/z info [zone]", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_INFO, TextColors.GOLD, "\n/z list", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_LIST, TextColors.GOLD, "\n/z create <name> [owner]", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_CREATE, TextColors.GOLD, "\n/z delete [zone]", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_DELETE, TextColors.GOLD, "\n/z coowner <add/remove> <player>", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_COOWNER, TextColors.GOLD, "\n/z setowner <player>", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_SETOWNER, TextColors.GOLD, "\n/z delowner", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_DELOWNER, TextColors.GOLD, "\n/z rename", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_RENAME, TextColors.GOLD, "\n/z perm <type> <perm> [true/false]", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_PERM, TextColors.GOLD, "\n/z flag <flag> [true/false]", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_FLAG, TextColors.GOLD, "\n/z sell <price>", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_SELL, TextColors.GOLD, "\n/z buy", TextColors.GRAY, " - ", TextColors.YELLOW, LanguageHandler.HELP_DESC_CMD_Z_BUY)); return CommandResult.success(); }
Example #11
Source File: VersionCommand.java From EagleFactions with MIT License | 6 votes |
@Override public CommandResult execute(final CommandSource source, final CommandContext context) throws CommandException { try { source.sendMessage(Text.of( TextActions.showText(Text.of(TextColors.BLUE, "Click to view Github")), TextActions.openUrl(new URL("https://github.com/Aquerr/EagleFactions")), PluginInfo.PLUGIN_PREFIX, TextColors.AQUA, PluginInfo.NAME, TextColors.WHITE, " - ", TextColors.GOLD, Messages.VERSION + " ", PluginInfo.VERSION, TextColors.WHITE, " made by ", TextColors.GOLD, PluginInfo.AUTHOR)); } catch(final MalformedURLException e) { e.printStackTrace(); } return CommandResult.success(); }
Example #12
Source File: HelpOpExecutor.java From EssentialCmds with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { String question = ctx.<String> getOne("question").get(); if (src instanceof Player) { Player player = (Player) src; for(Player p : Sponge.getServer().getOnlinePlayers()) { if(p.hasPermission("essentialcmds.helpop.receive")) p.sendMessage(Text.of(TextColors.RED, "[Help-Op]: ", TextColors.GOLD, player.getName(), TextColors.GRAY, " needs help! ", TextColors.WHITE, question)); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /helpop!")); } return CommandResult.success(); }
Example #13
Source File: GodExecutor.java From EssentialCmds with MIT License | 6 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { if (src instanceof Player) { Player player = (Player) src; if (EssentialCmds.godPlayers.contains(player.getUniqueId())) { EssentialCmds.godPlayers.remove(player.getUniqueId()); player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.RED, "Toggled god mode off!")); } else { EssentialCmds.godPlayers.add(player.getUniqueId()); player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.GOLD, "Toggled god mode on!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /god!")); } }
Example #14
Source File: NationadminDeleteExecutor.java From Nations with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (!ctx.<String>getOne("nation").isPresent()) { src.sendMessage(Text.of(TextColors.YELLOW, "/na delete <nation>")); return CommandResult.success(); } String nationName = ctx.<String>getOne("nation").get(); Nation nation = DataHandler.getNation(nationName); if (nation == null) { src.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_BADNATIONNAME)); return CommandResult.success(); } DataHandler.removeNation(nation.getUUID()); MessageChannel.TO_ALL.send(Text.of(TextColors.AQUA, LanguageHandler.INFO_NATIONFALL.replaceAll("\\{NATION\\}", nation.getName()))); return CommandResult.success(); }
Example #15
Source File: PlayerFreezeExecutor.java From EssentialCmds with MIT License | 6 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { Player targetPlayer = ctx.<Player> getOne("player").get(); if(targetPlayer.equals(src)) { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot freeze yourself!")); return; } if(EssentialCmds.frozenPlayers.contains(targetPlayer.getUniqueId())) { EssentialCmds.frozenPlayers.remove(targetPlayer.getUniqueId()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Un-froze player.")); } else { EssentialCmds.frozenPlayers.add(targetPlayer.getUniqueId()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Froze player.")); } }
Example #16
Source File: UnmuteExecutor.java From EssentialCmds with MIT License | 6 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { Player p = ctx.<Player> getOne("player").get(); if (EssentialCmds.muteList.remove(p.getUniqueId())) { src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Player un-muted.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "This player is not muted.")); } Utils.removeMute(p.getUniqueId()); }
Example #17
Source File: LoanTextUtils.java From EconomyLite with MIT License | 5 votes |
public static Text yesOrNo(String yes, String no) { Text accept = Text.of(TextColors.DARK_GRAY, "[", TextColors.GREEN, "YES", TextColors.DARK_GRAY, "]").toBuilder() .onHover(TextActions.showText(Text.of(TextColors.GREEN, "Yes!"))) .onClick(TextActions.runCommand(yes)) .build(); Text deny = Text.of(TextColors.DARK_GRAY, "[", TextColors.RED, "NO", TextColors.DARK_GRAY, "]").toBuilder() .onHover(TextActions.showText(Text.of(TextColors.RED, "No!"))) .onClick(TextActions.runCommand(no)) .build(); return accept.toBuilder().append(Text.of(" "), deny).build(); }
Example #18
Source File: ProtectionManagerImpl.java From EagleFactions with MIT License | 5 votes |
private void notifyPlayer(final User user) { if (this.chatConfig.shouldDisplayProtectionSystemMessages()) { user.getPlayer().ifPresent(x->x.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_DONT_HAVE_ACCESS_TO_DO_THIS))); } }
Example #19
Source File: CommandHelper.java From GriefPrevention with MIT License | 5 votes |
public static List<Text> stripeText(List<Object[]> texts) { Collections.sort(texts, rawTextComparator()); ImmutableList.Builder<Text> finalTexts = ImmutableList.builder(); for (int i = 0; i < texts.size(); i++) { Object[] text = texts.get(i); text[0] = i % 2 == 0 ? TextColors.GREEN : TextColors.AQUA; // Set starting color finalTexts.add(Text.of(text)); } return finalTexts.build(); }
Example #20
Source File: MoreExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).get(); stack.setQuantity(64); player.setItemInHand(HandTypes.MAIN_HAND, stack); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Stacked the item in your hand!")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You're not holding anything to stack!")); } } else if (src instanceof ConsoleSource) { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /more!")); } else if (src instanceof CommandBlockSource) { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /more!")); } return CommandResult.success(); }
Example #21
Source File: AccessCommand.java From EagleFactions with MIT License | 5 votes |
@Override public CommandResult execute(final CommandSource source, final CommandContext args) throws CommandException { if(!(source instanceof Player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.ONLY_IN_GAME_PLAYERS_CAN_USE_THIS_COMMAND)); final Player player = (Player)source; final Optional<Faction> optionalPlayerFaction = super.getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId()); if (!optionalPlayerFaction.isPresent()) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_IN_FACTION_IN_ORDER_TO_USE_THIS_COMMAND)); final Faction playerFaction = optionalPlayerFaction.get(); // Access can be run only by leader and officers final Optional<Faction> optionalChunkFaction = super.getPlugin().getFactionLogic().getFactionByChunk(player.getWorld().getUniqueId(), player.getLocation().getChunkPosition()); if (!optionalChunkFaction.isPresent()) throw new CommandException(PluginInfo.ERROR_PREFIX.concat(Text.of(Messages.THIS_PLACE_DOES_NOT_BELONG_TO_ANYONE))); final Faction chunkFaction = optionalChunkFaction.get(); if (!playerFaction.getName().equals(chunkFaction.getName())) throw new CommandException(PluginInfo.ERROR_PREFIX.concat(Text.of(Messages.THIS_PLACE_DOES_NOT_BELONG_TO_YOUR_FACTION))); if (!playerFaction.getLeader().equals(player.getUniqueId()) && !playerFaction.getOfficers().contains(player.getUniqueId()) && !super.getPlugin().getPlayerManager().hasAdminMode(player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_THE_FACTIONS_LEADER_OR_OFFICER_TO_DO_THIS)); // Get claim at player's location final Optional<Claim> optionalClaim = chunkFaction.getClaimAt(player.getWorld().getUniqueId(), player.getLocation().getChunkPosition()); final Claim claim = optionalClaim.get(); return showAccess(player, claim); }
Example #22
Source File: ClaimCommand.java From EagleFactions with MIT License | 5 votes |
private CommandResult preformNormalClaim(final Player player, final Faction faction, final Vector3i chunk) throws CommandException { final World world = player.getWorld(); final boolean isClaimableWorld = this.protectionConfig.getClaimableWorldNames().contains(world.getName()); if(!isClaimableWorld) throw new CommandException(PluginInfo.ERROR_PREFIX.concat(Text.of(TextColors.RED, Messages.YOU_CANNOT_CLAIM_TERRITORIES_IN_THIS_WORLD))); //If not admin then check faction perms for player if (!this.getPlugin().getPermsManager().canClaim(player.getUniqueId(), faction)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.PLAYERS_WITH_YOUR_RANK_CANT_CLAIM_LANDS)); //Check if faction has enough power to claim territory if (super.getPlugin().getPowerManager().getFactionMaxClaims(faction) <= faction.getClaims().size()) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOUR_FACTION_DOES_NOT_HAVE_POWER_TO_CLAIM_MORE_LANDS)); //If attacked then It should not be able to claim territories if (EagleFactionsPlugin.ATTACKED_FACTIONS.containsKey(faction.getName())) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOUR_FACTION_IS_UNDER_ATTACK + " " + MessageLoader.parseMessage(Messages.YOU_NEED_TO_WAIT_NUMBER_MINUTES_TO_BE_ABLE_TO_CLAIM_AGAIN, TextColors.RED, Collections.singletonMap(Placeholders.NUMBER, Text.of(TextColors.GOLD, EagleFactionsPlugin.ATTACKED_FACTIONS.get(faction.getName())))))); if (this.factionsConfig.requireConnectedClaims() && !super.getPlugin().getFactionLogic().isClaimConnected(faction, new Claim(world.getUniqueId(), chunk))) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.CLAIMS_NEED_TO_BE_CONNECTED)); boolean isCancelled = EventRunner.runFactionClaimEvent(player, faction, world, chunk); if (isCancelled) return CommandResult.empty(); super.getPlugin().getFactionLogic().startClaiming(player, faction, world.getUniqueId(), chunk); return CommandResult.success(); }
Example #23
Source File: SubjectListPane.java From ChatUI with MIT License | 5 votes |
private UIComponent createBottomBar() { return new UIComponent() { @Override public void draw(PlayerContext ctx, LineFactory lineFactory) { lineFactory.appendNewLine(Text.builder() .append( Text.builder("[Return]").color(TextColors.BLUE).onClick(ExtraUtils.clickAction(() -> { SubjectListPane.this.tab.setRoot(SubjectListPane.this.tab.getDashboard()); }, SubjectListPane.this.tab)).build(), Text.builder(SubjectListPane.this.addMode ? " [Cancel]" : " [Add]") .color(SubjectListPane.this.addMode ? TextColors.RED : TextColors.GREEN) .onClick(ExtraUtils.clickAction((Runnable) () -> SubjectListPane.this.addMode = !SubjectListPane.this.addMode, SubjectListPane.this.tab)) .build(), Text.builder(" [Scroll Up]") .color(SubjectListPane.this.tableScroll.canScrollUp() ? TextColors.WHITE : TextColors.GRAY) .onClick(ExtraUtils.clickAction(SubjectListPane.this.tableScroll::scrollUp, SubjectListPane.this.tab)) .build(), Text.builder(" [Scroll Down]") .color(SubjectListPane.this.tableScroll.canScrollDown() ? TextColors.WHITE : TextColors.GRAY) .onClick(ExtraUtils.clickAction(SubjectListPane.this.tableScroll::scrollDown, SubjectListPane.this.tab)) .build()) .build(), ctx); } }; }
Example #24
Source File: TextUtils.java From EconomyLite with MIT License | 5 votes |
public static Text yesOrNo(Consumer<CommandSource> yes, Consumer<CommandSource> no) { Text accept = Text.of(TextColors.DARK_GRAY, "[", TextColors.GREEN, "YES", TextColors.DARK_GRAY, "]").toBuilder() .onHover(TextActions.showText(Text.of(TextColors.GREEN, "Yes!"))) .onClick(TextActions.executeCallback(yes)) .build(); Text deny = Text.of(TextColors.DARK_GRAY, "[", TextColors.RED, "NO", TextColors.DARK_GRAY, "]").toBuilder() .onHover(TextActions.showText(Text.of(TextColors.RED, "No!"))) .onClick(TextActions.executeCallback(no)) .build(); return accept.toBuilder().append(Text.of(" "), deny).build(); }
Example #25
Source File: AddRuleExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { String rule = ctx.<String> getOne("rule").get(); Utils.addRule(rule); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Added rule.")); return CommandResult.success(); }
Example #26
Source File: Utils.java From Nations with MIT License | 5 votes |
public static Text formatNationSpawns(Nation nation, TextColor color, String cmd, int clicker) { if (clicker == CLICKER_DEFAULT) { return structureX( nation.getSpawns().keySet().iterator(), Text.builder(), (b) -> b.append(Text.of(TextColors.GRAY, LanguageHandler.FORMAT_NONE)), (b, spawnName) -> b.append(Text.builder(spawnName).color(color).onClick(TextActions.runCommand("/n " + cmd + " " + spawnName)).build()), (b) -> b.append(Text.of(color, ", "))).build(); } if (clicker == CLICKER_ADMIN || nation.getFlag("public")) { return structureX( nation.getSpawns().keySet().iterator(), Text.builder(), (b) -> b.append(Text.of(TextColors.GRAY, LanguageHandler.FORMAT_NONE)), (b, spawnName) -> b.append(Text.builder(spawnName).color(color).onClick(TextActions.runCommand("/n visit " + nation.getRealName() + " " + spawnName)).build()), (b) -> b.append(Text.of(color, ", "))).build(); } return structureX( nation.getSpawns().keySet().iterator(), Text.builder(), (b) -> b.append(Text.of(TextColors.GRAY, LanguageHandler.FORMAT_NONE)), (b, spawnName) -> b.append(Text.builder(spawnName).color(color).build()), (b) -> b.append(Text.of(color, ", "))).build(); }
Example #27
Source File: TextSplitter.java From ChatUI with MIT License | 5 votes |
public Format(Format parent, Text text) { this.format = TextFormat.of(text.getColor() == TextColors.NONE ? parent.format.getColor() : text.getColor(), inheritStyle(parent.format.getStyle(), text.getStyle())); this.onClick = text.getClickAction().orElse(parent.onClick); this.onHover = text.getHoverAction().orElse(parent.onHover); this.onShiftClick = text.getShiftClickAction().orElse(parent.onShiftClick); }
Example #28
Source File: DeleteWarpExecutor.java From EssentialCmds with MIT License | 5 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { String warpName = ctx.<String> getOne("warp name").get(); if (Utils.isWarpInConfig(warpName)) { String configWarpName = Utils.getConfigWarpName(warpName); Utils.deleteWarp(warpName); src.sendMessage(Text.of(TextColors.GREEN, "Success: ", TextColors.YELLOW, "Deleted warp " + configWarpName)); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "This warp doesn't exist!")); } }
Example #29
Source File: KillExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { Optional<Player> p = ctx.<Player> getOne("player"); if (p.isPresent() && src.hasPermission("essentialcmds.kill.others")) { p.get().offer(Keys.HEALTH, 0d); Utils.setLastTeleportOrDeathLocation(p.get().getUniqueId(), p.get().getLocation()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Killed player " + p.get().getName())); p.get().sendMessage(Text.of(TextColors.RED, "You have been killed by " + src.getName())); } else if (!p.isPresent()) { if (src instanceof Player) { Player player = (Player) src; player.offer(Keys.HEALTH, 0d); Utils.setLastTeleportOrDeathLocation(player.getUniqueId(), player.getLocation()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Killed yourself.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot kill yourself, you are not a player!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You do not have permission to kill other players!")); } return CommandResult.success(); }
Example #30
Source File: AutoClaimCommand.java From EagleFactions with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource source, CommandContext context) throws CommandException { if (!(source instanceof Player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.ONLY_IN_GAME_PLAYERS_CAN_USE_THIS_COMMAND)); final Player player = (Player)source; final Optional<Faction> optionalPlayerFaction = getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId()); if (!optionalPlayerFaction.isPresent()) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_IN_FACTION_IN_ORDER_TO_USE_THIS_COMMAND)); final Faction playerFaction = optionalPlayerFaction.get(); if (!playerFaction.getLeader().equals(player.getUniqueId()) && !playerFaction.getOfficers().contains(player.getUniqueId()) && !super.getPlugin().getPlayerManager().hasAdminMode(player)) throw new CommandException(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_THE_FACTIONS_LEADER_OR_OFFICER_TO_DO_THIS)); if(EagleFactionsPlugin.AUTO_CLAIM_LIST.contains(player.getUniqueId())) { EagleFactionsPlugin.AUTO_CLAIM_LIST.remove(player.getUniqueId()); player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.GREEN, Messages.AUTO_CLAIM_HAS_BEEN_TURNED_OFF)); } else { EagleFactionsPlugin.AUTO_CLAIM_LIST.add(player.getUniqueId()); player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.GREEN, Messages.AUTO_CLAIM_HAS_BEEN_TURNED_ON)); } return CommandResult.success(); }