diff --git a/bukkit/src/main/java/com/griefdefender/GDPlayerData.java b/bukkit/src/main/java/com/griefdefender/GDPlayerData.java index 999f760..16aeb82 100644 --- a/bukkit/src/main/java/com/griefdefender/GDPlayerData.java +++ b/bukkit/src/main/java/com/griefdefender/GDPlayerData.java @@ -32,11 +32,13 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.function.Consumer; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; @@ -100,6 +102,11 @@ public class GDPlayerData implements PlayerData { public boolean inTown = false; public boolean townChat = false; + public List chatLines = new ArrayList<>(); + public Instant recordChatTimestamp; + public Instant commandInputTimestamp; + public String commandInput; + public Consumer trustAddConsumer; // Always ignore active contexts by default // This prevents protection issues when other plugins call getActiveContext @@ -671,6 +678,48 @@ public int getPvpCombatTimeRemaining() { return combatTimeout - duration; } + public void updateRecordChat() { + final Player player = this.getSubject().getOnlinePlayer(); + if (this.recordChatTimestamp == null || player == null) { + return; + } + + final Instant now = Instant.now(); + final int timeout = GriefDefenderPlugin.getGlobalConfig().getConfig().gui.chatCaptureIdleTimeout; + if (timeout <= 0) { + return; + } + + if (this.recordChatTimestamp.plusSeconds(timeout).isBefore(now)) { + this.recordChatTimestamp = null; + } + } + + public boolean isRecordingChat() { + return this.recordChatTimestamp != null; + } + + public void updateCommandInput() { + final Player player = this.getSubject().getOnlinePlayer(); + if (this.commandInputTimestamp == null || player == null) { + return; + } + + final Instant now = Instant.now(); + final int timeout = GriefDefenderPlugin.getGlobalConfig().getConfig().gui.commandInputIdleTimeout; + if (timeout <= 0) { + return; + } + + if (this.commandInputTimestamp.plusSeconds(timeout).isBefore(now)) { + this.commandInputTimestamp = null; + } + } + + public boolean isWaitingForInput() { + return this.commandInputTimestamp != null; + } + public void onClaimDelete() { this.lastShovelLocation = null; this.eventResultCache = null; diff --git a/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java b/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java index 17bfc30..95d2db3 100644 --- a/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java +++ b/bukkit/src/main/java/com/griefdefender/cache/MessageCache.java @@ -256,6 +256,7 @@ public static MessageCache getInstance() { public Component LABEL_BLOCKS; public Component LABEL_BUILDERS; public Component LABEL_BUY; + public Component LABEL_CANCEL; public Component LABEL_CHILDREN; public Component LABEL_CONFIRM; public Component LABEL_CONTAINERS; @@ -276,6 +277,7 @@ public static MessageCache getInstance() { public Component LABEL_OWNER; public Component LABEL_PERMISSION; public Component LABEL_PLAYER; + public Component LABEL_PRESET; public Component LABEL_PRICE; public Component LABEL_RAID; public Component LABEL_RESIZABLE; @@ -386,6 +388,7 @@ public static MessageCache getInstance() { public Component TELEPORT_MOVE_CANCEL; public Component TELEPORT_NO_SAFE_LOCATION; public Component TITLE_ACCESSOR; + public Component TITLE_ADVANCED; public Component TITLE_ALL; public Component TITLE_BUILDER; public Component TITLE_CLAIM; @@ -407,6 +410,9 @@ public static MessageCache getInstance() { public Component TRUST_LIST_HEADER; public Component TRUST_NO_CLAIMS; public Component TRUST_SELF; + public Component UI_CLICK_ADD; + public Component UI_CLICK_ADD_GROUP; + public Component UI_CLICK_ADD_PLAYER; public Component UI_CLICK_CONFIRM; public Component UI_CLICK_REMOVE; public Component UNTRUST_NO_CLAIMS; @@ -618,11 +624,11 @@ public void loadCache() { FLAG_UI_OVERRIDE_NO_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-override-no-permission"); FLAG_UI_RETURN_FLAGS = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-return-flags"); LABEL_ACCESSORS = MessageStorage.MESSAGE_DATA.getMessage("label-accessors"); - LABEL_ALL = MessageStorage.MESSAGE_DATA.getMessage("label-all"); LABEL_AREA = MessageStorage.MESSAGE_DATA.getMessage("label-area"); LABEL_BLOCKS = MessageStorage.MESSAGE_DATA.getMessage("label-blocks"); LABEL_BUILDERS = MessageStorage.MESSAGE_DATA.getMessage("label-builders"); LABEL_BUY = MessageStorage.MESSAGE_DATA.getMessage("label-buy"); + LABEL_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("label-cancel"); LABEL_CHILDREN = MessageStorage.MESSAGE_DATA.getMessage("label-children"); LABEL_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("label-confirm"); LABEL_CONTAINERS = MessageStorage.MESSAGE_DATA.getMessage("label-containers"); @@ -644,6 +650,7 @@ public void loadCache() { LABEL_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("label-permission"); LABEL_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("label-player"); LABEL_PRICE = MessageStorage.MESSAGE_DATA.getMessage("label-price"); + LABEL_PRESET = MessageStorage.MESSAGE_DATA.getMessage("label-preset"); LABEL_RAID = MessageStorage.MESSAGE_DATA.getMessage("label-raid"); LABEL_RESIZABLE = MessageStorage.MESSAGE_DATA.getMessage("label-resizable"); LABEL_RESULT = MessageStorage.MESSAGE_DATA.getMessage("label-result"); @@ -753,6 +760,7 @@ public void loadCache() { TELEPORT_MOVE_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("teleport-move-cancel"); TELEPORT_NO_SAFE_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("teleport-no-safe-location"); TITLE_ACCESSOR = MessageStorage.MESSAGE_DATA.getMessage("title-accessor"); + TITLE_ADVANCED = MessageStorage.MESSAGE_DATA.getMessage("title-advanced"); TITLE_ALL = MessageStorage.MESSAGE_DATA.getMessage("title-all"); TITLE_BUILDER = MessageStorage.MESSAGE_DATA.getMessage("title-builder"); TITLE_CLAIM = MessageStorage.MESSAGE_DATA.getMessage("title-claim"); @@ -774,6 +782,9 @@ public void loadCache() { TRUST_LIST_HEADER = MessageStorage.MESSAGE_DATA.getMessage("trust-list-header"); TRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("trust-no-claims"); TRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("trust-self"); + UI_CLICK_ADD = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add"); + UI_CLICK_ADD_GROUP = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add-group"); + UI_CLICK_ADD_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add-player"); UI_CLICK_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("ui-click-confirm"); UI_CLICK_REMOVE = MessageStorage.MESSAGE_DATA.getMessage("ui-click-remove"); UNTRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("untrust-no-claims"); diff --git a/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java b/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java index 83e395d..32f84fb 100644 --- a/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java +++ b/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java @@ -63,6 +63,7 @@ import com.griefdefender.registry.FlagRegistryModule; import com.griefdefender.text.action.GDCallbackHolder; import com.griefdefender.util.CauseContextHelper; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import com.griefdefender.util.PermissionUtil; @@ -257,26 +258,38 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ Collections.sort(textComponents, UIHelper.PLAIN_COMPARATOR); - int fillSize = 20 - (textComponents.size() + 2); - for (int i = 0; i < fillSize; i++) { - textComponents.add(TextComponent.of(" ")); - } - String lastMenu = this.lastActiveMenuTypeMap.getIfPresent(src.getUniqueId()); MenuType lastActiveMenu = MenuType.CLAIM; if (lastMenu != null) { lastActiveMenu = MenuType.valueOf(lastMenu.toUpperCase()); } + + int fillSize = 20 - (textComponents.size() + 2); Component footer = null; if (player.hasPermission(GDPermissions.ADVANCED_FLAGS)) { footer = TextComponent.builder().append(whiteOpenBracket) - .append(TextComponent.of("PRESET").color(TextColor.GOLD)).append(whiteCloseBracket) - .append(" ") - .append(TextComponent.builder() - .append(TextComponent.of("ADVANCED").color(TextColor.GRAY) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimFlagConsumer(src, claim, lastActiveMenu))))) - .build()) - .build(); + .append(TextComponent.of("PRESET").color(TextColor.GOLD)).append(whiteCloseBracket) + .append(" ") + .append(TextComponent.builder() + .append(TextComponent.of("ADVANCED").color(TextColor.GRAY) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimFlagConsumer(src, claim, lastActiveMenu))))) + .build()) + .build(); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + System.out.println("TEST"); + footer = footer.append(TextComponent.builder() + .append("\n") + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")) + .build()); + fillSize = 20 - (textComponents.size() + 3); + } + } else if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder().append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")).build(); + fillSize = 20 - (textComponents.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textComponents.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() .title(flagHeadBuilder.build()).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textComponents).footer(footer); @@ -468,15 +481,12 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType } Collections.sort(textList, UIHelper.PLAIN_COMPARATOR); - int fillSize = 20 - (textList.size() + 2); - for (int i = 0; i < fillSize; i++) { - textList.add(TextComponent.of(" ")); - } - String lastActivePresetMenu = this.lastActivePresetMenuMap.getIfPresent(src.getUniqueId()); if (lastActivePresetMenu == null) { lastActivePresetMenu = "user"; } + + int fillSize = 20 - (textList.size() + 2); Component footer = null; if (player.hasPermission(GDPermissions.ADVANCED_FLAGS)) { footer = TextComponent.builder().append(TextComponent.builder() @@ -488,7 +498,22 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType .append(TextComponent.of("ADVANCED").color(TextColor.RED)) .append(whiteCloseBracket) .build(); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = footer.append(TextComponent.builder() + .append("\n") + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")) + .build()); + fillSize = 20 - (textList.size() + 3); + } + } else if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder().append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")).build(); + fillSize = 20 - (textList.size() + 3); } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() .title(claimFlagHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList).footer(footer); final PaginationList paginationList = paginationBuilder.build(); diff --git a/bukkit/src/main/java/com/griefdefender/command/ClaimOptionBase.java b/bukkit/src/main/java/com/griefdefender/command/ClaimOptionBase.java index 79ee99f..9ba2abc 100644 --- a/bukkit/src/main/java/com/griefdefender/command/ClaimOptionBase.java +++ b/bukkit/src/main/java/com/griefdefender/command/ClaimOptionBase.java @@ -67,6 +67,7 @@ import com.griefdefender.registry.OptionRegistryModule; import com.griefdefender.text.action.GDCallbackHolder; import com.griefdefender.util.CauseContextHelper; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import com.griefdefender.util.PermissionUtil; import net.kyori.text.Component; @@ -471,12 +472,17 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy Collections.sort(textList, UIHelper.PLAIN_COMPARATOR); int fillSize = 20 - (textList.size() + 2); + Component footer = null; + if (player != null && player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, playerData, "claimoption"); + fillSize = 20 - (textList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { textList.add(TextComponent.of(" ")); } - PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(claimOptionHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList); + .title(claimOptionHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList).footer(footer); final PaginationList paginationList = paginationBuilder.build(); Integer activePage = 1; activePage = PaginationUtil.getInstance().getActivePage(player.getUniqueId()); diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimBuy.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimBuy.java index 5022e47..aadcad4 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimBuy.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimBuy.java @@ -30,6 +30,7 @@ import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import com.google.common.collect.ImmutableMap; +import com.griefdefender.GDPlayerData; import com.griefdefender.GriefDefenderPlugin; import com.griefdefender.api.claim.Claim; import com.griefdefender.cache.MessageCache; @@ -37,6 +38,8 @@ import com.griefdefender.configuration.MessageStorage; import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissions; +import com.griefdefender.util.ChatCaptureUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.format.TextDecoration; @@ -69,6 +72,7 @@ public void execute(Player player) { return; } + final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); Set claimsForSale = new HashSet<>(); GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(player.getWorld().getUID()); for (Claim worldClaim : claimManager.getWorldClaims()) { @@ -88,9 +92,22 @@ public void execute(Player player) { } } - List claimsTextList = CommandHelper.generateClaimTextListCommand(new ArrayList(), claimsForSale, player.getWorld().getName(), null, player, CommandHelper.createCommandConsumer(player, "claimbuy", ""), false); + List textList = CommandHelper.generateClaimTextListCommand(new ArrayList(), claimsForSale, player.getWorld().getName(), null, player, CommandHelper.createCommandConsumer(player, "claimbuy", ""), false); + Component footer = null; + int fillSize = 20 - (textList.size() + 2); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, null, playerData, "claimbuy")) + .build(); + fillSize = 20 - (textList.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(MessageCache.getInstance().COMMAND_CLAIMBUY_TITLE).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList); + .title(MessageCache.getInstance().COMMAND_CLAIMBUY_TITLE).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(player); return; } diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimInfo.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimInfo.java index 40d1e08..b8953dd 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimInfo.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimInfo.java @@ -40,6 +40,7 @@ import com.griefdefender.api.claim.ClaimResult; import com.griefdefender.api.claim.ClaimType; import com.griefdefender.api.claim.ClaimTypes; +import com.griefdefender.api.claim.TrustType; import com.griefdefender.api.claim.TrustTypes; import com.griefdefender.api.permission.Context; import com.griefdefender.api.permission.option.Options; @@ -55,6 +56,7 @@ import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PermissionUtil; import com.griefdefender.util.PlayerUtil; @@ -204,14 +206,6 @@ public void execute(CommandSender src, String[] args) { Component name = claim.getName().orElse(null); Component greeting = claim.getData().getGreeting().orElse(null); Component farewell = claim.getData().getFarewell().orElse(null); - String accessors = ""; - String builders = ""; - String containers = ""; - String managers = ""; - String accessorGroups = ""; - String builderGroups = ""; - String containerGroups = ""; - String managerGroups = ""; final int minClaimLevel = gdClaim.getOwnerMinClaimLevel(); double claimY = gdClaim.getOwnerPlayerData() == null ? 65.0D : (minClaimLevel > 65.0D ? minClaimLevel : 65); @@ -278,53 +272,6 @@ public void execute(CommandSender src, String[] args) { .append(claimSize) .append(claimCost).build(); } - // users - final List accessorList = gdClaim.getUserTrustList(TrustTypes.ACCESSOR, true); - final List builderList = gdClaim.getUserTrustList(TrustTypes.BUILDER, true); - final List containerList = gdClaim.getUserTrustList(TrustTypes.CONTAINER, true); - final List managerList = gdClaim.getUserTrustList(TrustTypes.MANAGER, true); - for (UUID uuid : accessorList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - accessors += userName + " "; - } - } - for (UUID uuid : builderList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - builders += userName + " "; - } - } - for (UUID uuid : containerList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - containers += userName + " "; - } - } - for (UUID uuid : managerList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - managers += userName + " "; - } - } - - // groups - for (String group : gdClaim.getGroupTrustList(TrustTypes.ACCESSOR, true)) { - accessorGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.BUILDER, true)) { - builderGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.CONTAINER, true)) { - containerGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.MANAGER, true)) { - managerGroups += group + " "; - } /*if (gpClaim.isInTown()) { Text returnToClaimInfo = Text.builder().append(Text.of( @@ -617,29 +564,29 @@ public void execute(CommandSender src, String[] args) { .append(northEastCorner).build(); } Component claimAccessors = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW)) - .append(" : ") - .append(accessors.equals("") ? NONE : TextComponent.of(accessors, TextColor.BLUE)) - .append(" ") - .append(accessorGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.ACCESSOR)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_ACCESSORS)))) + .build(); Component claimBuilders = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_BUILDERS.color(TextColor.YELLOW)) - .append(" : ") - .append(builders.equals("") ? NONE : TextComponent.of(builders, TextColor.BLUE)) - .append(" ") - .append(builderGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_BUILDERS.color(TextColor.GREEN).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.BUILDER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_BUILDERS)))) + .build(); Component claimContainers = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_CONTAINERS.color(TextColor.YELLOW)) - .append(" : ") - .append(containers.equals("") ? NONE : TextComponent.of(containers, TextColor.BLUE)) - .append(" ") - .append(containerGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_CONTAINERS.color(TextColor.LIGHT_PURPLE).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.CONTAINER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_CONTAINERS)))) + .build(); Component claimCoowners = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_MANAGERS.color(TextColor.YELLOW)) - .append(" : ") - .append(managers.equals("") ? NONE : TextComponent.of(managers, TextColor.BLUE)) - .append(" ") - .append(managerGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_MANAGERS.color(TextColor.GOLD).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.MANAGER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_MANAGERS)))) + .build(); Component dateCreated = TextComponent.builder() .append(MessageCache.getInstance().LABEL_CREATED.color(TextColor.YELLOW)) .append(" : ") @@ -674,10 +621,15 @@ public void execute(CommandSender src, String[] args) { .append(" ") .append(claimDenyMessages) .build()); - textList.add(claimAccessors); - textList.add(claimBuilders); - textList.add(claimContainers); - textList.add(claimCoowners); + textList.add(TextComponent.builder() + .append(claimAccessors) + .append(" ") + .append(claimBuilders) + .append(" ") + .append(claimContainers) + .append(" ") + .append(claimCoowners) + .build()); textList.add(claimGreeting); textList.add(claimFarewell); textList.add(dateCreated); @@ -701,8 +653,19 @@ public void execute(CommandSender src, String[] args) { textList.remove(dateLastActive); } + int fillSize = 20 - (textList.size() + 2); + Component footer = null; + if (player != null && player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(player, gdClaim, playerData, "claiminfo"); + fillSize = 20 - (textList.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(MessageCache.getInstance().CLAIMINFO_UI_TITLE_CLAIMINFO.color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList); + .title(MessageCache.getInstance().CLAIMINFO_UI_TITLE_CLAIMINFO.color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(src); } @@ -715,6 +678,18 @@ public static Consumer createSettingsConsumer(CommandSender src, }; } + private Consumer createTrustListConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type) { + return consumer -> { + Component returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", "claiminfo"))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claiminfo", claim.getUniqueId().toString())))).build(); + CommandTrustList.showTrustList(src, claim, playerData, type, new ArrayList<>(), returnToClaimInfo); + }; + } + private List generateAdminSettings(CommandSender src, GDClaim claim) { List textList = new ArrayList<>(); Component returnToClaimInfo = TextComponent.builder() diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java index b77a606..4bb0954 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java @@ -51,6 +51,7 @@ import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import net.kyori.text.Component; import net.kyori.text.TextComponent; @@ -220,13 +221,20 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU .append(subTypeText) .append(" ") .append(townTypeText).build(); - final int fillSize = 20 - (claimsTextList.size() + 2); + + int fillSize = 20 - (claimsTextList.size() + 2); + Component footer = null; + if (src != null && src.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(src, null, user.getInternalPlayerData(), "claimlist"); + fillSize = 20 - (claimsTextList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { claimsTextList.add(TextComponent.of(" ")); } PaginationList paginationList = PaginationList.builder() - .title(claimListHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList).build(); + .title(claimListHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList).footer(footer).build(); Integer activePage = 1; if (src instanceof Player) { final Player player = (Player) src; diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimSchematic.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimSchematic.java index 4bc0591..03459a1 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimSchematic.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimSchematic.java @@ -44,6 +44,8 @@ import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.adapter.bukkit.TextAdapter; @@ -98,11 +100,11 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept return; } - List schematicTextList = new ArrayList<>(); + List textList = new ArrayList<>(); for (ClaimSchematic schematic : claim.schematics.values()) { final String schematicName = schematic.getName(); final Instant schematicDate = schematic.getDateCreated(); - schematicTextList.add( + textList.add( TextComponent.builder("") .append(schematicName, TextColor.GREEN) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(displayConfirmationConsumer(player, claim, schematic)))) @@ -113,13 +115,21 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept .build()); } - final int fillSize = 20 - (schematicTextList.size() + 2); + Component footer = null; + int fillSize = 20 - (textList.size() + 2); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, null, playerData, "claimschematic")) + .build(); + fillSize = 20 - (textList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { - schematicTextList.add(TextComponent.of(" ")); + textList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(schematicTextList); + .title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(player); } else if (action.equalsIgnoreCase("create")) { TextAdapter.sendComponent(player, TextComponent.of("Creating schematic backup...", TextColor.GREEN)); diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandTrustList.java b/bukkit/src/main/java/com/griefdefender/command/CommandTrustList.java index 7291bc9..466c6fa 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandTrustList.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandTrustList.java @@ -38,12 +38,15 @@ import com.griefdefender.cache.MessageCache; import com.griefdefender.cache.PermissionHolderCache; import com.griefdefender.claim.GDClaim; -import com.griefdefender.configuration.MessageDataConfig; +import com.griefdefender.configuration.IClaimData; import com.griefdefender.configuration.MessageStorage; import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; +import com.griefdefender.util.PermissionUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; @@ -53,6 +56,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -68,10 +72,10 @@ public class CommandTrustList extends BaseCommand { public void execute(Player player) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); - showTrustList(player, claim, TrustTypes.NONE); + showTrustList(player, claim, playerData, TrustTypes.NONE, new ArrayList<>(), null); } - public static void showTrustList(CommandSender src, GDClaim claim, TrustType type) { + public static void showTrustList(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, List messages, Component returnCommand) { final Component whiteOpenBracket = TextComponent.of("[", TextColor.AQUA); final Component whiteCloseBracket = TextComponent.of("]", TextColor.AQUA); final Component showAllText = MessageCache.getInstance().TRUST_CLICK_SHOW_LIST; @@ -86,12 +90,12 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ final Component allTypeText = TextComponent.builder("") .append(type == TrustTypes.NONE ? TextComponent.builder("") .append(whiteOpenBracket) - .append("ALL") + .append(MessageCache.getInstance().TITLE_ALL) .append(whiteCloseBracket) .build() : TextComponent.builder("") - .append("ALL",TextColor.GRAY) + .append(MessageCache.getInstance().TITLE_ALL.color(TextColor.GRAY)) .build()) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.NONE)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.NONE, returnCommand)))) .hoverEvent(HoverEvent.showText(showAllText)).build(); final Component accessorTrustText = TextComponent.builder("") .append(type == TrustTypes.ACCESSOR ? TextComponent.builder("") @@ -99,7 +103,7 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_ACCESSOR.color(TextColor.YELLOW)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_ACCESSOR.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.ACCESSOR)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.ACCESSOR, returnCommand)))) .hoverEvent(HoverEvent.showText(showAccessorText)).build(); final Component builderTrustText = TextComponent.builder("") .append(type == TrustTypes.BUILDER ? TextComponent.builder("") @@ -107,7 +111,7 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_BUILDER.color(TextColor.GREEN)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_BUILDER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.BUILDER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.BUILDER, returnCommand)))) .hoverEvent(HoverEvent.showText(showBuilderText)).build(); final Component containerTrustText = TextComponent.builder("") .append(type == TrustTypes.CONTAINER ? TextComponent.builder("") @@ -115,15 +119,15 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_CONTAINER.color(TextColor.LIGHT_PURPLE)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_CONTAINER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.CONTAINER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.CONTAINER, returnCommand)))) .hoverEvent(HoverEvent.showText(showContainerText)).build(); final Component managerTrustText = TextComponent.builder("") .append(type == TrustTypes.MANAGER ? TextComponent.builder("") .append(whiteOpenBracket) - .append("MANAGER", TextColor.GOLD) + .append(MessageCache.getInstance().TITLE_MANAGER.color(TextColor.GOLD)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_MANAGER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.MANAGER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.MANAGER, returnCommand)))) .hoverEvent(HoverEvent.showText(showManagerText)).build(); final Component claimTrustHead = TextComponent.builder() .append(" ") @@ -143,12 +147,25 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ List userIdList = new ArrayList<>(claim.getUserTrusts()); List trustList = new ArrayList<>(); trustList.add(TextComponent.empty()); - + if (returnCommand != null) { + trustList.add(returnCommand); + } if (type == TrustTypes.NONE) { // check highest trust first for (UUID uuid : claim.getInternalClaimData().getManagers()) { final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.GOLD)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getManagers(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(user.getUniqueId()); } @@ -158,97 +175,222 @@ public static void showTrustList(CommandSender src, GDClaim claim, TrustType typ } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.GREEN)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getBuilders(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - /*for (String group : claim.getInternalClaimData().getManagerGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - for (UUID uuid : claim.getInternalClaimData().getContainers()) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.LIGHT_PURPLE)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getContainers(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - - /* for (String group : claim.getInternalClaimData().getBuilderGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - + for (UUID uuid : claim.getInternalClaimData().getAccessors()) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.YELLOW)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getAccessors(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - - /*for (String group : claim.getInternalClaimData().getContainerGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - } - - player.sendMessage(permissions.build()); - permissions = Text.builder(">").color(TextColors.BLUE); - - for (UUID uuid : claim.getInternalClaimData().getAccessors()) { - User user = GriefDefenderPlugin.getOrCreateUser(uuid); - permissions.append(SPACE_TEXT, Text.of(user.getName())); - } - - for (String group : claim.getInternalClaimData().getAccessorGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - } else { - for (UUID uuid : claim.getUserTrusts(type)) { + final List trusts = claim.getUserTrustList(type); + trustList.add(TextComponent.builder("") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("+", TextColor.GREEN) + .hoverEvent(HoverEvent.showText(TextComponent.of("Click here to add"))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createInputConsumer(src, claim, playerData, type, messages, returnCommand)))) + .build()) + .append("]", TextColor.WHITE) + .build()); + + for (UUID uuid : trusts) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), getTrustColor(type))); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), trusts, uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } } + Component footer = null; int fillSize = 20 - (trustList.size() + 2); + if (src.hasPermission(GDPermissions.CHAT_CAPTURE)) { + fillSize = 20 - (trustList.size() + 3); + if (messages != null && !messages.isEmpty()) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(src, claim, playerData, "trustlist", returnCommand)) + .append(TextComponent.of("\n")) + .build(); + for (Component message : messages) { + footer = footer.append(message); + fillSize -= 1; + } + messages.clear(); + } else { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(src, claim, playerData, "trustlist", returnCommand)) + .build(); + } + } + for (int i = 0; i < fillSize; i++) { trustList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(claimTrustHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(trustList); + .title(claimTrustHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(trustList).footer(footer); paginationBuilder.sendTo(src); paginationBuilder.sendTo(src); } - private static TextColor getTrustColor(TrustType type) { - if (type == TrustTypes.NONE) { - return TextColor.WHITE; - } - if (type == TrustTypes.ACCESSOR) { - return TextColor.YELLOW; - } - if (type == TrustTypes.BUILDER) { - return TextColor.GREEN; - } - if (type == TrustTypes.CONTAINER) { - return TextColor.LIGHT_PURPLE; - } - return TextColor.GOLD; - } - - private static Consumer createTrustConsumer(CommandSender src, GDClaim claim, TrustType type) { + private static Consumer createTrustConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { return consumer -> { - showTrustList(src, claim, type); + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); + }; + } + + private static Consumer createInputConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, List messages, Component returnCommand) { + return consumer -> { + if (messages == null || messages.isEmpty()) { + playerData.commandInputTimestamp = Instant.now(); + playerData.trustAddConsumer = createAddConsumer(src, claim, playerData, type, returnCommand); + } + messages.add(TextComponent.builder() + .append(TextComponent.of("Do you want to add a ") + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_PLAYER.color(TextColor.GOLD)) + .clickEvent(ClickEvent.suggestCommand("player ")) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, + ImmutableMap.of("target", "player")))) + .build()) + .append(TextComponent.of(" or ")) + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_GROUP.color(TextColor.AQUA)) + .clickEvent(ClickEvent.suggestCommand("group ")) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, + ImmutableMap.of("target", "group")))) + .build())) + .append(" ? ") + .append("[") + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_CANCEL.color(TextColor.RED)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createCancelConsumer(src, claim, playerData, type, returnCommand)))) + .build()) + .append("]") + .build()); + showTrustList(src, claim, playerData, type, messages, returnCommand); + }; + } + + private static Consumer createAddConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { + return consumer -> { + String name = playerData.commandInput; + List messages = new ArrayList<>(); + if (playerData.commandInput.contains("player ")) { + name = name.replace("player ", ""); + if (!name.equalsIgnoreCase("public") && PermissionUtil.getInstance().lookupUserUniqueId(name) == null) { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", name))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + } else if (playerData.commandInput.contains("group ")) { + name = name.replace("group ", ""); + if (!name.equalsIgnoreCase("public") && !PermissionUtil.getInstance().hasGroupSubject(name)) { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", name))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + } else { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_INPUT, + ImmutableMap.of( + "input", playerData.commandInput))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + CommandHelper.executeCommand(src, "trust", name + " " + type.getName().toLowerCase()); + playerData.commandInputTimestamp = null; + playerData.trustAddConsumer = null; + showTrustList(src, claim, playerData, type, messages, returnCommand); + }; + } + + private static Consumer createCancelConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { + return consumer -> { + playerData.commandInputTimestamp = null; + playerData.trustAddConsumer = null; + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); + }; + } + + private static Consumer createRemoveConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand, IClaimData data, List trustList, UUID uuid) { + return consumer -> { + trustList.remove(uuid); + data.setRequiresSave(true); + data.save(); + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); }; } } diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandTrustPlayer.java b/bukkit/src/main/java/com/griefdefender/command/CommandTrustPlayer.java index 0b31625..35a7830 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandTrustPlayer.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandTrustPlayer.java @@ -51,6 +51,7 @@ import com.griefdefender.event.GDUserTrustClaimEvent; import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; +import com.griefdefender.util.PermissionUtil; import java.util.List; import java.util.UUID; @@ -86,6 +87,12 @@ public void execute(Player player, String target, @Optional String type) { if (target.equalsIgnoreCase("public")) { user = GriefDefenderPlugin.PUBLIC_USER; } else { + if (PermissionUtil.getInstance().lookupUserUniqueId(target) == null) { + GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", target))); + return; + } user = PermissionHolderCache.getInstance().getOrCreateUser(target); } diff --git a/bukkit/src/main/java/com/griefdefender/configuration/MessageStorage.java b/bukkit/src/main/java/com/griefdefender/configuration/MessageStorage.java index 48bcac9..486d5c4 100644 --- a/bukkit/src/main/java/com/griefdefender/configuration/MessageStorage.java +++ b/bukkit/src/main/java/com/griefdefender/configuration/MessageStorage.java @@ -151,6 +151,7 @@ public class MessageStorage { public static final String COMMAND_INVALID_AMOUNT = "command-invalid-amount"; public static final String COMMAND_INVALID_CLAIM = "command-invalid-claim"; public static final String COMMAND_INVALID_GROUP = "command-invalid-group"; + public static final String COMMAND_INVALID_INPUT = "command-invalid-input"; public static final String COMMAND_INVALID_PLAYER = "command-invalid-player"; public static final String COMMAND_INVALID_TYPE = "command-invalid-type"; public static final String COMMAND_OPTION_EXCEEDS_ADMIN = "command-option-exceeds-admin"; @@ -305,7 +306,10 @@ public class MessageStorage { public static final String TRUST_INDIVIDUAL_ALL_CLAIMS = "trust-individual-all-claims"; public static final String TRUST_PLUGIN_CANCEL = "trust-plugin-cancel"; public static final String TUTORIAL_CLAIM_BASIC = "tutorial-claim-basic"; + public static final String UI_CLICK_ADD_TARGET = "ui-click-add-target"; public static final String UI_CLICK_FILTER_TYPE = "ui-click-filter-type"; + public static final String UI_CLICK_RETURN_COMMAND = "ui-click-return-command"; + public static final String UI_CLICK_VIEW = "ui-click-view"; public static final String UNTRUST_INDIVIDUAL_ALL_CLAIMS = "untrust-individual-all-claims"; public static final String UNTRUST_INDIVIDUAL_SINGLE_CLAIM = "untrust-individual-single-claim"; public static final String UNTRUST_OWNER = "untrust-owner"; diff --git a/bukkit/src/main/java/com/griefdefender/configuration/category/GuiCategory.java b/bukkit/src/main/java/com/griefdefender/configuration/category/GuiCategory.java new file mode 100644 index 0000000..63c97fb --- /dev/null +++ b/bukkit/src/main/java/com/griefdefender/configuration/category/GuiCategory.java @@ -0,0 +1,37 @@ +/* + * This file is part of GriefDefender, licensed under the MIT License (MIT). + * + * Copyright (c) bloodmc + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.griefdefender.configuration.category; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class GuiCategory extends ConfigCategory { + + @Setting(value = "chat-capture-idle-timeout", comment = "The idle timeout in seconds when a command GUI will stop capturing chat.") + public int chatCaptureIdleTimeout = 15; + @Setting(value = "command-input-idle-timeout", comment = "The idle timeout in seconds when a command GUI will stop waiting for player input.") + public int commandInputIdleTimeout = 15; +} diff --git a/bukkit/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java b/bukkit/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java index 009ea69..07a1ea2 100644 --- a/bukkit/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java +++ b/bukkit/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java @@ -24,6 +24,7 @@ */ package com.griefdefender.configuration.type; +import com.griefdefender.configuration.category.GuiCategory; import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory; import com.griefdefender.configuration.category.DefaultPermissionCategory; import com.griefdefender.configuration.category.DynmapCategory; @@ -69,6 +70,8 @@ public class GlobalConfig extends ConfigBase { @Setting public EconomyCategory economy = new EconomyCategory(); @Setting + public GuiCategory gui = new GuiCategory(); + @Setting public PlayerDataCategory playerdata = new PlayerDataCategory(); @Setting public MessageCategory message = new MessageCategory(); diff --git a/bukkit/src/main/java/com/griefdefender/listener/CommandEventHandler.java b/bukkit/src/main/java/com/griefdefender/listener/CommandEventHandler.java index 03adadf..9a9058d 100644 --- a/bukkit/src/main/java/com/griefdefender/listener/CommandEventHandler.java +++ b/bukkit/src/main/java/com/griefdefender/listener/CommandEventHandler.java @@ -40,6 +40,9 @@ import com.griefdefender.storage.BaseStorage; import com.griefdefender.util.PaginationUtil; import net.kyori.text.Component; +import net.kyori.text.TextComponent; +import net.kyori.text.event.HoverEvent; +import net.kyori.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.PluginCommand; @@ -47,12 +50,20 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.server.RemoteServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; +import java.util.Iterator; + public class CommandEventHandler implements Listener { + private final DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.systemDefault()); private BaseStorage dataStore; public CommandEventHandler(BaseStorage dataStore) { @@ -69,6 +80,41 @@ public void onRemoteServerCommand(RemoteServerCommandEvent event) { // CauseTracker.getInstance().getCauseStack().add(event.getSender()); } + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerChatPost(AsyncPlayerChatEvent event) { + final Player player = event.getPlayer(); + final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); + final Iterator iterator = event.getRecipients().iterator(); + // check for command input + if (playerData.isWaitingForInput()) { + playerData.commandInput = event.getMessage(); + playerData.trustAddConsumer.accept(player); + event.setCancelled(true); + return; + } + + while (iterator.hasNext()) { + final Player receiver = iterator.next(); + if (receiver == player) { + continue; + } + + final GDPlayerData receiverData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(receiver.getWorld(), receiver.getUniqueId()); + if (receiverData.isRecordingChat()) { + iterator.remove(); + final String s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); + final Component message = LegacyComponentSerializer.legacy().deserialize(s, '&'); + final Component component = TextComponent.builder() + .append(TextComponent.builder() + .append(message) + .hoverEvent(HoverEvent.showText(TextComponent.of(formatter.format(Instant.now())))) + .build()) + .build(); + receiverData.chatLines.add(component); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerCommand(PlayerCommandPreprocessEvent event) { if (!GDFlags.COMMAND_EXECUTE && !GDFlags.COMMAND_EXECUTE_PVP) { diff --git a/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java b/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java index 2051633..8d6088e 100644 --- a/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java +++ b/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java @@ -49,6 +49,8 @@ import com.griefdefender.api.permission.option.Options; import com.griefdefender.api.permission.option.type.CreateModeType; import com.griefdefender.api.permission.option.type.CreateModeTypes; +import com.griefdefender.api.permission.option.type.GameModeType; +import com.griefdefender.api.permission.option.type.GameModeTypes; import com.griefdefender.api.permission.option.type.WeatherType; import com.griefdefender.api.permission.option.type.WeatherTypes; import com.griefdefender.cache.EventResultCache; @@ -1225,6 +1227,22 @@ private T getOptionTypeValue(TypeToken type, String value) { return (T) WeatherTypes.UNDEFINED; } + if (type.getRawType().isAssignableFrom(GameModeType.class)) { + if (value.equalsIgnoreCase("adventure")) { + return (T) GameModeTypes.ADVENTURE; + } + if (value.equalsIgnoreCase("creative")) { + return (T) GameModeTypes.CREATIVE; + } + if (value.equalsIgnoreCase("spectator")) { + return (T) GameModeTypes.SPECTATOR; + } + if (value.equalsIgnoreCase("survival")) { + return (T) GameModeTypes.SURVIVAL; + } + + return (T) GameModeTypes.UNDEFINED; + } if (type.getRawType().isAssignableFrom(Boolean.class)) { return (T) Boolean.valueOf(Boolean.parseBoolean(value)); } diff --git a/bukkit/src/main/java/com/griefdefender/permission/GDPermissions.java b/bukkit/src/main/java/com/griefdefender/permission/GDPermissions.java index a199d5c..e30e872 100644 --- a/bukkit/src/main/java/com/griefdefender/permission/GDPermissions.java +++ b/bukkit/src/main/java/com/griefdefender/permission/GDPermissions.java @@ -167,6 +167,7 @@ public class GDPermissions { // Misc public static final String COMMAND_HELP = "griefdefender.user.command.help"; + public static final String CHAT_CAPTURE = "griefdefender.user.chat.capture"; // Trust public static final String COMMAND_TRUST_GROUP = "griefdefender.user.claim.command.trust.group"; diff --git a/bukkit/src/main/java/com/griefdefender/task/PlayerTickTask.java b/bukkit/src/main/java/com/griefdefender/task/PlayerTickTask.java index 3296212..a0e726d 100644 --- a/bukkit/src/main/java/com/griefdefender/task/PlayerTickTask.java +++ b/bukkit/src/main/java/com/griefdefender/task/PlayerTickTask.java @@ -66,6 +66,8 @@ public void run() { } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); + // chat capture + playerData.updateRecordChat(); // health regen if (world.getFullTime() % 100 == 0L) { final GameMode gameMode = player.getGameMode(); diff --git a/bukkit/src/main/java/com/griefdefender/util/ChatCaptureUtil.java b/bukkit/src/main/java/com/griefdefender/util/ChatCaptureUtil.java new file mode 100644 index 0000000..4adb37c --- /dev/null +++ b/bukkit/src/main/java/com/griefdefender/util/ChatCaptureUtil.java @@ -0,0 +1,182 @@ +/* + * This file is part of GriefDefender, licensed under the MIT License (MIT). + * + * Copyright (c) bloodmc + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.griefdefender.util; + +import com.google.common.collect.ImmutableMap; +import com.griefdefender.GDPlayerData; +import com.griefdefender.GriefDefenderPlugin; +import com.griefdefender.api.claim.TrustType; +import com.griefdefender.api.claim.TrustTypes; +import com.griefdefender.cache.MessageCache; +import com.griefdefender.cache.PermissionHolderCache; +import com.griefdefender.claim.GDClaim; +import com.griefdefender.command.CommandHelper; +import com.griefdefender.command.CommandTrustList; +import com.griefdefender.configuration.MessageStorage; +import com.griefdefender.internal.pagination.PaginationList; +import com.griefdefender.permission.GDPermissionUser; +import com.griefdefender.text.action.GDCallbackHolder; +import net.kyori.text.Component; +import net.kyori.text.TextComponent; +import net.kyori.text.event.ClickEvent; +import net.kyori.text.event.HoverEvent; +import net.kyori.text.format.TextColor; +import net.kyori.text.format.TextDecoration; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class ChatCaptureUtil { + + private static ChatCaptureUtil instance; + private static final Component whiteOpenBracket = TextComponent.of("[", TextColor.AQUA); + private static final Component whiteCloseBracket = TextComponent.of("]", TextColor.AQUA); + + public static ChatCaptureUtil getInstance() { + return instance; + } + + static { + instance = new ChatCaptureUtil(); + } + + public Component createRecordChatComponent(Player player, GDClaim claim, GDPlayerData playerData, String command) { + return this.createRecordChatComponent(player, claim, playerData, command, null); + } + + public Component createRecordChatComponent(Player player, GDClaim claim, GDPlayerData playerData, String command, Component returnComponent) { + final Component chatSettings = TextComponent.builder() + .append(TextComponent.builder() + .append(whiteOpenBracket) + .append("RECORD-CHAT").color(TextColor.GOLD).append(whiteCloseBracket) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatSettingsConsumer(player, claim, command, returnComponent)))) + .hoverEvent(HoverEvent.showText(TextComponent.of("Click here to see recorded chat."))) + .build()) + .append(TextComponent.builder() + .append(" ") + .append(getRecordChatClickableInfoText(player, claim, MessageCache.getInstance().CLAIMINFO_UI_CLICK_TOGGLE, playerData.isRecordingChat() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED), command)) + .build()) + .build(); + return chatSettings; + } + + public Component getRecordChatClickableInfoText(CommandSender src, GDClaim claim, Component clickText, Component infoText, String command) { + boolean hasPermission = true; + if (claim != null && src instanceof Player) { + Component denyReason = claim.allowEdit((Player) src); + if (denyReason != null) { + clickText = denyReason; + hasPermission = false; + } + } + + TextComponent.Builder textBuilder = TextComponent.builder() + .append(infoText) + .hoverEvent(HoverEvent.showText(clickText)); + if (hasPermission) { + textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatInfoConsumer(src, claim, command)))); + } + return textBuilder.build(); + } + + private Consumer createChatInfoConsumer(CommandSender src, GDClaim claim, String command) { + return info -> { + if (!(src instanceof Player)) { + return; + } + final Player player = (Player) src; + final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player); + final GDPlayerData playerData = user.getInternalPlayerData(); + final boolean isRecordingChat = playerData.isRecordingChat(); + if (isRecordingChat) { + playerData.recordChatTimestamp = null; + } else { + playerData.recordChatTimestamp = Instant.now(); + playerData.chatLines.clear(); + } + if (command.equals("claiminfo")) { + CommandHelper.executeCommand(src, command, claim.getUniqueId().toString()); + } else { + CommandHelper.executeCommand(src, command, ""); + } + }; + } + + public Consumer createChatSettingsConsumer(Player player, GDClaim claim, String command, Component returnComponent) { + return settings -> { + PaginationList.Builder paginationBuilder = PaginationList.builder() + .title(TextComponent.of("RECORD-CHAT").color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(generateChatSettings(player, claim, command, returnComponent)); + paginationBuilder.sendTo(player); + }; + } + + public List generateChatSettings(Player player, GDClaim claim, String command, Component returnComponent) { + final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); + List textList = new ArrayList<>(); + Component returnToClaimInfo = null; + if (command.equals("claiminfo")) { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, claim.getUniqueId().toString())))).build(); + } else if (command.equals("trustlist")) { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, claim, playerData, TrustTypes.NONE, returnComponent)))).build(); + } else { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, "")))).build(); + } + textList.add(returnToClaimInfo); + for (Component chatLine : playerData.chatLines) { + textList.add(chatLine); + } + + int fillSize = 20 - (textList.size() + 2); + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + return textList; + } + + private Consumer createTrustListConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnComponent) { + return consumer -> { + CommandTrustList.showTrustList(src, claim, playerData, type, new ArrayList<>(), returnComponent); + }; + } +} diff --git a/bukkit/src/main/resources/assets/lang/de_DE.conf b/bukkit/src/main/resources/assets/lang/de_DE.conf index f6ec549..4d4e876 100644 --- a/bukkit/src/main/resources/assets/lang/de_DE.conf +++ b/bukkit/src/main/resources/assets/lang/de_DE.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&cDu bist bereits der Besitzer dieses Grundstückes." claim-owner-only="&cNur &6{player}&c kann das Grundstück anpassen." claim-protected-entity="&cDas gehört &6{player}&c." + claim-reserve-add="&aDer Grundstücksname &6{name}&a wurde zur Liste der reservierten Namen hinzugefügt." + claim-reserve-exists="&aDieser Grundstücksname ist bereits reserviert." + claim-reserved-name="&cDer von dir gewählte Name ist leider reserviert. Bitte wähle einen anderen Namen für dein Grundstück oder stelle sicher, dass du die Berechtigung hast diesen Namen zu verwenden." claim-respecting="&aGrundstücke werden nun respektiert." claim-restore-success="&aGrundstück erfolgreich wiederhergestellt." claim-show-nearby="&6{amount}&a Grundstücke in der Umgebung gefunden." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&cKeine gültige Anzahl eingegeben: &6{amount}&c." command-invalid-claim="&cDieser Befehl kann nicht auf {type}&c Grundstücken benutzt werden." command-invalid-group="&c &6{group}&c ist keine gültige Gruppe." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&6{player}&c ist kein gültiger Spieler." command-invalid-player-group="&cSpieler oder Gruppe nicht existent." command-invalid-type="&cTyp {type}&c existiert nicht." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&cOption {option}&c nicht gefunden." option-not-set="{option}&f ist nicht eingestellt.\n&dHinweis&f: Standardoption {value}&f ist solange aktiv." option-override-not-supported="&cGrundstücksart {type}&c unterstützt keine überschreibenden Einstellungen." - option-player-deny-flight="&cDu darfst in diesem Grundstück nicht fliegen und wurdest zu einem sicheren Landeplatz teleportiert." option-requires-contexts="&cDiese Option benötigt zum Einstellen den Kontext '&a{contexts}&c'." option-reset-success="&aGrundstückseinstellungen erfolgreich zurückgesetzt." option-set-target="&aSetze {type}&a für Option &b{option}&a auf {value}&a mit dem Kontext &7{contexts}&a für &6{target}&a." @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cKeine sichere Position gefunden!\n&aNutze '&f/claiminfo&a' um einen sicheren Spawnpunkt auf dem Grundstück zu setzen." teleport-success="&aDu wurdest zu {name}&a teleportiert." title-accessor=ZUGRIFFSBERECHTIGT + title-advanced=ADVANCED title-all=ALLE title-builder=BAUBERECHTIGT title-claim=GRUNDSTÜCK @@ -622,6 +626,7 @@ GriefDefender { title-manager=MANAGER title-override=ÜBERGEORDNET title-own=EIGENE + title-preset=PRESET tool-not-equipped="&cDu hast {tool}&c nicht ausgerüstet." town-chat-disabled="&aStadt Chat ausgestellt." town-chat-enabled="&aStadt Chat aktiviert." @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cKonnte {target}&c keine Erlaubnis erteilen. Ein Plugin hat dies verhindert." trust-self="&cDu kannst dir selbst Rechte für Grundstücke erteilen." tutorial-claim-basic="&eTutorial Video zum Thema Grundstücke: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Bestätigen." - ui-click-filter-type="Filtern nach: {type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Bestätigen" + ui-click-filter-type="Filtern nach: {type}&f" + ui-click-remove="Klicke hier, um den Eintrag zu entfernen" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&6{target}&a Erlaubnisse für deine Grundstücke zurückgenommen. Um Berechtigungen einzelner Grundstücke zu entfernen, stelle dich drauf und nutze: &f/untrust&a." untrust-individual-single-claim="&6{target}&a Erlaubnis für dieses Grundstück entfernt. Um Berechtigungen für alle Grundstücke zu entfernen, nutze: &f/untrustall&a." untrust-no-claims="&cDu hast keine Grundstücke mit Rechten für andere Spieler." diff --git a/bukkit/src/main/resources/assets/lang/en_US.conf b/bukkit/src/main/resources/assets/lang/en_US.conf index b5e559b..b338cea 100644 --- a/bukkit/src/main/resources/assets/lang/en_US.conf +++ b/bukkit/src/main/resources/assets/lang/en_US.conf @@ -191,6 +191,7 @@ GriefDefender { command-invalid-amount="&cInvalid amount &6{amount}&c entered." command-invalid-claim="&cThis command cannot be used in {type}&c claims." command-invalid-group="&cGroup &6{group}&c is not valid." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cPlayer &6{player}&c is not valid." command-invalid-player-group="&cNot a valid player or group." command-invalid-type="&cInvalid type {type}&c specified." @@ -615,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cNo safe location found in claim to teleport!\n&aUse the '&f/claiminfo&a' command to set a safe spawn point instead." teleport-success="&aYou have been teleported to {name}&a." title-accessor=ACCESSOR + title-advanced=ADVANCED title-all=ALL title-builder=BUILDER title-claim=CLAIM @@ -624,6 +626,7 @@ GriefDefender { title-manager=MANAGER title-override=OVERRIDE title-own=OWN + title-preset=PRESET tool-not-equipped="&cYou do not have {tool}&c equipped." town-chat-disabled="&aTown chat disabled." town-chat-enabled="&aTown chat enabled." @@ -645,9 +648,13 @@ GriefDefender { trust-plugin-cancel="&cCould not trust {target}&c. A plugin has denied it." trust-self="&cYou cannot trust yourself." tutorial-claim-basic="&eClick for Land Claim Help: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Click to confirm." - ui-click-filter-type="Click here to filter by {type}&f." - ui-click-remove="Click here to remove." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Click to confirm" + ui-click-filter-type="Click here to filter by {type}&f" + ui-click-remove="Click here to remove" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aRevoked &6{target}'s&a access to ALL your claims. To set permissions for a single claim, stand inside it and use &f/untrust&a." untrust-individual-single-claim="&aRevoked &6{target}'s&a access to this claim. To unset permissions for ALL your claims, use &f/untrustall&a." untrust-no-claims="&cYou have no claims to untrust." diff --git a/bukkit/src/main/resources/assets/lang/es_ES.conf b/bukkit/src/main/resources/assets/lang/es_ES.conf index a2c79bf..643396f 100644 --- a/bukkit/src/main/resources/assets/lang/es_ES.conf +++ b/bukkit/src/main/resources/assets/lang/es_ES.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&4&l[ERROR] &cYa eres el dueño del Claim." claim-owner-only="&4&l[ERROR] &cNo puedes configurar nada de este Claim, solo &6&o{player}&c puede modificarlo." claim-protected-entity="&4&l[ERROR] &cEsto pertenece a &6&o{player}&c." + claim-reserve-add="&aEl nombre del terreno &6&o'{name}' &aha sido añadido a la lista de &b&lN&bombres de &lT&berrenos &lR&beservados&a." + claim-reserve-exists="&4&l[ATENCION] &aEl nombre del terreno que especificó ya está reservado por un jugador." + claim-reserved-name="&4&l[ERROR] &c&lEl nombre del terreno que especificó está reservado. &cPor favor escoge otro o asegurate de que tienes el permiso apropiado." claim-respecting="&aAhora respetas los Claims." claim-restore-success="&2&l[RESTAURACION COMPLETADA] &a¡Los Claims han sido restaurados con éxito!" claim-show-nearby="&aCLAIMS CERCANOS ► &6&o{amount}&a." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&4&l[ERROR] &cCantidad inválida de &6{amount}&oCB's&c introducida." command-invalid-claim="&4&l[ERROR] &cEste comando no puede ser usado en Claims de tipo &l➜ {type}&c." command-invalid-group="&4&l[ERROR] &cEl grupo &6&o'{group}'&c NO es válido." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&4&l[ERROR] &cEl jugador &6&o'{player}'&c NO es válido." command-invalid-player-group="&4&l[ERROR] &cJugador o Grupo NO válidos." command-invalid-type="&4&l[ERROR] &cTipo especificado: {type}&c &l➜ INVALIDO." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&4&l[ERROR] &cOpción &6&o'{option}' &c&lNO-ENCONTRADA&c." option-not-set="&4&l[ERROR] &6&o'{option}'&c no está establecida.\n&4&l[NOTA] &cLa opción con valor de &6&o'{value}'&c estará activa hasta que se establezca." option-override-not-supported="&4&l[ERROR] &cEl Claim tipo &6&o'{type}'&c no soporta la opción de Sobrescribir." - option-player-deny-flight="&4&l[VOLAR-DESACTIVADO] &cNo tienes acceso a la habilidad de volar en este terreno. Serás teletransportado a un lugar seguro en el suelo." option-requires-contexts="&4&l[ERROR] &cEsta opción requiere el Contexto &6&o'{contexts}'&c para ser establecido." option-reset-success="&2&l[OPCIONES-RESETEADAS] &a¡Todas las opciones de Claim han sido reiniciadas al estado original con éxito!" option-set-target="&aEstablecido ( &e&o{type}&a ) una opción ( &b&o{option} &a)&a en (&6&o {value} &a)&a con el Contexto de (&7&o {contexts} &a)&a en el Objetivo de ( &c&o{target} &a)" @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&4&l[IMPOSIBLE-TELETRANSPORTARSE] &cNo existe zona segura en el terreno a la que teletransportarse.\n&4&l[NOTA] &aUsa '&6&o/claiminfo&a' para establecer un punto de Spawn seguro." teleport-success="&2&l[TELETRANSPORTADO] ➜ &6&o{name}" title-accessor=ACCEDER + title-advanced=ADVANCED title-all=TODO title-builder=CONSTRUIR title-claim=RECLAMAR @@ -622,6 +626,7 @@ GriefDefender { title-manager=ADMINISTRAR title-override=IGNORAR title-own=DUEÑO + title-preset=PRESET tool-not-equipped="&4&l[ERROR] &cNo tienes la &6&o'{tool}'&c equipada." town-chat-disabled="&2&l[CHAT-CIUDAD]&f ➜ &8&lACTIVADO&f&l/&c&lDESACTIVADO" town-chat-enabled="&2&l[CHAT-CIUDAD]&f ➜ &a&lACTIVADO&f&l/&8&lDESACTIVADO" @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&4&l[ERROR] &cNo puedes confiar a &6&o{target}&c. Un plugin lo ha denegado." trust-self="&4&l[ERROR] &cNo puedes darte permisos de Confianza a ti mismo." tutorial-claim-basic="&eClick para ayuda con el reclamo del terreno: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="CLICK para Confirmar." - ui-click-filter-type="CLICK para filtar por &6&o{type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="CLICK para Confirmar" + ui-click-filter-type="CLICK para filtar por &6&o{type}&f" + ui-click-remove="Click aqui para eliminar" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&4&l[ACCESO-ANULADO] &C➜ &6{target}&c a TODOS tus terrenos.\n&4&l[NOTA] &cPara denegar permisos de Confianza en un SOLO terreno tienes que estar dentro de él y usar &6&o'/untrust'&c." untrust-individual-single-claim="&4&l[ACCESO-ANULADO] &C➜ &6{target}&c a ESTE terreno.\n&4&l[NOTA] &cPara denegar permisos de Confianza en TODOS tus terrenos tienes que usar &6&o'/untrustall'&c." untrust-no-claims="&4&l[ERROR] &cNo tienes terrenos para quitar permisos de Confianza." diff --git a/bukkit/src/main/resources/assets/lang/fr_FR.conf b/bukkit/src/main/resources/assets/lang/fr_FR.conf index 85a1404..cdb53b1 100644 --- a/bukkit/src/main/resources/assets/lang/fr_FR.conf +++ b/bukkit/src/main/resources/assets/lang/fr_FR.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&cTu es déjà le propriétaire de ce terrain." claim-owner-only="&cSeulement &6{player}&c peut modifier ce terrain." claim-protected-entity="&cCela appartient à &6{player}&c." + claim-reserve-add="&aLe nom &6{name}&a de terrain a été ajouté à la liste de réservation." + claim-reserve-exists="&aLe nom de terrain que tu as spécifié est déjà réservé." + claim-reserved-name="&cLe nom de terrain que tu as spécifié est réservé. Merci d'en choisir un autre ou de vérifier que tu as la permission appropriée." claim-respecting="&aRespecte maintenant les terrains." claim-restore-success="&aRestauration du terrain avec succès." claim-show-nearby="&aTrouvé &6{amount}&a terrain(s) à proximité." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&cMontant invalide &6{amount}&c entré." command-invalid-claim="&cCette commande ne peut être utilisée dans les terrains de type {type}&c." command-invalid-group="&cGroupe &6{group}&c n'est pas valide." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cJoueur &6{player}&c n'est pas valide." command-invalid-player-group="&cPas un joueur ou groupe valide." command-invalid-type="&cType {type}&c invalide spécifié." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&cL'option {option}&c n'a pas été trouvée." option-not-set="{option}&f est actuellement non définit.\n&dNote&f: La valeur par défaut {value}&f de l'option sera active jusqu'à définition." option-override-not-supported="&cProtection de type {type}&c ne supporte pas les options outrepassantes." - option-player-deny-flight="&cTu n'as pas accès au fly dans cette protection et a été téléporté dans une zone sécurisée au sol." option-requires-contexts="&cCette option a besoin que le contexte '&a{contexts}&c' soi défini." option-reset-success="&aOption de la protection remises par défaut avec succès." option-set-target="&aDéfinis {type}&a de l'option &b{option}&a à {value}&a avec le contexte &7{contexts}&a sur la cible &6{target}&a." @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cPas de zone sécurisée trouvée dans la protection pour se téléporter !\n&aClique confirm pour téléporter malgré tout ou &autilise la commande '&f/claiminfo&a' pour définir une un point d'apparition sécurisé à la place." teleport-success="&aTu as été téléporté à {name}&a." title-accessor=ACCÉDANT + title-advanced=ADVANCED title-all=TOUS title-builder=CONSTRUTEUR title-claim=PROTECTION @@ -622,6 +626,7 @@ GriefDefender { title-manager=GÉRANT title-override=OUTREPASSANT title-own=POSSÈDE + title-preset=PRESET tool-not-equipped="&cTu n'as pas {tool}&c équipé." town-chat-disabled="&aChat de Village désactivé." town-chat-enabled="&aChat de Village activé." @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cImpossible d'avoir Confiance en {target}&c. Un plug-in l'a refusé." trust-self="&cTu ne peut pas te faire Confiance à toi-même." tutorial-claim-basic="&eClique pour l'aide sur la protection: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Clique pour confirmer." - ui-click-filter-type="Clique ici pour filtrer par {type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Clique pour confirmer" + ui-click-filter-type="Clique ici pour filtrer par {type}&f" + ui-click-remove="Clique ici pour supprimer" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aRévoque &6{target}&a accès à l'ENSEMBLE de tes protections. Pour définir la permission pour une seule protection, va dedans et utilises &f/untrust&a." untrust-individual-single-claim="&aRévoque &6{target}&a accès à cette protection. Pour définir la permission pour l'ENSEMBLE de tes protections, utilises &f/untrustall&a." untrust-no-claims="&cTu n'as pas de protection où enlever la confiance." diff --git a/bukkit/src/main/resources/assets/lang/ru_RU.conf b/bukkit/src/main/resources/assets/lang/ru_RU.conf index 238a7b0..18b8b65 100644 --- a/bukkit/src/main/resources/assets/lang/ru_RU.conf +++ b/bukkit/src/main/resources/assets/lang/ru_RU.conf @@ -58,6 +58,7 @@ GriefDefender { version="Вывести информацию о версии GriefDefender." } messages { + abandon-all-delay-warning="&aThese claims were recently created and cannot be abandoned." abandon-all-warning="&6Вы уверены, что хотите удалить &cВСЕ&6 ваши регионы?" abandon-claim-delay-warning="&aЭтот регион был создан недавно и не может быть удалён до &6{date}&a." abandon-claim-failed="&aНе удалось удалить регион. Результат действия: &f{result}&a." @@ -107,6 +108,9 @@ GriefDefender { claim-owner-already="&cВы уже являетесь владельцем этого региона." claim-owner-only="&cТолько &6{player}&c может редактировать этот регион." claim-protected-entity="&cЭто принадлежит игроку &6{player}&c." + claim-reserve-add="&aНазвание региона &6{name}&a добавлено в список зарезервированных." + claim-reserve-exists="&aЭто имя региона уже зарезервировано." + claim-reserved-name="&cУказанное имя региона зарезервировано. Пожалуйста, выберите другое или удостоверьтесь, что у вас есть необходимые разрешения." claim-respecting="&aИгнорирование регионов выключено." claim-restore-success="&aРегион успешно восстановлен." claim-show-nearby="&aПоблизости найдено &6{amount}&a регионов." @@ -169,6 +173,8 @@ GriefDefender { command-claiminfo-uuid-required="&cПри запуске не от имени игрока требуется UUID региона ." command-claiminherit-disabled="Наследование от родителя &cВЫКЛЮЧЕНО" command-claiminherit-enabled="Наследование от родителя &aВКЛЮЧЕНО" + command-claimmode-disabled="Claim mode &cOFF" + command-claimmode-enabled="Claim mode &aON&f\n&aLeft-click to inspect.\n&aRight-click to claim.&b\nNote&f: &aUse &f/claim&a to exit mode." command-claimspawn-not-found="&aНе удалось найти регион с именем {name}&a." command-claimunban-success-block="&aБлок с id &6{id}&a успешно &6РАЗБАНЕН&a." command-claimunban-success-entity="&aСущность с id &6{id}&a успешно &6РАЗБАНЕНА&a." @@ -185,6 +191,7 @@ GriefDefender { command-invalid-amount="&cВведено неверное количество: &6{amount}&c." command-invalid-claim="&cЭту команду нельзя использовать в регионах вида &f{type}&c." command-invalid-group="&cГруппа &6{group}&c не существует." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cИгрок &6{player}&c не найден." command-invalid-player-group="&cНе является игроком или группой." command-invalid-type="&cТип {type}&c не найден." @@ -474,7 +481,6 @@ GriefDefender { option-not-found="&cОпция &f{option}&c не найдена." option-not-set="&a{option}&f не установлена.\nПрименяется стандартное значение &a{value}&f." option-override-not-supported="&cРегионы вида &f{type}&c не поддерживают переопределение опций." - option-player-deny-flight="&cУ вас нет разрешения на полёт в этом регионе. Вы были телепортированы на безопасное место на земле." option-requires-contexts="&cЭта опция требует следующие контексты: '&a{contexts}&c'." option-reset-success="&aОпции региона успешно откачены на стандартные значения." option-set-target="&aОпция &b{option}&a вида &b{type}&a с контекстами &7{contexts}&a установлена в значение {value}&a для &6{target}&a." @@ -610,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cНе удалось найти безопасную точку для телепортации в этот регион!\n&aВоспользуйтесь '&f/claiminfo&a', чтобы установить безопасную точку телепортации/возрождения." teleport-success="&aВы были телепортированы в регион {name}&a." title-accessor=ДОСТУП + title-advanced=ADVANCED title-all=ВСЕ title-builder=СТРОИТЕЛЬСТВО title-claim=РЕГИОН @@ -619,6 +626,7 @@ GriefDefender { title-manager=УПРАВЛЕНИЕ title-override=ПЕРЕОПРЕДЕЛЕНИЕ title-own=ВЛАДЕЛЕЦ + title-preset=PRESET tool-not-equipped="&cУ вас нет &f{tool}&c." town-chat-disabled="&aЧат города отключён." town-chat-enabled="&aЧат города включён." @@ -640,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cНе удалось выдать разрешения игроку &f{target}&c. Плагин не разрешил." trust-self="&cНикому нельзя доверять. Особенно себе." tutorial-claim-basic="&eНажмите для получения по созданию регионов: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Нажмите для подтверждения." - ui-click-filter-type="&7Нажмите здесь, чтобы вывести только &f{type}&7." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Нажмите для подтверждения" + ui-click-filter-type="&7Нажмите здесь, чтобы вывести только &f{type}" + ui-click-remove="Нажмите здесь, чтобы убрать" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aОтозваны все разрешения игрока &6{target}&a во ВСЕХ ваших регионах. Чтобы настраивать разрешения в одном регионе, войдите в него и используйте &f/untrust&a." untrust-individual-single-claim="&aОтозваны все разрешения игрока &6{target}&a в этом регионе. Чтобы настроаивать разрешения во ВСЕХ ваших регионах, воспользуйтесь &f/untrustall&a." untrust-no-claims="&cУ вас нет регионов, из которых можно было бы выписать игрока." diff --git a/sponge/src/main/java/com/griefdefender/GDPlayerData.java b/sponge/src/main/java/com/griefdefender/GDPlayerData.java index 854ecde..108e440 100644 --- a/sponge/src/main/java/com/griefdefender/GDPlayerData.java +++ b/sponge/src/main/java/com/griefdefender/GDPlayerData.java @@ -51,6 +51,7 @@ import net.kyori.text.Component; import org.spongepowered.api.Sponge; import org.spongepowered.api.block.BlockSnapshot; +import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.data.Transaction; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.scheduler.Task; @@ -68,6 +69,7 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.function.Consumer; public class GDPlayerData implements PlayerData { @@ -98,6 +100,11 @@ public class GDPlayerData implements PlayerData { public boolean inTown = false; public boolean townChat = false; + public List chatLines = new ArrayList<>(); + public Instant recordChatTimestamp; + public Instant commandInputTimestamp; + public String commandInput; + public Consumer trustAddConsumer; // Always ignore active contexts by default // This prevents protection issues when other plugins call getActiveContext @@ -671,6 +678,48 @@ public int getPvpCombatTimeRemaining() { return combatTimeout - duration; } + public void updateRecordChat() { + final Player player = this.getSubject().getOnlinePlayer(); + if (this.recordChatTimestamp == null || player == null) { + return; + } + + final Instant now = Instant.now(); + final int timeout = GriefDefenderPlugin.getGlobalConfig().getConfig().gui.chatCaptureIdleTimeout; + if (timeout <= 0) { + return; + } + + if (this.recordChatTimestamp.plusSeconds(timeout).isBefore(now)) { + this.recordChatTimestamp = null; + } + } + + public boolean isRecordingChat() { + return this.recordChatTimestamp != null; + } + + public void updateCommandInput() { + final Player player = this.getSubject().getOnlinePlayer(); + if (this.commandInputTimestamp == null || player == null) { + return; + } + + final Instant now = Instant.now(); + final int timeout = GriefDefenderPlugin.getGlobalConfig().getConfig().gui.commandInputIdleTimeout; + if (timeout <= 0) { + return; + } + + if (this.commandInputTimestamp.plusSeconds(timeout).isBefore(now)) { + this.commandInputTimestamp = null; + } + } + + public boolean isWaitingForInput() { + return this.commandInputTimestamp != null; + } + public void onClaimDelete() { this.lastShovelLocation = null; this.eventResultCache = null; diff --git a/sponge/src/main/java/com/griefdefender/cache/MessageCache.java b/sponge/src/main/java/com/griefdefender/cache/MessageCache.java index 17bfc30..95d2db3 100644 --- a/sponge/src/main/java/com/griefdefender/cache/MessageCache.java +++ b/sponge/src/main/java/com/griefdefender/cache/MessageCache.java @@ -256,6 +256,7 @@ public static MessageCache getInstance() { public Component LABEL_BLOCKS; public Component LABEL_BUILDERS; public Component LABEL_BUY; + public Component LABEL_CANCEL; public Component LABEL_CHILDREN; public Component LABEL_CONFIRM; public Component LABEL_CONTAINERS; @@ -276,6 +277,7 @@ public static MessageCache getInstance() { public Component LABEL_OWNER; public Component LABEL_PERMISSION; public Component LABEL_PLAYER; + public Component LABEL_PRESET; public Component LABEL_PRICE; public Component LABEL_RAID; public Component LABEL_RESIZABLE; @@ -386,6 +388,7 @@ public static MessageCache getInstance() { public Component TELEPORT_MOVE_CANCEL; public Component TELEPORT_NO_SAFE_LOCATION; public Component TITLE_ACCESSOR; + public Component TITLE_ADVANCED; public Component TITLE_ALL; public Component TITLE_BUILDER; public Component TITLE_CLAIM; @@ -407,6 +410,9 @@ public static MessageCache getInstance() { public Component TRUST_LIST_HEADER; public Component TRUST_NO_CLAIMS; public Component TRUST_SELF; + public Component UI_CLICK_ADD; + public Component UI_CLICK_ADD_GROUP; + public Component UI_CLICK_ADD_PLAYER; public Component UI_CLICK_CONFIRM; public Component UI_CLICK_REMOVE; public Component UNTRUST_NO_CLAIMS; @@ -618,11 +624,11 @@ public void loadCache() { FLAG_UI_OVERRIDE_NO_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-override-no-permission"); FLAG_UI_RETURN_FLAGS = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-return-flags"); LABEL_ACCESSORS = MessageStorage.MESSAGE_DATA.getMessage("label-accessors"); - LABEL_ALL = MessageStorage.MESSAGE_DATA.getMessage("label-all"); LABEL_AREA = MessageStorage.MESSAGE_DATA.getMessage("label-area"); LABEL_BLOCKS = MessageStorage.MESSAGE_DATA.getMessage("label-blocks"); LABEL_BUILDERS = MessageStorage.MESSAGE_DATA.getMessage("label-builders"); LABEL_BUY = MessageStorage.MESSAGE_DATA.getMessage("label-buy"); + LABEL_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("label-cancel"); LABEL_CHILDREN = MessageStorage.MESSAGE_DATA.getMessage("label-children"); LABEL_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("label-confirm"); LABEL_CONTAINERS = MessageStorage.MESSAGE_DATA.getMessage("label-containers"); @@ -644,6 +650,7 @@ public void loadCache() { LABEL_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("label-permission"); LABEL_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("label-player"); LABEL_PRICE = MessageStorage.MESSAGE_DATA.getMessage("label-price"); + LABEL_PRESET = MessageStorage.MESSAGE_DATA.getMessage("label-preset"); LABEL_RAID = MessageStorage.MESSAGE_DATA.getMessage("label-raid"); LABEL_RESIZABLE = MessageStorage.MESSAGE_DATA.getMessage("label-resizable"); LABEL_RESULT = MessageStorage.MESSAGE_DATA.getMessage("label-result"); @@ -753,6 +760,7 @@ public void loadCache() { TELEPORT_MOVE_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("teleport-move-cancel"); TELEPORT_NO_SAFE_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("teleport-no-safe-location"); TITLE_ACCESSOR = MessageStorage.MESSAGE_DATA.getMessage("title-accessor"); + TITLE_ADVANCED = MessageStorage.MESSAGE_DATA.getMessage("title-advanced"); TITLE_ALL = MessageStorage.MESSAGE_DATA.getMessage("title-all"); TITLE_BUILDER = MessageStorage.MESSAGE_DATA.getMessage("title-builder"); TITLE_CLAIM = MessageStorage.MESSAGE_DATA.getMessage("title-claim"); @@ -774,6 +782,9 @@ public void loadCache() { TRUST_LIST_HEADER = MessageStorage.MESSAGE_DATA.getMessage("trust-list-header"); TRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("trust-no-claims"); TRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("trust-self"); + UI_CLICK_ADD = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add"); + UI_CLICK_ADD_GROUP = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add-group"); + UI_CLICK_ADD_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add-player"); UI_CLICK_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("ui-click-confirm"); UI_CLICK_REMOVE = MessageStorage.MESSAGE_DATA.getMessage("ui-click-remove"); UNTRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("untrust-no-claims"); diff --git a/sponge/src/main/java/com/griefdefender/command/ClaimFlagBase.java b/sponge/src/main/java/com/griefdefender/command/ClaimFlagBase.java index 8dc3c94..856ebba 100644 --- a/sponge/src/main/java/com/griefdefender/command/ClaimFlagBase.java +++ b/sponge/src/main/java/com/griefdefender/command/ClaimFlagBase.java @@ -63,6 +63,7 @@ import com.griefdefender.registry.FlagRegistryModule; import com.griefdefender.text.action.GDCallbackHolder; import com.griefdefender.util.CauseContextHelper; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import com.griefdefender.util.PermissionUtil; @@ -257,26 +258,38 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ Collections.sort(textComponents, UIHelper.PLAIN_COMPARATOR); - int fillSize = 20 - (textComponents.size() + 2); - for (int i = 0; i < fillSize; i++) { - textComponents.add(TextComponent.of(" ")); - } - String lastMenu = this.lastActiveMenuTypeMap.getIfPresent(src.getUniqueId()); MenuType lastActiveMenu = MenuType.CLAIM; if (lastMenu != null) { lastActiveMenu = MenuType.valueOf(lastMenu.toUpperCase()); } + + int fillSize = 20 - (textComponents.size() + 2); Component footer = null; if (player.hasPermission(GDPermissions.ADVANCED_FLAGS)) { footer = TextComponent.builder().append(whiteOpenBracket) - .append(TextComponent.of("PRESET").color(TextColor.GOLD)).append(whiteCloseBracket) - .append(" ") - .append(TextComponent.builder() - .append(TextComponent.of("ADVANCED").color(TextColor.GRAY) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimFlagConsumer(src, claim, lastActiveMenu))))) - .build()) - .build(); + .append(TextComponent.of("PRESET").color(TextColor.GOLD)).append(whiteCloseBracket) + .append(" ") + .append(TextComponent.builder() + .append(TextComponent.of("ADVANCED").color(TextColor.GRAY) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimFlagConsumer(src, claim, lastActiveMenu))))) + .build()) + .build(); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + System.out.println("TEST"); + footer = footer.append(TextComponent.builder() + .append("\n") + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")) + .build()); + fillSize = 20 - (textComponents.size() + 3); + } + } else if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder().append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")).build(); + fillSize = 20 - (textComponents.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textComponents.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() .title(flagHeadBuilder.build()).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textComponents).footer(footer); @@ -468,15 +481,12 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType } Collections.sort(textList, UIHelper.PLAIN_COMPARATOR); - int fillSize = 20 - (textList.size() + 2); - for (int i = 0; i < fillSize; i++) { - textList.add(TextComponent.of(" ")); - } - String lastActivePresetMenu = this.lastActivePresetMenuMap.getIfPresent(src.getUniqueId()); if (lastActivePresetMenu == null) { lastActivePresetMenu = "user"; } + + int fillSize = 20 - (textList.size() + 2); Component footer = null; if (player.hasPermission(GDPermissions.ADVANCED_FLAGS)) { footer = TextComponent.builder().append(TextComponent.builder() @@ -488,7 +498,22 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType .append(TextComponent.of("ADVANCED").color(TextColor.RED)) .append(whiteCloseBracket) .build(); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = footer.append(TextComponent.builder() + .append("\n") + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")) + .build()); + fillSize = 20 - (textList.size() + 3); + } + } else if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder().append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, src.getInternalPlayerData(), "claimflag")).build(); + fillSize = 20 - (textList.size() + 3); } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() .title(claimFlagHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList).footer(footer); final PaginationList paginationList = paginationBuilder.build(); diff --git a/sponge/src/main/java/com/griefdefender/command/ClaimOptionBase.java b/sponge/src/main/java/com/griefdefender/command/ClaimOptionBase.java index c0d1b6e..cd14285 100644 --- a/sponge/src/main/java/com/griefdefender/command/ClaimOptionBase.java +++ b/sponge/src/main/java/com/griefdefender/command/ClaimOptionBase.java @@ -67,6 +67,7 @@ import com.griefdefender.registry.OptionRegistryModule; import com.griefdefender.text.action.GDCallbackHolder; import com.griefdefender.util.CauseContextHelper; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import com.griefdefender.util.PermissionUtil; import net.kyori.text.Component; @@ -471,12 +472,17 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy Collections.sort(textList, UIHelper.PLAIN_COMPARATOR); int fillSize = 20 - (textList.size() + 2); + Component footer = null; + if (player != null && player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, playerData, "claimoption"); + fillSize = 20 - (textList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { textList.add(TextComponent.of(" ")); } - PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(claimOptionHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList); + .title(claimOptionHead).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList).footer(footer); final PaginationList paginationList = paginationBuilder.build(); Integer activePage = 1; activePage = PaginationUtil.getInstance().getActivePage(player.getUniqueId()); diff --git a/sponge/src/main/java/com/griefdefender/command/CommandClaimBuy.java b/sponge/src/main/java/com/griefdefender/command/CommandClaimBuy.java index c57de0f..e2aa83b 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandClaimBuy.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandClaimBuy.java @@ -30,6 +30,7 @@ import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import com.google.common.collect.ImmutableMap; +import com.griefdefender.GDPlayerData; import com.griefdefender.GriefDefenderPlugin; import com.griefdefender.api.claim.Claim; import com.griefdefender.cache.MessageCache; @@ -37,6 +38,8 @@ import com.griefdefender.configuration.MessageStorage; import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissions; +import com.griefdefender.util.ChatCaptureUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.format.TextDecoration; @@ -69,6 +72,7 @@ public void execute(Player player) { return; } + final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); Set claimsForSale = new HashSet<>(); GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(player.getWorld().getUniqueId()); for (Claim worldClaim : claimManager.getWorldClaims()) { @@ -88,9 +92,22 @@ public void execute(Player player) { } } - List claimsTextList = CommandHelper.generateClaimTextListCommand(new ArrayList(), claimsForSale, player.getWorld().getName(), null, player, CommandHelper.createCommandConsumer(player, "claimbuy", ""), false); + List textList = CommandHelper.generateClaimTextListCommand(new ArrayList(), claimsForSale, player.getWorld().getName(), null, player, CommandHelper.createCommandConsumer(player, "claimbuy", ""), false); + Component footer = null; + int fillSize = 20 - (textList.size() + 2); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, null, playerData, "claimbuy")) + .build(); + fillSize = 20 - (textList.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(MessageCache.getInstance().COMMAND_CLAIMBUY_TITLE).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList); + .title(MessageCache.getInstance().COMMAND_CLAIMBUY_TITLE).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(player); return; } diff --git a/sponge/src/main/java/com/griefdefender/command/CommandClaimInfo.java b/sponge/src/main/java/com/griefdefender/command/CommandClaimInfo.java index 5d0d55f..2e13ef7 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandClaimInfo.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandClaimInfo.java @@ -31,7 +31,6 @@ import co.aikar.commands.annotation.Syntax; import com.flowpowered.math.vector.Vector3i; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; import com.griefdefender.GDPlayerData; import com.griefdefender.GriefDefenderPlugin; import com.griefdefender.api.Tristate; @@ -39,20 +38,19 @@ import com.griefdefender.api.claim.ClaimResult; import com.griefdefender.api.claim.ClaimType; import com.griefdefender.api.claim.ClaimTypes; +import com.griefdefender.api.claim.TrustType; import com.griefdefender.api.claim.TrustTypes; -import com.griefdefender.api.permission.option.Options; import com.griefdefender.cache.MessageCache; import com.griefdefender.cache.PermissionHolderCache; import com.griefdefender.claim.GDClaim; import com.griefdefender.claim.GDClaimManager; -import com.griefdefender.configuration.MessageDataConfig; import com.griefdefender.configuration.MessageStorage; import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.internal.util.VecHelper; -import com.griefdefender.permission.GDPermissionManager; import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PermissionUtil; import com.griefdefender.util.PlayerUtil; import net.kyori.text.Component; @@ -199,14 +197,6 @@ public void execute(CommandSource src, String[] args) { Component name = claim.getName().orElse(null); Component greeting = claim.getData().getGreeting().orElse(null); Component farewell = claim.getData().getFarewell().orElse(null); - String accessors = ""; - String builders = ""; - String containers = ""; - String managers = ""; - String accessorGroups = ""; - String builderGroups = ""; - String containerGroups = ""; - String managerGroups = ""; final int minClaimLevel = gdClaim.getOwnerMinClaimLevel(); double claimY = gdClaim.getOwnerPlayerData() == null ? 65.0D : (minClaimLevel > 65.0D ? minClaimLevel : 65); @@ -273,53 +263,6 @@ public void execute(CommandSource src, String[] args) { .append(claimSize) .append(claimCost).build(); } - // users - final List accessorList = gdClaim.getUserTrustList(TrustTypes.ACCESSOR, true); - final List builderList = gdClaim.getUserTrustList(TrustTypes.BUILDER, true); - final List containerList = gdClaim.getUserTrustList(TrustTypes.CONTAINER, true); - final List managerList = gdClaim.getUserTrustList(TrustTypes.MANAGER, true); - for (UUID uuid : accessorList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - accessors += userName + " "; - } - } - for (UUID uuid : builderList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - builders += userName + " "; - } - } - for (UUID uuid : containerList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - containers += userName + " "; - } - } - for (UUID uuid : managerList) { - final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - final String userName = user.getFriendlyName(); - if (userName != null) { - managers += userName + " "; - } - } - - // groups - for (String group : gdClaim.getGroupTrustList(TrustTypes.ACCESSOR, true)) { - accessorGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.BUILDER, true)) { - builderGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.CONTAINER, true)) { - containerGroups += group + " "; - } - for (String group : gdClaim.getGroupTrustList(TrustTypes.MANAGER, true)) { - managerGroups += group + " "; - } /*if (gpClaim.isInTown()) { Text returnToClaimInfo = Text.builder().append(Text.of( @@ -551,7 +494,7 @@ public void execute(CommandSource src, String[] args) { .append(getClickableInfoText(src, claim, RAID_OVERRIDE, GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), owner, Options.RAID, gdClaim) == true ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))).build(); */ Component claimSpawn = null; - if (claim.getData().getSpawnPos().isPresent()) { + if (claim.getData().getSpawnPos().isPresent() && player != null && PermissionUtil.getInstance().canPlayerTeleport(player, gdClaim)) { Vector3i spawnPos = claim.getData().getSpawnPos().get(); Location spawnLoc = new Location<>(gdClaim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()); claimSpawn = TextComponent.builder() @@ -613,29 +556,29 @@ public void execute(CommandSource src, String[] args) { .append(northEastCorner).build(); } Component claimAccessors = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW)) - .append(" : ") - .append(accessors.equals("") ? NONE : TextComponent.of(accessors, TextColor.BLUE)) - .append(" ") - .append(accessorGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.ACCESSOR)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_ACCESSORS)))) + .build(); Component claimBuilders = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_BUILDERS.color(TextColor.YELLOW)) - .append(" : ") - .append(builders.equals("") ? NONE : TextComponent.of(builders, TextColor.BLUE)) - .append(" ") - .append(builderGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_BUILDERS.color(TextColor.GREEN).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.BUILDER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_BUILDERS)))) + .build(); Component claimContainers = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_CONTAINERS.color(TextColor.YELLOW)) - .append(" : ") - .append(containers.equals("") ? NONE : TextComponent.of(containers, TextColor.BLUE)) - .append(" ") - .append(containerGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_CONTAINERS.color(TextColor.LIGHT_PURPLE).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.CONTAINER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_CONTAINERS)))) + .build(); Component claimCoowners = TextComponent.builder() - .append(MessageCache.getInstance().LABEL_MANAGERS.color(TextColor.YELLOW)) - .append(" : ") - .append(managers.equals("") ? NONE : TextComponent.of(managers, TextColor.BLUE)) - .append(" ") - .append(managerGroups, TextColor.LIGHT_PURPLE).build(); + .append(MessageCache.getInstance().LABEL_MANAGERS.color(TextColor.GOLD).decoration(TextDecoration.ITALIC, true)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, gdClaim, playerData, TrustTypes.MANAGER)))) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_VIEW, + ImmutableMap.of("target", MessageCache.getInstance().LABEL_MANAGERS)))) + .build(); Component dateCreated = TextComponent.builder() .append(MessageCache.getInstance().LABEL_CREATED.color(TextColor.YELLOW)) .append(" : ") @@ -668,10 +611,15 @@ public void execute(CommandSource src, String[] args) { .append(" ") .append(claimDenyMessages) .build()); - textList.add(claimAccessors); - textList.add(claimBuilders); - textList.add(claimContainers); - textList.add(claimCoowners); + textList.add(TextComponent.builder() + .append(claimAccessors) + .append(" ") + .append(claimBuilders) + .append(" ") + .append(claimContainers) + .append(" ") + .append(claimCoowners) + .build()); textList.add(claimGreeting); textList.add(claimFarewell); textList.add(dateCreated); @@ -695,8 +643,19 @@ public void execute(CommandSource src, String[] args) { textList.remove(dateLastActive); } + int fillSize = 20 - (textList.size() + 2); + Component footer = null; + if (player != null && player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(player, gdClaim, playerData, "claiminfo"); + fillSize = 20 - (textList.size() + 3); + } + + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(MessageCache.getInstance().CLAIMINFO_UI_TITLE_CLAIMINFO.color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList); + .title(MessageCache.getInstance().CLAIMINFO_UI_TITLE_CLAIMINFO.color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(src); } @@ -709,6 +668,18 @@ public static Consumer createSettingsConsumer(CommandSource src, }; } + private Consumer createTrustListConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type) { + return consumer -> { + Component returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", "claiminfo"))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claiminfo", claim.getUniqueId().toString())))).build(); + CommandTrustList.showTrustList(src, claim, playerData, type, new ArrayList<>(), returnToClaimInfo); + }; + } + private List generateAdminSettings(CommandSource src, GDClaim claim) { List textList = new ArrayList<>(); Component returnToClaimInfo = TextComponent.builder() diff --git a/sponge/src/main/java/com/griefdefender/command/CommandClaimList.java b/sponge/src/main/java/com/griefdefender/command/CommandClaimList.java index a1c8eaa..2e4ca86 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandClaimList.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandClaimList.java @@ -50,6 +50,7 @@ import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; import com.griefdefender.util.PaginationUtil; import net.kyori.text.Component; import net.kyori.text.TextComponent; @@ -92,7 +93,7 @@ public CommandClaimList(ClaimType type) { @Syntax("[| ]") @Description("List information about a player's claim blocks and claims.") @Subcommand("claim list") - public void execute(Player src, @Optional User targetPlayer, @Optional World world) {//String[] args) { + public void execute(Player src, @Optional User targetPlayer, @Optional World world) { final GDPermissionUser user = targetPlayer == null ? PermissionHolderCache.getInstance().getOrCreateUser(src) : PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer); if (user == null) { GriefDefenderPlugin.sendMessage(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, @@ -219,13 +220,20 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU .append(subTypeText) .append(" ") .append(townTypeText).build(); - final int fillSize = 20 - (claimsTextList.size() + 2); + + int fillSize = 20 - (claimsTextList.size() + 2); + Component footer = null; + if (src != null && src.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = ChatCaptureUtil.getInstance().createRecordChatComponent(src, null, user.getInternalPlayerData(), "claimlist"); + fillSize = 20 - (claimsTextList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { claimsTextList.add(TextComponent.of(" ")); } PaginationList paginationList = PaginationList.builder() - .title(claimListHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList).build(); + .title(claimListHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(claimsTextList).footer(footer).build(); Integer activePage = 1; if (src instanceof Player) { final Player player = (Player) src; diff --git a/sponge/src/main/java/com/griefdefender/command/CommandClaimSchematic.java b/sponge/src/main/java/com/griefdefender/command/CommandClaimSchematic.java index 1e439a4..ef38402 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandClaimSchematic.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandClaimSchematic.java @@ -43,6 +43,8 @@ import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.adapter.spongeapi.TextAdapter; @@ -98,11 +100,11 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept return; } - List schematicTextList = new ArrayList<>(); + List textList = new ArrayList<>(); for (ClaimSchematic schematic : claim.schematics.values()) { final String schematicName = schematic.getName(); final Instant schematicDate = schematic.getDateCreated(); - schematicTextList.add( + textList.add( TextComponent.builder("") .append(schematicName, TextColor.GREEN) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(displayConfirmationConsumer(player, claim, schematic)))) @@ -113,13 +115,21 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept .build()); } - final int fillSize = 20 - (schematicTextList.size() + 2); + Component footer = null; + int fillSize = 20 - (textList.size() + 2); + if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, null, playerData, "claimschematic")) + .build(); + fillSize = 20 - (textList.size() + 3); + } + for (int i = 0; i < fillSize; i++) { - schematicTextList.add(TextComponent.of(" ")); + textList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(schematicTextList); + .title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer); paginationBuilder.sendTo(player); } else if (action.equalsIgnoreCase("create")) { TextAdapter.sendComponent(player, TextComponent.of("Creating schematic backup...", TextColor.GREEN)); diff --git a/sponge/src/main/java/com/griefdefender/command/CommandTrustList.java b/sponge/src/main/java/com/griefdefender/command/CommandTrustList.java index 77d8ec5..2c466d4 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandTrustList.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandTrustList.java @@ -37,12 +37,15 @@ import com.griefdefender.cache.MessageCache; import com.griefdefender.cache.PermissionHolderCache; import com.griefdefender.claim.GDClaim; -import com.griefdefender.configuration.MessageDataConfig; +import com.griefdefender.configuration.IClaimData; import com.griefdefender.configuration.MessageStorage; import com.griefdefender.internal.pagination.PaginationList; import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; import com.griefdefender.text.action.GDCallbackHolder; +import com.griefdefender.util.ChatCaptureUtil; +import com.griefdefender.util.PermissionUtil; + import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; @@ -52,6 +55,7 @@ import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; +import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -67,10 +71,10 @@ public class CommandTrustList extends BaseCommand { public void execute(Player player) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); - showTrustList(player, claim, TrustTypes.NONE); + showTrustList(player, claim, playerData, TrustTypes.NONE, new ArrayList<>(), null); } - public static void showTrustList(CommandSource src, GDClaim claim, TrustType type) { + public static void showTrustList(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, List messages, Component returnCommand) { final Component whiteOpenBracket = TextComponent.of("[", TextColor.AQUA); final Component whiteCloseBracket = TextComponent.of("]", TextColor.AQUA); final Component showAllText = MessageCache.getInstance().TRUST_CLICK_SHOW_LIST; @@ -85,12 +89,12 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ final Component allTypeText = TextComponent.builder("") .append(type == TrustTypes.NONE ? TextComponent.builder("") .append(whiteOpenBracket) - .append("ALL") + .append(MessageCache.getInstance().TITLE_ALL) .append(whiteCloseBracket) .build() : TextComponent.builder("") - .append("ALL",TextColor.GRAY) + .append(MessageCache.getInstance().TITLE_ALL.color(TextColor.GRAY)) .build()) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.NONE)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.NONE, returnCommand)))) .hoverEvent(HoverEvent.showText(showAllText)).build(); final Component accessorTrustText = TextComponent.builder("") .append(type == TrustTypes.ACCESSOR ? TextComponent.builder("") @@ -98,7 +102,7 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_ACCESSOR.color(TextColor.YELLOW)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_ACCESSOR.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.ACCESSOR)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.ACCESSOR, returnCommand)))) .hoverEvent(HoverEvent.showText(showAccessorText)).build(); final Component builderTrustText = TextComponent.builder("") .append(type == TrustTypes.BUILDER ? TextComponent.builder("") @@ -106,7 +110,7 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_BUILDER.color(TextColor.GREEN)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_BUILDER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.BUILDER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.BUILDER, returnCommand)))) .hoverEvent(HoverEvent.showText(showBuilderText)).build(); final Component containerTrustText = TextComponent.builder("") .append(type == TrustTypes.CONTAINER ? TextComponent.builder("") @@ -114,15 +118,15 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ .append(MessageCache.getInstance().TITLE_CONTAINER.color(TextColor.LIGHT_PURPLE)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_CONTAINER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.CONTAINER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.CONTAINER, returnCommand)))) .hoverEvent(HoverEvent.showText(showContainerText)).build(); final Component managerTrustText = TextComponent.builder("") .append(type == TrustTypes.MANAGER ? TextComponent.builder("") .append(whiteOpenBracket) - .append("MANAGER", TextColor.GOLD) + .append(MessageCache.getInstance().TITLE_MANAGER.color(TextColor.GOLD)) .append(whiteCloseBracket) .build() : MessageCache.getInstance().TITLE_MANAGER.color(TextColor.GRAY)) - .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, TrustTypes.MANAGER)))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustConsumer(src, claim, playerData, TrustTypes.MANAGER, returnCommand)))) .hoverEvent(HoverEvent.showText(showManagerText)).build(); final Component claimTrustHead = TextComponent.builder() .append(" ") @@ -142,12 +146,25 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ List userIdList = new ArrayList<>(claim.getUserTrusts()); List trustList = new ArrayList<>(); trustList.add(TextComponent.empty()); - + if (returnCommand != null) { + trustList.add(returnCommand); + } if (type == TrustTypes.NONE) { // check highest trust first for (UUID uuid : claim.getInternalClaimData().getManagers()) { final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.GOLD)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getManagers(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(user.getUniqueId()); } @@ -157,97 +174,222 @@ public static void showTrustList(CommandSource src, GDClaim claim, TrustType typ } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.GREEN)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getBuilders(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - /*for (String group : claim.getInternalClaimData().getManagerGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - for (UUID uuid : claim.getInternalClaimData().getContainers()) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.LIGHT_PURPLE)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getContainers(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - - /* for (String group : claim.getInternalClaimData().getBuilderGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - + for (UUID uuid : claim.getInternalClaimData().getAccessors()) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), TextColor.YELLOW)); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), claim.getInternalClaimData().getAccessors(), uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } - - /*for (String group : claim.getInternalClaimData().getContainerGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - } - - player.sendMessage(permissions.build()); - permissions = Text.builder(">").color(TextColors.BLUE); - - for (UUID uuid : claim.getInternalClaimData().getAccessors()) { - User user = GriefDefenderPlugin.getOrCreateUser(uuid); - permissions.append(SPACE_TEXT, Text.of(user.getName())); - } - - for (String group : claim.getInternalClaimData().getAccessorGroups()) { - permissions.append(SPACE_TEXT, Text.of(group)); - }*/ - } else { - for (UUID uuid : claim.getUserTrusts(type)) { + final List trusts = claim.getUserTrustList(type); + trustList.add(TextComponent.builder("") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("+", TextColor.GREEN) + .hoverEvent(HoverEvent.showText(TextComponent.of("Click here to add"))) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createInputConsumer(src, claim, playerData, type, messages, returnCommand)))) + .build()) + .append("]", TextColor.WHITE) + .build()); + + for (UUID uuid : trusts) { if (!userIdList.contains(uuid)) { continue; } final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid); - trustList.add(TextComponent.of(user.getName(), getTrustColor(type))); + trustList.add(TextComponent.builder("") + .append(user.getName(), TextColor.GOLD) + .append(" ") + .append("[", TextColor.WHITE) + .append(TextComponent.builder() + .append("x", TextColor.RED) + .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createRemoveConsumer(src, claim, playerData, type, returnCommand, claim.getInternalClaimData(), trusts, uuid)))) + .build()) + .append("]", TextColor.WHITE) + .build()); userIdList.remove(uuid); } } + Component footer = null; int fillSize = 20 - (trustList.size() + 2); + if (src.hasPermission(GDPermissions.CHAT_CAPTURE)) { + fillSize = 20 - (trustList.size() + 3); + if (messages != null && !messages.isEmpty()) { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(src, claim, playerData, "trustlist", returnCommand)) + .append(TextComponent.of("\n")) + .build(); + for (Component message : messages) { + footer = footer.append(message); + fillSize -= 1; + } + messages.clear(); + } else { + footer = TextComponent.builder() + .append(ChatCaptureUtil.getInstance().createRecordChatComponent(src, claim, playerData, "trustlist", returnCommand)) + .build(); + } + } + for (int i = 0; i < fillSize; i++) { trustList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() - .title(claimTrustHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(trustList); + .title(claimTrustHead).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(trustList).footer(footer); paginationBuilder.sendTo(src); paginationBuilder.sendTo(src); } - private static TextColor getTrustColor(TrustType type) { - if (type == TrustTypes.NONE) { - return TextColor.WHITE; - } - if (type == TrustTypes.ACCESSOR) { - return TextColor.YELLOW; - } - if (type == TrustTypes.BUILDER) { - return TextColor.GREEN; - } - if (type == TrustTypes.CONTAINER) { - return TextColor.LIGHT_PURPLE; - } - return TextColor.GOLD; - } - - private static Consumer createTrustConsumer(CommandSource src, GDClaim claim, TrustType type) { + private static Consumer createTrustConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { return consumer -> { - showTrustList(src, claim, type); + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); + }; + } + + private static Consumer createInputConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, List messages, Component returnCommand) { + return consumer -> { + if (messages == null || messages.isEmpty()) { + playerData.commandInputTimestamp = Instant.now(); + playerData.trustAddConsumer = createAddConsumer(src, claim, playerData, type, returnCommand); + } + messages.add(TextComponent.builder() + .append(TextComponent.of("Do you want to add a ") + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_PLAYER.color(TextColor.GOLD)) + .clickEvent(ClickEvent.suggestCommand("player ")) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, + ImmutableMap.of("target", "player")))) + .build()) + .append(TextComponent.of(" or ")) + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_GROUP.color(TextColor.AQUA)) + .clickEvent(ClickEvent.suggestCommand("group ")) + .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, + ImmutableMap.of("target", "group")))) + .build())) + .append(" ? ") + .append("[") + .append(TextComponent.builder() + .append(MessageCache.getInstance().LABEL_CANCEL.color(TextColor.RED)) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( + createCancelConsumer(src, claim, playerData, type, returnCommand)))) + .build()) + .append("]") + .build()); + showTrustList(src, claim, playerData, type, messages, returnCommand); + }; + } + + private static Consumer createAddConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { + return consumer -> { + String name = playerData.commandInput; + List messages = new ArrayList<>(); + if (playerData.commandInput.contains("player ")) { + name = name.replace("player ", ""); + if (!name.equalsIgnoreCase("public") && PermissionUtil.getInstance().lookupUserUniqueId(name) == null) { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", name))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + } else if (playerData.commandInput.contains("group ")) { + name = name.replace("group ", ""); + if (!name.equalsIgnoreCase("public") && !PermissionUtil.getInstance().hasGroupSubject(name)) { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", name))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + } else { + messages.add(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_INPUT, + ImmutableMap.of( + "input", playerData.commandInput))); + messages.add(TextComponent.of("\n")); + createInputConsumer(src, claim, playerData, type, messages, returnCommand).accept(src); + return; + } + CommandHelper.executeCommand(src, "trust", name + " " + type.getName().toLowerCase()); + playerData.commandInputTimestamp = null; + playerData.trustAddConsumer = null; + showTrustList(src, claim, playerData, type, messages, returnCommand); + }; + } + + private static Consumer createCancelConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { + return consumer -> { + playerData.commandInputTimestamp = null; + playerData.trustAddConsumer = null; + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); + }; + } + + private static Consumer createRemoveConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand, IClaimData data, List trustList, UUID uuid) { + return consumer -> { + trustList.remove(uuid); + data.setRequiresSave(true); + data.save(); + showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); }; } } diff --git a/sponge/src/main/java/com/griefdefender/command/CommandTrustPlayer.java b/sponge/src/main/java/com/griefdefender/command/CommandTrustPlayer.java index 2ba8976..e57ce03 100644 --- a/sponge/src/main/java/com/griefdefender/command/CommandTrustPlayer.java +++ b/sponge/src/main/java/com/griefdefender/command/CommandTrustPlayer.java @@ -48,6 +48,7 @@ import com.griefdefender.event.GDUserTrustClaimEvent; import com.griefdefender.permission.GDPermissionUser; import com.griefdefender.permission.GDPermissions; +import com.griefdefender.util.PermissionUtil; import net.kyori.text.Component; import net.kyori.text.adapter.spongeapi.TextAdapter; import org.spongepowered.api.entity.living.player.Player; @@ -84,6 +85,12 @@ public void execute(Player player, String target, @Optional String type) { if (target.equalsIgnoreCase("public")) { user = GriefDefenderPlugin.PUBLIC_USER; } else { + if (PermissionUtil.getInstance().lookupUserUniqueId(target) == null) { + GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", target))); + return; + } user = PermissionHolderCache.getInstance().getOrCreateUser(target); } diff --git a/sponge/src/main/java/com/griefdefender/configuration/MessageStorage.java b/sponge/src/main/java/com/griefdefender/configuration/MessageStorage.java index 2a6d877..e7ef41e 100644 --- a/sponge/src/main/java/com/griefdefender/configuration/MessageStorage.java +++ b/sponge/src/main/java/com/griefdefender/configuration/MessageStorage.java @@ -149,6 +149,7 @@ public class MessageStorage { public static final String COMMAND_INVALID_AMOUNT = "command-invalid-amount"; public static final String COMMAND_INVALID_CLAIM = "command-invalid-claim"; public static final String COMMAND_INVALID_GROUP = "command-invalid-group"; + public static final String COMMAND_INVALID_INPUT = "command-invalid-input"; public static final String COMMAND_INVALID_PLAYER = "command-invalid-player"; public static final String COMMAND_INVALID_TYPE = "command-invalid-type"; public static final String COMMAND_OPTION_EXCEEDS_ADMIN = "command-option-exceeds-admin"; @@ -303,7 +304,10 @@ public class MessageStorage { public static final String TRUST_INDIVIDUAL_ALL_CLAIMS = "trust-individual-all-claims"; public static final String TRUST_PLUGIN_CANCEL = "trust-plugin-cancel"; public static final String TUTORIAL_CLAIM_BASIC = "tutorial-claim-basic"; + public static final String UI_CLICK_ADD_TARGET = "ui-click-add-target"; public static final String UI_CLICK_FILTER_TYPE = "ui-click-filter-type"; + public static final String UI_CLICK_RETURN_COMMAND = "ui-click-return-command"; + public static final String UI_CLICK_VIEW = "ui-click-view"; public static final String UNTRUST_INDIVIDUAL_ALL_CLAIMS = "untrust-individual-all-claims"; public static final String UNTRUST_INDIVIDUAL_SINGLE_CLAIM = "untrust-individual-single-claim"; public static final String UNTRUST_OWNER = "untrust-owner"; diff --git a/sponge/src/main/java/com/griefdefender/configuration/category/GuiCategory.java b/sponge/src/main/java/com/griefdefender/configuration/category/GuiCategory.java new file mode 100644 index 0000000..63c97fb --- /dev/null +++ b/sponge/src/main/java/com/griefdefender/configuration/category/GuiCategory.java @@ -0,0 +1,37 @@ +/* + * This file is part of GriefDefender, licensed under the MIT License (MIT). + * + * Copyright (c) bloodmc + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.griefdefender.configuration.category; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class GuiCategory extends ConfigCategory { + + @Setting(value = "chat-capture-idle-timeout", comment = "The idle timeout in seconds when a command GUI will stop capturing chat.") + public int chatCaptureIdleTimeout = 15; + @Setting(value = "command-input-idle-timeout", comment = "The idle timeout in seconds when a command GUI will stop waiting for player input.") + public int commandInputIdleTimeout = 15; +} diff --git a/sponge/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java b/sponge/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java index 009ea69..07a1ea2 100644 --- a/sponge/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java +++ b/sponge/src/main/java/com/griefdefender/configuration/type/GlobalConfig.java @@ -24,6 +24,7 @@ */ package com.griefdefender.configuration.type; +import com.griefdefender.configuration.category.GuiCategory; import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory; import com.griefdefender.configuration.category.DefaultPermissionCategory; import com.griefdefender.configuration.category.DynmapCategory; @@ -69,6 +70,8 @@ public class GlobalConfig extends ConfigBase { @Setting public EconomyCategory economy = new EconomyCategory(); @Setting + public GuiCategory gui = new GuiCategory(); + @Setting public PlayerDataCategory playerdata = new PlayerDataCategory(); @Setting public MessageCategory message = new MessageCategory(); diff --git a/sponge/src/main/java/com/griefdefender/listener/PlayerEventHandler.java b/sponge/src/main/java/com/griefdefender/listener/PlayerEventHandler.java index fb6ab9b..4323e40 100644 --- a/sponge/src/main/java/com/griefdefender/listener/PlayerEventHandler.java +++ b/sponge/src/main/java/com/griefdefender/listener/PlayerEventHandler.java @@ -67,11 +67,11 @@ import com.griefdefender.util.PaginationUtil; import com.griefdefender.util.PlayerUtil; import com.griefdefender.util.SpongeUtil; -import io.github.nucleuspowered.nucleus.api.chat.NucleusChatChannel; import net.kyori.text.Component; import net.kyori.text.TextComponent; +import net.kyori.text.event.HoverEvent; import net.kyori.text.format.TextColor; - +import net.kyori.text.serializer.gson.GsonComponentSerializer; import org.spongepowered.api.Sponge; import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockType; @@ -121,8 +121,10 @@ import org.spongepowered.api.text.Text; import org.spongepowered.api.text.channel.MessageChannel; import org.spongepowered.api.text.channel.MessageReceiver; +import org.spongepowered.api.text.channel.MutableMessageChannel; import org.spongepowered.api.text.channel.type.FixedMessageChannel; import org.spongepowered.api.text.format.TextColors; +import org.spongepowered.api.text.serializer.TextSerializers; import org.spongepowered.api.util.blockray.BlockRay; import org.spongepowered.api.util.blockray.BlockRayHit; import org.spongepowered.api.world.Chunk; @@ -133,8 +135,13 @@ import java.math.BigDecimal; import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -148,6 +155,7 @@ public class PlayerEventHandler { private int lastInteractItemPrimaryTick = -1; private int lastInteractItemSecondaryTick = -1; private boolean lastInteractItemCancelled = false; + private final DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.systemDefault()); public PlayerEventHandler(BaseStorage dataStore, GriefDefenderPlugin plugin) { this.dataStore = dataStore; @@ -155,21 +163,63 @@ public PlayerEventHandler(BaseStorage dataStore, GriefDefenderPlugin plugin) { this.banService = Sponge.getServiceManager().getRegistration(BanService.class).get().getProvider(); } + @Listener(order = Order.POST) + public void onPlayerChatPost(MessageChannelEvent.Chat event) { + final CommandSource commandSource = (CommandSource) event.getSource(); + final MessageChannel channel = event.getChannel().orElse(null); + if (channel != null) { + final MutableMessageChannel mutableChannel = channel.asMutable(); + final Iterator iterator = mutableChannel.getMembers().iterator(); + List receiversToRemove = new ArrayList<>(); + while (iterator.hasNext()) { + final MessageReceiver receiver = iterator.next(); + if (receiver == commandSource) { + continue; + } + if (receiver instanceof Player) { + final Player playerReceiver = (Player) receiver; + final GDPlayerData receiverData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(playerReceiver.getWorld(), playerReceiver.getUniqueId()); + if (receiverData.isRecordingChat()) { + receiversToRemove.add(receiver); + final Component message = GsonComponentSerializer.INSTANCE.deserialize(TextSerializers.JSON.serialize(event.getMessage())); + final Component component = TextComponent.builder() + .append(TextComponent.builder() + .append(message) + .hoverEvent(HoverEvent.showText(TextComponent.of(formatter.format(Instant.now())))) + .build()) + .build(); + receiverData.chatLines.add(component); + } + } + } + for (MessageReceiver receiver : receiversToRemove) { + mutableChannel.removeMember(receiver); + } + event.setChannel(mutableChannel); + } + } @Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerChat(MessageChannelEvent.Chat event, @First Player player) { - GDTimings.PLAYER_CHAT_EVENT.startTimingIfSync(); - GriefDefenderConfig activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) { - GDTimings.PLAYER_CHAT_EVENT.stopTimingIfSync(); return; } + GDTimings.PLAYER_CHAT_EVENT.startTimingIfSync(); final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); + // check for command input + if (playerData.isWaitingForInput()) { + playerData.commandInput = event.getRawMessage().toPlain(); + playerData.trustAddConsumer.accept(player); + event.setCancelled(true); + return; + } + if (playerData.inTown && playerData.townChat) { final MessageChannel channel = event.getChannel().orElse(null); if (GriefDefenderPlugin.getInstance().nucleusApiProvider != null && channel != null) { - if (channel instanceof NucleusChatChannel) { + if (GriefDefenderPlugin.getInstance().nucleusApiProvider.isChatChannel(channel)) { + GDTimings.PLAYER_CHAT_EVENT.stopTimingIfSync(); return; } } @@ -819,7 +869,19 @@ public void onInteractBlock(InteractBlockEvent event) { } @Listener(order = Order.FIRST, beforeModifications = true) - public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand event, @First Player player) { + public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand event) { + User user = CauseContextHelper.getEventUser(event); + final Object source = CauseContextHelper.getEventFakePlayerSource(event); + final Player player = source instanceof Player ? (Player) source : null; + if (player == null || NMSUtil.getInstance().isFakePlayer(player)) { + if (user == null) { + user = player; + } + + this.handleFakePlayerInteractBlockPrimary(event, user, source); + return; + } + final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final HandType handType = event.getHandType(); final ItemStack itemInHand = player.getItemInHand(handType).orElse(ItemStack.empty()); @@ -854,7 +916,6 @@ public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand eve GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.startTimingIfSync(); final BlockSnapshot clickedBlock = event.getTargetBlock(); final Location location = clickedBlock.getLocation().orElse(null); - final Object source = player; if (location == null) { GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync(); return; diff --git a/sponge/src/main/java/com/griefdefender/permission/GDPermissionManager.java b/sponge/src/main/java/com/griefdefender/permission/GDPermissionManager.java index 2a12de5..44f1717 100644 --- a/sponge/src/main/java/com/griefdefender/permission/GDPermissionManager.java +++ b/sponge/src/main/java/com/griefdefender/permission/GDPermissionManager.java @@ -50,6 +50,8 @@ import com.griefdefender.api.permission.option.Options; import com.griefdefender.api.permission.option.type.CreateModeType; import com.griefdefender.api.permission.option.type.CreateModeTypes; +import com.griefdefender.api.permission.option.type.GameModeType; +import com.griefdefender.api.permission.option.type.GameModeTypes; import com.griefdefender.api.permission.option.type.WeatherType; import com.griefdefender.api.permission.option.type.WeatherTypes; import com.griefdefender.cache.EventResultCache; @@ -66,7 +68,6 @@ import com.griefdefender.internal.util.BlockUtil; import com.griefdefender.internal.util.NMSUtil; import com.griefdefender.registry.FlagRegistryModule; -import com.griefdefender.registry.OptionRegistryModule; import com.griefdefender.util.EntityUtils; import com.griefdefender.util.PermissionUtil; import net.kyori.text.Component; @@ -74,7 +75,6 @@ import net.kyori.text.adapter.spongeapi.TextAdapter; import net.kyori.text.format.TextColor; import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -89,7 +89,6 @@ import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.EntityType; -import org.spongepowered.api.entity.Item; import org.spongepowered.api.entity.living.Living; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.User; @@ -1427,6 +1426,22 @@ private T getOptionTypeValue(TypeToken type, String value) { return (T) WeatherTypes.UNDEFINED; } + if (type.getRawType().isAssignableFrom(GameModeType.class)) { + if (value.equalsIgnoreCase("adventure")) { + return (T) GameModeTypes.ADVENTURE; + } + if (value.equalsIgnoreCase("creative")) { + return (T) GameModeTypes.CREATIVE; + } + if (value.equalsIgnoreCase("spectator")) { + return (T) GameModeTypes.SPECTATOR; + } + if (value.equalsIgnoreCase("survival")) { + return (T) GameModeTypes.SURVIVAL; + } + + return (T) GameModeTypes.UNDEFINED; + } if (type.getRawType().isAssignableFrom(Boolean.class)) { return (T) Boolean.valueOf(Boolean.parseBoolean(value)); } diff --git a/sponge/src/main/java/com/griefdefender/permission/GDPermissions.java b/sponge/src/main/java/com/griefdefender/permission/GDPermissions.java index da889ab..7a46658 100644 --- a/sponge/src/main/java/com/griefdefender/permission/GDPermissions.java +++ b/sponge/src/main/java/com/griefdefender/permission/GDPermissions.java @@ -167,6 +167,7 @@ public class GDPermissions { // Misc public static final String COMMAND_HELP = "griefdefender.user.command.help"; + public static final String CHAT_CAPTURE = "griefdefender.user.chat.capture"; // Trust public static final String COMMAND_TRUST_GROUP = "griefdefender.user.claim.command.trust.group"; diff --git a/sponge/src/main/java/com/griefdefender/provider/NucleusProvider.java b/sponge/src/main/java/com/griefdefender/provider/NucleusProvider.java index f53740f..00af702 100644 --- a/sponge/src/main/java/com/griefdefender/provider/NucleusProvider.java +++ b/sponge/src/main/java/com/griefdefender/provider/NucleusProvider.java @@ -30,12 +30,14 @@ import com.griefdefender.storage.BaseStorage; import com.griefdefender.util.SpongeUtil; import io.github.nucleuspowered.nucleus.api.NucleusAPI; +import io.github.nucleuspowered.nucleus.api.chat.NucleusChatChannel; import io.github.nucleuspowered.nucleus.api.exceptions.PluginAlreadyRegisteredException; import io.github.nucleuspowered.nucleus.api.service.NucleusMessageTokenService; import io.github.nucleuspowered.nucleus.api.service.NucleusPrivateMessagingService; import net.kyori.text.Component; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.plugin.PluginContainer; +import org.spongepowered.api.text.channel.MessageChannel; import java.util.Optional; @@ -81,4 +83,8 @@ public void registerTokens() { // register {{town}} from {{pl:griefdefender:town}} messageTokenService.registerPrimaryToken("town", pc, "town"); } + + public boolean isChatChannel(MessageChannel channel) { + return channel instanceof NucleusChatChannel; + } } diff --git a/sponge/src/main/java/com/griefdefender/task/PlayerTickTask.java b/sponge/src/main/java/com/griefdefender/task/PlayerTickTask.java index 16a0fdf..0f0745f 100644 --- a/sponge/src/main/java/com/griefdefender/task/PlayerTickTask.java +++ b/sponge/src/main/java/com/griefdefender/task/PlayerTickTask.java @@ -59,6 +59,8 @@ public void run() { } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); + // chat capture + playerData.updateRecordChat(); // health regen if (world.getProperties().getTotalTime() % 100 == 0L) { final GameMode gameMode = player.get(Keys.GAME_MODE).get(); diff --git a/sponge/src/main/java/com/griefdefender/util/ChatCaptureUtil.java b/sponge/src/main/java/com/griefdefender/util/ChatCaptureUtil.java new file mode 100644 index 0000000..2d3d2e7 --- /dev/null +++ b/sponge/src/main/java/com/griefdefender/util/ChatCaptureUtil.java @@ -0,0 +1,182 @@ +/* + * This file is part of GriefDefender, licensed under the MIT License (MIT). + * + * Copyright (c) bloodmc + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.griefdefender.util; + +import com.google.common.collect.ImmutableMap; +import com.griefdefender.GDPlayerData; +import com.griefdefender.GriefDefenderPlugin; +import com.griefdefender.api.claim.TrustType; +import com.griefdefender.api.claim.TrustTypes; +import com.griefdefender.cache.MessageCache; +import com.griefdefender.cache.PermissionHolderCache; +import com.griefdefender.claim.GDClaim; +import com.griefdefender.command.CommandHelper; +import com.griefdefender.command.CommandTrustList; +import com.griefdefender.configuration.MessageStorage; +import com.griefdefender.internal.pagination.PaginationList; +import com.griefdefender.permission.GDPermissionUser; +import com.griefdefender.text.action.GDCallbackHolder; +import net.kyori.text.Component; +import net.kyori.text.TextComponent; +import net.kyori.text.event.ClickEvent; +import net.kyori.text.event.HoverEvent; +import net.kyori.text.format.TextColor; +import net.kyori.text.format.TextDecoration; +import org.spongepowered.api.command.CommandSource; +import org.spongepowered.api.entity.living.player.Player; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class ChatCaptureUtil { + + private static ChatCaptureUtil instance; + private static final Component whiteOpenBracket = TextComponent.of("[", TextColor.AQUA); + private static final Component whiteCloseBracket = TextComponent.of("]", TextColor.AQUA); + + public static ChatCaptureUtil getInstance() { + return instance; + } + + static { + instance = new ChatCaptureUtil(); + } + + public Component createRecordChatComponent(Player player, GDClaim claim, GDPlayerData playerData, String command) { + return this.createRecordChatComponent(player, claim, playerData, command, null); + } + + public Component createRecordChatComponent(Player player, GDClaim claim, GDPlayerData playerData, String command, Component returnComponent) { + final Component chatSettings = TextComponent.builder() + .append(TextComponent.builder() + .append(whiteOpenBracket) + .append("RECORD-CHAT").color(TextColor.GOLD).append(whiteCloseBracket) + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatSettingsConsumer(player, claim, command, returnComponent)))) + .hoverEvent(HoverEvent.showText(TextComponent.of("Click here to see recorded chat."))) + .build()) + .append(TextComponent.builder() + .append(" ") + .append(getRecordChatClickableInfoText(player, claim, MessageCache.getInstance().CLAIMINFO_UI_CLICK_TOGGLE, playerData.isRecordingChat() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED), command)) + .build()) + .build(); + return chatSettings; + } + + public Component getRecordChatClickableInfoText(CommandSource src, GDClaim claim, Component clickText, Component infoText, String command) { + boolean hasPermission = true; + if (claim != null && src instanceof Player) { + Component denyReason = claim.allowEdit((Player) src); + if (denyReason != null) { + clickText = denyReason; + hasPermission = false; + } + } + + TextComponent.Builder textBuilder = TextComponent.builder() + .append(infoText) + .hoverEvent(HoverEvent.showText(clickText)); + if (hasPermission) { + textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatInfoConsumer(src, claim, command)))); + } + return textBuilder.build(); + } + + private Consumer createChatInfoConsumer(CommandSource src, GDClaim claim, String command) { + return info -> { + if (!(src instanceof Player)) { + return; + } + final Player player = (Player) src; + final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player); + final GDPlayerData playerData = user.getInternalPlayerData(); + final boolean isRecordingChat = playerData.isRecordingChat(); + if (isRecordingChat) { + playerData.recordChatTimestamp = null; + } else { + playerData.recordChatTimestamp = Instant.now(); + playerData.chatLines.clear(); + } + if (command.equals("claiminfo")) { + CommandHelper.executeCommand(src, command, claim.getUniqueId().toString()); + } else { + CommandHelper.executeCommand(src, command, ""); + } + }; + } + + public Consumer createChatSettingsConsumer(Player player, GDClaim claim, String command, Component returnComponent) { + return settings -> { + PaginationList.Builder paginationBuilder = PaginationList.builder() + .title(TextComponent.of("RECORD-CHAT").color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(generateChatSettings(player, claim, command, returnComponent)); + paginationBuilder.sendTo(player); + }; + } + + public List generateChatSettings(Player player, GDClaim claim, String command, Component returnComponent) { + final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); + List textList = new ArrayList<>(); + Component returnToClaimInfo = null; + if (command.equals("claiminfo")) { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, claim.getUniqueId().toString())))).build(); + } else if (command.equals("trustlist")) { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, claim, playerData, TrustTypes.NONE, returnComponent)))).build(); + } else { + returnToClaimInfo = TextComponent.builder() + .append("[") + .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, + ImmutableMap.of("command", command))) + .append("]") + .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, "")))).build(); + } + textList.add(returnToClaimInfo); + for (Component chatLine : playerData.chatLines) { + textList.add(chatLine); + } + + int fillSize = 20 - (textList.size() + 2); + for (int i = 0; i < fillSize; i++) { + textList.add(TextComponent.of(" ")); + } + return textList; + } + + private Consumer createTrustListConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnComponent) { + return consumer -> { + CommandTrustList.showTrustList(src, claim, playerData, type, new ArrayList<>(), returnComponent); + }; + } +} diff --git a/sponge/src/main/java/com/griefdefender/util/PermissionUtil.java b/sponge/src/main/java/com/griefdefender/util/PermissionUtil.java index 036581d..42c0585 100644 --- a/sponge/src/main/java/com/griefdefender/util/PermissionUtil.java +++ b/sponge/src/main/java/com/griefdefender/util/PermissionUtil.java @@ -33,10 +33,12 @@ import com.griefdefender.api.permission.PermissionResult; import com.griefdefender.api.permission.flag.Flag; import com.griefdefender.api.permission.option.Option; +import com.griefdefender.cache.PermissionHolderCache; import com.griefdefender.claim.GDClaim; import com.griefdefender.permission.GDPermissionHolder; import com.griefdefender.permission.GDPermissions; import com.griefdefender.provider.PermissionProvider; +import org.spongepowered.api.entity.living.player.Player; import java.util.List; import java.util.Map; @@ -44,8 +46,6 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; -import org.spongepowered.api.entity.living.player.Player; - public class PermissionUtil { private final PermissionProvider PERMISSION_PROVIDER; diff --git a/sponge/src/main/resources/assets/lang/de_DE.conf b/sponge/src/main/resources/assets/lang/de_DE.conf index f6ec549..4d4e876 100644 --- a/sponge/src/main/resources/assets/lang/de_DE.conf +++ b/sponge/src/main/resources/assets/lang/de_DE.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&cDu bist bereits der Besitzer dieses Grundstückes." claim-owner-only="&cNur &6{player}&c kann das Grundstück anpassen." claim-protected-entity="&cDas gehört &6{player}&c." + claim-reserve-add="&aDer Grundstücksname &6{name}&a wurde zur Liste der reservierten Namen hinzugefügt." + claim-reserve-exists="&aDieser Grundstücksname ist bereits reserviert." + claim-reserved-name="&cDer von dir gewählte Name ist leider reserviert. Bitte wähle einen anderen Namen für dein Grundstück oder stelle sicher, dass du die Berechtigung hast diesen Namen zu verwenden." claim-respecting="&aGrundstücke werden nun respektiert." claim-restore-success="&aGrundstück erfolgreich wiederhergestellt." claim-show-nearby="&6{amount}&a Grundstücke in der Umgebung gefunden." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&cKeine gültige Anzahl eingegeben: &6{amount}&c." command-invalid-claim="&cDieser Befehl kann nicht auf {type}&c Grundstücken benutzt werden." command-invalid-group="&c &6{group}&c ist keine gültige Gruppe." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&6{player}&c ist kein gültiger Spieler." command-invalid-player-group="&cSpieler oder Gruppe nicht existent." command-invalid-type="&cTyp {type}&c existiert nicht." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&cOption {option}&c nicht gefunden." option-not-set="{option}&f ist nicht eingestellt.\n&dHinweis&f: Standardoption {value}&f ist solange aktiv." option-override-not-supported="&cGrundstücksart {type}&c unterstützt keine überschreibenden Einstellungen." - option-player-deny-flight="&cDu darfst in diesem Grundstück nicht fliegen und wurdest zu einem sicheren Landeplatz teleportiert." option-requires-contexts="&cDiese Option benötigt zum Einstellen den Kontext '&a{contexts}&c'." option-reset-success="&aGrundstückseinstellungen erfolgreich zurückgesetzt." option-set-target="&aSetze {type}&a für Option &b{option}&a auf {value}&a mit dem Kontext &7{contexts}&a für &6{target}&a." @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cKeine sichere Position gefunden!\n&aNutze '&f/claiminfo&a' um einen sicheren Spawnpunkt auf dem Grundstück zu setzen." teleport-success="&aDu wurdest zu {name}&a teleportiert." title-accessor=ZUGRIFFSBERECHTIGT + title-advanced=ADVANCED title-all=ALLE title-builder=BAUBERECHTIGT title-claim=GRUNDSTÜCK @@ -622,6 +626,7 @@ GriefDefender { title-manager=MANAGER title-override=ÜBERGEORDNET title-own=EIGENE + title-preset=PRESET tool-not-equipped="&cDu hast {tool}&c nicht ausgerüstet." town-chat-disabled="&aStadt Chat ausgestellt." town-chat-enabled="&aStadt Chat aktiviert." @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cKonnte {target}&c keine Erlaubnis erteilen. Ein Plugin hat dies verhindert." trust-self="&cDu kannst dir selbst Rechte für Grundstücke erteilen." tutorial-claim-basic="&eTutorial Video zum Thema Grundstücke: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Bestätigen." - ui-click-filter-type="Filtern nach: {type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Bestätigen" + ui-click-filter-type="Filtern nach: {type}&f" + ui-click-remove="Klicke hier, um den Eintrag zu entfernen" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&6{target}&a Erlaubnisse für deine Grundstücke zurückgenommen. Um Berechtigungen einzelner Grundstücke zu entfernen, stelle dich drauf und nutze: &f/untrust&a." untrust-individual-single-claim="&6{target}&a Erlaubnis für dieses Grundstück entfernt. Um Berechtigungen für alle Grundstücke zu entfernen, nutze: &f/untrustall&a." untrust-no-claims="&cDu hast keine Grundstücke mit Rechten für andere Spieler." diff --git a/sponge/src/main/resources/assets/lang/en_US.conf b/sponge/src/main/resources/assets/lang/en_US.conf index b5e559b..b338cea 100644 --- a/sponge/src/main/resources/assets/lang/en_US.conf +++ b/sponge/src/main/resources/assets/lang/en_US.conf @@ -191,6 +191,7 @@ GriefDefender { command-invalid-amount="&cInvalid amount &6{amount}&c entered." command-invalid-claim="&cThis command cannot be used in {type}&c claims." command-invalid-group="&cGroup &6{group}&c is not valid." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cPlayer &6{player}&c is not valid." command-invalid-player-group="&cNot a valid player or group." command-invalid-type="&cInvalid type {type}&c specified." @@ -615,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cNo safe location found in claim to teleport!\n&aUse the '&f/claiminfo&a' command to set a safe spawn point instead." teleport-success="&aYou have been teleported to {name}&a." title-accessor=ACCESSOR + title-advanced=ADVANCED title-all=ALL title-builder=BUILDER title-claim=CLAIM @@ -624,6 +626,7 @@ GriefDefender { title-manager=MANAGER title-override=OVERRIDE title-own=OWN + title-preset=PRESET tool-not-equipped="&cYou do not have {tool}&c equipped." town-chat-disabled="&aTown chat disabled." town-chat-enabled="&aTown chat enabled." @@ -645,9 +648,13 @@ GriefDefender { trust-plugin-cancel="&cCould not trust {target}&c. A plugin has denied it." trust-self="&cYou cannot trust yourself." tutorial-claim-basic="&eClick for Land Claim Help: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Click to confirm." - ui-click-filter-type="Click here to filter by {type}&f." - ui-click-remove="Click here to remove." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Click to confirm" + ui-click-filter-type="Click here to filter by {type}&f" + ui-click-remove="Click here to remove" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aRevoked &6{target}'s&a access to ALL your claims. To set permissions for a single claim, stand inside it and use &f/untrust&a." untrust-individual-single-claim="&aRevoked &6{target}'s&a access to this claim. To unset permissions for ALL your claims, use &f/untrustall&a." untrust-no-claims="&cYou have no claims to untrust." diff --git a/sponge/src/main/resources/assets/lang/es_ES.conf b/sponge/src/main/resources/assets/lang/es_ES.conf index a2c79bf..643396f 100644 --- a/sponge/src/main/resources/assets/lang/es_ES.conf +++ b/sponge/src/main/resources/assets/lang/es_ES.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&4&l[ERROR] &cYa eres el dueño del Claim." claim-owner-only="&4&l[ERROR] &cNo puedes configurar nada de este Claim, solo &6&o{player}&c puede modificarlo." claim-protected-entity="&4&l[ERROR] &cEsto pertenece a &6&o{player}&c." + claim-reserve-add="&aEl nombre del terreno &6&o'{name}' &aha sido añadido a la lista de &b&lN&bombres de &lT&berrenos &lR&beservados&a." + claim-reserve-exists="&4&l[ATENCION] &aEl nombre del terreno que especificó ya está reservado por un jugador." + claim-reserved-name="&4&l[ERROR] &c&lEl nombre del terreno que especificó está reservado. &cPor favor escoge otro o asegurate de que tienes el permiso apropiado." claim-respecting="&aAhora respetas los Claims." claim-restore-success="&2&l[RESTAURACION COMPLETADA] &a¡Los Claims han sido restaurados con éxito!" claim-show-nearby="&aCLAIMS CERCANOS ► &6&o{amount}&a." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&4&l[ERROR] &cCantidad inválida de &6{amount}&oCB's&c introducida." command-invalid-claim="&4&l[ERROR] &cEste comando no puede ser usado en Claims de tipo &l➜ {type}&c." command-invalid-group="&4&l[ERROR] &cEl grupo &6&o'{group}'&c NO es válido." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&4&l[ERROR] &cEl jugador &6&o'{player}'&c NO es válido." command-invalid-player-group="&4&l[ERROR] &cJugador o Grupo NO válidos." command-invalid-type="&4&l[ERROR] &cTipo especificado: {type}&c &l➜ INVALIDO." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&4&l[ERROR] &cOpción &6&o'{option}' &c&lNO-ENCONTRADA&c." option-not-set="&4&l[ERROR] &6&o'{option}'&c no está establecida.\n&4&l[NOTA] &cLa opción con valor de &6&o'{value}'&c estará activa hasta que se establezca." option-override-not-supported="&4&l[ERROR] &cEl Claim tipo &6&o'{type}'&c no soporta la opción de Sobrescribir." - option-player-deny-flight="&4&l[VOLAR-DESACTIVADO] &cNo tienes acceso a la habilidad de volar en este terreno. Serás teletransportado a un lugar seguro en el suelo." option-requires-contexts="&4&l[ERROR] &cEsta opción requiere el Contexto &6&o'{contexts}'&c para ser establecido." option-reset-success="&2&l[OPCIONES-RESETEADAS] &a¡Todas las opciones de Claim han sido reiniciadas al estado original con éxito!" option-set-target="&aEstablecido ( &e&o{type}&a ) una opción ( &b&o{option} &a)&a en (&6&o {value} &a)&a con el Contexto de (&7&o {contexts} &a)&a en el Objetivo de ( &c&o{target} &a)" @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&4&l[IMPOSIBLE-TELETRANSPORTARSE] &cNo existe zona segura en el terreno a la que teletransportarse.\n&4&l[NOTA] &aUsa '&6&o/claiminfo&a' para establecer un punto de Spawn seguro." teleport-success="&2&l[TELETRANSPORTADO] ➜ &6&o{name}" title-accessor=ACCEDER + title-advanced=ADVANCED title-all=TODO title-builder=CONSTRUIR title-claim=RECLAMAR @@ -622,6 +626,7 @@ GriefDefender { title-manager=ADMINISTRAR title-override=IGNORAR title-own=DUEÑO + title-preset=PRESET tool-not-equipped="&4&l[ERROR] &cNo tienes la &6&o'{tool}'&c equipada." town-chat-disabled="&2&l[CHAT-CIUDAD]&f ➜ &8&lACTIVADO&f&l/&c&lDESACTIVADO" town-chat-enabled="&2&l[CHAT-CIUDAD]&f ➜ &a&lACTIVADO&f&l/&8&lDESACTIVADO" @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&4&l[ERROR] &cNo puedes confiar a &6&o{target}&c. Un plugin lo ha denegado." trust-self="&4&l[ERROR] &cNo puedes darte permisos de Confianza a ti mismo." tutorial-claim-basic="&eClick para ayuda con el reclamo del terreno: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="CLICK para Confirmar." - ui-click-filter-type="CLICK para filtar por &6&o{type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="CLICK para Confirmar" + ui-click-filter-type="CLICK para filtar por &6&o{type}&f" + ui-click-remove="Click aqui para eliminar" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&4&l[ACCESO-ANULADO] &C➜ &6{target}&c a TODOS tus terrenos.\n&4&l[NOTA] &cPara denegar permisos de Confianza en un SOLO terreno tienes que estar dentro de él y usar &6&o'/untrust'&c." untrust-individual-single-claim="&4&l[ACCESO-ANULADO] &C➜ &6{target}&c a ESTE terreno.\n&4&l[NOTA] &cPara denegar permisos de Confianza en TODOS tus terrenos tienes que usar &6&o'/untrustall'&c." untrust-no-claims="&4&l[ERROR] &cNo tienes terrenos para quitar permisos de Confianza." diff --git a/sponge/src/main/resources/assets/lang/fr_FR.conf b/sponge/src/main/resources/assets/lang/fr_FR.conf index 85a1404..cdb53b1 100644 --- a/sponge/src/main/resources/assets/lang/fr_FR.conf +++ b/sponge/src/main/resources/assets/lang/fr_FR.conf @@ -108,6 +108,9 @@ GriefDefender { claim-owner-already="&cTu es déjà le propriétaire de ce terrain." claim-owner-only="&cSeulement &6{player}&c peut modifier ce terrain." claim-protected-entity="&cCela appartient à &6{player}&c." + claim-reserve-add="&aLe nom &6{name}&a de terrain a été ajouté à la liste de réservation." + claim-reserve-exists="&aLe nom de terrain que tu as spécifié est déjà réservé." + claim-reserved-name="&cLe nom de terrain que tu as spécifié est réservé. Merci d'en choisir un autre ou de vérifier que tu as la permission appropriée." claim-respecting="&aRespecte maintenant les terrains." claim-restore-success="&aRestauration du terrain avec succès." claim-show-nearby="&aTrouvé &6{amount}&a terrain(s) à proximité." @@ -188,6 +191,7 @@ GriefDefender { command-invalid-amount="&cMontant invalide &6{amount}&c entré." command-invalid-claim="&cCette commande ne peut être utilisée dans les terrains de type {type}&c." command-invalid-group="&cGroupe &6{group}&c n'est pas valide." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cJoueur &6{player}&c n'est pas valide." command-invalid-player-group="&cPas un joueur ou groupe valide." command-invalid-type="&cType {type}&c invalide spécifié." @@ -477,7 +481,6 @@ GriefDefender { option-not-found="&cL'option {option}&c n'a pas été trouvée." option-not-set="{option}&f est actuellement non définit.\n&dNote&f: La valeur par défaut {value}&f de l'option sera active jusqu'à définition." option-override-not-supported="&cProtection de type {type}&c ne supporte pas les options outrepassantes." - option-player-deny-flight="&cTu n'as pas accès au fly dans cette protection et a été téléporté dans une zone sécurisée au sol." option-requires-contexts="&cCette option a besoin que le contexte '&a{contexts}&c' soi défini." option-reset-success="&aOption de la protection remises par défaut avec succès." option-set-target="&aDéfinis {type}&a de l'option &b{option}&a à {value}&a avec le contexte &7{contexts}&a sur la cible &6{target}&a." @@ -613,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cPas de zone sécurisée trouvée dans la protection pour se téléporter !\n&aClique confirm pour téléporter malgré tout ou &autilise la commande '&f/claiminfo&a' pour définir une un point d'apparition sécurisé à la place." teleport-success="&aTu as été téléporté à {name}&a." title-accessor=ACCÉDANT + title-advanced=ADVANCED title-all=TOUS title-builder=CONSTRUTEUR title-claim=PROTECTION @@ -622,6 +626,7 @@ GriefDefender { title-manager=GÉRANT title-override=OUTREPASSANT title-own=POSSÈDE + title-preset=PRESET tool-not-equipped="&cTu n'as pas {tool}&c équipé." town-chat-disabled="&aChat de Village désactivé." town-chat-enabled="&aChat de Village activé." @@ -643,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cImpossible d'avoir Confiance en {target}&c. Un plug-in l'a refusé." trust-self="&cTu ne peut pas te faire Confiance à toi-même." tutorial-claim-basic="&eClique pour l'aide sur la protection: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Clique pour confirmer." - ui-click-filter-type="Clique ici pour filtrer par {type}&f." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Clique pour confirmer" + ui-click-filter-type="Clique ici pour filtrer par {type}&f" + ui-click-remove="Clique ici pour supprimer" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aRévoque &6{target}&a accès à l'ENSEMBLE de tes protections. Pour définir la permission pour une seule protection, va dedans et utilises &f/untrust&a." untrust-individual-single-claim="&aRévoque &6{target}&a accès à cette protection. Pour définir la permission pour l'ENSEMBLE de tes protections, utilises &f/untrustall&a." untrust-no-claims="&cTu n'as pas de protection où enlever la confiance." diff --git a/sponge/src/main/resources/assets/lang/ru_RU.conf b/sponge/src/main/resources/assets/lang/ru_RU.conf index 238a7b0..18b8b65 100644 --- a/sponge/src/main/resources/assets/lang/ru_RU.conf +++ b/sponge/src/main/resources/assets/lang/ru_RU.conf @@ -58,6 +58,7 @@ GriefDefender { version="Вывести информацию о версии GriefDefender." } messages { + abandon-all-delay-warning="&aThese claims were recently created and cannot be abandoned." abandon-all-warning="&6Вы уверены, что хотите удалить &cВСЕ&6 ваши регионы?" abandon-claim-delay-warning="&aЭтот регион был создан недавно и не может быть удалён до &6{date}&a." abandon-claim-failed="&aНе удалось удалить регион. Результат действия: &f{result}&a." @@ -107,6 +108,9 @@ GriefDefender { claim-owner-already="&cВы уже являетесь владельцем этого региона." claim-owner-only="&cТолько &6{player}&c может редактировать этот регион." claim-protected-entity="&cЭто принадлежит игроку &6{player}&c." + claim-reserve-add="&aНазвание региона &6{name}&a добавлено в список зарезервированных." + claim-reserve-exists="&aЭто имя региона уже зарезервировано." + claim-reserved-name="&cУказанное имя региона зарезервировано. Пожалуйста, выберите другое или удостоверьтесь, что у вас есть необходимые разрешения." claim-respecting="&aИгнорирование регионов выключено." claim-restore-success="&aРегион успешно восстановлен." claim-show-nearby="&aПоблизости найдено &6{amount}&a регионов." @@ -169,6 +173,8 @@ GriefDefender { command-claiminfo-uuid-required="&cПри запуске не от имени игрока требуется UUID региона ." command-claiminherit-disabled="Наследование от родителя &cВЫКЛЮЧЕНО" command-claiminherit-enabled="Наследование от родителя &aВКЛЮЧЕНО" + command-claimmode-disabled="Claim mode &cOFF" + command-claimmode-enabled="Claim mode &aON&f\n&aLeft-click to inspect.\n&aRight-click to claim.&b\nNote&f: &aUse &f/claim&a to exit mode." command-claimspawn-not-found="&aНе удалось найти регион с именем {name}&a." command-claimunban-success-block="&aБлок с id &6{id}&a успешно &6РАЗБАНЕН&a." command-claimunban-success-entity="&aСущность с id &6{id}&a успешно &6РАЗБАНЕНА&a." @@ -185,6 +191,7 @@ GriefDefender { command-invalid-amount="&cВведено неверное количество: &6{amount}&c." command-invalid-claim="&cЭту команду нельзя использовать в регионах вида &f{type}&c." command-invalid-group="&cГруппа &6{group}&c не существует." + command-invalid-input="&cInvalid command input '{input}&c'." command-invalid-player="&cИгрок &6{player}&c не найден." command-invalid-player-group="&cНе является игроком или группой." command-invalid-type="&cТип {type}&c не найден." @@ -474,7 +481,6 @@ GriefDefender { option-not-found="&cОпция &f{option}&c не найдена." option-not-set="&a{option}&f не установлена.\nПрименяется стандартное значение &a{value}&f." option-override-not-supported="&cРегионы вида &f{type}&c не поддерживают переопределение опций." - option-player-deny-flight="&cУ вас нет разрешения на полёт в этом регионе. Вы были телепортированы на безопасное место на земле." option-requires-contexts="&cЭта опция требует следующие контексты: '&a{contexts}&c'." option-reset-success="&aОпции региона успешно откачены на стандартные значения." option-set-target="&aОпция &b{option}&a вида &b{type}&a с контекстами &7{contexts}&a установлена в значение {value}&a для &6{target}&a." @@ -610,6 +616,7 @@ GriefDefender { teleport-no-safe-location="&cНе удалось найти безопасную точку для телепортации в этот регион!\n&aВоспользуйтесь '&f/claiminfo&a', чтобы установить безопасную точку телепортации/возрождения." teleport-success="&aВы были телепортированы в регион {name}&a." title-accessor=ДОСТУП + title-advanced=ADVANCED title-all=ВСЕ title-builder=СТРОИТЕЛЬСТВО title-claim=РЕГИОН @@ -619,6 +626,7 @@ GriefDefender { title-manager=УПРАВЛЕНИЕ title-override=ПЕРЕОПРЕДЕЛЕНИЕ title-own=ВЛАДЕЛЕЦ + title-preset=PRESET tool-not-equipped="&cУ вас нет &f{tool}&c." town-chat-disabled="&aЧат города отключён." town-chat-enabled="&aЧат города включён." @@ -640,8 +648,13 @@ GriefDefender { trust-plugin-cancel="&cНе удалось выдать разрешения игроку &f{target}&c. Плагин не разрешил." trust-self="&cНикому нельзя доверять. Особенно себе." tutorial-claim-basic="&eНажмите для получения по созданию регионов: &ahttp://bit.ly/mcgpuser" - ui-click-confirm="Нажмите для подтверждения." - ui-click-filter-type="&7Нажмите здесь, чтобы вывести только &f{type}&7." + ui-click-add="Click here to add" + ui-click-add-target="Click here to add &6{target}&f" + ui-click-confirm="Нажмите для подтверждения" + ui-click-filter-type="&7Нажмите здесь, чтобы вывести только &f{type}" + ui-click-remove="Нажмите здесь, чтобы убрать" + ui-click-return-command="&bReturn to &6{command}" + ui-click-view="Click here to view {target}" untrust-individual-all-claims="&aОтозваны все разрешения игрока &6{target}&a во ВСЕХ ваших регионах. Чтобы настраивать разрешения в одном регионе, войдите в него и используйте &f/untrust&a." untrust-individual-single-claim="&aОтозваны все разрешения игрока &6{target}&a в этом регионе. Чтобы настроаивать разрешения во ВСЕХ ваших регионах, воспользуйтесь &f/untrustall&a." untrust-no-claims="&cУ вас нет регионов, из которых можно было бы выписать игрока."