Update for 1.5.5 release.

* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
  - Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
  Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.

Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
This commit is contained in:
bloodshot 2020-12-28 17:28:12 -05:00
parent a9cf25ef2a
commit 671d63a09b
242 changed files with 2608 additions and 873 deletions

@ -1 +1 @@
Subproject commit 920a6101dc1a616c431321fffa31516b951b2fa8
Subproject commit dd5aa2224cd1c8bb31b20a9938e3388ff894b095

View File

@ -46,6 +46,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.User;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ShovelType;
@ -246,6 +248,11 @@ public void refreshPlayerOptions() {
});
}
@Override
public User getUser() {
return this.getSubject();
}
@Override
public String getName() {
if (this.playerName == null) {
@ -359,7 +366,7 @@ private void revertVisualBlocks(Player player, GDClaim claim, UUID visualUniqueI
for (int i = 0; i < visualTransactions.size(); i++) {
BlockSnapshot snapshot = visualTransactions.get(i).getOriginal();
// If original block does not exist or chunk is not loaded, do not send to player
if (!snapshot.getLocation().getChunk().isLoaded() || !snapshot.matchesWorldState()) {
if (!snapshot.matchesWorldState()) {
if (claim != null) {
claim.markVisualDirty = true;
}
@ -764,6 +771,25 @@ public double getTotalTax() {
return totalTax;
}
@Override
public boolean canPvp(Claim claim) {
if (!((GDClaim) claim).getWorld().getPVP()) {
return false;
}
if (!claim.isPvpAllowed()) {
return false;
}
if (GDOptions.PVP) {
final Tristate result = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), this.getSubject(), Options.PVP, claim);
if (result != Tristate.UNDEFINED) {
return result.asBoolean();
}
}
return true;
}
@Override
public boolean inPvpCombat() {
final Player player = this.getSubject().getOnlinePlayer();
if (this.lastPvpTimestamp == null || player == null) {
@ -784,8 +810,9 @@ public boolean inPvpCombat() {
return true;
}
public int getPvpCombatTimeRemaining() {
return this.getPvpCombatTimeRemaining(null);
@Override
public int getRemainingPvpCombatTime(Claim claim) {
return this.getPvpCombatTimeRemaining((GDClaim) claim);
}
public int getPvpCombatTimeRemaining(GDClaim claim) {

View File

@ -635,7 +635,7 @@ public void onEnable(boolean reload) {
Bukkit.getPluginManager().registerEvents(new PlayerEventHandler(dataStore), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new EntityEventHandler(dataStore), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new WorldEventHandler(), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new NMSUtil(), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(NMSUtil.getInstance(), GDBootstrap.getInstance());
// run cleanup task
int cleanupTaskInterval = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.expirationCleanupInterval;
@ -691,7 +691,7 @@ public void onEnable(boolean reload) {
}
new PlayerTickTask();
if (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.isRentSignEnabled()) {
this.runningTasks.add(new SignUpdateTask(100));
this.runningTasks.add(new SignUpdateTask(GriefDefenderPlugin.getGlobalConfig().getConfig().economy.signUpdateInterval));
}
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) {
this.runningTasks.add(new RentDelinquentApplyTask());
@ -744,7 +744,91 @@ private void cleanup() {
public void registerBaseCommands() {
PaperCommandManager manager = new PaperCommandManager(GDBootstrap.getInstance());
this.commandManager = manager;
manager.getCommandReplacements().addReplacement("griefdefender", "gd|griefdefender");
manager.getCommandReplacements().addReplacements(
"griefdefender", "gd|griefdefender",
"abandon-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_ABANDON_ALL),
"abandon-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_ABANDON_CLAIM),
"abandon-top", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_ABANDON_TOP),
"abandon-world", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_ABANDON_WORLD),
"buy-blocks", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_BUY_BLOCKS),
"buy-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_BUY_CLAIM),
"callback", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CALLBACK),
"claim-ban", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_BAN),
"claim-bank", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_BANK),
"claim-clear", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_CLEAR),
"claim-contract", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_CONTRACT),
"claim-create", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_CREATE),
"claim-debug", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_DEBUG),
"claim-expand", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_EXPAND),
"claim-farewell", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_FAREWELL),
"claim-greeting", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_GREETING),
"claim-ignore", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_IGNORE),
"claim-info", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_INFO),
"claim-inherit", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_INHERIT),
"claim-investigate", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_INVESTIGATE),
"claim-list", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_LIST),
"claim-name", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_NAME),
"claim-rent", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_RENT),
"claim-reserve", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_RESERVE),
"claim-restore", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_RESTORE),
"claim-setspawn", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_SETSPAWN),
"claim-spawn", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_SPAWN),
"claim-tax", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_TAX),
"claim-tool", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_TOOL),
"claim-transfer", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_TRANSFER),
"claim-unban", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_UNBAN),
"claim-worldedit", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CLAIM_WORLDEDIT),
"confirm", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CONFIRM),
"cuboid", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_CUBOID),
"debug", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_DEBUG),
"delete-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_DELETE_ALL),
"delete-all-admin", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_DELETE_ALL_ADMIN),
"delete-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_DELETE_CLAIM),
"delete-top", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_DELETE_TOP),
"economy-block-transfer", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_ECONOMY_BLOCK_TRANSFER),
"flag-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_FLAG_CLAIM),
"flag-group", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_FLAG_GROUP),
"flag-player", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_FLAG_PLAYER),
"flag-reset", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_FLAG_RESET),
"help", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_HELP),
"mode-admin", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_ADMIN),
"mode-basic", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_BASIC),
"mode-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_CLAIM),
"mode-nature", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_NATURE),
"mode-subdivision", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_SUBDIVISION),
"mode-town", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_MODE_TOWN),
"option-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_OPTION_CLAIM),
"option-group", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_OPTION_GROUP),
"option-player", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_OPTION_PLAYER),
"permission-group", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PERMISSION_GROUP),
"permission-player", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PERMISSION_PLAYER),
"player-adjust-bonus-blocks", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_ADJUST_BONUS_BLOCKS),
"player-adjust-bonus-blocks-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_ADJUST_BONUS_BLOCKS_ALL),
"player-give-blocks", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_GIVE_BLOCKS),
"player-give-pet", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_GIVE_PET),
"player-info", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_INFO),
"player-set-accrued-blocks", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_SET_ACCRUED_BLOCKS),
"player-unlock-drops", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_PLAYER_UNLOCK_DROPS),
"reload", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_RELOAD),
"schematic", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_SCHEMATIC),
"sell-blocks", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_SELL_BLOCKS),
"sell-claim", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_SELL_CLAIM),
"town-chat", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TOWN_CHAT),
"town-tag", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TOWN_TAG),
"trapped", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRAPPED),
"trust-access", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_ACCESS),
"trust-container", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_CONTAINER),
"trust-group", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_GROUP),
"trust-group-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_GROUP_ALL),
"trust-list", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_LIST),
"trust-player", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_PLAYER),
"trust-player-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_TRUST_PLAYER_ALL),
"untrust-group", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_UNTRUST_GROUP),
"untrust-group-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_UNTRUST_GROUP_ALL),
"untrust-player", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_UNTRUST_PLAYER),
"untrust-player-all", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_UNTRUST_PLAYER_ALL),
"version", this.getCommandDescriptionTranslation(MessageStorage.DESCRIPTION_VERSION)
);
manager.registerCommand(new CommandAccessTrust());
manager.registerCommand(new CommandAdjustBonusClaimBlocks());
manager.registerCommand(new CommandAdjustBonusClaimBlocksAll());
@ -1019,6 +1103,10 @@ public void registerBaseCommands() {
});
}
private String getCommandDescriptionTranslation(String message) {
return PlainComponentSerializer.INSTANCE.serialize(messageData.getDescription(message));
}
public PaperCommandManager getCommandManager() {
return this.commandManager;
}

View File

