mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-26 12:55:46 +01:00
Various enhancements.
* Add '/claimreserve' command for administrators to reserve claim names. * Add support for untrusting specific type via all untrust commands. * Add #pet context support. * Hide teleport button if player does not have access to teleport. * Fix pagination error when swapping between menu's. Fixes #8 Fixes #25 Fixes #26 Fixes #91 Fixes #93
This commit is contained in:
parent
fcd6ed4e89
commit
d5213a3d64
@ -116,6 +116,7 @@
|
||||
import com.griefdefender.command.CommandClaimOptionPlayer;
|
||||
import com.griefdefender.command.CommandClaimPermissionGroup;
|
||||
import com.griefdefender.command.CommandClaimPermissionPlayer;
|
||||
import com.griefdefender.command.CommandClaimReserve;
|
||||
import com.griefdefender.command.CommandClaimSchematic;
|
||||
import com.griefdefender.command.CommandClaimSell;
|
||||
import com.griefdefender.command.CommandClaimSellBlocks;
|
||||
@ -619,6 +620,7 @@ public void registerBaseCommands() {
|
||||
manager.registerCommand(new CommandClaimOptionPlayer());
|
||||
manager.registerCommand(new CommandClaimPermissionGroup());
|
||||
manager.registerCommand(new CommandClaimPermissionPlayer());
|
||||
manager.registerCommand(new CommandClaimReserve());
|
||||
manager.registerCommand(new CommandClaimSchematic());
|
||||
manager.registerCommand(new CommandClaimSell());
|
||||
manager.registerCommand(new CommandClaimSellBlocks());
|
||||
|
@ -69,6 +69,8 @@ public static MessageCache getInstance() {
|
||||
public Component CLAIM_OWNER_ALREADY;
|
||||
public Component CLAIM_OWNER_ONLY;
|
||||
public Component CLAIM_RESPECTING;
|
||||
public Component CLAIM_RESERVE_EXISTS;
|
||||
public Component CLAIM_RESERVED_NAME;
|
||||
public Component CLAIM_RESTORE_SUCCESS;
|
||||
public Component CLAIM_TOO_FAR;
|
||||
public Component CLAIMINFO_UI_ADMIN_SETTINGS;
|
||||
@ -406,6 +408,7 @@ public static MessageCache getInstance() {
|
||||
public Component TRUST_NO_CLAIMS;
|
||||
public Component TRUST_SELF;
|
||||
public Component UI_CLICK_CONFIRM;
|
||||
public Component UI_CLICK_REMOVE;
|
||||
public Component UNTRUST_NO_CLAIMS;
|
||||
public Component UNTRUST_SELF;
|
||||
|
||||
@ -432,6 +435,8 @@ public void loadCache() {
|
||||
CLAIM_NOT_YOURS = MessageStorage.MESSAGE_DATA.getMessage("claim-not-yours");
|
||||
CLAIM_OWNER_ALREADY = MessageStorage.MESSAGE_DATA.getMessage("claim-owner-already");
|
||||
CLAIM_OWNER_ONLY = MessageStorage.MESSAGE_DATA.getMessage("claim-owner-only");
|
||||
CLAIM_RESERVE_EXISTS = MessageStorage.MESSAGE_DATA.getMessage("claim-reserve-exists");
|
||||
CLAIM_RESERVED_NAME = MessageStorage.MESSAGE_DATA.getMessage("claim-reserved-name");
|
||||
CLAIM_RESPECTING = MessageStorage.MESSAGE_DATA.getMessage("claim-respecting");
|
||||
CLAIM_RESTORE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("claim-restore-success");
|
||||
CLAIM_TOO_FAR = MessageStorage.MESSAGE_DATA.getMessage("claim-too-far");
|
||||
@ -770,6 +775,7 @@ public void loadCache() {
|
||||
TRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("trust-no-claims");
|
||||
TRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("trust-self");
|
||||
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");
|
||||
UNTRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("untrust-self");
|
||||
|
||||
|
@ -995,12 +995,14 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
|
||||
|
||||
private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, String flagGroup) {
|
||||
return consumer -> {
|
||||
PaginationUtil.getInstance().resetActivePage(src.getUniqueId());
|
||||
showCustomFlags(src, claim, flagGroup);
|
||||
};
|
||||
}
|
||||
|
||||
private Consumer<CommandSender> createClaimFlagConsumer(GDPermissionUser src, GDClaim claim, MenuType flagType) {
|
||||
return consumer -> {
|
||||
PaginationUtil.getInstance().resetActivePage(src.getUniqueId());
|
||||
showFlagPermissions(src, claim, flagType);
|
||||
};
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ public void execute(CommandSender src, String[] args) {
|
||||
.append(" : ")
|
||||
.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()
|
||||
@ -566,52 +566,56 @@ public void execute(CommandSender src, String[] args) {
|
||||
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_SPAWN))
|
||||
.build();
|
||||
}
|
||||
Component southWestCorner = TextComponent.builder()
|
||||
.append("SW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southEastCorner = TextComponent.builder()
|
||||
.append("SE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_SOUTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(southWestCorner)
|
||||
.append(southEastCorner).build();
|
||||
Component northWestCorner = TextComponent.builder()
|
||||
.append("NW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northEastCorner = TextComponent.builder()
|
||||
.append("NE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_NORTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(northWestCorner)
|
||||
.append(northEastCorner).build();
|
||||
Component southCorners = null;
|
||||
Component northCorners = null;
|
||||
if (!claim.isWilderness() && player != null && PermissionUtil.getInstance().canPlayerTeleport(player, gdClaim)) {
|
||||
Component southWestCorner = TextComponent.builder()
|
||||
.append("SW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southEastCorner = TextComponent.builder()
|
||||
.append("SE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
southCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_SOUTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(southWestCorner)
|
||||
.append(southEastCorner).build();
|
||||
Component northWestCorner = TextComponent.builder()
|
||||
.append("NW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northEastCorner = TextComponent.builder()
|
||||
.append("NE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
northCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_NORTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(northWestCorner)
|
||||
.append(northEastCorner).build();
|
||||
}
|
||||
Component claimAccessors = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
@ -679,8 +683,10 @@ public void execute(CommandSender src, String[] args) {
|
||||
textList.add(dateCreated);
|
||||
textList.add(dateLastActive);
|
||||
textList.add(claimId);
|
||||
textList.add(northCorners);
|
||||
textList.add(southCorners);
|
||||
if (northCorners != null && southCorners != null) {
|
||||
textList.add(northCorners);
|
||||
textList.add(southCorners);
|
||||
}
|
||||
if (!claim.getParent().isPresent()) {
|
||||
textList.remove(claimInherit);
|
||||
}
|
||||
@ -693,8 +699,6 @@ public void execute(CommandSender src, String[] args) {
|
||||
textList.remove(claimInherit);
|
||||
textList.remove(claimTypeInfo);
|
||||
textList.remove(dateLastActive);
|
||||
textList.remove(northCorners);
|
||||
textList.remove(southCorners);
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
@ -35,13 +34,17 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
import com.griefdefender.configuration.GriefDefenderConfig;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@ -61,6 +64,16 @@ public void execute(Player player, String name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasPermission(GDPermissions.USE_RESERVED_CLAIM_NAMES)) {
|
||||
final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID());
|
||||
for (String str : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
if (FilenameUtils.wildcardMatch(name, str)) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_RESERVED_NAME);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Component text = LegacyComponentSerializer.legacy().deserialize(name, '&');
|
||||
if (text == TextComponent.empty()) {
|
||||
claim.getInternalClaimData().setName(null);
|
||||
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
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 com.google.common.collect.ImmutableMap;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.configuration.GriefDefenderConfig;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
import com.griefdefender.internal.pagination.PaginationList;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.text.action.GDCallbackHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_RESERVE)
|
||||
public class CommandClaimReserve extends BaseCommand {
|
||||
|
||||
@CommandAlias("claimreserve")
|
||||
@Syntax("[<name>]")
|
||||
@Description("Reserves a claim name for administrator use.")
|
||||
@Subcommand("claim reserve")
|
||||
public void execute(CommandSender src, @Optional String name) {
|
||||
GriefDefenderConfig<?> activeConfig = null;
|
||||
if (src instanceof Player) {
|
||||
final Player player = (Player) src;
|
||||
activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID());
|
||||
} else {
|
||||
activeConfig = GriefDefenderPlugin.getGlobalConfig();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
List<Component> nameList = new ArrayList<>();
|
||||
for (String reserved : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
nameList.add(TextComponent.builder("")
|
||||
.append(reserved, TextColor.GREEN)
|
||||
.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(activeConfig, name))))
|
||||
.build())
|
||||
.append("]", TextColor.WHITE)
|
||||
.build());
|
||||
}
|
||||
|
||||
final int fillSize = 20 - (nameList.size() + 2);
|
||||
for (int i = 0; i < fillSize; i++) {
|
||||
nameList.add(TextComponent.of(" "));
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
.title(TextComponent.of("Reserved Claim Names", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(nameList);
|
||||
paginationBuilder.sendTo(src);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String str : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
if (FilenameUtils.wildcardMatch(name, str)) {
|
||||
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESERVE_EXISTS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeConfig.getConfig().claim.reservedClaimNames.add(name);
|
||||
activeConfig.save();
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_RESERVE_ADD,
|
||||
ImmutableMap.of(
|
||||
"name", name));
|
||||
GriefDefenderPlugin.sendMessage(src, message);
|
||||
}
|
||||
|
||||
private Consumer<CommandSender> createRemoveConsumer(GriefDefenderConfig<?> activeConfig, String name) {
|
||||
return consumer -> {
|
||||
activeConfig.getConfig().claim.reservedClaimNames.remove(name);
|
||||
activeConfig.save();
|
||||
};
|
||||
}
|
||||
}
|
@ -113,6 +113,11 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept
|
||||
.build());
|
||||
}
|
||||
|
||||
final int fillSize = 20 - (schematicTextList.size() + 2);
|
||||
for (int i = 0; i < fillSize; i++) {
|
||||
schematicTextList.add(TextComponent.of(" "));
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
.title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(schematicTextList);
|
||||
paginationBuilder.sendTo(player);
|
||||
|
@ -627,35 +627,35 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claiminfo", claim.getUniqueId().toString(), createReturnClaimListConsumer(src, returnCommand)))))
|
||||
.hoverEvent(HoverEvent.showText(basicInfo)).build();
|
||||
|
||||
Component claimCoordsTPClick = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, VecHelper.toLocation(claim.getWorld(), southWest), claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", southWest.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
|
||||
Component claimSpawn = null;
|
||||
if (claim.getData().getSpawnPos().isPresent()) {
|
||||
Vector3i spawnPos = claim.getData().getSpawnPos().get();
|
||||
Location spawnLoc = new Location(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, spawnLoc, claim, true))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
if (player !=null && PermissionUtil.getInstance().canPlayerTeleport(player, claim)) {
|
||||
final Vector3i spawnPos = claim.getData().getSpawnPos().orElse(null);
|
||||
if (spawnPos != null) {
|
||||
Location spawnLoc = new Location(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, spawnLoc, claim, true))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", "'s spawn @ " + spawnPos.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
} else {
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, VecHelper.toLocation(claim.getWorld(), southWest), claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", "'s spawn @ " + spawnPos.toString(),
|
||||
"target", southWest.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
} else {
|
||||
claimSpawn = claimCoordsTPClick;
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
List<Component> childrenTextList = new ArrayList<>();
|
||||
@ -682,8 +682,7 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(showChildrenList(childrenTextList, src, returnCommand, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().CLAIMLIST_UI_CLICK_VIEW_CHILDREN)).build();
|
||||
claimsTextList.add(TextComponent.builder("")
|
||||
.append(claimSpawn)
|
||||
.append(" ")
|
||||
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
|
||||
.append(claimInfoCommandClick)
|
||||
.append(" : ", TextColor.WHITE)
|
||||
.append(claim.getOwnerName().color(TextColor.GOLD))
|
||||
@ -696,8 +695,7 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.build());
|
||||
} else {
|
||||
claimsTextList.add(TextComponent.builder("")
|
||||
.append(claimSpawn)
|
||||
.append(" ")
|
||||
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
|
||||
.append(claimInfoCommandClick)
|
||||
.append(" : ", TextColor.WHITE)
|
||||
.append(claim.getOwnerName().color(TextColor.GOLD))
|
||||
@ -988,34 +986,9 @@ public static Consumer<CommandSender> createTeleportConsumer(CommandSender src,
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
Player player = (Player) src;
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
if (!playerData.canIgnoreClaim(gdClaim) && !playerData.canManageAdminClaims) {
|
||||
// if not owner of claim, validate perms
|
||||
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
if (!gdClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
|
||||
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null) {
|
||||
// Allow non-trusted to TP to claims for sale
|
||||
if (!gdClaim.getEconomyData().isForSale()) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = (Player) src;
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
final int teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
|
||||
if (isClaimSpawn) {
|
||||
if (teleportDelay > 0) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
|
||||
@ -37,6 +38,8 @@
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -50,18 +53,31 @@
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.adapter.bukkit.TextAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_UNTRUST_GROUP)
|
||||
public class CommandUntrustGroup extends BaseCommand {
|
||||
|
||||
@CommandCompletion("@gdgroups @gddummy")
|
||||
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrustgroup")
|
||||
@Description("Revokes group access to your claim.")
|
||||
@Syntax("<group>")
|
||||
@Syntax("<group> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrust group")
|
||||
public void execute(Player player, String target) {
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
if (group == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_GROUP, ImmutableMap.of(
|
||||
@ -93,22 +109,45 @@ public void execute(Player player, String target) {
|
||||
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDGroupTrustClaimEvent.Remove event =
|
||||
new GDGroupTrustClaimEvent.Remove(claim, ImmutableList.of(group.getName()), TrustTypes.NONE);
|
||||
new GDGroupTrustClaimEvent.Remove(claim, ImmutableList.of(group.getName()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
TextAdapter.sendComponent(player, event.getMessage().orElse(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.TRUST_PLUGIN_CANCEL,
|
||||
ImmutableMap.of("target", group))));
|
||||
ImmutableMap.of("target", group.getName()))));
|
||||
return;
|
||||
}
|
||||
|
||||
claim.removeAllTrustsFromGroup(group.getName());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllGroupTrust(claim, group);
|
||||
} else {
|
||||
this.removeGroupTrust(claim, group, trustType);
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_SINGLE_CLAIM,
|
||||
ImmutableMap.of(
|
||||
"target", group));
|
||||
"target", group.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeGroupTrust(GDClaim claim, GDPermissionGroup group, TrustType type) {
|
||||
final List<String> trustList = claim.getGroupTrustList(type);
|
||||
if (trustList.remove(group.getName())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeGroupTrust((GDClaim) child, group, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllGroupTrust(Claim claim, GDPermissionGroup holder) {
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
gdClaim.removeAllTrustsFromGroup(holder.getName());
|
||||
gdClaim.getInternalClaimData().setRequiresSave(true);
|
||||
gdClaim.getInternalClaimData().save();
|
||||
for (Claim child : gdClaim.children) {
|
||||
this.removeAllGroupTrust(child, holder);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
|
||||
@ -38,6 +39,7 @@
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -52,6 +54,7 @@
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@ -61,11 +64,21 @@ public class CommandUntrustGroupAll extends BaseCommand {
|
||||
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrustallgroup")
|
||||
@Description("Revokes group access to all your claims")
|
||||
@Syntax("<group>")
|
||||
@Syntax("<group> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrustall group")
|
||||
public void execute(Player player, String target, String type) {
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
// validate player argument
|
||||
if (group == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_GROUP,
|
||||
@ -87,17 +100,22 @@ public void execute(Player player, String target, String type) {
|
||||
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDGroupTrustClaimEvent.Remove
|
||||
event = new GDGroupTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(group.getName()), TrustTypes.NONE);
|
||||
event = new GDGroupTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(group.getName()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
TextAdapter.sendComponent(player, event.getMessage().orElse(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.TRUST_PLUGIN_CANCEL,
|
||||
ImmutableMap.of("target", group))));
|
||||
ImmutableMap.of("target", group.getName()))));
|
||||
return;
|
||||
}
|
||||
|
||||
for (Claim claim : claimList) {
|
||||
this.removeAllGroupTrust(claim, group);
|
||||
final GDClaim gdClaim = (GDClaim) claim;
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllGroupTrust(gdClaim, group);
|
||||
} else {
|
||||
this.removeGroupTrust(gdClaim, group, trustType);
|
||||
}
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_ALL_CLAIMS,
|
||||
@ -106,6 +124,17 @@ public void execute(Player player, String target, String type) {
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeGroupTrust(GDClaim claim, GDPermissionGroup group, TrustType type) {
|
||||
final List<String> trustList = claim.getGroupTrustList(type);
|
||||
if (trustList.remove(group.getName())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeGroupTrust((GDClaim) child, group, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllGroupTrust(Claim claim, GDPermissionGroup holder) {
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
gdClaim.removeAllTrustsFromGroup(holder.getName());
|
||||
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
|
||||
@ -41,6 +42,8 @@
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -50,18 +53,32 @@
|
||||
import com.griefdefender.permission.GDPermissionUser;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_UNTRUST_PLAYER)
|
||||
public class CommandUntrustPlayer extends BaseCommand {
|
||||
|
||||
@CommandCompletion("@gdplayers @gddummy")
|
||||
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrust|ut")
|
||||
@Description("Revokes player access to your claim.")
|
||||
@Syntax("<player>")
|
||||
@Syntax("<player> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrust player")
|
||||
public void execute(Player player, String target) {
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GDPermissionUser user;
|
||||
if (target.equalsIgnoreCase("public")) {
|
||||
user = GriefDefenderPlugin.PUBLIC_USER;
|
||||
@ -101,7 +118,7 @@ public void execute(Player player, String target) {
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDUserTrustClaimEvent.Remove
|
||||
event =
|
||||
new GDUserTrustClaimEvent.Remove(claim, ImmutableList.of(user.getUniqueId()), TrustTypes.NONE);
|
||||
new GDUserTrustClaimEvent.Remove(claim, ImmutableList.of(user.getUniqueId()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
@ -110,13 +127,37 @@ public void execute(Player player, String target) {
|
||||
return;
|
||||
}
|
||||
|
||||
claim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
System.out.println("Removing user " + user.getUniqueId());
|
||||
final GDClaim gdClaim = (GDClaim) claim;
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllUserTrust(gdClaim, user);
|
||||
} else {
|
||||
this.removeUserTrust(gdClaim, user, trustType);
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_SINGLE_CLAIM,
|
||||
ImmutableMap.of(
|
||||
"target", user.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeUserTrust(GDClaim claim, GDPermissionUser user, TrustType type) {
|
||||
final List<UUID> trustList = claim.getUserTrustList(type);
|
||||
if (trustList.remove(user.getUniqueId())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeUserTrust((GDClaim) child, user, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllUserTrust(GDClaim claim, GDPermissionUser user) {
|
||||
claim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
for (Claim child : claim.children) {
|
||||
this.removeAllUserTrust((GDClaim) child, user);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
|
||||
@ -38,6 +39,7 @@
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -52,18 +54,31 @@
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_UNTRUSTALL_PLAYER)
|
||||
public class CommandUntrustPlayerAll extends BaseCommand {
|
||||
|
||||
@CommandCompletion("@gdplayers @gddummy")
|
||||
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrustall")
|
||||
@Description("Revokes player access to all your claims.")
|
||||
@Syntax("<player>")
|
||||
@Syntax("<player> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrustall player")
|
||||
public void execute(Player player, String target) {
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GDPermissionUser user;
|
||||
if (target.equalsIgnoreCase("public")) {
|
||||
user = GriefDefenderPlugin.PUBLIC_USER;
|
||||
@ -96,7 +111,7 @@ public void execute(Player player, String target) {
|
||||
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDUserTrustClaimEvent.Remove
|
||||
event = new GDUserTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(user.getUniqueId()), TrustTypes.NONE);
|
||||
event = new GDUserTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(user.getUniqueId()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
@ -106,7 +121,12 @@ public void execute(Player player, String target) {
|
||||
}
|
||||
|
||||
for (Claim claim : claimList) {
|
||||
this.removeAllUserTrust(claim, user);
|
||||
final GDClaim gdClaim = (GDClaim) claim;
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllUserTrust(gdClaim, user);
|
||||
} else {
|
||||
this.removeUserTrust(gdClaim, user, trustType);
|
||||
}
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_ALL_CLAIMS,
|
||||
@ -115,13 +135,23 @@ public void execute(Player player, String target) {
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeAllUserTrust(Claim claim, GDPermissionUser user) {
|
||||
final GDClaim gdClaim = ((GDClaim) claim);
|
||||
gdClaim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
gdClaim.getInternalClaimData().setRequiresSave(true);
|
||||
gdClaim.getInternalClaimData().save();
|
||||
for (Claim child : gdClaim.children) {
|
||||
this.removeAllUserTrust(child, user);
|
||||
private void removeUserTrust(GDClaim claim, GDPermissionUser user, TrustType type) {
|
||||
final List<UUID> trustList = claim.getUserTrustList(type);
|
||||
if (trustList.remove(user.getUniqueId())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeUserTrust((GDClaim) child, user, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllUserTrust(GDClaim claim, GDPermissionUser user) {
|
||||
claim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
for (Claim child : claim.children) {
|
||||
this.removeAllUserTrust((GDClaim) child, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ public class MessageStorage {
|
||||
public static final String CLAIM_NAME = "claim-name";
|
||||
public static final String CLAIM_OWNER_ONLY = "claim-owner-only";
|
||||
public static final String CLAIM_PROTECTED_ENTITY = "claim-protected-entity";
|
||||
public static final String CLAIM_RESERVE_ADD = "claim-reserve-add";
|
||||
public static final String CLAIM_SHOW_NEARBY = "claim-show-nearby";
|
||||
public static final String CLAIM_SIZE_MIN = "claim-size-min";
|
||||
public static final String CLAIM_SIZE_MAX = "claim-size-max";
|
||||
|
@ -24,6 +24,9 @@
|
||||
*/
|
||||
package com.griefdefender.configuration.category;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ -55,6 +58,12 @@ public class ClaimCategory extends ConfigCategory {
|
||||
@Setting(value = "claims-enabled",
|
||||
comment = "Whether claiming is enabled or not. (0 = Disabled, 1 = Enabled)")
|
||||
public int claimsEnabled = 1;
|
||||
@Setting(value = "reserved-claim-names", comment = "A list of reserved claim names for use only by administrators."
|
||||
+ "\nNote: Names support wildcards '?' and '*' by using Apache's wildcard matcher."
|
||||
+ "\nThe wildcard '?' represents a single character."
|
||||
+ "\nThe wildcard '*' represents zero or more characters."
|
||||
+ "\nFor more information on usage, see https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/FilenameUtils.html#wildcardMatch(java.lang.String,%20java.lang.String)")
|
||||
public List<String> reservedClaimNames = new ArrayList<>();
|
||||
@Setting(value = "bank-tax-system", comment = "Whether to enable the bank/tax system for claims. Set to true to enable.")
|
||||
public boolean bankTaxSystem = false;
|
||||
@Setting(value = "tax-apply-hour", comment = "The specific hour in day to apply tax to all claims.")
|
||||
|
@ -33,5 +33,6 @@ public class ContextGroupKeys {
|
||||
public static final String FOOD = "#food";
|
||||
public static final String MISC = "#misc";
|
||||
public static final String MONSTER = "#monster";
|
||||
public static final String PET = "#pet";
|
||||
public static final String VEHICLE = "#vehicle";
|
||||
}
|
||||
|
@ -104,6 +104,7 @@
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -561,7 +562,7 @@ public Set<Context> getPermissionContexts(GDClaim claim, Object obj, boolean isS
|
||||
String id = type.getId();
|
||||
|
||||
if (!(targetEntity instanceof Player)) {
|
||||
addCustomEntityTypeContexts(targetEntity, contexts, type, isSource);
|
||||
addCustomEntityTypeContexts(targetEntity, id, contexts, type, isSource);
|
||||
}
|
||||
|
||||
if (this.isObjectIdBanned(claim, id, BanType.ENTITY)) {
|
||||
@ -691,7 +692,7 @@ public boolean isObjectIdBanned(GDClaim claim, String id, BanType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contexts, GDEntityType type, boolean isSource) {
|
||||
public void addCustomEntityTypeContexts(Entity targetEntity, String id, Set<Context> contexts, GDEntityType type, boolean isSource) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_ALL);
|
||||
} else {
|
||||
@ -710,7 +711,6 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
return;
|
||||
}
|
||||
|
||||
final String contextKey = isSource ? "source" : "target";
|
||||
//contexts.add(new Context(contextKey, "#" + creatureType));
|
||||
if (creatureType.contains("animal")) {
|
||||
if (isSource) {
|
||||
@ -718,12 +718,14 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
} else {
|
||||
contexts.add(ContextGroups.TARGET_ANIMAL);
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else if (creatureType.contains("aquatic")) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_AQUATIC);
|
||||
} else {
|
||||
contexts.add(ContextGroups.TARGET_AQUATIC);
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else if (creatureType.contains("monster")) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_MONSTER);
|
||||
@ -736,6 +738,7 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
} else {
|
||||
contexts.add(ContextGroups.TARGET_AMBIENT);
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_MISC);
|
||||
@ -745,6 +748,16 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPetContext(Entity targetEntity, String id, Set<Context> contexts) {
|
||||
if (this.eventSubject != null && this.eventSubject instanceof GDPermissionUser) {
|
||||
final GDPermissionUser user = (GDPermissionUser) this.eventSubject;
|
||||
final UUID uuid = NMSUtil.getInstance().getTameableOwnerUUID(targetEntity);
|
||||
if (uuid != null && uuid.equals(user.getUniqueId())) {
|
||||
contexts.add(new Context(ContextGroupKeys.PET, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayerContexts(Player player, Set<Context> contexts) {
|
||||
if(!PermissionUtil.getInstance().containsKey(contexts, "used_item") && NMSUtil.getInstance().getActiveItem(player, this.currentEvent) != null) {
|
||||
final ItemStack stack = NMSUtil.getInstance().getActiveItem(player, this.currentEvent);
|
||||
|
@ -136,6 +136,7 @@ public class GDPermissions {
|
||||
public static final String COMMAND_CLAIM_CLEAR = "griefdefender.admin.claim.command.clear";
|
||||
public static final String COMMAND_CLAIM_PERMISSION_GROUP = "griefdefender.admin.claim.command.permission-group";
|
||||
public static final String COMMAND_CLAIM_PERMISSION_PLAYER = "griefdefender.admin.claim.command.permission-player";
|
||||
public static final String COMMAND_CLAIM_RESERVE = "griefdefender.user.claim.command.reserve-name";
|
||||
public static final String COMMAND_CLAIM_SCHEMATIC = "griefdefender.admin.claim.command.schematic";
|
||||
public static final String COMMAND_IGNORE_CLAIMS = "griefdefender.admin.claim.command.ignore.base";
|
||||
public static final String COMMAND_DELETE_CLAIM_BASE = "griefdefender.admin.claim.command.delete.base";
|
||||
@ -162,6 +163,7 @@ public class GDPermissions {
|
||||
public static final String MANAGE_GLOBAL_OPTIONS = "griefdefender.admin.claim.option.global";
|
||||
public static final String MANAGE_OVERRIDE_OPTIONS = "griefdefender.admin.claim.option.override";
|
||||
public static final String SET_ADMIN_FLAGS = "griefdefender.admin.claim.set-admin-flags";
|
||||
public static final String USE_RESERVED_CLAIM_NAMES = "griefdefender.admin.claim.use-reserved-names";
|
||||
|
||||
// Misc
|
||||
public static final String COMMAND_HELP = "griefdefender.user.command.help";
|
||||
|
@ -28,16 +28,23 @@
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.Tristate;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.PermissionResult;
|
||||
import com.griefdefender.api.permission.flag.Flag;
|
||||
import com.griefdefender.api.permission.option.Option;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
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 net.kyori.text.adapter.bukkit.TextAdapter;
|
||||
import net.kyori.text.format.TextColor;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -270,4 +277,30 @@ public Tristate getTristateFromString(String value) {
|
||||
|
||||
return tristate;
|
||||
}
|
||||
|
||||
public boolean canPlayerTeleport(Player player, GDClaim claim) {
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
if (!playerData.canIgnoreClaim(claim) && !playerData.canManageAdminClaims) {
|
||||
// if not owner of claim, validate perms
|
||||
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
|
||||
return false;
|
||||
}
|
||||
if (!claim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
|
||||
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null) {
|
||||
// Allow non-trusted to TP to claims for sale
|
||||
if (!claim.getEconomyData().isForSale()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ GriefDefender {
|
||||
claim-owner-already="&cYou are already the claim owner."
|
||||
claim-owner-only="&cOnly &6{player}&c can modify this claim."
|
||||
claim-protected-entity="&cThat belongs to &6{player}&c."
|
||||
claim-reserve-add="&aThe claim name &6{name}&a has been added to the reserved list."
|
||||
claim-reserve-exists="&aThe claim name you specified is already reserved."
|
||||
claim-reserved-name="&cThe claim name you specified is reserved. Please choose another or ensure you have the appropriate permission."
|
||||
claim-respecting="&aNow respecting claims."
|
||||
claim-restore-success="&aSuccessfully restored claim."
|
||||
claim-show-nearby="&aFound &6{amount}&a nearby claims."
|
||||
@ -644,6 +647,7 @@ GriefDefender {
|
||||
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."
|
||||
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."
|
||||
|
@ -91,6 +91,7 @@
|
||||
import com.griefdefender.command.CommandClaimOptionPlayer;
|
||||
import com.griefdefender.command.CommandClaimPermissionGroup;
|
||||
import com.griefdefender.command.CommandClaimPermissionPlayer;
|
||||
import com.griefdefender.command.CommandClaimReserve;
|
||||
import com.griefdefender.command.CommandClaimSchematic;
|
||||
import com.griefdefender.command.CommandClaimSell;
|
||||
import com.griefdefender.command.CommandClaimSellBlocks;
|
||||
@ -690,6 +691,7 @@ public void registerBaseCommands() {
|
||||
manager.registerCommand(new CommandClaimOptionPlayer());
|
||||
manager.registerCommand(new CommandClaimPermissionGroup());
|
||||
manager.registerCommand(new CommandClaimPermissionPlayer());
|
||||
manager.registerCommand(new CommandClaimReserve());
|
||||
manager.registerCommand(new CommandClaimSchematic());
|
||||
manager.registerCommand(new CommandClaimSell());
|
||||
manager.registerCommand(new CommandClaimSellBlocks());
|
||||
|
@ -69,6 +69,8 @@ public static MessageCache getInstance() {
|
||||
public Component CLAIM_OWNER_ALREADY;
|
||||
public Component CLAIM_OWNER_ONLY;
|
||||
public Component CLAIM_RESPECTING;
|
||||
public Component CLAIM_RESERVE_EXISTS;
|
||||
public Component CLAIM_RESERVED_NAME;
|
||||
public Component CLAIM_RESTORE_SUCCESS;
|
||||
public Component CLAIM_TOO_FAR;
|
||||
public Component CLAIMINFO_UI_ADMIN_SETTINGS;
|
||||
@ -406,6 +408,7 @@ public static MessageCache getInstance() {
|
||||
public Component TRUST_NO_CLAIMS;
|
||||
public Component TRUST_SELF;
|
||||
public Component UI_CLICK_CONFIRM;
|
||||
public Component UI_CLICK_REMOVE;
|
||||
public Component UNTRUST_NO_CLAIMS;
|
||||
public Component UNTRUST_SELF;
|
||||
|
||||
@ -432,6 +435,8 @@ public void loadCache() {
|
||||
CLAIM_NOT_YOURS = MessageStorage.MESSAGE_DATA.getMessage("claim-not-yours");
|
||||
CLAIM_OWNER_ALREADY = MessageStorage.MESSAGE_DATA.getMessage("claim-owner-already");
|
||||
CLAIM_OWNER_ONLY = MessageStorage.MESSAGE_DATA.getMessage("claim-owner-only");
|
||||
CLAIM_RESERVE_EXISTS = MessageStorage.MESSAGE_DATA.getMessage("claim-reserve-exists");
|
||||
CLAIM_RESERVED_NAME = MessageStorage.MESSAGE_DATA.getMessage("claim-reserved-name");
|
||||
CLAIM_RESPECTING = MessageStorage.MESSAGE_DATA.getMessage("claim-respecting");
|
||||
CLAIM_RESTORE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("claim-restore-success");
|
||||
CLAIM_TOO_FAR = MessageStorage.MESSAGE_DATA.getMessage("claim-too-far");
|
||||
@ -770,6 +775,7 @@ public void loadCache() {
|
||||
TRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("trust-no-claims");
|
||||
TRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("trust-self");
|
||||
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");
|
||||
UNTRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("untrust-self");
|
||||
|
||||
|
@ -995,12 +995,14 @@ private Consumer<CommandSource> createFlagConsumer(GDPermissionUser src, GDClaim
|
||||
|
||||
private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, String flagGroup) {
|
||||
return consumer -> {
|
||||
PaginationUtil.getInstance().resetActivePage(src.getUniqueId());
|
||||
showCustomFlags(src, claim, flagGroup);
|
||||
};
|
||||
}
|
||||
|
||||
private Consumer<CommandSource> createClaimFlagConsumer(GDPermissionUser src, GDClaim claim, MenuType flagType) {
|
||||
return consumer -> {
|
||||
PaginationUtil.getInstance().resetActivePage(src.getUniqueId());
|
||||
showFlagPermissions(src, claim, flagType);
|
||||
};
|
||||
}
|
||||
|
@ -53,6 +53,7 @@
|
||||
import com.griefdefender.permission.GDPermissionUser;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.text.action.GDCallbackHolder;
|
||||
import com.griefdefender.util.PermissionUtil;
|
||||
import com.griefdefender.util.PlayerUtil;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
@ -561,52 +562,56 @@ public void execute(CommandSource src, String[] args) {
|
||||
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_SPAWN))
|
||||
.build();
|
||||
}
|
||||
Component southWestCorner = TextComponent.builder()
|
||||
.append("SW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southEastCorner = TextComponent.builder()
|
||||
.append("SE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_SOUTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(southWestCorner)
|
||||
.append(southEastCorner).build();
|
||||
Component northWestCorner = TextComponent.builder()
|
||||
.append("NW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northEastCorner = TextComponent.builder()
|
||||
.append("NE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_NORTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(northWestCorner)
|
||||
.append(northEastCorner).build();
|
||||
Component southCorners = null;
|
||||
Component northCorners = null;
|
||||
if (!claim.isWilderness() && player != null && PermissionUtil.getInstance().canPlayerTeleport(player, gdClaim)) {
|
||||
Component southWestCorner = TextComponent.builder()
|
||||
.append("SW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component southEastCorner = TextComponent.builder()
|
||||
.append("SE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(southEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, southEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("SE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
southCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_SOUTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(southWestCorner)
|
||||
.append(southEastCorner).build();
|
||||
Component northWestCorner = TextComponent.builder()
|
||||
.append("NW", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northWest).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northWest, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NW").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
Component northEastCorner = TextComponent.builder()
|
||||
.append("NE", TextColor.LIGHT_PURPLE)
|
||||
.append(" : ")
|
||||
.append(VecHelper.toVector3i(northEast).toString(), TextColor.GRAY)
|
||||
.append(" ")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(player, northEast, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMINFO_UI_TELEPORT_DIRECTION,
|
||||
ImmutableMap.of("direction", TextComponent.of("NE").color(TextColor.AQUA)))))
|
||||
.build();
|
||||
northCorners = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().CLAIMINFO_UI_NORTH_CORNERS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
.append(northWestCorner)
|
||||
.append(northEastCorner).build();
|
||||
}
|
||||
Component claimAccessors = TextComponent.builder()
|
||||
.append(MessageCache.getInstance().LABEL_ACCESSORS.color(TextColor.YELLOW))
|
||||
.append(" : ")
|
||||
@ -672,8 +677,10 @@ public void execute(CommandSource src, String[] args) {
|
||||
textList.add(dateCreated);
|
||||
textList.add(dateLastActive);
|
||||
textList.add(claimId);
|
||||
textList.add(northCorners);
|
||||
textList.add(southCorners);
|
||||
if (northCorners != null && southCorners != null) {
|
||||
textList.add(northCorners);
|
||||
textList.add(southCorners);
|
||||
}
|
||||
if (!claim.getParent().isPresent()) {
|
||||
textList.remove(claimInherit);
|
||||
}
|
||||
@ -686,8 +693,6 @@ public void execute(CommandSource src, String[] args) {
|
||||
textList.remove(claimInherit);
|
||||
textList.remove(claimTypeInfo);
|
||||
textList.remove(dateLastActive);
|
||||
textList.remove(northCorners);
|
||||
textList.remove(southCorners);
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
|
@ -33,12 +33,16 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
import com.griefdefender.configuration.GriefDefenderConfig;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@ -58,6 +62,16 @@ public void execute(Player player, String name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasPermission(GDPermissions.USE_RESERVED_CLAIM_NAMES)) {
|
||||
final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties());
|
||||
for (String str : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
if (FilenameUtils.wildcardMatch(name, str)) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_RESERVED_NAME);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Component text = LegacyComponentSerializer.legacy().deserialize(name, '&');
|
||||
if (text == TextComponent.empty()) {
|
||||
claim.getInternalClaimData().setName(null);
|
||||
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
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 com.google.common.collect.ImmutableMap;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.configuration.GriefDefenderConfig;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
import com.griefdefender.internal.pagination.PaginationList;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.text.action.GDCallbackHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_RESERVE)
|
||||
public class CommandClaimReserve extends BaseCommand {
|
||||
|
||||
@CommandAlias("claimreserve")
|
||||
@Syntax("[<name>]")
|
||||
@Description("Reserves a claim name for administrator use.")
|
||||
@Subcommand("claim reserve")
|
||||
public void execute(CommandSource src, @Optional String name) {
|
||||
GriefDefenderConfig<?> activeConfig = null;
|
||||
if (src instanceof Player) {
|
||||
final Player player = (Player) src;
|
||||
activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties());
|
||||
} else {
|
||||
activeConfig = GriefDefenderPlugin.getGlobalConfig();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
List<Component> nameList = new ArrayList<>();
|
||||
for (String reserved : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
nameList.add(TextComponent.builder("")
|
||||
.append(reserved, TextColor.GREEN)
|
||||
.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(activeConfig, name))))
|
||||
.build())
|
||||
.append("]", TextColor.WHITE)
|
||||
.build());
|
||||
}
|
||||
|
||||
final int fillSize = 20 - (nameList.size() + 2);
|
||||
for (int i = 0; i < fillSize; i++) {
|
||||
nameList.add(TextComponent.of(" "));
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
.title(TextComponent.of("Reserved Claim Names", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(nameList);
|
||||
paginationBuilder.sendTo(src);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String str : activeConfig.getConfig().claim.reservedClaimNames) {
|
||||
if (FilenameUtils.wildcardMatch(name, str)) {
|
||||
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESERVE_EXISTS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeConfig.getConfig().claim.reservedClaimNames.add(name);
|
||||
activeConfig.save();
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_RESERVE_ADD,
|
||||
ImmutableMap.of(
|
||||
"name", name));
|
||||
GriefDefenderPlugin.sendMessage(src, message);
|
||||
}
|
||||
|
||||
private Consumer<CommandSource> createRemoveConsumer(GriefDefenderConfig<?> activeConfig, String name) {
|
||||
return consumer -> {
|
||||
activeConfig.getConfig().claim.reservedClaimNames.remove(name);
|
||||
activeConfig.save();
|
||||
};
|
||||
}
|
||||
}
|
@ -113,6 +113,11 @@ public void execute(Player player, @Optional String[] args) throws CommandExcept
|
||||
.build());
|
||||
}
|
||||
|
||||
final int fillSize = 20 - (schematicTextList.size() + 2);
|
||||
for (int i = 0; i < fillSize; i++) {
|
||||
schematicTextList.add(TextComponent.of(" "));
|
||||
}
|
||||
|
||||
PaginationList.Builder paginationBuilder = PaginationList.builder()
|
||||
.title(TextComponent.of("Schematics", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(schematicTextList);
|
||||
paginationBuilder.sendTo(player);
|
||||
|
@ -636,35 +636,35 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claiminfo", claim.getUniqueId().toString(), createReturnClaimListConsumer(src, returnCommand)))))
|
||||
.hoverEvent(HoverEvent.showText(basicInfo)).build();
|
||||
|
||||
Component claimCoordsTPClick = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, VecHelper.toLocation(claim.getWorld(), southWest), claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", southWest.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
|
||||
Component claimSpawn = null;
|
||||
if (claim.getData().getSpawnPos().isPresent()) {
|
||||
Vector3i spawnPos = claim.getData().getSpawnPos().get();
|
||||
Location<World> spawnLoc = new Location<>(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, spawnLoc, claim, true))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
if (player !=null && PermissionUtil.getInstance().canPlayerTeleport(player, claim)) {
|
||||
final Vector3i spawnPos = claim.getData().getSpawnPos().orElse(null);
|
||||
if (spawnPos != null) {
|
||||
Location spawnLoc = new Location(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, spawnLoc, claim, true))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", "'s spawn @ " + spawnPos.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
} else {
|
||||
claimSpawn = TextComponent.builder("")
|
||||
.append("[")
|
||||
.append("TP", TextColor.LIGHT_PURPLE)
|
||||
.append("]")
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createTeleportConsumer(src, VecHelper.toLocation(claim.getWorld(), southWest), claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TELEPORT_TARGET,
|
||||
ImmutableMap.of(
|
||||
"name", teleportName,
|
||||
"target", "'s spawn @ " + spawnPos.toString(),
|
||||
"target", southWest.toString(),
|
||||
"world", claim.getWorld().getName()))))
|
||||
.build();
|
||||
} else {
|
||||
claimSpawn = claimCoordsTPClick;
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
List<Component> childrenTextList = new ArrayList<>();
|
||||
@ -691,8 +691,7 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(showChildrenList(childrenTextList, src, returnCommand, claim))))
|
||||
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().CLAIMLIST_UI_CLICK_VIEW_CHILDREN)).build();
|
||||
claimsTextList.add(TextComponent.builder("")
|
||||
.append(claimSpawn)
|
||||
.append(" ")
|
||||
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
|
||||
.append(claimInfoCommandClick)
|
||||
.append(" : ", TextColor.WHITE)
|
||||
.append(claim.getOwnerName().color(TextColor.GOLD))
|
||||
@ -705,8 +704,7 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
|
||||
.build());
|
||||
} else {
|
||||
claimsTextList.add(TextComponent.builder("")
|
||||
.append(claimSpawn)
|
||||
.append(" ")
|
||||
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
|
||||
.append(claimInfoCommandClick)
|
||||
.append(" : ", TextColor.WHITE)
|
||||
.append(claim.getOwnerName().color(TextColor.GOLD))
|
||||
@ -999,34 +997,9 @@ public static Consumer<CommandSource> createTeleportConsumer(CommandSource src,
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
Player player = (Player) src;
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
if (!playerData.canIgnoreClaim(gdClaim) && !playerData.canManageAdminClaims) {
|
||||
// if not owner of claim, validate perms
|
||||
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
if (!gdClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
|
||||
if (GriefDefenderPlugin.getInstance().economyService.isPresent()) {
|
||||
// Allow non-trusted to TP to claims for sale
|
||||
if (!gdClaim.getEconomyData().isForSale()) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
|
||||
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = (Player) src;
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
final int teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
|
||||
if (isClaimSpawn) {
|
||||
if (teleportDelay > 0) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
|
||||
@ -37,6 +38,8 @@
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -53,16 +56,29 @@
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.service.permission.Subject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_UNTRUST_GROUP)
|
||||
public class CommandUntrustGroup extends BaseCommand {
|
||||
|
||||
@CommandCompletion("@gdgroups @gddummy")
|
||||
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrustgroup")
|
||||
@Description("Revokes group access to your claim.")
|
||||
@Syntax("<group>")
|
||||
@Syntax("<group> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrust group")
|
||||
public void execute(Player player, String target) {
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
if (group == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_GROUP, ImmutableMap.of(
|
||||
@ -94,22 +110,45 @@ public void execute(Player player, String target) {
|
||||
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDGroupTrustClaimEvent.Remove event =
|
||||
new GDGroupTrustClaimEvent.Remove(claim, ImmutableList.of(group.getName()), TrustTypes.NONE);
|
||||
new GDGroupTrustClaimEvent.Remove(claim, ImmutableList.of(group.getName()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
TextAdapter.sendComponent(player, event.getMessage().orElse(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.TRUST_PLUGIN_CANCEL,
|
||||
ImmutableMap.of("target", group))));
|
||||
ImmutableMap.of("target", group.getName()))));
|
||||
return;
|
||||
}
|
||||
|
||||
claim.removeAllTrustsFromGroup(group.getName());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllGroupTrust(claim, group);
|
||||
} else {
|
||||
this.removeGroupTrust(claim, group, trustType);
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_SINGLE_CLAIM,
|
||||
ImmutableMap.of(
|
||||
"target", group));
|
||||
"target", group.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeGroupTrust(GDClaim claim, GDPermissionGroup group, TrustType type) {
|
||||
final List<String> trustList = claim.getGroupTrustList(type);
|
||||
if (trustList.remove(group.getName())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeGroupTrust((GDClaim) child, group, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllGroupTrust(Claim claim, GDPermissionGroup holder) {
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
gdClaim.removeAllTrustsFromGroup(holder.getName());
|
||||
gdClaim.getInternalClaimData().setRequiresSave(true);
|
||||
gdClaim.getInternalClaimData().save();
|
||||
for (Claim child : gdClaim.children) {
|
||||
this.removeAllGroupTrust(child, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -37,6 +38,7 @@
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -52,6 +54,7 @@
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@ -61,11 +64,21 @@ public class CommandUntrustGroupAll extends BaseCommand {
|
||||
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrustallgroup")
|
||||
@Description("Revokes group access to all your claims")
|
||||
@Syntax("<group>")
|
||||
@Syntax("<group> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrustall group")
|
||||
public void execute(Player player, String target, String type) {
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final GDPermissionGroup group = PermissionHolderCache.getInstance().getOrCreateGroup(target);
|
||||
// validate player argument
|
||||
if (group == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_GROUP,
|
||||
@ -87,17 +100,22 @@ public void execute(Player player, String target, String type) {
|
||||
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDGroupTrustClaimEvent.Remove
|
||||
event = new GDGroupTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(group.getName()), TrustTypes.NONE);
|
||||
event = new GDGroupTrustClaimEvent.Remove(new ArrayList<>(claimList), ImmutableList.of(group.getName()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
TextAdapter.sendComponent(player, event.getMessage().orElse(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.TRUST_PLUGIN_CANCEL,
|
||||
ImmutableMap.of("target", group))));
|
||||
ImmutableMap.of("target", group.getName()))));
|
||||
return;
|
||||
}
|
||||
|
||||
for (Claim claim : claimList) {
|
||||
this.removeAllGroupTrust(claim, group);
|
||||
final GDClaim gdClaim = (GDClaim) claim;
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllGroupTrust(gdClaim, group);
|
||||
} else {
|
||||
this.removeGroupTrust(gdClaim, group, trustType);
|
||||
}
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_ALL_CLAIMS,
|
||||
@ -106,6 +124,17 @@ public void execute(Player player, String target, String type) {
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeGroupTrust(GDClaim claim, GDPermissionGroup group, TrustType type) {
|
||||
final List<String> trustList = claim.getGroupTrustList(type);
|
||||
if (trustList.remove(group.getName())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeGroupTrust((GDClaim) child, group, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllGroupTrust(Claim claim, GDPermissionGroup holder) {
|
||||
GDClaim gdClaim = (GDClaim) claim;
|
||||
gdClaim.removeAllTrustsFromGroup(holder.getName());
|
||||
|
@ -29,6 +29,7 @@
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -36,6 +37,8 @@
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
@ -50,16 +53,30 @@
|
||||
import net.kyori.text.adapter.spongeapi.TextAdapter;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_UNTRUST_PLAYER)
|
||||
public class CommandUntrustPlayer extends BaseCommand {
|
||||
|
||||
@CommandCompletion("@gdplayers @gddummy")
|
||||
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
|
||||
@CommandAlias("untrust|ut")
|
||||
@Description("Revokes player access to your claim.")
|
||||
@Syntax("<player>")
|
||||
@Syntax("<player> [<accessor|builder|container|manager>]")
|
||||
@Subcommand("untrust player")
|
||||
public void execute(Player player, String target) {
|
||||
public void execute(Player player, String target, @Optional String type) {
|
||||
TrustType trustType = null;
|
||||
if (type == null) {
|
||||
trustType = TrustTypes.NONE;
|
||||
} else {
|
||||
trustType = CommandHelper.getTrustType(type);
|
||||
if (trustType == null) {
|
||||
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_INVALID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GDPermissionUser user;
|
||||
if (target.equalsIgnoreCase("public")) {
|
||||
user = GriefDefenderPlugin.PUBLIC_USER;
|
||||
@ -100,7 +117,7 @@ public void execute(Player player, String target) {
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
GDUserTrustClaimEvent.Remove
|
||||
event =
|
||||
new GDUserTrustClaimEvent.Remove(claim, ImmutableList.of(user.getUniqueId()), TrustTypes.NONE);
|
||||
new GDUserTrustClaimEvent.Remove(claim, ImmutableList.of(user.getUniqueId()), trustType);
|
||||
GriefDefender.getEventManager().post(event);
|
||||
GDCauseStackManager.getInstance().popCause();
|
||||
if (event.cancelled()) {
|
||||
@ -109,13 +126,36 @@ public void execute(Player player, String target) {
|
||||
return;
|
||||
}
|
||||
|
||||
claim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
final GDClaim gdClaim = (GDClaim) claim;
|
||||
if (trustType == TrustTypes.NONE) {
|
||||
this.removeAllUserTrust(gdClaim, user);
|
||||
} else {
|
||||
this.removeUserTrust(gdClaim, user, trustType);
|
||||
}
|
||||
|
||||
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UNTRUST_INDIVIDUAL_SINGLE_CLAIM,
|
||||
ImmutableMap.of(
|
||||
"target", user.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
|
||||
private void removeUserTrust(GDClaim claim, GDPermissionUser user, TrustType type) {
|
||||
final List<UUID> trustList = claim.getUserTrustList(type);
|
||||
if (trustList.remove(user.getUniqueId())) {
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
}
|
||||
for (Claim child : claim.children) {
|
||||
this.removeUserTrust((GDClaim) child, user, type);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAllUserTrust(GDClaim claim, GDPermissionUser user) {
|
||||
claim.removeAllTrustsFromUser(user.getUniqueId());
|
||||
claim.getInternalClaimData().setRequiresSave(true);
|
||||
claim.getInternalClaimData().save();
|
||||
for (Claim child : claim.children) {
|
||||
this.removeAllUserTrust((GDClaim) child, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ public class MessageStorage {
|
||||
public static final String CLAIM_NAME = "claim-name";
|
||||
public static final String CLAIM_OWNER_ONLY = "claim-owner-only";
|
||||
public static final String CLAIM_PROTECTED_ENTITY = "claim-protected-entity";
|
||||
public static final String CLAIM_RESERVE_ADD = "claim-reserve-add";
|
||||
public static final String CLAIM_SHOW_NEARBY = "claim-show-nearby";
|
||||
public static final String CLAIM_SIZE_MIN = "claim-size-min";
|
||||
public static final String CLAIM_SIZE_MAX = "claim-size-max";
|
||||
|
@ -24,6 +24,9 @@
|
||||
*/
|
||||
package com.griefdefender.configuration.category;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ -55,6 +58,12 @@ public class ClaimCategory extends ConfigCategory {
|
||||
@Setting(value = "claims-enabled",
|
||||
comment = "Whether claiming is enabled or not. (0 = Disabled, 1 = Enabled)")
|
||||
public int claimsEnabled = 1;
|
||||
@Setting(value = "reserved-claim-names", comment = "A list of reserved claim names for use only by administrators."
|
||||
+ "\nNote: Names support wildcards '?' and '*' by using Apache's wildcard matcher."
|
||||
+ "\nThe wildcard '?' represents a single character."
|
||||
+ "\nThe wildcard '*' represents zero or more characters."
|
||||
+ "\nFor more information on usage, see https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/FilenameUtils.html#wildcardMatch(java.lang.String,%20java.lang.String)")
|
||||
public List<String> reservedClaimNames = new ArrayList<>();
|
||||
@Setting(value = "bank-tax-system", comment = "Whether to enable the bank/tax system for claims. Set to true to enable.")
|
||||
public boolean bankTaxSystem = false;
|
||||
@Setting(value = "tax-apply-hour", comment = "The specific hour in day to apply tax to all claims.")
|
||||
|
@ -33,5 +33,6 @@ public class ContextGroupKeys {
|
||||
public static final String FOOD = "#food";
|
||||
public static final String MISC = "#misc";
|
||||
public static final String MONSTER = "#monster";
|
||||
public static final String PET = "#pet";
|
||||
public static final String VEHICLE = "#vehicle";
|
||||
}
|
||||
|
@ -37,7 +37,6 @@
|
||||
import com.griefdefender.api.claim.ClaimContexts;
|
||||
import com.griefdefender.api.claim.ClaimType;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.ContextKeys;
|
||||
import com.griefdefender.api.permission.PermissionManager;
|
||||
@ -122,6 +121,7 @@
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -649,7 +649,7 @@ public Set<Context> getPermissionContexts(GDClaim claim, Object obj, boolean isS
|
||||
}
|
||||
|
||||
if (type != null && !(targetEntity instanceof Player)) {
|
||||
addCustomEntityTypeContexts(targetEntity, contexts, type, modId, isSource);
|
||||
addCustomEntityTypeContexts(targetEntity, contexts, type, modId, id, isSource);
|
||||
}
|
||||
|
||||
if (this.isObjectIdBanned(claim, id, BanType.ENTITY)) {
|
||||
@ -828,7 +828,7 @@ public boolean isObjectIdBanned(GDClaim claim, String id, BanType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contexts, GDEntityType type, String modId, boolean isSource) {
|
||||
public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contexts, GDEntityType type, String modId, String id, boolean isSource) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_ALL);
|
||||
if (modId != null && !modId.isEmpty()) {
|
||||
@ -877,7 +877,6 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
}
|
||||
}
|
||||
|
||||
final String contextKey = isSource ? "source" : "target";
|
||||
//contexts.add(new Context(contextKey, "#" + creatureType));
|
||||
if (creatureType.contains("animal")) {
|
||||
if (isSource) {
|
||||
@ -891,6 +890,7 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
contexts.add(new Context(ContextKeys.TARGET, modId + ":" + ContextGroupKeys.ANIMAL));
|
||||
}
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else if (creatureType.contains("aquatic")) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_AQUATIC);
|
||||
@ -903,6 +903,7 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
contexts.add(new Context(ContextKeys.TARGET, modId + ":" + ContextGroupKeys.AQUATIC));
|
||||
}
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else if (creatureType.contains("monster")) {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_MONSTER);
|
||||
@ -927,6 +928,7 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
contexts.add(new Context(ContextKeys.TARGET, modId + ":" + ContextGroupKeys.AMBIENT));
|
||||
}
|
||||
}
|
||||
this.checkPetContext(targetEntity, id, contexts);
|
||||
} else {
|
||||
if (isSource) {
|
||||
contexts.add(ContextGroups.SOURCE_MISC);
|
||||
@ -942,6 +944,16 @@ public void addCustomEntityTypeContexts(Entity targetEntity, Set<Context> contex
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPetContext(Entity targetEntity, String id, Set<Context> contexts) {
|
||||
if (this.eventSubject != null && this.eventSubject instanceof GDPermissionUser) {
|
||||
final GDPermissionUser user = (GDPermissionUser) this.eventSubject;
|
||||
final UUID uuid = targetEntity.getCreator().orElse(null);
|
||||
if (uuid != null && uuid.equals(user.getUniqueId())) {
|
||||
contexts.add(new Context(ContextGroupKeys.PET, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayerContexts(Player player, Set<Context> contexts) {
|
||||
if(!PermissionUtil.getInstance().containsKey(contexts, "used_item") && NMSUtil.getInstance().getActiveItem(player, this.currentEvent) != null) {
|
||||
final ItemStack stack = NMSUtil.getInstance().getActiveItem(player, this.currentEvent);
|
||||
|
@ -136,6 +136,7 @@ public class GDPermissions {
|
||||
public static final String COMMAND_CLAIM_CLEAR = "griefdefender.admin.claim.command.clear";
|
||||
public static final String COMMAND_CLAIM_PERMISSION_GROUP = "griefdefender.admin.claim.command.permission-group";
|
||||
public static final String COMMAND_CLAIM_PERMISSION_PLAYER = "griefdefender.admin.claim.command.permission-player";
|
||||
public static final String COMMAND_CLAIM_RESERVE = "griefdefender.user.claim.command.reserve-name";
|
||||
public static final String COMMAND_CLAIM_SCHEMATIC = "griefdefender.admin.claim.command.schematic";
|
||||
public static final String COMMAND_IGNORE_CLAIMS = "griefdefender.admin.claim.command.ignore.base";
|
||||
public static final String COMMAND_DELETE_CLAIM_BASE = "griefdefender.admin.claim.command.delete.base";
|
||||
@ -162,6 +163,7 @@ public class GDPermissions {
|
||||
public static final String MANAGE_GLOBAL_OPTIONS = "griefdefender.admin.claim.option.global";
|
||||
public static final String MANAGE_OVERRIDE_OPTIONS = "griefdefender.admin.claim.option.override";
|
||||
public static final String SET_ADMIN_FLAGS = "griefdefender.admin.claim.set-admin-flags";
|
||||
public static final String USE_RESERVED_CLAIM_NAMES = "griefdefender.admin.claim.use-reserved-names";
|
||||
|
||||
// Misc
|
||||
public static final String COMMAND_HELP = "griefdefender.user.command.help";
|
||||
|
@ -28,13 +28,14 @@
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.Tristate;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
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 java.util.List;
|
||||
@ -43,6 +44,8 @@
|
||||
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;
|
||||
@ -264,4 +267,30 @@ public Tristate getTristateFromString(String value) {
|
||||
|
||||
return tristate;
|
||||
}
|
||||
|
||||
public boolean canPlayerTeleport(Player player, GDClaim claim) {
|
||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
|
||||
if (!playerData.canIgnoreClaim(claim) && !playerData.canManageAdminClaims) {
|
||||
// if not owner of claim, validate perms
|
||||
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
|
||||
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
|
||||
return false;
|
||||
}
|
||||
if (!claim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
|
||||
if (GriefDefenderPlugin.getInstance().economyService.orElse(null) != null) {
|
||||
// Allow non-trusted to TP to claims for sale
|
||||
if (!claim.getEconomyData().isForSale()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ GriefDefender {
|
||||
claim-owner-already="&cYou are already the claim owner."
|
||||
claim-owner-only="&cOnly &6{player}&c can modify this claim."
|
||||
claim-protected-entity="&cThat belongs to &6{player}&c."
|
||||
claim-reserve-add="&aThe claim name &6{name}&a has been added to the reserved list."
|
||||
claim-reserve-exists="&aThe claim name you specified is already reserved."
|
||||
claim-reserved-name="&cThe claim name you specified is reserved. Please choose another or ensure you have the appropriate permission."
|
||||
claim-respecting="&aNow respecting claims."
|
||||
claim-restore-success="&aSuccessfully restored claim."
|
||||
claim-show-nearby="&aFound &6{amount}&a nearby claims."
|
||||
@ -644,6 +647,7 @@ GriefDefender {
|
||||
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."
|
||||
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."
|
||||
|
Loading…
Reference in New Issue
Block a user