Java Code Examples for org.spongepowered.api.text.format.TextColors#GOLD
The following examples show how to use
org.spongepowered.api.text.format.TextColors#GOLD .
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: CommandHelper.java From GriefPrevention with MIT License | 5 votes |
public static TextColor getFlagTypeColor(FlagType type) { TextColor color = TextColors.LIGHT_PURPLE; if (type == FlagType.CLAIM) { color = TextColors.GOLD; } else if (type == FlagType.OVERRIDE) { color = TextColors.RED; } return color; }
Example 2
Source File: CommandTrustList.java From GriefPrevention with MIT License | 5 votes |
private static TextColor getTrustColor(TrustType type) { if (type == TrustType.NONE) { return TextColors.WHITE; } if (type == TrustType.ACCESSOR) { return TextColors.YELLOW; } if (type == TrustType.BUILDER) { return TextColors.GREEN; } if (type == TrustType.CONTAINER) { return TextColors.LIGHT_PURPLE; } return TextColors.GOLD; }
Example 3
Source File: CommandClaimOptionPlayer.java From GriefPrevention with MIT License | 4 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } String option = args.<String>getOne("option").orElse(null); if (option != null && !option.startsWith("griefprevention.")) { option = "griefprevention." + option; } Double value = args.<Double>getOne("value").orElse(null); final User user = args.<User>getOne("user").orElse(null); final boolean isGlobalOption = GPOptions.GLOBAL_OPTIONS.contains(option); // Check if global option if (isGlobalOption && !player.hasPermission(GPPermissions.MANAGE_GLOBAL_OPTIONS)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionGlobalOption.toText()); return CommandResult.success(); } Set<Context> contexts = new HashSet<>(); if (!isGlobalOption) { final GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (claim.isSubdivision()) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.commandOptionInvalidClaim.toText()); return CommandResult.success(); } if (!playerData.canManageOption(player, claim, false)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionPlayerOption.toText()); return CommandResult.success(); } final Text message = GriefPreventionPlugin.instance.messageData.permissionClaimManage .apply(ImmutableMap.of( "type", claim.getType().name())).build(); if (claim.isWilderness() && !player.hasPermission(GPPermissions.MANAGE_WILDERNESS)) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } else if (claim.isAdminClaim() && !player.hasPermission(GPPermissions.COMMAND_ADMIN_CLAIMS)) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } if (option != null && value != null) { // Validate new value against admin set value Double tempValue = GPOptionHandler.getClaimOptionDouble(user, claim, option, playerData); if (tempValue != value) { final Text message2 = GriefPreventionPlugin.instance.messageData.commandOptionExceedsAdmin .apply(ImmutableMap.of( "original_value", value, "admin_value", tempValue)).build(); GriefPreventionPlugin.sendMessage(src, message2); return CommandResult.success(); } contexts.add(claim.getContext()); } } if (option == null || value == null) { // display current options for user List<Object[]> optionList = Lists.newArrayList(); Map<String, String> options = user.getSubjectData().getOptions(contexts); for (Map.Entry<String, String> optionEntry : options.entrySet()) { String optionValue = optionEntry.getValue(); Object[] optionText = new Object[] { TextColors.GREEN, optionEntry.getKey(), " ", TextColors.GOLD, optionValue }; optionList.add(optionText); } List<Text> finalTexts = CommandHelper.stripeText(optionList); PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder paginationBuilder = paginationService.builder() .title(Text.of(TextColors.AQUA, user.getName() + " Claim Options")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(finalTexts); paginationBuilder.sendTo(src); return CommandResult.success(); } final String flagOption = option; final Double newOptionValue = value; user.getSubjectData().setOption(contexts, option, newOptionValue.toString()) .thenAccept(consumer -> { if (consumer.booleanValue()) { GriefPreventionPlugin.sendMessage(src, Text.of("Set option ", TextColors.AQUA, flagOption, TextColors.WHITE, " to ", TextColors.GREEN, newOptionValue, TextColors.WHITE, " on user ", TextColors.GOLD, user.getName(), TextColors.WHITE, ".")); } else { GriefPreventionPlugin.sendMessage(src, Text.of(TextColors.RED, "The permission plugin failed to set the option.")); } }); return CommandResult.success(); }
Example 4
Source File: CommandClaimOptionGroup.java From GriefPrevention with MIT License | 4 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } String option = args.<String>getOne("option").orElse(null); if (option != null && !option.startsWith("griefprevention.")) { option = "griefprevention." + option; } final Double value = args.<Double>getOne("value").orElse(null); final String group = args.<String>getOne("group").orElse(null); final boolean isGlobalOption = GPOptions.GLOBAL_OPTIONS.contains(option); // Check if global option if (isGlobalOption && !player.hasPermission(GPPermissions.MANAGE_GLOBAL_OPTIONS)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionGlobalOption.toText()); return CommandResult.success(); } Set<Context> contexts = new HashSet<>(); final Subject subj = PermissionUtils.getGroupSubject(group); if (!isGlobalOption) { final GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (claim.isSubdivision()) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.commandOptionInvalidClaim.toText()); return CommandResult.success(); } if (!playerData.canManageOption(player, claim, true)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionGroupOption.toText()); return CommandResult.success(); } if (!PermissionUtils.hasGroupSubject(group)) { GriefPreventionPlugin.sendMessage(player,GriefPreventionPlugin.instance.messageData.commandGroupInvalid.toText()); return CommandResult.success(); } final Text message = GriefPreventionPlugin.instance.messageData.permissionClaimManage .apply(ImmutableMap.of( "type", claim.getType().name())).build(); if (claim.isWilderness() && !player.hasPermission(GPPermissions.MANAGE_WILDERNESS)) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } else if (claim.isAdminClaim() && !player.hasPermission(GPPermissions.COMMAND_ADMIN_CLAIMS)) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } // Validate new value against admin set value if (option != null && value != null) { Double tempValue = GPOptionHandler.getClaimOptionDouble(player, claim, option, playerData); if (tempValue != value) { final Text message2 = GriefPreventionPlugin.instance.messageData.commandOptionExceedsAdmin .apply(ImmutableMap.of( "original_value", value, "admin_value", tempValue)).build(); GriefPreventionPlugin.sendMessage(src, message2); return CommandResult.success(); } contexts.add(claim.getContext()); } } if (option == null || value == null) { List<Object[]> optionList = Lists.newArrayList(); Map<String, String> options = subj.getSubjectData().getOptions(contexts); for (Map.Entry<String, String> optionEntry : options.entrySet()) { String optionValue = optionEntry.getValue(); Object[] optionText = new Object[] { TextColors.GREEN, optionEntry.getKey(), " ", TextColors.GOLD, optionValue }; optionList.add(optionText); } List<Text> finalTexts = CommandHelper.stripeText(optionList); PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder paginationBuilder = paginationService.builder() .title(Text.of(TextColors.AQUA, subj.getIdentifier() + " Claim Options")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(finalTexts); paginationBuilder.sendTo(src); return CommandResult.success(); } final String flagOption = option; subj.getSubjectData().setOption(contexts, option, value.toString()) .thenAccept(consumer -> { if (consumer.booleanValue()) { GriefPreventionPlugin.sendMessage(src, Text.of("Set option ", TextColors.AQUA, flagOption, TextColors.WHITE, " to ", TextColors.GREEN, value, TextColors.WHITE, " on group ", TextColors.GOLD, subj.getIdentifier(), TextColors.WHITE, ".")); } else { GriefPreventionPlugin.sendMessage(src, Text.of(TextColors.RED, "The permission plugin failed to set the option.")); } }); return CommandResult.success(); }
Example 5
Source File: CommandClaimPermissionGroup.java From GriefPrevention with MIT License | 4 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } final String permission = args.<String>getOne("permission").orElse(null); if (permission != null && !player.hasPermission(permission)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionAssignWithoutHaving.toText()); return CommandResult.success(); } final String group = args.<String>getOne("group").orElse(null); final String value = args.<String>getOne("value").orElse(null); if (!PermissionUtils.hasGroupSubject(group)) { GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.commandGroupInvalid.toText()); return CommandResult.success(); } final Subject subj = PermissionUtils.getGroupSubject(group); GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation()); final Text message = GriefPreventionPlugin.instance.messageData.permissionClaimManage .apply(ImmutableMap.of( "type", claim.getType().name())).build(); if (claim.isWilderness() && !playerData.canManageWilderness) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } else if (claim.isAdminClaim() && !playerData.canManageAdminClaims) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } Set<Context> contexts = new HashSet<>(); contexts.add(claim.getContext()); if (permission == null || value == null) { List<Object[]> permList = Lists.newArrayList(); Map<String, Boolean> permissions = subj.getSubjectData().getPermissions(contexts); for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) { Boolean permValue = permissionEntry.getValue(); Object[] permText = new Object[] { TextColors.GREEN, permissionEntry.getKey(), " ", TextColors.GOLD, permValue.toString() }; permList.add(permText); } List<Text> finalTexts = CommandHelper.stripeText(permList); PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder paginationBuilder = paginationService.builder() .title(Text.of(TextColors.AQUA, subj.getIdentifier() + " Permissions")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(finalTexts); paginationBuilder.sendTo(src); return CommandResult.success(); } Tristate tristateValue = PlayerUtils.getTristateFromString(value); if (tristateValue == null) { GriefPreventionPlugin.sendMessage(src, Text.of(TextColors.RED, "Invalid value entered. '" + value + "' is not a valid value. Valid values are : true, false, undefined, 1, -1, or 0.")); return CommandResult.success(); } subj.getSubjectData().setPermission(contexts, permission, tristateValue); GriefPreventionPlugin.sendMessage(src, Text.of("Set permission ", TextColors.AQUA, permission, TextColors.WHITE, " to ", TextColors.GREEN, tristateValue, TextColors.WHITE, " on group ", TextColors.GOLD, subj.getIdentifier(), TextColors.WHITE, ".")); return CommandResult.success(); }
Example 6
Source File: CommandClaimPermissionPlayer.java From GriefPrevention with MIT License | 4 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } final String permission = args.<String>getOne("permission").orElse(null); if (permission != null && !player.hasPermission(permission)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionAssignWithoutHaving.toText()); return CommandResult.success(); } final User user = args.<User>getOne("user").orElse(null); final String value = args.<String>getOne("value").orElse(null); final GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation()); final Text message = GriefPreventionPlugin.instance.messageData.permissionClaimManage .apply(ImmutableMap.of( "type", claim.getType().name())).build(); if (claim.isWilderness() && !playerData.canManageWilderness) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } else if (claim.isAdminClaim() && !playerData.canManageAdminClaims) { GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); } Set<Context> contexts = new HashSet<>(); contexts.add(claim.getContext()); if (permission == null || value == null) { // display current permissions for user List<Object[]> permList = Lists.newArrayList(); Map<String, Boolean> permissions = user.getSubjectData().getPermissions(contexts); for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) { Boolean permValue = permissionEntry.getValue(); Object[] permText = new Object[] { TextColors.GREEN, permissionEntry.getKey(), " ", TextColors.GOLD, permValue.toString() }; permList.add(permText); } List<Text> finalTexts = CommandHelper.stripeText(permList); PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder paginationBuilder = paginationService.builder() .title(Text.of(TextColors.AQUA, user.getName() + " Permissions")).padding(Text.of(TextStyles.STRIKETHROUGH, "-")).contents(finalTexts); paginationBuilder.sendTo(src); return CommandResult.success(); } Tristate tristateValue = PlayerUtils.getTristateFromString(value); if (tristateValue == null) { GriefPreventionPlugin.sendMessage(src, Text.of(TextColors.RED, "Invalid value entered. '" + value + "' is not a valid value. Valid values are : true, false, undefined, 1, -1, or 0.")); return CommandResult.success(); } user.getSubjectData().setPermission(contexts, permission, tristateValue); GriefPreventionPlugin.sendMessage(src, Text.of("Set permission ", TextColors.AQUA, permission, TextColors.WHITE, " to ", TextColors.GREEN, tristateValue, TextColors.WHITE, " on user ", TextColors.GOLD, user.getName(), TextColors.WHITE, ".")); return CommandResult.success(); }