@ -324,7 +324,6 @@ public static MessageCache getInstance() {
public Component LABEL_DEFAULT;
public Component LABEL_DISPLAYING;
public Component LABEL_EXPIRED;
public Component LABEL_FALSE;
public Component LABEL_FAREWELL;
public Component LABEL_FILTER;
public Component LABEL_FLAG;
@ -360,7 +359,6 @@ public static MessageCache getInstance() {
public Component LABEL_SPAWN;
public Component LABEL_STATUS;
public Component LABEL_TARGET;
public Component LABEL_TRUE;
public Component LABEL_TRUST;
public Component LABEL_TYPE;
public Component LABEL_UNKNOWN;
@ -424,6 +422,7 @@ public static MessageCache getInstance() {
public Component PERMISSION_COMMAND_TRUST;
public Component PERMISSION_CUBOID;
public Component PERMISSION_EDIT_CLAIM;
public Component PERMISSION_FALSE;
public Component PERMISSION_FIRE_SPREAD;
public Component PERMISSION_FLAG_DEFAULTS;
public Component PERMISSION_FLAG_OVERRIDES;
@ -442,6 +441,8 @@ public static MessageCache getInstance() {
public Component PERMISSION_PLAYER_OPTION;
public Component PERMISSION_PLAYER_VIEW_OTHERS;
public Component PERMISSION_TAX;
public Component PERMISSION_TRUE;
public Component PERMISSION_UNDEFINED;
public Component PERMISSION_VISUAL_CLAIMS_NEARBY;
public Component PLAYER_ITEM_DROPS_LOCK;
public Component PLUGIN_EVENT_CANCEL;
@ -796,7 +797,6 @@ public void loadCache() {
LABEL_DEFAULT = MessageStorage.MESSAGE_DATA.getMessage("label-default");
LABEL_DISPLAYING = MessageStorage.MESSAGE_DATA.getMessage("label-displaying");
LABEL_EXPIRED = MessageStorage.MESSAGE_DATA.getMessage("label-expired");
LABEL_FALSE = MessageStorage.MESSAGE_DATA.getMessage("label-false");
LABEL_FAREWELL = MessageStorage.MESSAGE_DATA.getMessage("label-farewell");
LABEL_FILTER = MessageStorage.MESSAGE_DATA.getMessage("label-filter");
LABEL_FLAG = MessageStorage.MESSAGE_DATA.getMessage("label-flag");
@ -832,7 +832,6 @@ public void loadCache() {
LABEL_SPAWN = MessageStorage.MESSAGE_DATA.getMessage("label-spawn");
LABEL_STATUS = MessageStorage.MESSAGE_DATA.getMessage("label-status");
LABEL_TARGET = MessageStorage.MESSAGE_DATA.getMessage("label-target");
LABEL_TRUE = MessageStorage.MESSAGE_DATA.getMessage("label-true");
LABEL_TRUST = MessageStorage.MESSAGE_DATA.getMessage("label-trust");
LABEL_TYPE = MessageStorage.MESSAGE_DATA.getMessage("label-type");
LABEL_UNKNOWN = MessageStorage.MESSAGE_DATA.getMessage("label-unknown");
@ -896,6 +895,7 @@ public void loadCache() {
PERMISSION_COMMAND_TRUST = MessageStorage.MESSAGE_DATA.getMessage("permission-command-trust");
PERMISSION_CUBOID = MessageStorage.MESSAGE_DATA.getMessage("permission-cuboid");
PERMISSION_EDIT_CLAIM = MessageStorage.MESSAGE_DATA.getMessage("permission-edit-claim");
PERMISSION_FALSE = MessageStorage.MESSAGE_DATA.getMessage("permission-false");
PERMISSION_FIRE_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("permission-fire-spread");
PERMISSION_FLAG_DEFAULTS = MessageStorage.MESSAGE_DATA.getMessage("permission-flag-defaults");
PERMISSION_FLAG_OVERRIDES = MessageStorage.MESSAGE_DATA.getMessage("permission-flag-overrides");
@ -914,6 +914,8 @@ public void loadCache() {
PERMISSION_PLAYER_OPTION = MessageStorage.MESSAGE_DATA.getMessage("permission-player-option");
PERMISSION_PLAYER_VIEW_OTHERS = MessageStorage.MESSAGE_DATA.getMessage("permission-player-view-others");
PERMISSION_TAX = MessageStorage.MESSAGE_DATA.getMessage("permission-tax");
PERMISSION_TRUE = MessageStorage.MESSAGE_DATA.getMessage("permission-true");
PERMISSION_UNDEFINED = MessageStorage.MESSAGE_DATA.getMessage("permission-undefined");
PERMISSION_VISUAL_CLAIMS_NEARBY = MessageStorage.MESSAGE_DATA.getMessage("permission-visual-claims-nearby");
PLAYER_ITEM_DROPS_LOCK = MessageStorage.MESSAGE_DATA.getMessage("player-item-drops-lock");
PLUGIN_EVENT_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("plugin-event-cancel");

View File

@ -53,6 +53,8 @@
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.data.ClaimData;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
@ -2630,6 +2632,15 @@ public Optional<UUID> getEconomyAccountId() {
return Optional.empty();
}
@Override
public boolean isPvpAllowed() {
final Set<Context> contexts = new HashSet<>();
contexts.add(new Context(ContextKeys.SOURCE, "minecraft:player"));
contexts.add(new Context(ContextKeys.TARGET, "minecraft:player"));
final Tristate result = GDPermissionManager.getInstance().getActiveFlagPermissionValue(this, GriefDefenderPlugin.DEFAULT_HOLDER, Flags.ENTITY_DAMAGE, contexts);
return result == Tristate.TRUE;
}
public static class ClaimBuilder implements Builder {
private UUID ownerUniqueId;

View File

@ -120,7 +120,6 @@ protected ClaimFlagBase(ClaimSubjectType type) {
public void execute(Player player, String[] args) throws InvalidCommandArgument {
final GDPermissionUser src = PermissionHolderCache.getInstance().getOrCreateUser(player);
final GDPermissionHolder commandSubject = subject;
final GDPlayerData playerData = src.getInternalPlayerData();
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
String commandFlag = null;
@ -401,74 +400,24 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
.append(overrideFlagText).build();
}
Set<Context> defaultContexts = new HashSet<>();
Set<Context> overrideContexts = new HashSet<>();
if (claim.isAdminClaim()) {
defaultContexts.add(ClaimContexts.ADMIN_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.ADMIN_OVERRIDE_CONTEXT);
} else if (claim.isBasicClaim() || claim.isSubdivision()) {
defaultContexts.add(ClaimContexts.BASIC_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.BASIC_OVERRIDE_CONTEXT);
} else if (claim.isTown()) {
defaultContexts.add(ClaimContexts.TOWN_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.TOWN_OVERRIDE_CONTEXT);
} else {
defaultContexts.add(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT);
}
if (!claim.isWilderness()) {
defaultContexts.add(ClaimContexts.USER_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.USER_OVERRIDE_CONTEXT);
}
defaultContexts.add(claim.getWorldContext());
defaultContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
overrideContexts.add(claim.getWorldContext());
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
overrideContexts.add(claim.getOverrideClaimContext());
Map<String, UIFlagData> filteredContextMap = new HashMap<>();
Map<String, UIFlagData> flagDataMap = new HashMap<>();
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getTransientPermissions(GriefDefenderPlugin.GD_DEFAULT_HOLDER).entrySet()) {
final Set<Context> contextSet = mapEntry.getKey();
if (contextSet.contains(claim.getDefaultTypeContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
this.addFilteredContexts(GriefDefenderPlugin.GD_DEFAULT_HOLDER, flagDataMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
} else if (contextSet.contains(ClaimContexts.GLOBAL_DEFAULT_CONTEXT) || (!claim.isWilderness() && contextSet.contains(ClaimContexts.USER_DEFAULT_CONTEXT))) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
this.addFilteredContexts(GriefDefenderPlugin.GD_DEFAULT_HOLDER, flagDataMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
}
}
final List<Claim> inheritParents = claim.getInheritedParents();
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getAllPermanentPermissions().entrySet()) {
final Set<Context> contextSet = mapEntry.getKey();
if (contextSet.contains(claim.getDefaultTypeContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
} else if (contextSet.contains(ClaimContexts.GLOBAL_DEFAULT_CONTEXT) || (!claim.isWilderness() && contextSet.contains(ClaimContexts.USER_DEFAULT_CONTEXT))) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.DEFAULT, mapEntry.getValue());
}
if (displayType != MenuType.DEFAULT) {
if (contextSet.contains(claim.getContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.CLAIM, mapEntry.getValue());
}
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
// check parent context
if (contextSet.contains(parent.getContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.INHERIT, mapEntry.getValue());
}
}
if (contextSet.contains(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT) || (!claim.isWilderness() && contextSet.contains(ClaimContexts.USER_OVERRIDE_CONTEXT))) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.OVERRIDE, mapEntry.getValue());
}
if (contextSet.contains(claim.getOverrideClaimContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.OVERRIDE, mapEntry.getValue());
} else if (contextSet.contains(claim.getOverrideTypeContext())) {
this.addFilteredContexts(filteredContextMap, contextSet, MenuType.OVERRIDE, mapEntry.getValue());
}
}
}
this.generateFilteredContexts(claim, GriefDefenderPlugin.GD_DEFAULT_HOLDER, flagDataMap, displayType, inheritParents);
this.generateFilteredContexts(claim, GriefDefenderPlugin.GD_CLAIM_HOLDER, flagDataMap, displayType, inheritParents);
this.generateFilteredContexts(claim, GriefDefenderPlugin.GD_DEFINITION_HOLDER, flagDataMap, displayType, inheritParents);
this.generateFilteredContexts(claim, GriefDefenderPlugin.GD_OVERRIDE_HOLDER, flagDataMap, displayType, inheritParents);
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
final UIFlagData flagData = mapEntry.getValue();
for (UIFlagData flagData : flagDataMap.values()) {
final Flag flag = flagData.flag;
if (!GDFlags.isFlagEnabled(flag)) {
continue;
@ -482,7 +431,7 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
Component flagText = TextComponent.builder()
.append(getFlagText(flag, contexts))
.append(" ")
.append(this.getClickableText(src, claim, flag, flagHolder, contexts, displayType))
.append(this.getClickableText(src, flagData.holder, claim, flag, flagHolder, contexts, displayType))
.build();
final int hashCode = Objects.hash(flag.getPermission(), contexts);
Map<Integer, Component> componentMap = textMap.get(flag.getPermission());
@ -547,17 +496,69 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
paginationList.sendTo(player, activePage);
}
private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
private void generateFilteredContexts(GDClaim claim, GDPermissionHolder holder, Map<String, UIFlagData> flagDataMap, MenuType displayType, List<Claim> inheritParents) {
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getPermanentPermissions(holder).entrySet()) {
final Set<Context> contextSet = mapEntry.getKey();
final Map<String, Boolean> flagPermissions = mapEntry.getValue();
if (displayType == MenuType.DEFAULT && (holder == GriefDefenderPlugin.GD_DEFAULT_HOLDER || holder == GriefDefenderPlugin.GD_DEFINITION_HOLDER)) {
if (contextSet.contains(claim.getDefaultTypeContext())) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.DEFAULT, flagPermissions);
} else if (contextSet.contains(ClaimContexts.GLOBAL_DEFAULT_CONTEXT) || (!claim.isWilderness() && contextSet.contains(ClaimContexts.USER_DEFAULT_CONTEXT))) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.DEFAULT, flagPermissions);
}
}
if (displayType == MenuType.CLAIM && holder != GriefDefenderPlugin.GD_OVERRIDE_HOLDER) {
boolean inheritPermission = false;
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
// check parent context
if (contextSet.contains(parent.getContext())) {
inheritPermission = true;
break;
}
}
if (inheritPermission) {
continue;
}
if (contextSet.contains(claim.getContext())) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.CLAIM, flagPermissions);
}
}
if (displayType == MenuType.INHERIT && holder != GriefDefenderPlugin.GD_OVERRIDE_HOLDER) {
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
// check parent context
if (contextSet.contains(parent.getContext())) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.INHERIT, flagPermissions);
}
}
}
if (displayType == MenuType.OVERRIDE && holder != GriefDefenderPlugin.GD_CLAIM_HOLDER) {
if (contextSet.contains(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT) || (!claim.isWilderness() && contextSet.contains(ClaimContexts.USER_OVERRIDE_CONTEXT))) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.OVERRIDE, flagPermissions);
}
if (contextSet.contains(claim.getOverrideClaimContext())) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.OVERRIDE, flagPermissions);
} else if (contextSet.contains(claim.getOverrideTypeContext())) {
this.addFilteredContexts(holder, flagDataMap, contextSet, MenuType.OVERRIDE, flagPermissions);
}
}
}
}
private void addFilteredContexts(GDPermissionHolder holder, Map<String, UIFlagData> flagDataMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) {
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
if (flag == null) {
continue;
}
final UIFlagData flagData = filteredContextMap.get(permissionEntry.getKey());
final UIFlagData flagData = flagDataMap.get(permissionEntry.getKey());
if (flagData != null) {
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
// set new holder
flagData.setHolder(holder);
} else {
filteredContextMap.put(permissionEntry.getKey(), new UIFlagData(flag, permissionEntry.getValue(), type, contexts));
flagDataMap.put(permissionEntry.getKey(), new UIFlagData(holder, flag, permissionEntry.getValue(), type, contexts));
}
}
}
@ -696,7 +697,13 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
} else if (defaultResult == Tristate.FALSE) {
valueColor = TextColor.RED;
}
valueBuilder.append(String.valueOf(defaultResult).toLowerCase(), valueColor);
if (defaultResult == Tristate.TRUE) {
valueBuilder.append(MessageCache.getInstance().PERMISSION_TRUE.color(valueColor));
} else if (defaultResult == Tristate.FALSE) {
valueBuilder.append(MessageCache.getInstance().PERMISSION_FALSE.color(valueColor));
} else {
valueBuilder.append(MessageCache.getInstance().PERMISSION_UNDEFINED.color(valueColor));
}
}
if (hasEditPermission) {
@ -941,7 +948,7 @@ public GDActiveFlagData getActiveDefinitionResult(GDClaim claim, GDFlagDefinitio
return new GDActiveFlagData(flagDefinition, flagData,Tristate.UNDEFINED, permissionContexts, GDActiveFlagData.Type.UNDEFINED);
}
private Component getClickableText(GDPermissionUser src, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Set<Context> contexts, MenuType displayType) {
private Component getClickableText(GDPermissionUser src, GDPermissionHolder holder, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Set<Context> contexts, MenuType displayType) {
Component hoverEventText = TextComponent.empty();
final MenuType flagType = flagHolder.getType();
final Player player = src.getOnlinePlayer();
@ -1029,15 +1036,20 @@ public int compare(Context o1, Context o2) {
}
}
TextComponent.Builder valueBuilder = TextComponent.builder()
.append(String.valueOf(value), flagHolder.getColor())
.hoverEvent(HoverEvent.showText(hoverText));
TextComponent.Builder valueBuilder = TextComponent.builder();
if (value) {
valueBuilder.append(MessageCache.getInstance().PERMISSION_TRUE.color(flagHolder.getColor()));
} else {
valueBuilder.append(MessageCache.getInstance().PERMISSION_FALSE.color(flagHolder.getColor()));
}
valueBuilder.hoverEvent(HoverEvent.showText(hoverText));
TextComponent.Builder textBuilder = null;
if (hasEditPermission) {
textBuilder = TextComponent.builder()
.append(valueBuilder
.hoverEvent(HoverEvent.showText(hoverText))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, claim, flag, flagHolder, newValue, contexts, displayType))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, holder, claim, flag, flagHolder, newValue, contexts, displayType))))
.build());
} else {
textBuilder = TextComponent.builder()
@ -1081,7 +1093,7 @@ public int compare(Context o1, Context o2) {
.append(TextComponent.builder()
.append("x", TextColor.RED)
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, claim, flag, flagHolder, Tristate.UNDEFINED, contexts, displayType))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, holder, claim, flag, flagHolder, Tristate.UNDEFINED, contexts, displayType))))
.build())
.append("]", TextColor.WHITE);
}
@ -1129,7 +1141,7 @@ private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, G
};
}
private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Tristate newValue, Set<Context> contexts, MenuType displayType) {
private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDPermissionHolder holder, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Tristate newValue, Set<Context> contexts, MenuType displayType) {
final Player player = src.getOnlinePlayer();
return consumer -> {
GDCauseStackManager.getInstance().pushCause(player);
@ -1167,7 +1179,7 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
newContexts.add(serverContext);
}
GDFlagPermissionEvent.Set event = new GDFlagPermissionEvent.Set(this.subject, flag, newValue, newContexts);
GDFlagPermissionEvent.Set event = new GDFlagPermissionEvent.Set(holder, flag, newValue, newContexts);
GriefDefender.getEventManager().post(event);
GDCauseStackManager.getInstance().popCause();
if (event.cancelled()) {
@ -1175,7 +1187,7 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
}
if (displayType == MenuType.DEFAULT || (hasDefaultContext && src.getInternalPlayerData().canManageFlagDefaults)) {
CompletableFuture<PermissionResult> future = PermissionUtil.getInstance().setPermissionValue(this.subject, flag.getPermission(), newValue, newContexts);
CompletableFuture<PermissionResult> future = PermissionUtil.getInstance().setPermissionValue(holder, flag.getPermission(), newValue, newContexts);
future.thenAccept(r -> {
Bukkit.getScheduler().runTask(GDBootstrap.getInstance(), () -> {
showFlagPermissions(src, claim, displayType);
@ -1185,12 +1197,12 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
}
final Context permServerContext = serverContext;
CompletableFuture<PermissionResult> future = PermissionUtil.getInstance().setPermissionValue(this.subject, flag, newValue, newContexts);
CompletableFuture<PermissionResult> future = PermissionUtil.getInstance().setPermissionValue(holder, flag, newValue, newContexts);
future.thenAcceptAsync(r -> {
if (!r.successful()) {
// Try again without server context
newContexts.remove(permServerContext);
CompletableFuture<PermissionResult> newFuture = PermissionUtil.getInstance().setPermissionValue(this.subject, flag, newValue, newContexts, false, true);
CompletableFuture<PermissionResult> newFuture = PermissionUtil.getInstance().setPermissionValue(holder, flag, newValue, newContexts, false, true);
newFuture.thenAccept(r2 -> {
if (r2.successful()) {
Bukkit.getScheduler().runTask(GDBootstrap.getInstance(), () -> {

View File

@ -39,6 +39,8 @@
import com.griefdefender.cache.MessageCache;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.storage.BaseStorage;
import net.kyori.text.Component;
import net.kyori.text.adapter.bukkit.TextAdapter;
import org.bukkit.Bukkit;
@ -53,29 +55,40 @@ public class CommandAdjustBonusClaimBlocks extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("acb|adjustclaimblocks")
@Description("Adjusts a player's bonus claim block total by amount specified")
@Description("%player-adjust-bonus-blocks")
@Syntax("<player> <amount>")
@Subcommand("player adjustbonusblocks")
public void execute(CommandSender src, OfflinePlayer user, int amount, @Optional String worldName) {
World world = worldName == null ? null : Bukkit.getServer().getWorld(worldName);
if (world == null) {
if (src instanceof Player) {
world = ((Player) src).getWorld();
} else {
world = Bukkit.getServer().getWorlds().get(0);
World world = null;
GDPlayerData playerData = null;
if (BaseStorage.USE_GLOBAL_PLAYER_STORAGE) {
playerData = BaseStorage.GLOBAL_PLAYER_DATA.get(user.getUniqueId());
if (playerData == null) {
playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreateGlobalPlayerData(user.getUniqueId());
}
} else {
world = worldName == null ? null : Bukkit.getServer().getWorld(worldName);
if (world == null) {
if (src instanceof Player) {
world = ((Player) src).getWorld();
} else {
world = Bukkit.getServer().getWorlds().get(0);
}
}
playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world.getUID(), user.getUniqueId());
}
if (world == null || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
if (!BaseStorage.USE_GLOBAL_PLAYER_STORAGE && (world == null || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID()))) {
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_DISABLED_WORLD);
return;
}
GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world.getUID(), user.getUniqueId());
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + amount);
final int totalBonus = playerData.getBonusClaimBlocks();
playerData.setBonusClaimBlocks(totalBonus + amount);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ADJUST_BONUS_BLOCKS_SUCCESS, ImmutableMap.of(
"player", user.getName(),
"amount", amount,
"total", playerData.getBonusClaimBlocks() + amount));
"total", totalBonus + amount));
TextAdapter.sendComponent(src, message);
GriefDefenderPlugin.getInstance().getLogger().info(
src.getName() + " adjusted " + user.getName() + "'s bonus claim blocks by " + amount + ".");

View File

@ -57,7 +57,7 @@
public class CommandAdjustBonusClaimBlocksAll extends BaseCommand {
@CommandAlias("acball|adjustclaimblocksall")
@Description("Adjusts bonus claim block total for all online players by amount specified")
@Description("%player-adjust-bonus-blocks-all")
@Syntax("<amount>")
@Subcommand("player adjustbonusblocksall")
public void execute(CommandSender src, int amount) {

View File

@ -36,7 +36,7 @@
public class CommandCallback extends BaseCommand {
@CommandAlias("gd:callback")
@Description("Execute a callback registered as part of a Text object. Primarily for internal use")
@Description("%callback")
public void execute(CommandSender src, String[] args) {
final UUID callbackId = UUID.fromString(args[0]);
final Consumer<CommandSender> callback = GDCallbackHolder.getInstance().getCallbackForUUID(callbackId);

View File

@ -76,21 +76,15 @@ public class CommandClaimAbandon extends BaseCommand {
protected boolean abandonTopClaim = false;
@CommandAlias("abandon|abandonclaim")
@Description("Abandons a claim")
@Description("%abandon-claim")
@Subcommand("abandon claim")
public void execute(Player player) {
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation());
final UUID ownerId = claim.getOwnerUniqueId();
GDPermissionUser user = null;
if (ownerId != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(ownerId);
} else {
user = PermissionHolderCache.getInstance().getOrCreateUser(player);
}
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player.getUniqueId());
final GDPlayerData playerData = user.getInternalPlayerData();
final boolean isAdmin = playerData.canIgnoreClaim(claim);
final boolean isTown = claim.isTown();
if (claim.isWilderness()) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ABANDON_CLAIM_MISSING);
return;
@ -109,7 +103,6 @@ public void execute(Player player) {
Set<Claim> invalidClaims = new HashSet<>();
for (Claim child : claim.getChildren(true)) {
if (child.getOwnerUniqueId() == null || !child.getOwnerUniqueId().equals(ownerId)) {
//return CommandResult.empty();
invalidClaims.add(child);
}
}
@ -122,19 +115,38 @@ public void execute(Player player) {
}
}
}
final int abandonDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), user, Options.ABANDON_DELAY, claim);
if (abandonDelay > 0) {
final Instant localNow = Instant.now();
final Instant dateCreated = claim.getInternalClaimData().getDateCreated();
final Instant delayExpires = dateCreated.plus(Duration.ofDays(abandonDelay));
final boolean delayActive = !delayExpires.isBefore(localNow);
if (delayActive) {
TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.ABANDON_CLAIM_DELAY_WARNING,
ImmutableMap.of("date", Date.from(delayExpires))));
if (!isAdmin && (claim.isTown() && claim.children.size() > 0)) {
Set<Claim> childClaims = new HashSet<>();
for (Claim child : claim.getChildren(true)) {
if (!child.isBasicClaim()) {
continue;
}
if (child.getOwnerUniqueId().equals(user.getUniqueId())) {
childClaims.add(child);
}
}
if (!childClaims.isEmpty()) {
GriefDefenderPlugin.sendMessage(player, TextComponent.of("Abandon town failed! You must abandon all basic children claims owned by you first.", TextColor.RED));
CommandHelper.showClaims(player, childClaims, 0, true);
return;
}
}
if (!isAdmin) {
final int abandonDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), user, Options.ABANDON_DELAY, claim);
if (abandonDelay > 0) {
final Instant localNow = Instant.now();
final Instant dateCreated = claim.getInternalClaimData().getDateCreated();
final Instant delayExpires = dateCreated.plus(Duration.ofDays(abandonDelay));
final boolean delayActive = !delayExpires.isBefore(localNow);
if (delayActive) {
TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.ABANDON_CLAIM_DELAY_WARNING,
ImmutableMap.of("date", Date.from(delayExpires))));
return;
}
}
}
final boolean autoSchematicRestore = GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().claim.claimAutoSchematicRestore;
final Component confirmationText = TextComponent.builder()
.append(autoSchematicRestore ? MessageCache.getInstance().SCHEMATIC_ABANDON_RESTORE_WARNING : MessageCache.getInstance().ABANDON_WARNING)
@ -197,6 +209,17 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player source,
}
if (!claim.isAdminClaim()) {
// check parent
final Claim parentClaim = claim.getParent().orElse(null);
if (parentClaim != null && parentClaim.isTown()) {
if (parentClaim.isUserTrusted(user.getUniqueId(), TrustTypes.MANAGER)) {
int remainingBlocks = playerData.getRemainingClaimBlocks();
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ABANDON_SUCCESS, ImmutableMap.of(
"amount", remainingBlocks));
GriefDefenderPlugin.sendMessage(source, message);
return;
}
}
final double abandonReturnRatio = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), user, Options.ABANDON_RETURN_RATIO, claim);
if (GriefDefenderPlugin.getInstance().isEconomyModeEnabled()) {
final Economy economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi();

View File

@ -76,7 +76,7 @@ public class CommandClaimAbandonAll extends BaseCommand {
@CommandCompletion("@gdworlds @gddummy")
@CommandAlias("abandonall|abandonallclaims")
@Description("Abandons ALL your claims")
@Description("%abandon-all")
@Subcommand("abandon all")
public void execute(Player player, @Optional String worldName) {
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player);

View File

@ -40,7 +40,7 @@ public CommandClaimAbandonTop() {
}
@CommandAlias("abandontop")
@Description("Abandons top level claim")
@Description("%abandon-top")
@Subcommand("abandon top")
public void execute(Player player) {
super.execute(player);

View File

@ -74,7 +74,7 @@ public class CommandClaimAbandonWorld extends BaseCommand {
@CommandCompletion("@gdworlds @gddummy")
@CommandAlias("abandonworld")
@Description("Special admin command used to abandon ALL user claims in world")
@Description("%abandon-world")
@Subcommand("abandon world")
@Syntax("[<world>]")
public void execute(Player player, @Optional String worldName) {
@ -170,7 +170,7 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player source,
if (GriefDefenderPlugin.getInstance().isEconomyModeEnabled()) {
final Economy economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi();
if (!economy.hasAccount(user.getOfflinePlayer())) {
return;
continue;
}
final EconomyResponse result = economy.depositPlayer(user.getOfflinePlayer(), refund);

View File

@ -41,7 +41,7 @@
public class CommandClaimAdmin extends BaseCommand {
@CommandAlias("modeadmin|adminclaims|ac")
@Description("Switches the shovel tool to administrative claims mode")
@Description("%mode-admin")
@Subcommand("mode admin")
public void execute(Player player) {

View File

@ -54,7 +54,7 @@ public class CommandClaimBan extends BaseCommand {
@CommandCompletion("@gdbantypes @gdmcids @gddummy")
@CommandAlias("claimban")
@Description("Bans target id from all usage.")
@Description("%claim-ban")
@Syntax("hand | <type> <target> [<message>]")
@Subcommand("ban")
public void execute(Player player, String type, @Optional String id, @Optional String message) {

View File

@ -44,7 +44,7 @@ public class CommandClaimBank extends BaseCommand {
protected boolean townOnly = false;
@CommandAlias("claimbank")
@Description("Used for claim bank queries")
@Description("%claim-bank")
@Syntax("<withdraw|deposit> <amount>")
@Subcommand("claim bank")
public void execute(Player player, @Optional String[] args) throws CommandException {

View File

@ -41,7 +41,7 @@
public class CommandClaimBasic extends BaseCommand {
@CommandAlias("modebasic|basicclaims|bc")
@Description("Switches the shovel tool back to basic claims mode")
@Description("%mode-basic")
@Subcommand("mode basic")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -56,7 +56,7 @@
public class CommandClaimBuy extends BaseCommand {
@CommandAlias("claimbuy")
@Description("List all claims available for purchase.\nNote: Requires economy plugin.")
@Description("%buy-claim")
@Subcommand("buy claim")
public void execute(Player player) {
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {

View File

@ -54,7 +54,7 @@
public class CommandClaimBuyBlocks extends BaseCommand {
@CommandAlias("buyclaim|buyclaimblocks|buyblocks")
@Description("Purchases additional claim blocks with server money.\nNote: Requires economy plugin.")
@Description("%buy-blocks")
@Syntax("[<amount>]")
@Subcommand("buy blocks")
public void execute(Player player, @Optional Integer blockCount) {
@ -78,6 +78,11 @@ public void execute(Player player, @Optional Integer blockCount) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final double economyBlockCost = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), player, Options.ECONOMY_BLOCK_COST);
if (economyBlockCost <= 0) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_BLOCK_BUY_SELL_DISABLED);
return;
}
final double balance = economy.getBalance(player);
if (blockCount == null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_BLOCK_PURCHASE_COST, ImmutableMap.of(

View File

@ -60,7 +60,7 @@ public class CommandClaimClear extends BaseCommand {
@CommandCompletion("@gdentityids @gddummy")
@CommandAlias("claimclear")
@Description("Allows clearing of entities within one or more claims.")
@Description("%claim-clear")
@Syntax("<entity_id> [claim_uuid]")
@Subcommand("claim clear")
public void execute(Player player, String target, @Optional String claimId) {

View File

@ -45,6 +45,7 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
@ -68,7 +69,7 @@ public class CommandClaimContract extends BaseCommand {
@CommandCompletion("@gddummy @gdblockfaces @gddummy")
@CommandAlias("claimcontract|contractclaim")
@Description("Contracts/Shrinks the claim from the direction you are facing.")
@Description("%claim-contract")
@Syntax("<amount> [direction]")
@Subcommand("claim contract")
public void execute(Player player, int amount, @Optional String direction) {
@ -130,7 +131,9 @@ public void execute(Player player, int amount, @Optional String direction) {
greater.getZ() - amount);
}
GDCauseStackManager.getInstance().pushCause(player);
final ClaimResult result = claim.resize(point1, point2);
GDCauseStackManager.getInstance().popCause();
if (!result.successful()) {
if (result.getResultType() == ClaimResultType.OVERLAPPING_CLAIM) {
GDClaim overlapClaim = (GDClaim) result.getClaim().get();

View File

@ -72,7 +72,7 @@ public class CommandClaimCreate extends BaseCommand {
@CommandCompletion("@gddummy @gdclaimtypes @gddummy")
@CommandAlias("claimcreate")
@Description("Creates a claim around the player.")
@Description("%claim-create")
@Syntax("<radius> [type]")
@Subcommand("claim create")
public void execute(Player player, int radius, @Optional String type) {

View File

@ -41,7 +41,7 @@
public class CommandClaimCuboid extends BaseCommand {
@CommandAlias("cuboid")
@Description("Toggles cuboid claims mode.")
@Description("%cuboid")
@Subcommand("cuboid")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -59,7 +59,7 @@ public class CommandClaimDelete extends BaseCommand {
protected boolean deleteTopLevelClaim = false;
@CommandAlias("deleteclaim")
@Description("Deletes the claim you're standing in, even if it's not your claim.")
@Description("%delete-claim")
@Subcommand("delete claim")
public void execute(Player player) {
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation());

View File

@ -74,7 +74,7 @@ public class CommandClaimDeleteAll extends BaseCommand {
@CommandCompletion("@gdplayers @gdworlds @gddummy")
@CommandAlias("deleteall")
@Description("Delete all of another player's claims.")
@Description("%delete-all")
@Syntax("<player> [<world>]")
@Subcommand("delete all")
public void execute(Player src, String otherPlayer, @Optional String worldName) {

View File

@ -61,7 +61,7 @@
public class CommandClaimDeleteAllAdmin extends BaseCommand {
@CommandAlias("deletealladmin")
@Description("Deletes all administrative claims.")
@Description("%delete-all-admin")
@Subcommand("delete alladmin")
public void execute(Player player, @Optional String worldName) {
World world = null;
@ -95,23 +95,29 @@ public void execute(Player player, @Optional String worldName) {
TextAdapter.sendComponent(player, confirmationText);
}
private static Consumer<CommandSender> createConfirmationConsumer(Player player, World world) {
private static Consumer<CommandSender> createConfirmationConsumer(Player player, World targetWorld) {
return confirm -> {
final UUID worldUniqueId = world != null ? world.getUID() : null;
ClaimResult claimResult = GriefDefenderPlugin.getInstance().dataStore.deleteAllAdminClaims(player, worldUniqueId);
if (!claimResult.successful()) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_TYPE_NOT_FOUND,
ImmutableMap.of(
"type", ClaimTypes.ADMIN.getName().toLowerCase()));
GriefDefenderPlugin.sendMessage(player, claimResult.getMessage().orElse(message));
return;
final UUID worldUniqueId = targetWorld != null ? targetWorld.getUID() : null;
if (worldUniqueId == null) {
for (World world : Bukkit.getWorlds()) {
GriefDefenderPlugin.getInstance().dataStore.deleteAllAdminClaims(player, world.getUID());
}
} else {
ClaimResult claimResult = GriefDefenderPlugin.getInstance().dataStore.deleteAllAdminClaims(player, worldUniqueId);
if (!claimResult.successful()) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_TYPE_NOT_FOUND,
ImmutableMap.of(
"type", ClaimTypes.ADMIN.getName().toLowerCase()));
GriefDefenderPlugin.sendMessage(player, claimResult.getMessage().orElse(message));
return;
}
}
Component message = null;
if (world != null) {
if (targetWorld != null) {
message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_ALL_TYPE_SUCCESS_WORLD, ImmutableMap.of(
"type", TextComponent.of("ADMIN").color(TextColor.RED),
"world", world.getName()));
"world", targetWorld.getName()));
} else {
message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_ALL_TYPE_SUCCESS, ImmutableMap.of(
"type", TextComponent.of("ADMIN").color(TextColor.RED)));

View File

@ -40,7 +40,7 @@ public CommandClaimDeleteTop() {
}
@CommandAlias("deletetop")
@Description("Deletes the claim you're standing in, even if it's not your claim.")
@Description("%delete-top")
@Subcommand("delete top")
public void execute(Player player) {
super.execute(player);

View File

@ -45,6 +45,7 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
@ -68,7 +69,7 @@ public class CommandClaimExpand extends BaseCommand {
@CommandCompletion("@gddummy @gdblockfaces @gddummy")
@CommandAlias("claimexpand|expandclaim")
@Description("Expands the claim in the direction you are facing.")
@Description("%claim-expand")
@Syntax("<amount> [direction]")
@Subcommand("claim expand")
public void execute(Player player, int amount, @Optional String direction) {
@ -130,7 +131,9 @@ public void execute(Player player, int amount, @Optional String direction) {
greater.getZ() + amount);
}
GDCauseStackManager.getInstance().pushCause(player);
final ClaimResult result = claim.resize(point1, point2);
GDCauseStackManager.getInstance().popCause();
if (!result.successful()) {
if (result.getResultType() == ClaimResultType.OVERLAPPING_CLAIM) {
GDClaim overlapClaim = (GDClaim) result.getClaim().get();

View File

@ -49,7 +49,7 @@
public class CommandClaimFarewell extends BaseCommand {
@CommandAlias("claimfarewell")
@Description("Sets the farewell message of your claim.")
@Description("%claim-farewell")
@Syntax("<message>|clear")
@Subcommand("claim farewell")
public void execute(Player player, String message) {

View File

@ -46,11 +46,11 @@ public CommandClaimFlag() {
@CommandCompletion("@gdflags @gdmcids @gdtristates @gdcontexts @gddummy")
@CommandAlias("cf|claimflag")
@Description("Gets/Sets claim flags in the claim you are standing in.")
@Description("%flag-claim")
@Syntax("<flag> <target> <value> [context[key=value]]")
@Subcommand("flag claim")
public void execute(Player player, @Optional String[] args) throws InvalidCommandArgument {
this.subject = GriefDefenderPlugin.DEFAULT_HOLDER;
this.subject = GriefDefenderPlugin.GD_DEFAULT_HOLDER;
this.friendlySubjectName = "ALL";
super.execute(player, args);
}

View File

@ -44,7 +44,7 @@
public class CommandClaimFlagDebug extends BaseCommand {
@CommandAlias("cfdebug")
@Description("Toggles claim flag debug mode.")
@Description("%claim-debug")
@Subcommand("claim debug")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -51,7 +51,7 @@ public CommandClaimFlagGroup() {
@CommandCompletion("@gdgroups @gdflags @gdmcids @gdtristates @gdcontexts @gddummy")
@CommandAlias("cfg")
@Description("Gets/Sets flag permission for a group in claim you are standing in.")
@Description("%flag-group")
@Syntax("<group> <flag> <target> <value> [context[key=value]]")
@Subcommand("flag group")
public void execute(Player player, String group, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -51,7 +51,7 @@ public CommandClaimFlagPlayer() {
@CommandCompletion("@gdplayers @gdflags @gdmcids @gdtristates @gdcontexts @gddummy")
@CommandAlias("cfp")
@Description("Gets/Sets flag permission for a player in claim you are standing in.")
@Description("%flag-player")
@Syntax("<player> <flag> <target> <value> [context[key=value]]")
@Subcommand("flag player")
public void execute(Player src, OfflinePlayer player, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -56,7 +56,7 @@
public class CommandClaimFlagReset extends BaseCommand {
@CommandAlias("cfr")
@Description("Resets a claim to flag defaults.")
@Description("%flag-reset")
@Subcommand("flag reset")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -49,7 +49,7 @@
public class CommandClaimGreeting extends BaseCommand {
@CommandAlias("claimgreeting")
@Description("Sets the greeting message of your claim.")
@Description("%claim-greeting")
@Syntax("<message>|clear")
@Subcommand("claim greeting")
public void execute(Player player, String message) {

View File

@ -44,7 +44,7 @@
public class CommandClaimIgnore extends BaseCommand {
@CommandAlias("claimignore|ignoreclaims|ic")
@Description("Toggles ignore claims mode.")
@Description("%claim-ignore")
@Subcommand("claim ignore")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -27,6 +27,7 @@
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.Subcommand;
import co.aikar.commands.annotation.Syntax;
@ -112,6 +113,7 @@ public CommandClaimInfo(boolean useTownInfo) {
}
@CommandAlias("claiminfo")
@Description("%claim-info")
@Syntax("[claim_uuid]")
@Subcommand("claim info")
public void execute(CommandSender src, String[] args) {

View File

@ -45,7 +45,7 @@
public class CommandClaimInherit extends BaseCommand {
@CommandAlias("claiminherit")
@Description("Toggles subdivision inherit mode.")
@Description("%claim-inherit")
@Subcommand("claim inherit")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -31,7 +31,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import com.google.common.collect.ImmutableMap;
import com.google.common.reflect.TypeToken;
@ -58,15 +57,13 @@
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.format.TextColor;
@CommandAlias("%griefdefender")
@CommandPermission(GDPermissions.COMMAND_CLAIM_INVESTIGATE)
public class CommandClaimInvestigate extends BaseCommand {
@CommandAlias("claiminvestigate")
@Description("Investigates the target or nearby claims.")
@Description("%claim-investigate")
@Syntax("[area|hide|hideall]")
@Subcommand("claim investigate")
public void execute(Player player, @Optional String cmd) {

View File

@ -61,7 +61,6 @@
import net.kyori.text.format.TextColor;
import net.kyori.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -93,7 +92,7 @@ public CommandClaimList(ClaimType type) {
@CommandCompletion("@gdplayers @gdworlds @gddummy")
@CommandAlias("claimlist|claimslist")
@Syntax("[<player>|<player> <world>]")
@Description("List information about a player's claim blocks and claims.")
@Description("%claim-list")
@Subcommand("claim list")
public void execute(Player src, @Optional String targetPlayer, @Optional World world) {
GDPermissionUser user = null;

View File

@ -46,7 +46,7 @@
public class CommandClaimMode extends BaseCommand {
@CommandAlias("claim|claimmode")
@Description("Toggles claim mode creation. Note: This will default to basic claim mode.")
@Description("%mode-claim")
@Subcommand("mode claim")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -53,7 +53,7 @@ public class CommandClaimName extends BaseCommand {
@CommandAlias("claimname")
@Syntax("<name>|clear")
@Description("Sets the name of your claim.")
@Description("%claim-name")
@Subcommand("claim name")
public void execute(Player player, String name) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -47,7 +47,7 @@ public CommandClaimOption() {
@CommandCompletion("@gdoptions @gdcontexts @gddummy")
@CommandAlias("cod|claimoption")
@Description("Gets/Sets claim options in the claim you are standing in.")
@Description("%option-claim")
@Syntax("[<option> <value> [context[key=value]]")
@Subcommand("option claim")
public void execute(Player player, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -51,7 +51,7 @@ public CommandClaimOptionGroup() {
@CommandCompletion("@gdgroups @gdoptions @gdcontexts @gddummy")
@CommandAlias("cog")
@Description("Gets/Sets option for a group in claim you are standing in.")
@Description("%option-group")
@Syntax("<group> <option> <value> [context[key=value]]")
@Subcommand("option group")
public void execute(Player player, String group, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -47,7 +47,7 @@ public CommandClaimOptionPlayer() {
@CommandCompletion("@gdplayers @gdoptions @gdcontexts @gddummy")
@CommandAlias("cop")
@Description("Gets/Sets option for a player in claim you are standing in.")
@Description("%option-player")
@Syntax("<player> <option> <value> [context[key=value]]")
@Subcommand("option player")
public void execute(Player src, OfflinePlayer player, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -67,7 +67,7 @@ public class CommandClaimPermissionGroup extends BaseCommand {
@CommandCompletion("@gdgroups @gddummy")
@CommandAlias("cpg")
@Description("Sets a permission on a group with a claim context.")
@Description("%permission-group")
@Syntax("<group> [<permission> <value>]")
@Subcommand("permission group")
public void execute(Player player, String group, @Optional String[] args) throws CommandException, InvalidCommandArgument {

View File

@ -68,7 +68,7 @@ public class CommandClaimPermissionPlayer extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("cpp")
@Description("Sets a permission on a player with a claim context.")
@Description("%permission-player")
@Syntax("<player> [<permission> <value>]")
@Subcommand("permission player")
public void execute(Player player, OfflinePlayer otherPlayer, @Optional String[] args) throws CommandException, InvalidCommandArgument {

View File

@ -34,6 +34,7 @@
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.ImmutableMap;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
@ -46,12 +47,12 @@
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.pagination.PaginationList;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.text.action.GDCallbackHolder;
import com.griefdefender.util.ChatCaptureUtil;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PermissionUtil;
import com.griefdefender.util.PlayerUtil;
import com.griefdefender.util.SignUtil;
@ -63,6 +64,8 @@
import net.kyori.text.format.TextDecoration;
import net.kyori.text.serializer.plain.PlainComponentSerializer;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import java.time.Instant;
@ -79,7 +82,7 @@ public class CommandClaimRent extends BaseCommand {
@CommandCompletion("@gdrentcommands @gddummy")
@CommandAlias("claimrent")
@Description("Used to rent/list claims. \nNote: Requires economy plugin.")
@Description("%claim-rent")
@Syntax("create <rate> [<max_days>]|info|list|cancel]")
@Subcommand("claim rent")
public void execute(Player player, @Optional String[] args) {
@ -128,8 +131,13 @@ public void execute(Player player, @Optional String[] args) {
}
return;
}
EconomyUtil.getInstance().rentCancelConfirmation(player, claim, null);
Sign sign = null;
final Vector3i signPos = claim.getEconomyData().getRentSignPosition();
if (signPos != null) {
sign = SignUtil.getSign(VecHelper.toLocation(player.getWorld(), signPos));
}
EconomyUtil.getInstance().rentCancelConfirmation(player, claim, sign);
return;
} else if (subCommand.equalsIgnoreCase("clearbalance")) {
if (args.length != 2) {
@ -226,6 +234,15 @@ public void execute(Player player, @Optional String[] args) {
if (claim.isWilderness()) {
return;
}
if (!claim.getEconomyData().isForRent() && !claim.getEconomyData().isRented()) {
if (player.getUniqueId().equals(claim.getOwnerUniqueId())) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_CLAIM_RENT_OWNER_NOT_RENTING);
} else {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_CLAIM_RENT_NOT_RENTING);
}
return;
}
final UUID ownerUniqueId = claim.getOwnerUniqueId();
final boolean isAdmin = player.getUniqueId().equals(ownerUniqueId) || player.hasPermission(GDPermissions.COMMAND_DELETE_ADMIN_CLAIMS) || claim.allowEdit(player) == null;
List<Component> textList = new ArrayList<>();

View File

@ -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.Optional;
@ -62,7 +61,7 @@ public class CommandClaimReserve extends BaseCommand {
@CommandAlias("claimreserve")
@Syntax("[<name>]")
@Description("Reserves a claim name for administrator use.")
@Description("%claim-reserve")
@Subcommand("claim reserve")
public void execute(CommandSender src, @Optional String name) {
GriefDefenderConfig<?> activeConfig = null;

View File

@ -67,7 +67,7 @@
public class CommandClaimSchematic extends BaseCommand {
@CommandAlias("claimschematic")
@Description("Manages claim schematics. Use '/claimschematic create <name>' to create a live backup of claim.")
@Description("%schematic")
@Syntax("<create|delete> <name>")
@Subcommand("schematic")
public void execute(Player player, @Optional String[] args) throws CommandException, InvalidCommandArgument {

View File

@ -55,7 +55,7 @@
public class CommandClaimSell extends BaseCommand {
@CommandAlias("claimsell")
@Description("Puts your claim up for sale. Use /claimsell amount.\nNote: Requires economy plugin.")
@Description("%sell-claim")
@Syntax("<amount> | cancel")
@Subcommand("sell claim")
public void execute(Player player, String arg) throws InvalidCommandArgument {
@ -68,12 +68,12 @@ public void execute(Player player, String arg) throws InvalidCommandArgument {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation());
if (claim.isAdminClaim() || claim.isWilderness()) {
if (claim.isWilderness()) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_CLAIM_NOT_FOR_SALE);
return;
}
if (!playerData.canIgnoreClaim(claim) && !player.getUniqueId().equals(claim.getOwnerUniqueId())) {
if ((claim.isAdminClaim() && !playerData.canManageAdminClaims) || !claim.isAdminClaim() && !playerData.canIgnoreClaim(claim) && !player.getUniqueId().equals(claim.getOwnerUniqueId())) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().PERMISSION_CLAIM_SALE);
return;
}

View File

@ -49,7 +49,7 @@
public class CommandClaimSellBlocks extends BaseCommand {
@CommandAlias("sellclaim|sellclaimblocks|sellblocks")
@Description("Sell your claim blocks for server money.\nNote: Requires economy plugin.")
@Description("%sell-blocks")
@Syntax("[<amount>]")
@Subcommand("sell blocks")
public void execute(Player player, @Optional Integer blockCount) {

View File

@ -46,7 +46,7 @@
public class CommandClaimSetSpawn extends BaseCommand {
@CommandAlias("claimsetspawn")
@Description("Sets the spawn of claim.")
@Description("%claim-setspawn")
@Subcommand("claim setspawn")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -59,7 +59,7 @@
public class CommandClaimSpawn extends BaseCommand {
@CommandAlias("claimspawn")
@Description("Teleports you to claim spawn if available.")
@Description("%claim-spawn")
@Syntax("[name] [user]")
@Subcommand("claim spawn")
public void execute(Player player, @Optional String claimName, @Optional OfflinePlayer targetPlayer) {

View File

@ -41,7 +41,7 @@
public class CommandClaimSubdivision extends BaseCommand {
@CommandAlias("modesubdivide|subdivideclaims|sc")
@Description("Switches the shovel tool to subdivision mode, used to subdivide your claims.")
@Description("%mode-subdivision")
@Subcommand("mode subdivide")
public void execute(Player player) {

View File

@ -59,7 +59,7 @@ public class CommandClaimTax extends BaseCommand {
@CommandCompletion("@gdtaxcommands @gddummy")
@CommandAlias("claimtax")
@Description("Used for claim tax management.")
@Description("%claim-tax")
@Syntax("balance|pay <amount>")
@Subcommand("claim tax")
public void execute(Player player, String[] args) throws CommandException {

View File

@ -42,7 +42,7 @@
public class CommandClaimTool extends BaseCommand {
@CommandAlias("claimtool")
@Description("Toggles claim tool on/off.")
@Description("%claim-tool")
@Subcommand("mode tool")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -41,7 +41,7 @@
public class CommandClaimTown extends BaseCommand {
@CommandAlias("modetown|townclaims")
@Description("Switches the shovel tool to town claims mode.")
@Description("%mode-town")
@Subcommand("mode town")
public void execute(Player player) {

View File

@ -33,7 +33,7 @@ public class CommandClaimTransfer extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("claimtransfer|transferclaim")
@Description("Transfers a basic or admin claim to another player.")
@Description("%claim-transfer")
@Syntax("<player>")
@Subcommand("claim transfer")
public void execute(Player player, OfflinePlayer otherPlayer) {

View File

@ -42,7 +42,6 @@
import com.griefdefender.internal.registry.BlockTypeRegistryModule;
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.GDPermissions;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -53,7 +52,7 @@ public class CommandClaimUnban extends BaseCommand {
@CommandCompletion("@gdbantypes @gdmcids @gddummy")
@CommandAlias("claimunban")
@Description("Unbans target id allowing it to be used again.")
@Description("%claim-unban")
@Syntax("hand | <type> <target>")
@Subcommand("unban")
public void execute(Player player, String type, @Optional String id) {

View File

@ -39,8 +39,8 @@
public class CommandClaimWorldEdit extends BaseCommand {
@CommandAlias("claimwe|claimworldedit")
@Description("Uses the worldedit selection to create a claim.")
@Subcommand("claim worldedit|claim we")
@Description("%claim-worldedit")
@Subcommand("claim worldedit|we")
public void execute(Player player) {
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() == null) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().COMMAND_WORLDEDIT_MISSING);

View File

@ -56,7 +56,7 @@
public class CommandDebug extends BaseCommand {
@CommandAlias("gddebug")
@Description("Captures all GD actions for debugging purposes.")
@Description("%debug")
@Syntax("<record|paste|on|off> [filter]")
@Subcommand("debug")
public void execute(CommandSender src, String command, @Optional String filter) {

View File

@ -65,7 +65,7 @@
public class CommandGDBlockTransfer extends BaseCommand {
@CommandAlias("gdblocktransfer")
@Description("Transfers ALL player remaining accrued/bonus claim blocks into currency then sets their accrued and bonus amounts to 0.\nNote: This MUST be used if you are switching from claim blocks system to economy mode.")
@Description("%economy-block-transfer")
@Subcommand("economy blocktransfer")
public void execute(CommandSender source, @Optional Integer blockCount) {
// if economy is disabled, don't do anything

View File

@ -45,7 +45,7 @@
public class CommandGDConfirm extends BaseCommand {
@CommandAlias("gdconfirm")
@Description("Alternate way to confirm chat confirmations.")
@Description("%confirm")
@Subcommand("confirm")
public void execute(Player player) {

View File

@ -39,7 +39,7 @@
public class CommandGDReload extends BaseCommand {
@CommandAlias("gdreload")
@Description("Reloads GriefDefender's configuration settings.")
@Description("%reload")
@Subcommand("reload")
public void execute(CommandSender src) {
GriefDefenderPlugin.getInstance().loadConfig();

View File

@ -43,7 +43,7 @@
public class CommandGDVersion extends BaseCommand {
@CommandAlias("gdversion")
@Description("Displays GriefDefender's version information.")
@Description("%version")
@Subcommand("version")
public void execute(CommandSender src) {

View File

@ -36,7 +36,7 @@ public class CommandGiveBlocks extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("giveblocks")
@Description("Gives claim blocks to another player.")
@Description("%player-give-blocks")
@Syntax("<player> <amount>")
@Subcommand("giveblocks")
public void execute(Player src, OfflinePlayer targetPlayer, int amount) {

View File

@ -22,7 +22,7 @@ public class CommandGivePet extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("givepet")
@Description("Transfers a pet to a new owner.")
@Description("%player-give-pet")
@Syntax("<player>")
@Subcommand("givepet")
public void execute(Player player, OfflinePlayer newOwner) {

View File

@ -42,7 +42,7 @@
public class CommandHelp extends BaseCommand {
@HelpCommand
@Description("Displays GriefDefender command help.")
@Description("%help")
public void execute(CommandSender src) {
PaginationList.Builder paginationBuilder =
PaginationList.builder().title(TextComponent.of("Showing GriefDefender Help", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(GriefDefenderPlugin.helpComponents);

View File

@ -1018,11 +1018,15 @@ private static boolean validateCommandMapping(CommandSender src, String command,
Command commandMapping = NMSUtil.getInstance().getBukkitCommandMap().getCommand(command);
if (commandMapping == null) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PLUGIN_COMMAND_NOT_FOUND,
ImmutableMap.of(
"command", command,
"id", pluginId)));
return false;
// check mod command mapping
commandMapping = NMSUtil.getInstance().getModCommandMap().getCommand(command);
if (commandMapping == null) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PLUGIN_COMMAND_NOT_FOUND,
ImmutableMap.of(
"command", command,
"id", pluginId)));
return false;
}
}
return true;
}

View File

@ -75,7 +75,7 @@ public class CommandPlayerInfo extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("gdplayerinfo|playerinfo")
@Description("Gets information about a player.")
@Description("%player-info")
@Syntax("[<player>|<player> <world>]")
@Subcommand("player info")
public void execute(CommandSender src, @Optional String[] args) throws InvalidCommandArgument {

View File

@ -54,7 +54,7 @@
public class CommandRestoreClaim extends BaseCommand {
@CommandAlias("restoreclaim|claimrestore")
@Description("Restores claim to its natural state. Use with caution.")
@Description("%claim-restore")
@Subcommand("claim restore")
public void execute(Player player) {

View File

@ -48,7 +48,7 @@
public class CommandRestoreNature extends BaseCommand {
@CommandAlias("modenature")
@Description("Switches the shovel tool to restoration mode.")
@Description("%mode-nature")
@Subcommand("mode nature")
public void execute(Player player) {
if (true) {

View File

@ -54,7 +54,7 @@ public class CommandSetAccruedClaimBlocks extends BaseCommand {
@CommandCompletion("@gdplayers @gddummy")
@CommandAlias("scb|setaccruedblocks")
@Description("Updates a player's accrued claim block total.")
@Description("%player-set-accrued-blocks")
@Syntax("<player> <amount> [world]")
@Subcommand("player setaccruedblocks")
public void execute(CommandSender src, String player, int amount, @Optional String worldName) throws InvalidCommandArgument {

View File

@ -41,7 +41,7 @@
public class CommandTownChat extends BaseCommand {
@CommandAlias("townchat")
@Description("Toggles town chat.")
@Description("%town-chat")
@Subcommand("town chat")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -49,7 +49,7 @@
public class CommandTownTag extends BaseCommand {
@CommandAlias("towntag")
@Description("Sets the tag of your town.")
@Description("%town-tag")
@Syntax("<tag>")
@Subcommand("town tag")
public void execute(Player player, String tag) {

View File

@ -66,11 +66,7 @@ public class CommandTrustGroup extends BaseCommand {
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
@CommandAlias("trustgroup")
@Description("Grants a group access to your claim."
+ "\nAccessor: access to interact with all blocks except inventory."
+ "\nContainer: access to interact with all blocks including inventory."
+ "\nBuilder: access to everything above including ability to place and break blocks."
+ "\nManager: access to everything above including ability to manage claim settings.")
@Description("%trust-group")
@Syntax("<group> [<accessor|builder|container|manager>]")
@Subcommand("trust group")
public void execute(Player player, String groupName, @Optional String type) {

View File

@ -61,11 +61,7 @@ public class CommandTrustGroupAll extends BaseCommand {
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
@CommandAlias("trustallgroup")
@Description("Grants a group access to all your claims."
+ "\nAccessor: access to interact with all blocks except inventory."
+ "\nContainer: access to interact with all blocks including inventory."
+ "\nBuilder: access to everything above including ability to place and break blocks."
+ "\nManager: access to everything above including ability to manage claim settings.")
@Description("%trust-group-all")
@Syntax("<group> <accessor|builder|container|manager>")
@Subcommand("trustall group")
public void execute(Player player, String target, String type) {

View File

@ -67,7 +67,7 @@
public class CommandTrustList extends BaseCommand {
@CommandAlias("trustlist")
@Description("Manages trust for the claim you're standing in.")
@Description("%trust-list")
@Subcommand("trust list")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -64,11 +64,7 @@ public class CommandTrustPlayer extends BaseCommand {
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
@CommandAlias("trust")
@Description("Grants a player access to your claim."
+ "\nAccessor: access to interact with all blocks except inventory."
+ "\nContainer: access to interact with all blocks including inventory."
+ "\nBuilder: access to everything above including ability to place and break blocks."
+ "\nManager: access to everything above including ability to manage claim settings.")
@Description("%trust-player")
@Syntax("<player> [<accessor|builder|container|manager>]")
@Subcommand("trust player")
public void execute(Player player, String target, @Optional String type) {

View File

@ -64,11 +64,7 @@ public class CommandTrustPlayerAll extends BaseCommand {
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
@CommandAlias("trustall")
@Description("Grants a player access to all your claims."
+ "\nAccessor: access to interact with all blocks except inventory."
+ "\nContainer: access to interact with all blocks including inventory."
+ "\nBuilder: access to everything above including ability to place and break blocks."
+ "\nManager: access to everything above including ability to manage claim settings.")
@Description("%trust-player-all")
@Syntax("<player> <accessor|builder|container|manager>")
@Subcommand("trustall player")
public void execute(Player player, String target, @Optional String type) {

View File

@ -49,7 +49,6 @@
import com.griefdefender.event.GDGroupTrustClaimEvent;
import com.griefdefender.permission.GDPermissionGroup;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.Component;
import net.kyori.text.adapter.bukkit.TextAdapter;
@ -63,7 +62,7 @@ public class CommandUntrustGroup extends BaseCommand {
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
@CommandAlias("untrustgroup")
@Description("Revokes group access to your claim.")
@Description("%untrust-group")
@Syntax("<group> [<accessor|builder|container|manager>]")
@Subcommand("untrust group")
public void execute(Player player, String target, @Optional String type) {

View File

@ -63,7 +63,7 @@ public class CommandUntrustGroupAll extends BaseCommand {
@CommandCompletion("@gdgroups @gdtrusttypes @gddummy")
@CommandAlias("untrustallgroup")
@Description("Revokes group access to all your claims")
@Description("%untrust-group-all")
@Syntax("<group> [<accessor|builder|container|manager>]")
@Subcommand("untrustall group")
public void execute(Player player, String target, @Optional String type) {

View File

@ -64,7 +64,7 @@ public class CommandUntrustPlayer extends BaseCommand {
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
@CommandAlias("untrust|ut")
@Description("Revokes player access to your claim.")
@Description("%untrust-player")
@Syntax("<player> [<accessor|builder|container|manager>]")
@Subcommand("untrust player")
public void execute(Player player, String target, @Optional String type) {

View File

@ -64,7 +64,7 @@ public class CommandUntrustPlayerAll extends BaseCommand {
@CommandCompletion("@gdplayers @gdtrusttypes @gddummy")
@CommandAlias("untrustall")
@Description("Revokes player access to all your claims.")
@Description("%untrust-player-all")
@Syntax("<player> [<accessor|builder|container|manager>]")
@Subcommand("untrustall player")
public void execute(Player player, String target, @Optional String type) {

View File

@ -52,7 +52,7 @@ public class CommandAccessTrust extends BaseCommand {
@CommandCompletion("@gdplayers")
@CommandAlias("at|accesstrust")
@Description("Grants a player access to interact with all blocks except inventory.")
@Description("%trust-access")
@Syntax("<player>")
public void execute(Player src, String target) {

View File

@ -52,7 +52,7 @@ public class CommandContainerTrust extends BaseCommand {
@CommandCompletion("@gdplayers")
@CommandAlias("ct|containertrust")
@Description("Grants a player access to interact with all blocks including inventory.")
@Description("%trust-container")
@Syntax("<player>")
public void execute(Player src, String target) {

View File

@ -60,7 +60,7 @@
public class CommandTrapped extends BaseCommand {
@CommandAlias("trapped")
@Description("Teleports the player to a safe location if stuck and unable to build.")
@Description("%trapped")
@Subcommand("player trapped")
public void execute(Player player) {
final GameMode gameMode = player.getGameMode();

View File

@ -40,7 +40,7 @@
public class CommandUnlockDrops extends BaseCommand {
@CommandAlias("unlockdrops")
@Description("Allows other players to pickup any items dropped from death.")
@Description("%player-unlock-drops")
@Subcommand("player unlockdrops")
public void execute(Player player) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());

View File

@ -45,6 +45,16 @@ public class MessageDataConfig extends ConfigCategory {
@Setting("messages")
public Map<String, String> messageMap = new HashMap<>();
public Component getDescription(String message) {
String rawMessage = this.descriptionMap.get(message);
if (rawMessage == null) {
// Should never happen but in case it does, return empty
return TextComponent.empty();
}
return LegacyComponentSerializer.legacy().deserialize(rawMessage, '&');
}
public Component getMessage(String message) {
return this.getMessage(message, ImmutableMap.of());
}

View File

@ -48,46 +48,88 @@ public class MessageStorage {
public static MessageDataConfig MESSAGE_DATA;
// descriptions
public static String DESCRIPTION_ABANDON_ALL = "abandon-all";
public static String DESCRIPTION_ABANDON_CLAIM = "abandon-claim";
public static String DESCRIPTION_ABANDON_TOP = "abandon-top";
public static String DESCRIPTION_BUY_BLOCKS = "buy-blocks";
public static String DESCRIPTION_CALLBACK = "callback";
public static String DESCRIPTION_CLAIM_BANK = "claim-bank";
public static String DESCRIPTION_CLAIM_CLEAR = "claim-clear";
public static String DESCRIPTION_CLAIM_DEBUG = "claim-debug";
public static String DESCRIPTION_CLAIM_FAREWELL = "claim-farewell";
public static String DESCRIPTION_CLAIM_GREETING = "claim-greeting";
public static String DESCRIPTION_CLAIM_IGNORE = "claim-ignore";
public static String DESCRIPTION_CLAIM_INFO = "claim-info";
public static String DESCRIPTION_CLAIM_INHERIT = "claim-inherit";
public static String DESCRIPTION_CLAIM_LIST = "claim-list";
public static String DESCRIPTION_CLAIM_NAME = "claim-name";
public static String DESCRIPTION_CLAIM_RESTORE = "claim-restore";
public static String DESCRIPTION_CLAIM_SETSPAWN = "claim-setspawn";
public static String DESCRIPTION_CLAIM_SPAWN = "claim-spawn";
public static String DESCRIPTION_CLAIM_TRANSFER = "claim-transfer";
public static String DESCRIPTION_CLAIM_WORLDEDIT = "claim-worldedit";
public static String DESCRIPTION_CUBOID = "cuboid";
public static String DESCRIPTION_DEBUG = "debug";
public static String DESCRIPTION_DELETE_ALL = "delete-all";
public static String DESCRIPTION_DELETE_ALL_ADMIN = "delete-all-admin";
public static String DESCRIPTION_DELETE_CLAIM = "delete-claim";
public static String DESCRIPTION_DELETE_TOP = "delete-top";
public static String DESCRIPTION_FLAG_CLAIM = "flag-claim";
public static String DESCRIPTION_FLAG_GROUP = "flag-group";
public static String DESCRIPTION_FLAG_PLAYER = "flag-player";
public static String DESCRIPTION_FLAG_RESET = "flag-reset";
public static String DESCRIPTION_MODE_ADMIN = "mode-admin";
public static String DESCRIPTION_MODE_BASIC = "mode-basic";
public static String DESCRIPTION_MODE_NATURE = "mode-nature";
public static String DESCRIPTION_MODE_SUBDIVISION = "mode-subdivision";
public static String DESCRIPTION_MODE_TOWN = "mode-town";
public static String DESCRIPTION_OPTION_CLAIM = "option-claim";
public static String DESCRIPTION_PERMISSION_GROUP = "permission-group";
public static String DESCRIPTION_PERMISSION_PLAYER = "permission-player";
public static String DESCRIPTION_PLAYER_ADJUST_BONUS_BLOCKS = "player-adjust-bonus-blocks";
public static String DESCRIPTION_PLAYER_INFO = "player-info";
public static final String DESCRIPTION_ABANDON_ALL = "abandon-all";
public static final String DESCRIPTION_ABANDON_CLAIM = "abandon-claim";
public static final String DESCRIPTION_ABANDON_TOP = "abandon-top";
public static final String DESCRIPTION_ABANDON_WORLD = "abandon-world";
public static final String DESCRIPTION_BUY_BLOCKS = "buy-blocks";
public static final String DESCRIPTION_BUY_CLAIM = "buy-claim";
public static final String DESCRIPTION_CALLBACK = "callback";
public static final String DESCRIPTION_CLAIM_BAN = "claim-ban";
public static final String DESCRIPTION_CLAIM_BANK = "claim-bank";
public static final String DESCRIPTION_CLAIM_CLEAR = "claim-clear";
public static final String DESCRIPTION_CLAIM_CONTRACT = "claim-contract";
public static final String DESCRIPTION_CLAIM_CREATE = "claim-create";
public static final String DESCRIPTION_CLAIM_DEBUG = "claim-debug";
public static final String DESCRIPTION_CLAIM_EXPAND = "claim-expand";
public static final String DESCRIPTION_CLAIM_FAREWELL = "claim-farewell";
public static final String DESCRIPTION_CLAIM_GREETING = "claim-greeting";
public static final String DESCRIPTION_CLAIM_IGNORE = "claim-ignore";
public static final String DESCRIPTION_CLAIM_INFO = "claim-info";
public static final String DESCRIPTION_CLAIM_INHERIT = "claim-inherit";
public static final String DESCRIPTION_CLAIM_INVESTIGATE = "claim-investigate";
public static final String DESCRIPTION_CLAIM_LIST = "claim-list";
public static final String DESCRIPTION_CLAIM_NAME = "claim-name";
public static final String DESCRIPTION_CLAIM_RENT = "claim-rent";
public static final String DESCRIPTION_CLAIM_RESERVE = "claim-reserve";
public static final String DESCRIPTION_CLAIM_RESTORE = "claim-restore";
public static final String DESCRIPTION_CLAIM_SETSPAWN = "claim-setspawn";
public static final String DESCRIPTION_CLAIM_SPAWN = "claim-spawn";
public static final String DESCRIPTION_CLAIM_TAX = "claim-tax";
public static final String DESCRIPTION_CLAIM_TOOL = "claim-tool";
public static final String DESCRIPTION_CLAIM_TRANSFER = "claim-transfer";
public static final String DESCRIPTION_CLAIM_UNBAN = "claim-unban";
public static final String DESCRIPTION_CLAIM_WORLDEDIT = "claim-worldedit";
public static final String DESCRIPTION_CONFIRM = "confirm";
public static final String DESCRIPTION_CUBOID = "cuboid";
public static final String DESCRIPTION_DEBUG = "debug";
public static final String DESCRIPTION_DELETE_ALL = "delete-all";
public static final String DESCRIPTION_DELETE_ALL_ADMIN = "delete-all-admin";
public static final String DESCRIPTION_DELETE_CLAIM = "delete-claim";
public static final String DESCRIPTION_DELETE_TOP = "delete-top";
public static final String DESCRIPTION_ECONOMY_BLOCK_TRANSFER = "economy-block-transfer";
public static final String DESCRIPTION_FLAG_CLAIM = "flag-claim";
public static final String DESCRIPTION_FLAG_GROUP = "flag-group";
public static final String DESCRIPTION_FLAG_PLAYER = "flag-player";
public static final String DESCRIPTION_FLAG_RESET = "flag-reset";
public static final String DESCRIPTION_HELP = "help";
public static final String DESCRIPTION_MODE_ADMIN = "mode-admin";
public static final String DESCRIPTION_MODE_BASIC = "mode-basic";
public static final String DESCRIPTION_MODE_CLAIM = "mode-claim";
public static final String DESCRIPTION_MODE_NATURE = "mode-nature";
public static final String DESCRIPTION_MODE_SUBDIVISION = "mode-subdivision";
public static final String DESCRIPTION_MODE_TOWN = "mode-town";
public static final String DESCRIPTION_OPTION_CLAIM = "option-claim";
public static final String DESCRIPTION_OPTION_GROUP = "option-group";
public static final String DESCRIPTION_OPTION_PLAYER = "option-player";
public static final String DESCRIPTION_PERMISSION_GROUP = "permission-group";
public static final String DESCRIPTION_PERMISSION_PLAYER = "permission-player";
public static final String DESCRIPTION_PLAYER_ADJUST_BONUS_BLOCKS = "player-adjust-bonus-blocks";
public static final String DESCRIPTION_PLAYER_ADJUST_BONUS_BLOCKS_ALL = "player-adjust-bonus-blocks-all";
public static final String DESCRIPTION_PLAYER_GIVE_BLOCKS = "player-give-blocks";
public static final String DESCRIPTION_PLAYER_GIVE_PET = "player-give-pet";
public static final String DESCRIPTION_PLAYER_INFO = "player-info";
public static final String DESCRIPTION_PLAYER_SET_ACCRUED_BLOCKS = "player-set-accrued-blocks";
public static final String DESCRIPTION_PLAYER_UNLOCK_DROPS = "player-unlock-drops";
public static final String DESCRIPTION_RELOAD = "reload";
public static final String DESCRIPTION_SCHEMATIC = "schematic";
public static final String DESCRIPTION_SELL_BLOCKS = "sell-blocks";
public static final String DESCRIPTION_SELL_CLAIM = "sell-claim";
public static final String DESCRIPTION_TOWN_CHAT = "town-chat";
public static final String DESCRIPTION_TOWN_TAG = "town-tag";
public static final String DESCRIPTION_TRAPPED = "trapped";
public static final String DESCRIPTION_TRUST_ACCESS = "trust-access";
public static final String DESCRIPTION_TRUST_CONTAINER = "trust-container";
public static final String DESCRIPTION_TRUST_GROUP = "trust-group";
public static final String DESCRIPTION_TRUST_GROUP_ALL = "trust-group-all";
public static final String DESCRIPTION_TRUST_LIST = "trust-list";
public static final String DESCRIPTION_TRUST_PLAYER = "trust-player";
public static final String DESCRIPTION_TRUST_PLAYER_ALL = "trust-player-all";
public static final String DESCRIPTION_UNTRUST_GROUP = "untrust-group";
public static final String DESCRIPTION_UNTRUST_GROUP_ALL = "untrust-group-all";
public static final String DESCRIPTION_UNTRUST_PLAYER = "untrust-player";
public static final String DESCRIPTION_UNTRUST_PLAYER_ALL = "untrust-player-all";
public static final String DESCRIPTION_VERSION = "version";
// messages with parameters
public static final String ABANDON_ALL_WARNING_WORLD = "abandon-all-warning-world";
@ -123,6 +165,8 @@ public class MessageStorage {
public static final String CLAIM_MODE_START = "claim-mode-start";
public static final String CLAIM_NAME = "claim-name";
public static final String CLAIM_OWNER_ONLY = "claim-owner-only";
public static final String CLAIM_PREFIX_ENTER = "claim-prefix-enter";
public static final String CLAIM_PREFIX_EXIT = "claim-prefix-enter";
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";

View File

@ -0,0 +1,39 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration.category;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ContextCategory extends ConfigCategory {
@Setting(value = "player-equipment", comment = "Whether player equipment contexts should be applied during permission checks. (Default: true)")
public boolean playerEquipment = true;
@Setting(value = "potion-effects", comment = "Whether potion effect contexts should be applied during permission checks. (Default: true)")
public boolean potionEffects = true;
@Setting(value = "enchantments", comment = "Whether item enchantment contexts should be applied during permission checks. (Default: false)")
public boolean enchantments = false;
}

View File

@ -38,7 +38,7 @@ public class EconomyCategory extends ConfigCategory {
+ "\nNote: Using this mode disables the '/buyblocks' command as claim creation will pull funds directly from a player's economy balance."
+ "\nNote: If players have existing claimblocks from past configurations, an admin must use the '/ecomigrateblocks' command to convert remainder to currency.")
public boolean economyMode = false;
@Setting(value = "use-claim-block-task", comment = "Claim blocks earned will be converted to economy based on 'claim-block-cost'."
@Setting(value = "use-claim-block-task", comment = "Claim blocks earned will be converted to economy based on 'economy-block-cost'."
+ "\n(Default: false)\nNote: This setting can only be used if 'economy-mode' is true.")
public boolean useClaimBlockTask = false;
@Setting(value = "bank-system", comment = "Whether to enable the bank system for claims. Set to true to enable.")
@ -70,8 +70,8 @@ public class EconomyCategory extends ConfigCategory {
public int rentDelinquentApplyHour = 0;
@Setting(value = "rent-transaction-log-limit", comment = "The amount of transactions to keep for history. Default: 60")
public int rentTransactionLogLimit = 60;
@Setting(value = "sign-update-interval", comment = "The interval in minutes for updating sign data. Default: 5. Set to 0 to disable.")
public int signUpdateInterval = 5;
@Setting(value = "sign-update-interval", comment = "The interval in minutes for updating sign data. Default: 1. Set to 0 to disable.")
public int signUpdateInterval = 1;
@Setting(value = "tax-transaction-log-limit", comment = "The amount of transactions to keep for history. Default: 60")
public int taxTransactionLogLimit = 60;
@Setting(value = "tax-apply-hour", comment = "The specific hour in day to apply tax to all claims. Note: This uses military time and accepts values between 0-23. Default: 0")

View File

@ -52,8 +52,12 @@ public class ModCategory {
+ "\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 Map<String, String> modIdMap = new HashMap<>();
@Setting(value = "block-id-convert-list", comment = "Used to override generic block id's to their actual id during TE and item usage if available. Add the target block id to list if you want to force a conversion when detected."
+ "\nNote: This is useful for mods such as IC2 which uses the generic id 'ic2:te' for its multi-block.")
public List<String> blockIdConvertList = new ArrayList<>();
public ModCategory() {
this.blockIdConvertList.add("ic2:te");
this.fakePlayerIdentifiers.add("41C82C87-7AfB-4024-BA57-13D2C99CAE77"); // Forge FakePlayer
this.fakePlayerIdentifiers.add("BFC3377F-C3C9-3382-9DA6-79B50A9AFE57"); // OpenMods
this.fakePlayerIdentifiers.add("0D0C4CA0-4FF1-11E4-916C-0800200C9A66"); // ComputerCraft
@ -77,6 +81,13 @@ public boolean isFakePlayer(Player player) {
return false;
}
public boolean convertBlockId(String id) {
if (this.blockIdConvertList.contains(id)) {
return true;
}
return false;
}
public String getModId(String clazz) {
for (Entry<String, String> entry : this.modIdMap.entrySet()) {
final String modPackage = entry.getKey();

View File

@ -25,6 +25,7 @@
package com.griefdefender.configuration.type;
import com.griefdefender.configuration.category.GuiCategory;
import com.griefdefender.configuration.category.ContextCategory;
import com.griefdefender.configuration.category.DynmapCategory;
import com.griefdefender.configuration.category.MessageCategory;
import com.griefdefender.configuration.category.MigratorCategory;
@ -36,6 +37,8 @@
public class GlobalConfig extends ConfigBase {
@Setting
public ContextCategory context = new ContextCategory();
@Setting
public DynmapCategory dynmap = new DynmapCategory();
@Setting

View File

@ -64,6 +64,10 @@ public EventCause getCurrentCause() {
public GDCauseStackManager pushCause(Object obj) {
checkNotNull(obj, "obj");
if (NMSUtil.getInstance().getRunningServerTicks() != tick_stored) {
this.cached_cause = null;
this.cause.clear();
}
if (obj instanceof OfflinePlayer) {
obj = PermissionHolderCache.getInstance().getOrCreateUser((OfflinePlayer) obj);
}

View File

@ -36,6 +36,7 @@
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.option.GDOptions;
@ -158,7 +159,13 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
pluginId = pluginCommand.getPlugin().getName().toLowerCase();
}
if (pluginId == null) {
pluginId = "minecraft";
// check modId for hybrid servers
final String modId = NMSUtil.getInstance().getCommandModId(command);
if (modId != null) {
pluginId = modId;
} else {
pluginId = "minecraft";
}
}
}

View File

@ -190,14 +190,16 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
TextComponent welcomeMessage = (TextComponent) gpEvent.getEnterMessage().orElse(null);
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty()) && !fromClaim.isParent(toClaim)) {
ChatType chatType = gpEvent.getEnterMessageChatType();
final Component enterPrefix = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_PREFIX_ENTER, ImmutableMap.of(
"owner", toClaim.getOwnerDisplayName()));
if (chatType == ChatTypes.ACTION_BAR) {
TextAdapter.sendActionBar(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? enterPrefix : TextComponent.empty())
.append(welcomeMessage)
.build());
} else {
TextAdapter.sendComponent(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? enterPrefix : TextComponent.empty())
.append(welcomeMessage)
.build());
}
@ -206,14 +208,16 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
Component farewellMessage = gpEvent.getExitMessage().orElse(null);
if (farewellMessage != null && !farewellMessage.equals(TextComponent.empty()) && !toClaim.isParent(fromClaim)) {
ChatType chatType = gpEvent.getExitMessageChatType();
final Component exitPrefix = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_PREFIX_EXIT, ImmutableMap.of(
"owner", fromClaim.getOwnerDisplayName()));
if (chatType == ChatTypes.ACTION_BAR) {
TextAdapter.sendActionBar(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? exitPrefix : TextComponent.empty())
.append(farewellMessage)
.build());
} else {
TextAdapter.sendComponent(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? exitPrefix : TextComponent.empty())
.append(farewellMessage)
.build());
}
@ -293,14 +297,16 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
Component welcomeMessage = gpEvent.getEnterMessage().orElse(null);
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty()) && !fromClaim.isParent(toClaim)) {
ChatType chatType = gpEvent.getEnterMessageChatType();
final Component enterPrefix = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_PREFIX_ENTER, ImmutableMap.of(
"owner", toClaim.getOwnerDisplayName()));
if (chatType == ChatTypes.ACTION_BAR) {
TextAdapter.sendActionBar(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? enterPrefix : TextComponent.empty())
.append(welcomeMessage)
.build());
} else {
TextAdapter.sendComponent(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? enterPrefix : TextComponent.empty())
.append(welcomeMessage)
.build());
}
@ -309,14 +315,16 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
Component farewellMessage = gpEvent.getExitMessage().orElse(null);
if (farewellMessage != null && !farewellMessage.equals(TextComponent.empty()) && !toClaim.isParent(fromClaim)) {
ChatType chatType = gpEvent.getExitMessageChatType();
final Component exitPrefix = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_PREFIX_EXIT, ImmutableMap.of(
"owner", fromClaim.getOwnerDisplayName()));
if (chatType == ChatTypes.ACTION_BAR) {
TextAdapter.sendActionBar(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? exitPrefix : TextComponent.empty())
.append(farewellMessage)
.build());
} else {
TextAdapter.sendComponent(player, TextComponent.builder("")
.append(showGpPrefix ? GriefDefenderPlugin.GD_TEXT : TextComponent.empty())
.append(showGpPrefix ? exitPrefix : TextComponent.empty())
.append(farewellMessage)
.build());
}

View File

@ -77,6 +77,7 @@
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@ -95,6 +96,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent;
@ -139,9 +141,6 @@ public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
}
final Block block = event.getBlock();
if (block.isEmpty()) {
return;
}
final World world = event.getBlock().getWorld();
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
return;
@ -304,6 +303,25 @@ public void onVehicleDestroy(VehicleDestroyEvent event) {
GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(PotionSplashEvent event) {
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
final ThrownPotion thrownPotion = event.getEntity();
if (event.getAffectedEntities().isEmpty()) {
return;
}
for (LivingEntity entity : event.getAffectedEntities()) {
if (protectEntity(event, thrownPotion, entity)) {
event.setIntensity(entity, 0);
}
}
if (event.getAffectedEntities().isEmpty()) {
event.setCancelled(true);
}
GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityCombustByBlockEvent event) {
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
@ -353,8 +371,16 @@ public void onHangingBreakEvent(HangingBreakByEntityEvent event) {
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player) {
final Player player = (Player) event.getDamager();
Object source = event.getDamager();
if (source instanceof Projectile) {
final Projectile projectile = (Projectile) event.getDamager();
final ProjectileSource projectileSource = projectile.getShooter();
if (projectileSource != null) {
source = projectileSource;
}
}
if (source instanceof Player) {
final Player player = (Player) source;
GDCauseStackManager.getInstance().pushCause(player);
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
// check give pet
@ -461,10 +487,16 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
GDPermissionUser user = null;
if (source instanceof Player && targetUser != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(((Player) source).getUniqueId());
if (user.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, user, targetUser);
}
if (user == null && source instanceof ThrownPotion) {
final GDEntity gdEntity = EntityTracker.getCachedEntity(((ThrownPotion) source).getEntityId());
if (gdEntity != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
}
}
if (user != null && user.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, source, user, targetUser);
}
Flag flag = Flags.ENTITY_DAMAGE;
ProjectileSource projectileSource = null;
@ -485,7 +517,7 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
if (owner != null && targetUser != null && !owner.equals(targetUser.getUniqueId())) {
final GDPermissionUser sourceUser = PermissionHolderCache.getInstance().getOrCreateUser(owner);
if (sourceUser.getOnlinePlayer() != null && targetUser.getOnlinePlayer() != null) {
return this.getPvpProtectResult(event, claim, sourceUser, targetUser);
return this.getPvpProtectResult(event, claim, source, sourceUser, targetUser);
}
}
@ -581,57 +613,56 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
return false;
}
private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser source, GDPermissionUser target) {
private boolean getPvpProtectResult(Event event, GDClaim claim, Object source, GDPermissionUser sourceUser, GDPermissionUser targetUser) {
if (!GriefDefenderPlugin.getActiveConfig(claim.getWorldUniqueId()).getConfig().pvp.enabled) {
return false;
}
final Player sourcePlayer = source.getOnlinePlayer();
final Player targetPlayer = target.getOnlinePlayer();
final boolean sourceInCombat = source.getInternalPlayerData().inPvpCombat();
final boolean targetInCombat = target.getInternalPlayerData().inPvpCombat();
final Player sourcePlayer = sourceUser.getOnlinePlayer();
final Player targetPlayer = targetUser.getOnlinePlayer();
final boolean sourceInCombat = sourceUser.getInternalPlayerData().inPvpCombat();
final boolean targetInCombat = targetUser.getInternalPlayerData().inPvpCombat();
final GameMode sourceGameMode = sourcePlayer.getGameMode();
if (sourceGameMode == GameMode.CREATIVE && !source.getInternalPlayerData().canIgnoreClaim(claim) && !sourcePlayer.hasPermission(GDPermissions.BYPASS_PVP_CREATIVE)) {
if (sourceGameMode == GameMode.CREATIVE && !sourceUser.getInternalPlayerData().canIgnoreClaim(claim) && !sourcePlayer.hasPermission(GDPermissions.BYPASS_PVP_CREATIVE)) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_SOURCE_CREATIVE_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp-creative-disabled", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp-creative-disabled", Tristate.FALSE);
return true;
}
// Always check if source or target is in combat and if so allow PvP
// This prevents a player from moving to another claim where PvP is disabled
if (sourceInCombat && targetInCombat && (source.getInternalPlayerData().lastPvpTimestamp == target.getInternalPlayerData().lastPvpTimestamp)) {
if (sourceInCombat && targetInCombat && (sourceUser.getInternalPlayerData().lastPvpTimestamp == targetUser.getInternalPlayerData().lastPvpTimestamp)) {
final Instant now = Instant.now();
source.getInternalPlayerData().lastPvpTimestamp = now;
target.getInternalPlayerData().lastPvpTimestamp = now;
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp-combat", Tristate.TRUE);
sourceUser.getInternalPlayerData().lastPvpTimestamp = now;
targetUser.getInternalPlayerData().lastPvpTimestamp = now;
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp-combat", Tristate.TRUE);
return false;
}
// Check world pvp setting
if (!claim.getWorld().getPVP()) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_CLAIM_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp-world-disabled", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp-world-disabled", Tristate.FALSE);
return true;
}
final GDClaim sourceClaim = this.baseStorage.getClaimAt(sourcePlayer.getLocation());
// Check flags
Tristate sourceResult = GDPermissionManager.getInstance().getFinalPermission(event, sourcePlayer.getLocation(), sourceClaim, Flags.ENTITY_DAMAGE, sourcePlayer, targetPlayer, sourcePlayer, true);
Tristate targetResult = GDPermissionManager.getInstance().getFinalPermission(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE, targetPlayer, sourcePlayer, targetPlayer, true);
Tristate sourceResult = GDPermissionManager.getInstance().getFinalPermission(event, sourcePlayer.getLocation(), sourceClaim, Flags.ENTITY_DAMAGE, source, targetPlayer, sourcePlayer, true);
if (sourceResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_SOURCE_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp-source", Tristate.FALSE);
return true;
}
Tristate targetResult = GDPermissionManager.getInstance().getFinalPermission(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE, source, sourcePlayer, targetPlayer, true);
if (targetResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_TARGET_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp-source", Tristate.FALSE);
return true;
}
// Check options
if (GDOptions.PVP) {
sourceResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), source, Options.PVP, sourceClaim);
targetResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), target, Options.PVP, claim);
sourceResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), sourceUser, Options.PVP, sourceClaim);
targetResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), targetUser, Options.PVP, claim);
}
if (sourceResult == Tristate.UNDEFINED) {
sourceResult = Tristate.fromBoolean(sourceClaim.getWorld().getPVP());
@ -641,19 +672,19 @@ private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser
}
if (sourceResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_SOURCE_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), sourceClaim, Options.PVP.getPermission(), source, targetPlayer, source, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), sourceClaim, Options.PVP.getPermission(), source, targetPlayer, sourceUser, "pvp", Tristate.FALSE);
return true;
}
if (targetResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_TARGET_NOT_ALLOWED);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Options.PVP.getPermission(), source, targetPlayer, source, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Options.PVP.getPermission(), source, targetPlayer, sourceUser, "pvp", Tristate.FALSE);
return true;
}
final Instant now = Instant.now();
source.getInternalPlayerData().lastPvpTimestamp = now;
target.getInternalPlayerData().lastPvpTimestamp = now;
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp", Tristate.TRUE);
sourceUser.getInternalPlayerData().lastPvpTimestamp = now;
targetUser.getInternalPlayerData().lastPvpTimestamp = now;
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, sourceUser, "pvp", Tristate.TRUE);
return false;
}

View File

@ -992,7 +992,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
// Cancel event if player is unable to teleport during PvP combat
final boolean pvpCombatTeleport = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), player, Options.PVP_COMBAT_TELEPORT, sourceClaim);
if (!pvpCombatTeleport) {
final int combatTimeRemaining = playerData.getPvpCombatTimeRemaining();
final int combatTimeRemaining = playerData.getPvpCombatTimeRemaining(sourceClaim);
if (combatTimeRemaining > 0) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PVP_IN_COMBAT_NOT_ALLOWED,
ImmutableMap.of(

Some files were not shown because too many files have changed in this diff Show More