Fix users accessing trust without permission.

This commit is contained in:
bloodshot 2020-01-16 19:28:19 -05:00
parent 8f4d761c76
commit b8c3bfe820
4 changed files with 82 additions and 68 deletions

View File

@ -563,30 +563,6 @@ public class CommandClaimInfo extends BaseCommand {
.append(northWestCorner)
.append(northEastCorner).build();
}
Component claimAccessors = TextComponent.builder()
.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.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.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.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(" : ")
@ -621,15 +597,41 @@ public class CommandClaimInfo extends BaseCommand {
.append(" ")
.append(claimDenyMessages)
.build());
textList.add(TextComponent.builder()
.append(claimAccessors)
.append(" ")
.append(claimBuilders)
.append(" ")
.append(claimContainers)
.append(" ")
.append(claimCoowners)
.build());
if (allowEdit == null) {
Component claimAccessors = TextComponent.builder()
.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.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.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.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();
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);

View File

@ -67,11 +67,16 @@ import java.util.function.Consumer;
public class CommandTrustList extends BaseCommand {
@CommandAlias("trustlist")
@Description("Lists permissions for the claim you're standing in.")
@Description("Manages trust for the claim you're standing in.")
@Subcommand("trust list")
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());
final Component message = claim.allowGrantPermission(player);
if (message != null) {
GriefDefenderPlugin.sendMessage(player, message);
return;
}
showTrustList(player, claim, playerData, TrustTypes.NONE, new ArrayList<>(), null);
}

View File

@ -555,30 +555,6 @@ public class CommandClaimInfo extends BaseCommand {
.append(northWestCorner)
.append(northEastCorner).build();
}
Component claimAccessors = TextComponent.builder()
.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.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.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.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(" : ")
@ -611,15 +587,41 @@ public class CommandClaimInfo extends BaseCommand {
.append(" ")
.append(claimDenyMessages)
.build());
textList.add(TextComponent.builder()
.append(claimAccessors)
.append(" ")
.append(claimBuilders)
.append(" ")
.append(claimContainers)
.append(" ")
.append(claimCoowners)
.build());
if (allowEdit == null) {
Component claimAccessors = TextComponent.builder()
.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.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.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.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();
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);

View File

@ -66,11 +66,16 @@ import java.util.function.Consumer;
public class CommandTrustList extends BaseCommand {
@CommandAlias("trustlist")
@Description("Lists permissions for the claim you're standing in.")
@Description("Manages trust for the claim you're standing in.")
@Subcommand("trust list")
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());
final Component message = claim.allowGrantPermission(player);
if (message != null) {
GriefDefenderPlugin.sendMessage(player, message);
return;
}
showTrustList(player, claim, playerData, TrustTypes.NONE, new ArrayList<>(), null);
}