1.3.1 Update

* Fix wrong type being displaying in /claiminfo.
* Fix claim teleport in nether.
* Fix claim visuals in/out of liquids.
* Fix inventory check on interaction.
* Fix walkspeed, gamemode, and weather options not resetting back to default on claim exit.
* Fix option gui not displaying decimals for doubles.
* Fix entity dupe on schematic restore.
* Fix claim schematic creation dates on load.
* Fix wither causing damage when spawned by players.
* Fix ice/snow form flags.
* Fix visuals not showing on snow.
* Fix inability to attack tameable entities with no owner.
* Fix claim cleanup task exiting prematurely.
* Fix scaffolding not breaking fully.
* Fix Flag GUI preset/advanced translations.
* Fix '/cog <group>' not displaying options for group.
* Fix option GUI toggle value hover.
* Fix block burn across blocks not triggering block-spread.
* Fix monsters such as phantom and ghast not being ignored during entity-damage checks.
* Fixed tamed entity protection when source is not entity.
* Fix snow-melt showing up as block-modify instead of block-break
* Fix player buckets not checking place or break.
* Fix 'fire-spread' and 'vehicle-use' flag definitions.
* Fix NPE when changing claim type
* Fix visuals loading unloaded chunks.
* Fix player options not being set while in claim.
* Fix isTileInventory check.
* Fix user playerdata in PlaceHolderProvider.
* Fix claim resize exploit.
* Fix flag definitions GUI not showing inheritance values.
* Fix entity explosion getting wrong user sometimes.
* Fix tracking data not always being saved.
* Fix #crops tag not working.
* Fix tnt chain explosions.
* Add 'player-fly-speed' option.
* Add support for decimal values in option GUI.
* Add missing translation when deleting all player claims.
* Add restore claim in progress message.
* Add pl_PL language support. Thanks to Maul for contribution
* Add permission 'griefdefender.admin.bypass.pvp-creative' to bypass pvp creative protection.
* Add permission 'griefdefender.user.claim.rent.base' for new '/claimrent' command.
* Add permission 'griefdefender.user.claim.rent.sign' to control rent sign usage.
* Add permission 'griefdefender.user.claim.sell.sign' to control sell sign usage.
* Add flag definition 'turtle-egg-hatch'
* Add flag definition 'falling-block-break' .
* Add flag definition 'fire-entity-damage'.
* Add flag/option enable control to respective configs.
* Add group context support for flag definitions.
* Add new context gd_claim_default=user and gd_claim_override=user which applies to all claim types except wilderness and admin.
* Add owner override support with gd_claim_override=claim context. You can use this context to have owners be affected in claims. They also have the ability to toggle these.
* Add villager-trade and villager-farm definitions.
* Add /claimtax command.
* Add /claimrent command.
  Note: To create a rental via command
  ex. /claimrent 10h - creates rental for $10 per hour
  ex. /claimrent 10h 5 - creates rental for $10 per hour w/ max 5 days.
* Add claim restore functionality for 1.14+ servers.
  Note: To restore a claim, use /claimrestore
* Add toggle support for isExpired in /claiminfo
* Add Rent/Sell signs.
* Add item frame rotation protection.
* Add support for 'AsyncWorldEdit'.
* Add /claimrent command for displaying rentable claims.
* Add PvP config to manage pvp control.
* Add PvP protection when flying during PvP.
* Add PvP protection when in creative mode.
* Add override support for options.
* Add gd_claim_override=claim support for /cf command.
* Add entity-damage logs for monster damage.
* Add tracking support for piston item spawns.
* Add client visual queue to avoid sending too much traffic in a single tick. Default 12 block changes per tick.
  See 'client-visuals-per-tick' in global.conf to change.
* Add 'filler-spacing' to visual config. Default 10
* Add explosion surface blacklists for block/entities.
* Add new flag 'inventory-item-move'
* Add falling block tracking.
* Add rent-schematic-restore-admin for controlling rent restores in admin claims.
* Add explosion-cancel-block-limit for controlling explosion block size limit in devents.
* Enhance claim visual functionality.
* Refactor visual backend to be more efficient with server resources.
* Ensure block transactions are never sent more than once to client during a single visual update.
* Further enhance visual functionality with left/right clicks.
* Improve '/gddebug' by adding a fully functional filter.
  Ex. '/gddebug record creeper' would show all actions with creeper.
  Ex. '/gddebug record claim' will show only claim you are standing in.
* Cleanup option permission lookups.
* Implement visual API.
* Improve claim getChunks call.
* Improve context display in debug paste.
* Allow renters to interact with living entities.
* Allow bank/tax systems to be used separately.
* Allow pistons to be protected in wilderness.
* Confirm buttons will now be invalidated after first click.
* Deny owner item spawns in claim that is rented and can restore.
* Deny '/giveblocks' on self.
* Check max accrued blocks during /giveblocks.
* Only adjust accrued blocks when using /giveblocks.
* Optimize tracking data saves.
* Force last active date save on player login.
* Ignore drowning damage.
* Move 'pvp' user definition to admin.
* Change 'player-health-regen' option default to 0.
* Change 'player-walk-speed' option default to 0.
* Change 'tax-rate' option default to 0.1
* Change 'fall-entity-damage' to global default context.
* Change 'fall-player-damage' to global default context.
This commit is contained in:
bloodshot 2020-06-05 19:26:14 -04:00
parent 53176a7f90
commit 61a9d8efd1
275 changed files with 14549 additions and 8831 deletions

@ -1 +1 @@
Subproject commit f70078d269283943ca65c20fe16c7650050932ee
Subproject commit 33bd795ad41a886b58066b3d82759b7d1f89b854

View File

@ -27,11 +27,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.checkerframework.checker.nullness.qual.Nullable;
import com.google.common.collect.ImmutableList;
import com.google.inject.Singleton;
@ -44,8 +44,8 @@
import com.griefdefender.api.claim.ClaimManager;
import com.griefdefender.api.data.PlayerData;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.provider.WorldEditProvider;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.storage.BaseStorage;
@Singleton
@ -68,7 +68,7 @@ public boolean isEconomyModeEnabled() {
@Override
public boolean isProtectionModuleEnabled(Flag flag) {
return GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(flag.toString());
return GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(flag.toString());
}
@Override
@ -81,6 +81,37 @@ public Optional<PlayerData> getPlayerData(UUID worldUniqueId, UUID playerUniqueI
return Optional.ofNullable(GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(worldUniqueId, playerUniqueId));
}
@Override
public @Nullable Claim getClaim(UUID uuid) {
for (World world : Bukkit.getServer().getWorlds()) {
final ClaimManager claimManager = this.getClaimManager(world.getUID());
if (claimManager == null) {
continue;
}
if (claimManager.getWildernessClaim().getUniqueId().equals(uuid)) {
return claimManager.getWildernessClaim();
}
for (Claim claim : claimManager.getWorldClaims()) {
if (claim.getUniqueId().equals(uuid)) {
return claim;
}
}
}
return null;
}
@Override
public List<Claim> getAllClaims() {
List<Claim> claimList = new ArrayList<>();
for (World world : Bukkit.getServer().getWorlds()) {
claimList.addAll(this.getClaimManager(world.getUID()).getWorldClaims());
}
return ImmutableList.copyOf(claimList);
}
@Override
public List<Claim> getAllPlayerClaims(UUID playerUniqueId) {
List<Claim> claimList = new ArrayList<>();
@ -117,4 +148,9 @@ public User getUser(UUID uuid) {
public Group getGroup(String name) {
return PermissionHolderCache.getInstance().getOrCreateGroup(name);
}
@Override
public @Nullable WorldEditProvider getWorldEditProvider() {
return GriefDefenderPlugin.getInstance().getWorldEditProvider();
}
}

View File

@ -36,11 +36,12 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.zip.GZIPOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.google.common.collect.ImmutableMap;
@ -48,7 +49,10 @@
import com.google.gson.JsonObject;
import com.griefdefender.api.Tristate;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.util.HttpClient;
import net.kyori.text.Component;
@ -77,11 +81,30 @@ public class GDDebugData {
private final List<String> records;
private final long startTime = System.currentTimeMillis();
private boolean verbose;
private OfflinePlayer target;
private GDPermissionUser user;
private String filter;
private UUID claimUniqueId;
public GDDebugData(CommandSender source, OfflinePlayer target, boolean verbose) {
public GDDebugData(CommandSender source, String filter, boolean verbose) {
this.source = source;
this.target = target;
if (filter != null) {
if (!filter.equalsIgnoreCase("claim")) {
this.user = PermissionHolderCache.getInstance().getOrCreateUser(filter);
if (this.user == null) {
this.filter = filter;
} else {
this.filter = this.user.getName();
}
} else {
if (source instanceof Player) {
final Player player = (Player) source;
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation());
this.claimUniqueId = claim.getUniqueId();
this.filter = claim.getUniqueId().toString();
}
}
}
this.verbose = verbose;
this.records = new ArrayList<>();
this.header = new ArrayList<>();
@ -100,7 +123,12 @@ public GDDebugData(CommandSender source, OfflinePlayer target, boolean verbose)
this.header.add("| LuckPerms Version | " + version);
}
}
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_USER) + " | " + (this.target == null ? "ALL" : this.target.getName()) + "|");
if (this.claimUniqueId != null) {
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_CLAIM) + " | " + this.claimUniqueId.toString() + "|");
} else if (this.filter != null) {
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_FILTER) + " | " + filter + "|");
}
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_USER) + " | " + (this.user == null ? PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().TITLE_ALL) : this.user.getName()) + "|");
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_RECORD_START) + " | " + DATE_FORMAT.format(new Date(this.startTime)) + "|");
}
@ -114,7 +142,12 @@ public void addRecord(String flag, String trust, String source, String target, S
.append("Pasting output...", TextColor.GREEN).build());
this.pasteRecords();
this.records.clear();
GriefDefenderPlugin.debugActive = false;
if (this.user != null) {
GriefDefenderPlugin.getInstance().getDebugUserMap().remove(this.user.getName());
}
if (GriefDefenderPlugin.getInstance().getDebugUserMap().isEmpty()) {
GriefDefenderPlugin.debugActive = false;
}
TextAdapter.sendComponent(this.source, TextComponent.builder("").append(GD_TEXT).append("Debug ", TextColor.GRAY).append("OFF", TextColor.RED).build());
}
}
@ -123,22 +156,22 @@ public CommandSender getSource() {
return this.source;
}
public OfflinePlayer getTarget() {
return this.target;
public GDPermissionUser getUser() {
return this.user;
}
public String getFilter() {
return this.filter;
}
public UUID getClaimUniqueId() {
return this.claimUniqueId;
}
public boolean isRecording() {
return !this.verbose;
}
public void setTarget(OfflinePlayer user) {
this.target = user;
}
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
public void pasteRecords() {
if (this.records.isEmpty()) {
TextAdapter.sendComponent(this.source, MessageCache.getInstance().DEBUG_NO_RECORDS);
@ -194,6 +227,10 @@ public void pasteRecords() {
.clickEvent(ClickEvent.openUrl(jUrl.toString())).build());
}
public void stop() {
this.records.clear();
}
private static String postContent(String content) throws IOException {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
try (GZIPOutputStream writer = new GZIPOutputStream(byteOut)) {

View File

@ -28,14 +28,17 @@
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@ -54,19 +57,20 @@
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.api.permission.option.type.CreateModeType;
import com.griefdefender.api.permission.option.type.CreateModeTypes;
import com.griefdefender.api.permission.option.type.GameModeType;
import com.griefdefender.api.permission.option.type.GameModeTypes;
import com.griefdefender.cache.EventResultCache;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.PlayerStorageData;
import com.griefdefender.internal.block.BlockSnapshot;
import com.griefdefender.internal.block.BlockTransaction;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.provider.VaultProvider;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.PermissionUtil;
@ -85,23 +89,21 @@ public class GDPlayerData implements PlayerData {
public Location lastShovelLocation;
public Location endShovelLocation;
public Location lastValidInspectLocation;
public Location lastNonAirInspectLocation;
public boolean claimMode = false;
public ShovelType shovelMode = ShovelTypes.BASIC;
public GDClaim claimResizing;
public GDClaim claimSubdividing;
public List<BlockTransaction> visualBlocks = new ArrayList<>();
public UUID visualClaimId;
public Map<UUID, BukkitTask> claimVisualRevertTasks = new HashMap<>();
public Map<UUID, List<BlockTransaction>> visualClaimBlocks = new HashMap<>();
public List<BlockSnapshot> queuedVisuals = new ArrayList<>();
public UUID tempVisualUniqueId = null;
public UUID petRecipientUniqueId;
public BukkitTask visualRevertTask;
private final VaultProvider vaultProvider = GriefDefenderPlugin.getInstance().getVaultProvider();
public boolean ignoreClaims = false;
public boolean debugClaimPermissions = false;
public WeakReference<GDClaim> lastClaim = new WeakReference<>(null);
public boolean inTown = false;
public boolean townChat = false;
public List<Component> chatLines = new ArrayList<>();
@ -124,6 +126,9 @@ public class GDPlayerData implements PlayerData {
public boolean allowFlight = false;
public boolean ignoreFallDamage = false;
public boolean inLiquid = false;
public GameModeType lastGameMode = GameModeTypes.UNDEFINED;
// teleport data
public int teleportDelay = 0;
@ -135,7 +140,6 @@ public class GDPlayerData implements PlayerData {
// cached global option values
public int minClaimLevel;
private CreateModeType optionClaimCreateMode;
private Integer optionMaxAccruedBlocks;
// cached permission values
public boolean canManageAdminClaims = false;
@ -153,6 +157,7 @@ public class GDPlayerData implements PlayerData {
public boolean dataInitialized = false;
public boolean showVisualFillers = true;
public boolean showNoClaimsFoundMessage = true;
public boolean useRestoreSchematic = false;
private boolean checkedDimensionHeight = false;
@ -215,9 +220,13 @@ public void refreshPlayerOptions() {
});
}
public String getPlayerName() {
@Override
public String getName() {
if (this.playerName == null) {
GDPermissionUser user = this.playerSubject.get();
GDPermissionUser user = null;
if (this.playerSubject != null) {
user = this.playerSubject.get();
}
if (user == null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(this.playerID);
}
@ -232,27 +241,78 @@ public String getPlayerName() {
return this.playerName;
}
public void revertActiveVisual(Player player) {
if (this.visualRevertTask != null) {
this.visualRevertTask.cancel();
this.visualRevertTask = null;
@Override
public void revertAllVisuals() {
final Player player = this.getSubject().getOnlinePlayer();
if (player == null) {
return;
}
this.lastShovelLocation = null;
GDClaim claim = null;
if (this.visualClaimId != null) {
claim = (GDClaim) GriefDefenderPlugin.getInstance().dataStore.getClaim(this.worldUniqueId, this.visualClaimId);
if (claim != null) {
claim.playersWatching.remove(this.playerID);
}
}
this.visualClaimId = null;
if (this.visualBlocks.isEmpty()|| !player.getWorld().equals(this.visualBlocks.get(0).getFinal().getLocation().getWorld())) {
if (this.visualClaimBlocks.isEmpty()) {
return;
}
for (int i = 0; i < this.visualBlocks.size(); i++) {
BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal();
for (Map.Entry<UUID, BukkitTask> mapEntry : this.claimVisualRevertTasks.entrySet()) {
mapEntry.getValue().cancel();
}
final List<UUID> visualIds = new ArrayList<>(this.visualClaimBlocks.keySet());
for (UUID visualUniqueId : visualIds) {
final Claim claim = GriefDefenderPlugin.getInstance().dataStore.getClaim(player.getWorld().getUID(), visualUniqueId);
this.revertVisualBlocks(player, (GDClaim) claim, visualUniqueId);
}
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().revertAllVisuals(this.playerID);
}
// Revert any temp visuals
if (this.tempVisualUniqueId != null) {
this.revertClaimVisual(null, this.tempVisualUniqueId);
this.tempVisualUniqueId = null;
}
}
@Override
public void revertVisual(UUID uuid) {
final Claim claim = GriefDefenderPlugin.getInstance().dataStore.getClaim(this.worldUniqueId, uuid);
this.revertClaimVisual((GDClaim) claim, uuid);
}
@Override
public void revertVisual(Claim claim) {
this.revertClaimVisual((GDClaim) claim);
}
public void revertClaimVisual(GDClaim claim) {
this.revertClaimVisual(claim, claim.getUniqueId());
}
public void revertClaimVisual(GDClaim claim, UUID visualUniqueId) {
final Player player = this.getSubject().getOnlinePlayer();
if (player == null) {
return;
}
for (Map.Entry<UUID, BukkitTask> mapEntry : this.claimVisualRevertTasks.entrySet()) {
if (visualUniqueId.equals(mapEntry.getKey())) {
mapEntry.getValue().cancel();
break;
}
}
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().revertClaimCUIVisual(visualUniqueId, this.playerID);
}
this.revertVisualBlocks(player, claim, visualUniqueId);
}
private void revertVisualBlocks(Player player, GDClaim claim, UUID visualUniqueId) {
this.lastShovelLocation = null;
final List<BlockTransaction> visualTransactions = this.visualClaimBlocks.get(visualUniqueId);
if (visualTransactions == null || visualTransactions.isEmpty()) {
return;
}
for (int i = 0; i < visualTransactions.size(); i++) {
BlockSnapshot snapshot = visualTransactions.get(i).getOriginal();
// If original block does not exist, do not send to player
if (!snapshot.matchesWorldState()) {
if (claim != null) {
@ -262,7 +322,17 @@ public void revertActiveVisual(Player player) {
}
NMSUtil.getInstance().sendBlockChange(player, snapshot);
}
this.visualBlocks.clear();
if (claim != null) {
claim.playersWatching.remove(this.playerID);
}
this.claimVisualRevertTasks.remove(visualUniqueId);
this.visualClaimBlocks.remove(visualUniqueId);
// Revert any temp visuals
if (this.tempVisualUniqueId != null) {
this.revertClaimVisual(null, this.tempVisualUniqueId);
this.tempVisualUniqueId = null;
}
}
@Override
@ -611,8 +681,8 @@ public double getTaxRate(ClaimType type) {
}
@Override
public String getSubjectId() {
return this.getSubject().getIdentifier();
public UUID getUniqueId() {
return this.getSubject().getUniqueId();
}
public GDPermissionUser getSubject() {
@ -629,7 +699,7 @@ public void sendTaxExpireMessage(Player player, GDClaim claim) {
final double taxRate = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), player, Options.TAX_RATE, claim);
final double taxOwed = claim.getClaimBlocks() * taxRate;
final double remainingDays = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.TAX_EXPIRATION_DAYS_KEEP, claim);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_CLAIM_EXPIRED, ImmutableMap.of(
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_EXPIRED, ImmutableMap.of(
"days", remainingDays,
"amount", taxOwed));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
@ -673,7 +743,10 @@ public int getPvpCombatTimeRemaining() {
}
final Instant now = Instant.now();
final int combatTimeout = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PVP_COMBAT_TIMEOUT);
int combatTimeout = 0;
if (GDOptions.isOptionEnabled(Options.PVP_COMBAT_TIMEOUT)) {
combatTimeout = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PVP_COMBAT_TIMEOUT);
}
if (combatTimeout <= 0) {
return 0;
}
@ -737,18 +810,17 @@ public void onClaimDelete() {
}
public void onDisconnect() {
this.visualBlocks.clear();
this.claimVisualRevertTasks.clear();
this.visualClaimBlocks.clear();
this.queuedVisuals.clear();
this.claimMode = false;
this.ignoreClaims = false;
this.lastShovelLocation = null;
this.eventResultCache = null;
this.claimResizing = null;
this.claimSubdividing = null;
this.visualClaimId = null;
this.commandInputTimestamp = null;
this.recordChatTimestamp = null;
if (this.visualRevertTask != null) {
this.visualRevertTask.cancel();
this.visualRevertTask = null;
}
this.tempVisualUniqueId = null;
}
}

View File

@ -48,11 +48,8 @@
import org.apache.commons.lang3.LocaleUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster;
import org.bukkit.event.Event;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.plugin.Plugin;
@ -68,7 +65,7 @@
import com.griefdefender.api.claim.ClaimSchematic;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.economy.BankTransaction;
import com.griefdefender.api.economy.PaymentTransaction;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
@ -119,6 +116,7 @@
import com.griefdefender.command.CommandClaimOptionPlayer;
import com.griefdefender.command.CommandClaimPermissionGroup;
import com.griefdefender.command.CommandClaimPermissionPlayer;
import com.griefdefender.command.CommandClaimRent;
import com.griefdefender.command.CommandClaimReserve;
import com.griefdefender.command.CommandClaimSchematic;
import com.griefdefender.command.CommandClaimSell;
@ -126,6 +124,7 @@
import com.griefdefender.command.CommandClaimSetSpawn;
import com.griefdefender.command.CommandClaimSpawn;
import com.griefdefender.command.CommandClaimSubdivision;
import com.griefdefender.command.CommandClaimTax;
import com.griefdefender.command.CommandClaimTown;
import com.griefdefender.command.CommandClaimTransfer;
import com.griefdefender.command.CommandClaimUnban;
@ -168,9 +167,10 @@
import com.griefdefender.configuration.serializer.WeatherTypeSerializer;
import com.griefdefender.configuration.type.ConfigBase;
import com.griefdefender.configuration.type.GlobalConfig;
import com.griefdefender.economy.GDBankTransaction;
import com.griefdefender.economy.GDPaymentTransaction;
import com.griefdefender.inject.GriefDefenderImplModule;
import com.griefdefender.internal.provider.WorldEditProvider;
import com.griefdefender.internal.provider.GDTagProvider;
import com.griefdefender.internal.provider.GDWorldEditProvider;
import com.griefdefender.internal.provider.WorldGuardProvider;
import com.griefdefender.internal.registry.BlockTypeRegistryModule;
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
@ -202,6 +202,7 @@
import com.griefdefender.provider.VaultProvider;
import com.griefdefender.registry.ChatTypeRegistryModule;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.ClaimVisualTypeRegistryModule;
import com.griefdefender.registry.CreateModeTypeRegistryModule;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
@ -216,6 +217,10 @@
import com.griefdefender.task.ClaimBlockTask;
import com.griefdefender.task.ClaimCleanupTask;
import com.griefdefender.task.PlayerTickTask;
import com.griefdefender.task.RentApplyTask;
import com.griefdefender.task.RentDelinquentApplyTask;
import com.griefdefender.task.SignUpdateTask;
import com.griefdefender.task.TaxApplyTask;
import com.griefdefender.util.PermissionUtil;
import co.aikar.commands.BaseCommand;
@ -241,8 +246,8 @@ public class GriefDefenderPlugin {
public static final String IMPLEMENTATION_NAME = GriefDefenderPlugin.class.getPackage().getImplementationTitle();
public static final String IMPLEMENTATION_VERSION = GriefDefenderPlugin.class.getPackage().getImplementationVersion() == null ? "unknown" : GriefDefenderPlugin.class.getPackage().getImplementationVersion();
private Path configPath = Paths.get(".", "plugins", "GriefDefender");
public FlagConfig flagConfig;
public OptionConfig optionConfig;
private static FlagConfig flagConfig;
private static OptionConfig optionConfig;
public MessageStorage messageStorage;
public MessageDataConfig messageData;
public Map<UUID, Random> worldGeneratorRandoms = new HashMap<>();
@ -271,7 +276,8 @@ public class GriefDefenderPlugin {
private DynmapProvider dynmapProvider;
private EssentialsProvider essentialsProvider;
private WorldEditProvider worldEditProvider;
private GDTagProvider tagProvider;
private GDWorldEditProvider worldEditProvider;
private WorldGuardProvider worldGuardProvider;
private VaultProvider vaultProvider;
private PermissionProvider permissionProvider;
@ -305,7 +311,7 @@ public static void addEventLogEntry(Event event, Claim claim, Location location,
final String eventLocation = location == null ? "none" : VecHelper.toVector3i(location).toString();
for (GDDebugData debugEntry : GriefDefenderPlugin.getInstance().getDebugUserMap().values()) {
final CommandSender debugSource = debugEntry.getSource();
final OfflinePlayer debugUser = debugEntry.getTarget();
final GDPermissionUser debugUser = debugEntry.getUser();
if (debugUser != null) {
if (permissionSubject == null) {
continue;
@ -314,6 +320,36 @@ public static void addEventLogEntry(Event event, Claim claim, Location location,
if (!permissionSubject.getIdentifier().equals(debugUser.getUniqueId().toString())) {
continue;
}
} else if (debugEntry.getClaimUniqueId() != null) {
if (!claim.getUniqueId().equals(debugEntry.getClaimUniqueId())) {
continue;
}
} else if (debugEntry.getFilter() != null) {
//check filter
final String filter = debugEntry.getFilter();
boolean match = false;
if (permission.contains(filter)) {
match = true;
} else if (targetId.contains(filter)) {
match = true;
} else if (sourceId.contains(filter)) {
match = true;
} else {
// check contexts
for (Context context : contexts) {
if (context.getKey().contains(filter)) {
match = true;
break;
}
if (context.getValue().contains(filter)) {
match = true;
break;
}
}
}
if (!match) {
continue;
}
}
String messageUser = permissionSubject.getFriendlyName();
@ -358,8 +394,15 @@ public static void addEventLogEntry(Event event, Claim claim, Location location,
contextList.add("<b>server</b>=global");
}
Collections.sort(contextList);
for (String context : contextList) {
contextStr += context + "<br />";
for (int i = 0; i < contextList.size(); i++) {
contextStr += contextList.get(i);
if (i % 2 != 0) {
contextStr += "<br />";
} else {
if (i != contextList.size() - 1) {
contextStr += ", ";
}
}
}
String locationStr = "";
@ -451,6 +494,7 @@ public void onEnable() {
Guice.createInjector(Stage.PRODUCTION, new GriefDefenderImplModule());
ChatTypeRegistryModule.getInstance().registerDefaults();
ClaimTypeRegistryModule.getInstance().registerDefaults();
ClaimVisualTypeRegistryModule.getInstance().registerDefaults();
ShovelTypeRegistryModule.getInstance().registerDefaults();
TrustTypeRegistryModule.getInstance().registerDefaults();
FlagRegistryModule.getInstance().registerDefaults();
@ -462,7 +506,7 @@ public void onEnable() {
GameModeTypeRegistryModule.getInstance().registerDefaults();
WeatherTypeRegistryModule.getInstance().registerDefaults();
OptionRegistryModule.getInstance().registerDefaults();
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
GriefDefender.getRegistry().registerBuilderSupplier(PaymentTransaction.Builder.class, GDPaymentTransaction.PaymentTransactionBuilder::new);
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
GriefDefender.getRegistry().registerBuilderSupplier(FlagData.Builder.class, GDFlagData.FlagDataBuilder::new);
GriefDefender.getRegistry().registerBuilderSupplier(FlagDefinition.Builder.class, GDFlagDefinition.FlagDefinitionBuilder::new);
@ -487,8 +531,8 @@ public void onEnable() {
return;
}
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null || Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null) {
this.worldEditProvider = new WorldEditProvider();
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null || Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null || Bukkit.getPluginManager().getPlugin("AsyncWorldEdit") != null) {
this.worldEditProvider = new GDWorldEditProvider();
GriefDefender.getRegistry().registerBuilderSupplier(ClaimSchematic.Builder.class, GDClaimSchematic.ClaimSchematicBuilder::new);
}
@ -511,6 +555,10 @@ public void onEnable() {
this.getLogger().info("GriefDefender PlaceholderAPI expansion enabled!");
}
if (getMajorMinecraftVersion() > 13) {
this.tagProvider = new GDTagProvider();
}
if (this.dataStore == null) {
try {
this.dataStore = new FileStorage();
@ -580,13 +628,30 @@ public void onEnable() {
GriefDefenderPlugin.getGlobalConfig().save();
}
new ClaimBlockTask();
if (!isEconomyModeEnabled() || GriefDefenderPlugin.getGlobalConfig().getConfig().economy.useClaimBlockTask) {
new ClaimBlockTask();
}
new PlayerTickTask();
if (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.isRentSignEnabled()) {
new SignUpdateTask(100);
}
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) {
new RentDelinquentApplyTask();
new RentApplyTask();
}
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null) {
if (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.taxSystem) {
// run tax task
new TaxApplyTask();
}
}
registerBaseCommands();
this.getLogger().info("Loaded successfully.");
}
public void onDisable() {
this.getLogger().info("Saving claim data...");
// Spigot disables plugins before calling world save on shutdown so we need to manually save here
for (World world : Bukkit.getServer().getWorlds()) {
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
@ -599,8 +664,8 @@ public void onDisable() {
}
claimWorldManager.save();
claimWorldManager.playerIndexStorage.savePlayerDatData();
}
this.getLogger().info("Save complete.");
}
public void registerBaseCommands() {
@ -646,6 +711,7 @@ public void registerBaseCommands() {
manager.registerCommand(new CommandClaimOptionPlayer());
manager.registerCommand(new CommandClaimPermissionGroup());
manager.registerCommand(new CommandClaimPermissionPlayer());
manager.registerCommand(new CommandClaimRent());
manager.registerCommand(new CommandClaimReserve());
manager.registerCommand(new CommandClaimSchematic());
manager.registerCommand(new CommandClaimSell());
@ -653,6 +719,7 @@ public void registerBaseCommands() {
manager.registerCommand(new CommandClaimSetSpawn());
manager.registerCommand(new CommandClaimSpawn());
manager.registerCommand(new CommandClaimSubdivision());
manager.registerCommand(new CommandClaimTax());
manager.registerCommand(new CommandClaimTown());
manager.registerCommand(new CommandClaimTransfer());
manager.registerCommand(new CommandClaimUnban());
@ -825,6 +892,26 @@ public void registerBaseCommands() {
for (InventoryType type : InventoryType.values()) {
tabList.add(type.name().toLowerCase());
}
if (getMajorMinecraftVersion() > 13) {
for (Set<Context> contexts : this.tagProvider.getTagMap().values()) {
for (Context context : contexts) {
tabList.add("#" + context.getKey() + ":" + context.getValue());
if (context.getKey().equalsIgnoreCase("minecraft")) {
tabList.add("#" + context.getValue());
}
}
}
// Add GD group keys
tabList.add(ContextGroupKeys.AMBIENT);
tabList.add(ContextGroupKeys.ANIMAL);
tabList.add(ContextGroupKeys.AQUATIC);
tabList.add(ContextGroupKeys.FOOD);
tabList.add(ContextGroupKeys.MISC);
tabList.add(ContextGroupKeys.MONSTER);
tabList.add(ContextGroupKeys.PET);
tabList.add(ContextGroupKeys.VEHICLE);
tabList.addAll(this.tagProvider.getTagMap().keySet());
}
return ImmutableList.copyOf(tabList);
});
manager.getCommandCompletions().registerCompletion("gdtristates", c -> {
@ -840,6 +927,12 @@ public void registerBaseCommands() {
}
return ImmutableList.copyOf(tabList);
});
manager.getCommandCompletions().registerCompletion("gdrentcommands", c -> {
return ImmutableList.of("cancel", "clearbalance", "create", "info", "list");
});
manager.getCommandCompletions().registerCompletion("gdtaxcommands", c -> {
return ImmutableList.of("balance", "pay");
});
manager.getCommandCompletions().registerCompletion("gddummy", c -> {
return ImmutableList.of();
});
@ -991,6 +1084,14 @@ public static GriefDefenderConfig<GlobalConfig> getGlobalConfig() {
return BaseStorage.globalConfig;
}
public static FlagConfig getFlagConfig() {
return flagConfig;
}
public static OptionConfig getOptionConfig() {
return optionConfig;
}
public boolean claimsEnabledForWorld(UUID worldUniqueId) {
return GriefDefenderPlugin.getActiveConfig(worldUniqueId).getConfig().claim.claimsEnabled != 0;
}
@ -1003,15 +1104,6 @@ public Map<String, GDDebugData> getDebugUserMap() {
return this.debugUserMap;
}
public static boolean isEntityProtected(Entity entity) {
// ignore monsters
if (entity instanceof Monster) {
return false;
}
return true;
}
public static GDPermissionUser getOrCreateUser(UUID uuid) {
if (uuid == null) {
return null;
@ -1131,7 +1223,11 @@ public EssentialsProvider getEssentialsProvider() {
return this.essentialsProvider;
}
public WorldEditProvider getWorldEditProvider() {
public GDTagProvider getTagProvider() {
return this.tagProvider;
}
public GDWorldEditProvider getWorldEditProvider() {
return this.worldEditProvider;
}

View File

@ -55,6 +55,7 @@ public static MessageCache getInstance() {
public Component BANK_CLICK_VIEW_TRANSACTIONS;
public Component BANK_DEPOSIT_NO_FUNDS;
public Component BANK_TITLE_TRANSACTIONS;
public Component BANK_SYSTEM_DISABLED;
public Component BANK_TAX_SYSTEM_DISABLED;
public Component CLAIM_AUTOMATIC_NOTIFICATION;
public Component CLAIM_CHEST_CONFIRMATION;
@ -71,6 +72,7 @@ public static MessageCache getInstance() {
public Component CLAIM_RESPECTING;
public Component CLAIM_RESERVE_EXISTS;
public Component CLAIM_RESERVED_NAME;
public Component CLAIM_RESTORE_IN_PROGRESS;
public Component CLAIM_RESTORE_SUCCESS;
public Component CLAIM_TOO_FAR;
public Component CLAIMINFO_UI_ADMIN_SETTINGS;
@ -89,6 +91,7 @@ public static MessageCache getInstance() {
public Component CLAIMINFO_UI_REQUIRES_CLAIM_BLOCKS;
public Component CLAIMINFO_UI_RETURN_BANKINFO;
public Component CLAIMINFO_UI_RETURN_CLAIMINFO;
public Component CLAIMINFO_UI_RETURN_RENTINFO;
public Component CLAIMINFO_UI_RETURN_SETTINGS;
public Component CLAIMINFO_UI_SIZE_RESTRICTIONS;
public Component CLAIMINFO_UI_SOUTH_CORNERS;
@ -98,6 +101,7 @@ public static MessageCache getInstance() {
public Component CLAIMINFO_UI_TOWN_SETTINGS;
public Component CLAIMLIST_UI_CLICK_INFO;
public Component CLAIMLIST_UI_CLICK_PURCHASE;
public Component CLAIMLIST_UI_CLICK_RENT;
public Component CLAIMLIST_UI_CLICK_VIEW_CHILDREN;
public Component CLAIMLIST_UI_CLICK_VIEW_CLAIMS;
public Component CLAIMLIST_UI_NO_CLAIMS_FOUND;
@ -142,8 +146,25 @@ public static MessageCache getInstance() {
public Component ECONOMY_BLOCK_ONLY_BUY;
public Component ECONOMY_BLOCK_ONLY_SELL;
public Component ECONOMY_CLAIM_NOT_FOR_SALE;
public Component ECONOMY_CLAIM_RENT_CANCEL_CONFIRMATION;
public Component ECONOMY_CLAIM_RENT_RESTORE_CANCEL_CONFIRMATION;
public Component ECONOMY_CLAIM_RENT_CANCELLED;
public Component ECONOMY_CLAIM_RENT_NOT_RENTING;
public Component ECONOMY_CLAIM_RENT_OWNER_NOT_RENTING;
public Component ECONOMY_CLAIM_SALE_CANCEL_CONFIRMATION;
public Component ECONOMY_CLAIM_SALE_CANCELLED;
public Component ECONOMY_NOT_INSTALLED;
public Component ECONOMY_SIGN_RENT_DAYS_LEFT;
public Component ECONOMY_SIGN_RENT_DESCRIPTION;
public Component ECONOMY_SIGN_RENT_FOOTER;
public Component ECONOMY_SIGN_RENTED_LINE1;
public Component ECONOMY_SIGN_RENTED_LINE3;
public Component ECONOMY_SIGN_RENTED_LINE4;
public Component ECONOMY_SIGN_SELL_DESCRIPTION;
public Component ECONOMY_SIGN_SELL_FOOTER;
public Component ECONOMY_SIGN_SOLD_LINE1;
public Component ECONOMY_SIGN_SOLD_LINE3;
public Component ECONOMY_SIGN_SOLD_LINE4;
public Component ECONOMY_VIRTUAL_NOT_SUPPORTED;
public Component FEATURE_NOT_AVAILABLE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING;
@ -155,8 +176,11 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS;
public Component FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF;
public Component FLAG_DESCRIPTION_CUSTOM_EXP_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_ENTITY_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FALLING_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_BLOCK_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_ENTITY_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_ICE_FORM;
@ -179,10 +203,12 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEMFRAME_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO;
public Component FLAG_DESCRIPTION_CUSTOM_PISTON_ITEM_SPAWN;
public Component FLAG_DESCRIPTION_CUSTOM_PISTON_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PVP;
@ -197,11 +223,14 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_TURTLE_EGG_HATCH;
public Component FLAG_DESCRIPTION_CUSTOM_USE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_VILLAGER_FARM;
public Component FLAG_DESCRIPTION_CUSTOM_VILLAGER_TRADE;
public Component FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_WATER_FLOW;
public Component FLAG_DESCRIPTION_BLOCK_BREAK;
@ -254,39 +283,57 @@ public static MessageCache getInstance() {
public Component LABEL_ACCESSORS;
public Component LABEL_ALL;
public Component LABEL_AREA;
public Component LABEL_AVAILABLE;
public Component LABEL_BALANCE;
public Component LABEL_BLOCKS;
public Component LABEL_BUILDERS;
public Component LABEL_BUY;
public Component LABEL_CANCEL;
public Component LABEL_CHILDREN;
public Component LABEL_CLAIM;
public Component LABEL_CONFIRM;
public Component LABEL_CONTAINERS;
public Component LABEL_CONTEXT;
public Component LABEL_CREATED;
public Component LABEL_DAY;
public Component LABEL_DAYS;
public Component LABEL_DEFAULT;
public Component LABEL_DISPLAYING;
public Component LABEL_EXPIRED;
public Component LABEL_FAREWELL;
public Component LABEL_FILTER;
public Component LABEL_FLAG;
public Component LABEL_GREETING;
public Component LABEL_GROUP;
public Component LABEL_HOUR;
public Component LABEL_HOURS;
public Component LABEL_INFO;
public Component LABEL_INHERIT;
public Component LABEL_LOCATION;
public Component LABEL_MANAGERS;
public Component LABEL_MINUTE;
public Component LABEL_MINUTES;
public Component LABEL_NAME;
public Component LABEL_NO;
public Component LABEL_NONE;
public Component LABEL_OUTPUT;
public Component LABEL_OWED;
public Component LABEL_OWNER;
public Component LABEL_PAYMENT;
public Component LABEL_PERMISSION;
public Component LABEL_PLAYER;
public Component LABEL_PRESET;
public Component LABEL_PRICE;
public Component LABEL_RAID;
public Component LABEL_RATE;
public Component LABEL_RENT;
public Component LABEL_RENTER;
public Component LABEL_RESIZABLE;
public Component LABEL_RESULT;
public Component LABEL_SCHEMATIC;
public Component LABEL_SOURCE;
public Component LABEL_SPAWN;
public Component LABEL_STATUS;
public Component LABEL_TARGET;
public Component LABEL_TRUST;
public Component LABEL_TYPE;
@ -331,7 +378,6 @@ public static MessageCache getInstance() {
public Component OPTION_DESCRIPTION_PLAYER_KEEP_LEVEL;
public Component OPTION_DESCRIPTION_PLAYER_WALK_SPEED;
public Component OPTION_DESCRIPTION_PLAYER_WEATHER;
public Component OPTION_DESCRIPTION_RADIUS_LIST;
public Component OPTION_DESCRIPTION_RADIUS_INSPECT;
public Component OPTION_DESCRIPTION_TAX_EXPIRATION;
public Component OPTION_DESCRIPTION_TAX_EXPIRATION_DAYS_KEEP;
@ -369,17 +415,35 @@ public static MessageCache getInstance() {
public Component PERMISSION_PLAYER_ADMIN_FLAGS;
public Component PERMISSION_PLAYER_OPTION;
public Component PERMISSION_PLAYER_VIEW_OTHERS;
public Component PERMISSION_TAX;
public Component PERMISSION_VISUAL_CLAIMS_NEARBY;
public Component PLAYERINFO_UI_TITLE;
public Component PLUGIN_EVENT_CANCEL;
public Component PLUGIN_RELOAD;
public Component PVP_CLAIM_NOT_ALLOWED;
public Component PVP_SOURCE_CREATIVE_NOT_ALLOWED;
public Component PVP_SOURCE_FLY_NOT_ALLOWED;
public Component PVP_SOURCE_NOT_ALLOWED;
public Component PVP_TARGET_NOT_ALLOWED;
public Component RENT_SYSTEM_DISABLED;
public Component RENT_UI_CLICK_CANCEL;
public Component RENT_UI_CLICK_RENT;
public Component RENT_UI_END_DATE;
public Component RENT_UI_HOVER_END_DATE;
public Component RENT_UI_INFO_HEADER;
public Component RENT_UI_MINIMUM;
public Component RENT_UI_NEXT_PAYMENT_DUE_DATE;
public Component RENT_UI_NO_TRANSACTIONS;
public Component RENT_UI_RETURN_INFO;
public Component RENT_UI_START_DATE;
public Component RENT_UI_VIEW_TRANSACTIONS;
public Component RENT_UI_TITLE_TRANSACTIONS;
public Component RESIZE_OVERLAP;
public Component RESIZE_OVERLAP_SUBDIVISION;
public Component RESIZE_SAME_LOCATION;
public Component RESIZE_START;
public Component RESULT_TYPE_FAIL;
public Component RESULT_TYPE_SUCCESS;
public Component SCHEMATIC_ABANDON_ALL_RESTORE_WARNING;
public Component SCHEMATIC_ABANDON_RESTORE_WARNING;
public Component SCHEMATIC_CREATE;
@ -387,19 +451,26 @@ public static MessageCache getInstance() {
public Component SCHEMATIC_CREATE_FAIL;
public Component SCHEMATIC_NONE;
public Component SPAWN_NOT_SET;
public Component TAX_NO_BALANCE;
public Component TAX_SYSTEM_DISABLED;
public Component TELEPORT_MOVE_CANCEL;
public Component TELEPORT_NO_SAFE_LOCATION;
public Component TITLE_ACCESSOR;
public Component TITLE_ADMIN;
public Component TITLE_ADVANCED;
public Component TITLE_ALL;
public Component TITLE_BUILDER;
public Component TITLE_BUY;
public Component TITLE_CLAIM;
public Component TITLE_CONTAINER;
public Component TITLE_DEFAULT;
public Component TITLE_GROUP;
public Component TITLE_INHERIT;
public Component TITLE_MANAGER;
public Component TITLE_OWN;
public Component TITLE_OVERRIDE;
public Component TITLE_PRESET;
public Component TITLE_RENT;
public Component TOWN_CHAT_DISABLED;
public Component TOWN_CHAT_ENABLED;
public Component TOWN_NOT_FOUND;
@ -417,6 +488,8 @@ public static MessageCache getInstance() {
public Component UI_CLICK_ADD_PLAYER;
public Component UI_CLICK_CONFIRM;
public Component UI_CLICK_REMOVE;
public Component UI_CLICK_VIEW_TRANSACTIONS;
public Component UI_PAY_NEXT_DUE_DATE;
public Component UNTRUST_NO_CLAIMS;
public Component UNTRUST_SELF;
@ -429,6 +502,7 @@ public void loadCache() {
ABANDON_WARNING = MessageStorage.MESSAGE_DATA.getMessage("abandon-warning");
BANK_CLICK_VIEW_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("bank-click-view-transactions");
BANK_DEPOSIT_NO_FUNDS = MessageStorage.MESSAGE_DATA.getMessage("bank-deposit-no-funds");
BANK_SYSTEM_DISABLED = MessageStorage.MESSAGE_DATA.getMessage("bank-system-disabled");
BANK_TAX_SYSTEM_DISABLED = MessageStorage.MESSAGE_DATA.getMessage("bank-tax-system-disabled");
BANK_TITLE_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("bank-title-transactions");
CLAIM_AUTOMATIC_NOTIFICATION = MessageStorage.MESSAGE_DATA.getMessage("claim-automatic-notification");
@ -446,6 +520,7 @@ public void loadCache() {
CLAIM_RESERVE_EXISTS = MessageStorage.MESSAGE_DATA.getMessage("claim-reserve-exists");
CLAIM_RESERVED_NAME = MessageStorage.MESSAGE_DATA.getMessage("claim-reserved-name");
CLAIM_RESPECTING = MessageStorage.MESSAGE_DATA.getMessage("claim-respecting");
CLAIM_RESTORE_IN_PROGRESS = MessageStorage.MESSAGE_DATA.getMessage("claim-restore-in-progress");
CLAIM_RESTORE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("claim-restore-success");
CLAIM_TOO_FAR = MessageStorage.MESSAGE_DATA.getMessage("claim-too-far");
CLAIMINFO_UI_ADMIN_SETTINGS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-admin-settings");
@ -464,6 +539,7 @@ public void loadCache() {
CLAIMINFO_UI_REQUIRES_CLAIM_BLOCKS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-requires-claim-blocks");
CLAIMINFO_UI_RETURN_BANKINFO = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-return-bankinfo");
CLAIMINFO_UI_RETURN_CLAIMINFO = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-return-claiminfo");
CLAIMINFO_UI_RETURN_RENTINFO = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-return-rentinfo");
CLAIMINFO_UI_RETURN_SETTINGS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-return-settings");
CLAIMINFO_UI_SIZE_RESTRICTIONS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-size-restrictions");
CLAIMINFO_UI_SOUTH_CORNERS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-south-corners");
@ -473,6 +549,7 @@ public void loadCache() {
CLAIMINFO_UI_TOWN_SETTINGS = MessageStorage.MESSAGE_DATA.getMessage("claiminfo-ui-town-settings");
CLAIMLIST_UI_CLICK_INFO = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-click-info");
CLAIMLIST_UI_CLICK_PURCHASE = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-click-purchase");
CLAIMLIST_UI_CLICK_RENT = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-click-rent");
CLAIMLIST_UI_CLICK_VIEW_CHILDREN = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-click-view-children");
CLAIMLIST_UI_CLICK_VIEW_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-click-view-claims");
CLAIMLIST_UI_NO_CLAIMS_FOUND = MessageStorage.MESSAGE_DATA.getMessage("claimlist-ui-no-claims-found");
@ -517,8 +594,24 @@ public void loadCache() {
ECONOMY_BLOCK_ONLY_BUY = MessageStorage.MESSAGE_DATA.getMessage("economy-block-only-buy");
ECONOMY_BLOCK_ONLY_SELL = MessageStorage.MESSAGE_DATA.getMessage("economy-block-only-sell");
ECONOMY_CLAIM_NOT_FOR_SALE = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-not-for-sale");
ECONOMY_CLAIM_RENT_CANCEL_CONFIRMATION = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-rent-cancel-confirmation");
ECONOMY_CLAIM_RENT_RESTORE_CANCEL_CONFIRMATION = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-rent-restore-cancel-confirmation");
ECONOMY_CLAIM_RENT_CANCELLED = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-rent-cancelled");
ECONOMY_CLAIM_RENT_NOT_RENTING = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-rent-not-renting");
ECONOMY_CLAIM_RENT_OWNER_NOT_RENTING = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-rent-owner-not-renting");
ECONOMY_CLAIM_SALE_CANCEL_CONFIRMATION = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-sale-cancel-confirmation");
ECONOMY_CLAIM_SALE_CANCELLED = MessageStorage.MESSAGE_DATA.getMessage("economy-claim-sale-cancelled");
ECONOMY_NOT_INSTALLED = MessageStorage.MESSAGE_DATA.getMessage("economy-not-installed");
ECONOMY_SIGN_RENT_DESCRIPTION = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-rent-description");
ECONOMY_SIGN_RENT_FOOTER = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-rent-footer");
ECONOMY_SIGN_RENTED_LINE1 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-rented-line1");
ECONOMY_SIGN_RENTED_LINE3 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-rented-line3");
ECONOMY_SIGN_RENTED_LINE4 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-rented-line4");
ECONOMY_SIGN_SELL_DESCRIPTION = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-sell-description");
ECONOMY_SIGN_SELL_FOOTER = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-sell-footer");
ECONOMY_SIGN_SOLD_LINE1 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-sold-line1");
ECONOMY_SIGN_SOLD_LINE3 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-sold-line3");
ECONOMY_SIGN_SOLD_LINE4 = MessageStorage.MESSAGE_DATA.getMessage("economy-sign-sold-line4");
ECONOMY_VIRTUAL_NOT_SUPPORTED = MessageStorage.MESSAGE_DATA.getMessage("economy-virtual-not-supported");
FEATURE_NOT_AVAILABLE = MessageStorage.MESSAGE_DATA.getMessage("feature-not-available");
FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-trampling");
@ -530,8 +623,11 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-damage-animals");
FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enderman-grief");
FLAG_DESCRIPTION_CUSTOM_EXP_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exp-drop");
FLAG_DESCRIPTION_CUSTOM_FALL_ENTITY_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-entity-damage");
FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-player-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-damage");
FLAG_DESCRIPTION_CUSTOM_FALLING_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-falling-block-break");
FLAG_DESCRIPTION_CUSTOM_FIRE_BLOCK_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-block-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_ENTITY_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-entity-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-spread");
FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-grass-growth");
FLAG_DESCRIPTION_CUSTOM_ICE_FORM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-ice-form");
@ -539,12 +635,13 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lava-flow");
FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-leaf-decay");
FLAG_DESCRIPTION_CUSTOM_LIGHTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lighter");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-animal-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-player-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-spawn");
FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mushroom-growth");
FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mycelium-spread");
FLAG_DESCRIPTION_CUSTOM_PISTON_ITEM_SPAWN = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-piston-item-spawn");
FLAG_DESCRIPTION_CUSTOM_PISTON_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-piston-use");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-break");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-place");
@ -555,6 +652,7 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-entity-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-exit");
FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-inventory-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEMFRAME_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-itemframe-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-drop");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-pickup");
FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-portal-use");
@ -572,8 +670,11 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-aquatic");
FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-block-explosion");
FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-entity-explosion");
FLAG_DESCRIPTION_CUSTOM_TURTLE_EGG_HATCH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-turtle-egg-hatch");
FLAG_DESCRIPTION_CUSTOM_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-use");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-use");
FLAG_DESCRIPTION_CUSTOM_VILLAGER_FARM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-villager-farm");
FLAG_DESCRIPTION_CUSTOM_VILLAGER_TRADE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-villager-trade");
FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vine-growth");
FLAG_DESCRIPTION_CUSTOM_WATER_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-water-flow");
FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-block-break");
@ -626,40 +727,59 @@ public void loadCache() {
FLAG_UI_OVERRIDE_NO_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-override-no-permission");
FLAG_UI_RETURN_FLAGS = MessageStorage.MESSAGE_DATA.getMessage("flag-ui-return-flags");
LABEL_ACCESSORS = MessageStorage.MESSAGE_DATA.getMessage("label-accessors");
LABEL_ALL = MessageStorage.MESSAGE_DATA.getMessage("label-all");
LABEL_AREA = MessageStorage.MESSAGE_DATA.getMessage("label-area");
LABEL_AVAILABLE = MessageStorage.MESSAGE_DATA.getMessage("label-available");
LABEL_BALANCE = MessageStorage.MESSAGE_DATA.getMessage("label-balance");
LABEL_BLOCKS = MessageStorage.MESSAGE_DATA.getMessage("label-blocks");
LABEL_BUILDERS = MessageStorage.MESSAGE_DATA.getMessage("label-builders");
LABEL_BUY = MessageStorage.MESSAGE_DATA.getMessage("label-buy");
LABEL_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("label-cancel");
LABEL_CHILDREN = MessageStorage.MESSAGE_DATA.getMessage("label-children");
LABEL_CLAIM = MessageStorage.MESSAGE_DATA.getMessage("label-claim");
LABEL_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("label-confirm");
LABEL_CONTAINERS = MessageStorage.MESSAGE_DATA.getMessage("label-containers");
LABEL_CONTEXT = MessageStorage.MESSAGE_DATA.getMessage("label-context");
LABEL_CREATED = MessageStorage.MESSAGE_DATA.getMessage("label-created");
LABEL_DAY = MessageStorage.MESSAGE_DATA.getMessage("label-day");
LABEL_DAYS = MessageStorage.MESSAGE_DATA.getMessage("label-days");
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_FAREWELL = MessageStorage.MESSAGE_DATA.getMessage("label-farewell");
LABEL_FILTER = MessageStorage.MESSAGE_DATA.getMessage("label-filter");
LABEL_FLAG = MessageStorage.MESSAGE_DATA.getMessage("label-flag");
LABEL_GREETING = MessageStorage.MESSAGE_DATA.getMessage("label-greeting");
LABEL_GROUP = MessageStorage.MESSAGE_DATA.getMessage("label-group");
LABEL_HOUR = MessageStorage.MESSAGE_DATA.getMessage("label-hour");
LABEL_HOURS = MessageStorage.MESSAGE_DATA.getMessage("label-hours");
LABEL_INFO = MessageStorage.MESSAGE_DATA.getMessage("label-info");
LABEL_INHERIT = MessageStorage.MESSAGE_DATA.getMessage("label-inherit");
LABEL_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("label-location");
LABEL_MANAGERS = MessageStorage.MESSAGE_DATA.getMessage("label-managers");
LABEL_MINUTE = MessageStorage.MESSAGE_DATA.getMessage("label-minute");
LABEL_MINUTES = MessageStorage.MESSAGE_DATA.getMessage("label-minutes");
LABEL_NAME = MessageStorage.MESSAGE_DATA.getMessage("label-name");
LABEL_NO = MessageStorage.MESSAGE_DATA.getMessage("label-no");
LABEL_NONE = MessageStorage.MESSAGE_DATA.getMessage("label-none");
LABEL_OUTPUT = MessageStorage.MESSAGE_DATA.getMessage("label-output");
LABEL_OWED = MessageStorage.MESSAGE_DATA.getMessage("label-owed");
LABEL_OWNER = MessageStorage.MESSAGE_DATA.getMessage("label-owner");
LABEL_PAYMENT = MessageStorage.MESSAGE_DATA.getMessage("label-payment");
LABEL_PERMISSION = MessageStorage.MESSAGE_DATA.getMessage("label-permission");
LABEL_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("label-player");
LABEL_PRICE = MessageStorage.MESSAGE_DATA.getMessage("label-price");
LABEL_PRESET = MessageStorage.MESSAGE_DATA.getMessage("label-preset");
LABEL_RAID = MessageStorage.MESSAGE_DATA.getMessage("label-raid");
LABEL_RATE = MessageStorage.MESSAGE_DATA.getMessage("label-rate");
LABEL_RENT = MessageStorage.MESSAGE_DATA.getMessage("label-rent");
LABEL_RENTER = MessageStorage.MESSAGE_DATA.getMessage("label-renter");
LABEL_RESIZABLE = MessageStorage.MESSAGE_DATA.getMessage("label-resizable");
LABEL_RESULT = MessageStorage.MESSAGE_DATA.getMessage("label-result");
LABEL_SCHEMATIC = MessageStorage.MESSAGE_DATA.getMessage("label-schematic");
LABEL_SOURCE = MessageStorage.MESSAGE_DATA.getMessage("label-source");
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_TRUST = MessageStorage.MESSAGE_DATA.getMessage("label-trust");
LABEL_TYPE = MessageStorage.MESSAGE_DATA.getMessage("label-type");
@ -672,6 +792,8 @@ public void loadCache() {
MODE_NATURE = MessageStorage.MESSAGE_DATA.getMessage("mode-nature");
MODE_SUBDIVISION = MessageStorage.MESSAGE_DATA.getMessage("mode-subdivision");
MODE_TOWN = MessageStorage.MESSAGE_DATA.getMessage("mode-town");
OPTION_APPLY_PLAYER_DENY_FLIGHT = MessageStorage.MESSAGE_DATA.getMessage("option-apply-player-deny-flight");
OPTION_APPLY_PLAYER_DENY_GODMODE = MessageStorage.MESSAGE_DATA.getMessage("option-apply-player-deny-godmode");
OPTION_DESCRIPTION_ABANDON_DELAY = MessageStorage.MESSAGE_DATA.getMessage("option-description-abandon-delay");
OPTION_DESCRIPTION_ABANDON_RETURN_RATIO = MessageStorage.MESSAGE_DATA.getMessage("option-description-abandon-return-ratio");
OPTION_DESCRIPTION_BLOCKS_ACCRUED_PER_HOUR = MessageStorage.MESSAGE_DATA.getMessage("option-description-blocks-accrued-per-hour");
@ -702,13 +824,10 @@ public void loadCache() {
OPTION_DESCRIPTION_PLAYER_KEEP_LEVEL = MessageStorage.MESSAGE_DATA.getMessage("option-description-player-keep-level");
OPTION_DESCRIPTION_PLAYER_WALK_SPEED = MessageStorage.MESSAGE_DATA.getMessage("option-description-player-walk-speed");
OPTION_DESCRIPTION_PLAYER_WEATHER = MessageStorage.MESSAGE_DATA.getMessage("option-description-player-weather");
OPTION_DESCRIPTION_RADIUS_LIST = MessageStorage.MESSAGE_DATA.getMessage("option-description-radius-list");
OPTION_DESCRIPTION_RADIUS_INSPECT = MessageStorage.MESSAGE_DATA.getMessage("option-description-radius-inspect");
OPTION_DESCRIPTION_TAX_EXPIRATION = MessageStorage.MESSAGE_DATA.getMessage("option-description-tax-expiration");
OPTION_DESCRIPTION_TAX_EXPIRATION_DAYS_KEEP = MessageStorage.MESSAGE_DATA.getMessage("option-description-tax-expiration-days-keep");
OPTION_DESCRIPTION_TAX_RATE = MessageStorage.MESSAGE_DATA.getMessage("option-description-tax-rate");
OPTION_APPLY_PLAYER_DENY_FLIGHT = MessageStorage.MESSAGE_DATA.getMessage("option-apply-player-deny-flight");
OPTION_APPLY_PLAYER_DENY_GODMODE = MessageStorage.MESSAGE_DATA.getMessage("option-apply-player-deny-godmode");
OPTION_UI_CLICK_REMOVE = MessageStorage.MESSAGE_DATA.getMessage("option-ui-click-remove");
OWNER_ADMIN = MessageStorage.MESSAGE_DATA.getMessage("owner-admin");
PERMISSION_ASSIGN_WITHOUT_HAVING = MessageStorage.MESSAGE_DATA.getMessage("permission-assign-without-having");
@ -742,17 +861,35 @@ public void loadCache() {
PERMISSION_PLAYER_ADMIN_FLAGS = MessageStorage.MESSAGE_DATA.getMessage("permission-player-admin-flags");
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_VISUAL_CLAIMS_NEARBY = MessageStorage.MESSAGE_DATA.getMessage("permission-visual-claims-nearby");
PLAYERINFO_UI_TITLE = MessageStorage.MESSAGE_DATA.getMessage("playerinfo-ui-title");
PLUGIN_EVENT_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("plugin-event-cancel");
PLUGIN_RELOAD = MessageStorage.MESSAGE_DATA.getMessage("plugin-reload");
PVP_CLAIM_NOT_ALLOWED = MessageStorage.MESSAGE_DATA.getMessage("pvp-claim-not-allowed");
PVP_SOURCE_CREATIVE_NOT_ALLOWED = MessageStorage.MESSAGE_DATA.getMessage("pvp-source-creative-not-allowed");
PVP_SOURCE_FLY_NOT_ALLOWED = MessageStorage.MESSAGE_DATA.getMessage("pvp-source-fly-not-allowed");
PVP_SOURCE_NOT_ALLOWED = MessageStorage.MESSAGE_DATA.getMessage("pvp-source-not-allowed");
PVP_TARGET_NOT_ALLOWED = MessageStorage.MESSAGE_DATA.getMessage("pvp-target-not-allowed");
RENT_SYSTEM_DISABLED = MessageStorage.MESSAGE_DATA.getMessage("rent-system-disabled");
RENT_UI_CLICK_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-click-cancel");
RENT_UI_CLICK_RENT = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-click-rent");
RENT_UI_END_DATE = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-end-date");
RENT_UI_HOVER_END_DATE = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-hover-end-date");
RENT_UI_INFO_HEADER = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-info-header");
RENT_UI_MINIMUM = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-minimum");
RENT_UI_NEXT_PAYMENT_DUE_DATE = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-next-payment-due-date");
RENT_UI_NO_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-no-transactions");
RENT_UI_RETURN_INFO = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-return-info");
RENT_UI_START_DATE = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-start-date");
RENT_UI_VIEW_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-view-transactions");
RENT_UI_TITLE_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("rent-ui-title-transactions");
RESIZE_OVERLAP = MessageStorage.MESSAGE_DATA.getMessage("resize-overlap");
RESIZE_OVERLAP_SUBDIVISION = MessageStorage.MESSAGE_DATA.getMessage("resize-overlap-subdivision");
RESIZE_SAME_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("resize-same-location");
RESIZE_START = MessageStorage.MESSAGE_DATA.getMessage("resize-start");
RESULT_TYPE_FAIL = MessageStorage.MESSAGE_DATA.getMessage("result-type-fail");
RESULT_TYPE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("result-type-success");
SCHEMATIC_ABANDON_ALL_RESTORE_WARNING = MessageStorage.MESSAGE_DATA.getMessage("schematic-abandon-all-restore-warning");
SCHEMATIC_ABANDON_RESTORE_WARNING = MessageStorage.MESSAGE_DATA.getMessage("schematic-abandon-restore-warning");
SCHEMATIC_CREATE = MessageStorage.MESSAGE_DATA.getMessage("schematic-create");
@ -760,19 +897,26 @@ public void loadCache() {
SCHEMATIC_CREATE_FAIL = MessageStorage.MESSAGE_DATA.getMessage("schematic-create-fail");
SCHEMATIC_NONE = MessageStorage.MESSAGE_DATA.getMessage("schematic-none");
SPAWN_NOT_SET = MessageStorage.MESSAGE_DATA.getMessage("spawn-not-set");
TAX_NO_BALANCE = MessageStorage.MESSAGE_DATA.getMessage("tax-no-balance");
TAX_SYSTEM_DISABLED = MessageStorage.MESSAGE_DATA.getMessage("tax-system-disabled");
TELEPORT_MOVE_CANCEL = MessageStorage.MESSAGE_DATA.getMessage("teleport-move-cancel");
TELEPORT_NO_SAFE_LOCATION = MessageStorage.MESSAGE_DATA.getMessage("teleport-no-safe-location");
TITLE_ACCESSOR = MessageStorage.MESSAGE_DATA.getMessage("title-accessor");
TITLE_ADMIN = MessageStorage.MESSAGE_DATA.getMessage("title-admin");
TITLE_ADVANCED = MessageStorage.MESSAGE_DATA.getMessage("title-advanced");
TITLE_ALL = MessageStorage.MESSAGE_DATA.getMessage("title-all");
TITLE_BUILDER = MessageStorage.MESSAGE_DATA.getMessage("title-builder");
TITLE_BUY = MessageStorage.MESSAGE_DATA.getMessage("title-buy");
TITLE_CLAIM = MessageStorage.MESSAGE_DATA.getMessage("title-claim");
TITLE_CONTAINER = MessageStorage.MESSAGE_DATA.getMessage("title-container");
TITLE_DEFAULT = MessageStorage.MESSAGE_DATA.getMessage("title-default");
TITLE_GROUP = MessageStorage.MESSAGE_DATA.getMessage("title-group");
TITLE_INHERIT = MessageStorage.MESSAGE_DATA.getMessage("title-inherit");
TITLE_MANAGER = MessageStorage.MESSAGE_DATA.getMessage("title-manager");
TITLE_OWN = MessageStorage.MESSAGE_DATA.getMessage("title-own");
TITLE_OVERRIDE = MessageStorage.MESSAGE_DATA.getMessage("title-override");
TITLE_PRESET = MessageStorage.MESSAGE_DATA.getMessage("title-preset");
TITLE_RENT = MessageStorage.MESSAGE_DATA.getMessage("title-rent");
TOWN_CHAT_DISABLED = MessageStorage.MESSAGE_DATA.getMessage("town-chat-disabled");
TOWN_CHAT_ENABLED = MessageStorage.MESSAGE_DATA.getMessage("town-chat-enabled");
TOWN_NOT_FOUND = MessageStorage.MESSAGE_DATA.getMessage("town-not-found");
@ -790,6 +934,8 @@ public void loadCache() {
UI_CLICK_ADD_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("ui-click-add-player");
UI_CLICK_CONFIRM = MessageStorage.MESSAGE_DATA.getMessage("ui-click-confirm");
UI_CLICK_REMOVE = MessageStorage.MESSAGE_DATA.getMessage("ui-click-remove");
UI_CLICK_VIEW_TRANSACTIONS = MessageStorage.MESSAGE_DATA.getMessage("ui-click-view-transactions");
UI_PAY_NEXT_DUE_DATE = MessageStorage.MESSAGE_DATA.getMessage("ui-pay-next-due-date");
UNTRUST_NO_CLAIMS = MessageStorage.MESSAGE_DATA.getMessage("untrust-no-claims");
UNTRUST_SELF = MessageStorage.MESSAGE_DATA.getMessage("untrust-self");

View File

@ -36,6 +36,7 @@
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.User;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimBlockSystem;
import com.griefdefender.api.claim.ClaimContexts;
@ -45,10 +46,13 @@
import com.griefdefender.api.claim.ClaimSchematic;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.claim.ClaimVisual;
import com.griefdefender.api.claim.ClaimVisualTypes;
import com.griefdefender.api.claim.ShovelTypes;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.data.ClaimData;
import com.griefdefender.api.data.EconomyData;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.cache.MessageCache;
@ -68,9 +72,8 @@
import com.griefdefender.event.GDTransferClaimEvent;
import com.griefdefender.event.GDUserTrustClaimEvent;
import com.griefdefender.internal.provider.WorldGuardProvider;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.internal.visual.ClaimVisual;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
@ -78,6 +81,7 @@
import com.griefdefender.provider.VaultProvider;
import com.griefdefender.registry.TrustTypeRegistryModule;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PermissionUtil;
@ -142,12 +146,11 @@ public class GDClaim implements Claim {
public GDClaim parent = null;
public Set<Claim> children = new HashSet<>();
public ClaimVisual claimVisual;
public List<UUID> playersWatching = new ArrayList<>();
public GDClaimVisual claimVisual;
public Set<UUID> playersWatching = new HashSet<>();
public Map<String, ClaimSchematic> schematics = new HashMap<>();
private GDPlayerData ownerPlayerData;
private static final int MAX_AREA = GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME ? 2560000 : 10000;
public GDClaim(World world, Vector3i point1, Vector3i point2, ClaimType type, UUID ownerUniqueId, boolean cuboid) {
this(world, point1, point2, type, ownerUniqueId, cuboid, null);
@ -253,9 +256,14 @@ public void setType(ClaimType type) {
}
}
public ClaimVisual getVisualizer() {
@Override
public ClaimVisual getClaimVisual() {
return this.getVisualizer();
}
public GDClaimVisual getVisualizer() {
if (this.claimVisual == null || this.markVisualDirty) {
this.claimVisual = new ClaimVisual(this, ClaimVisual.getClaimVisualType(this));
this.claimVisual = new GDClaimVisual(this, GDClaimVisual.getClaimVisualType(this));
this.markVisualDirty = false;
}
return this.claimVisual;
@ -267,12 +275,35 @@ public void resetVisuals() {
final Player spongePlayer = Bukkit.getServer().getPlayer(playerUniqueId);
final GDPlayerData data = this.worldClaimManager.getOrCreatePlayerData(playerUniqueId);
if (spongePlayer != null) {
data.revertActiveVisual(spongePlayer);
data.revertClaimVisual(this);
}
}
this.claimVisual = null;
}
@Override
public boolean hasActiveVisual(User user) {
if (user == null) {
return false;
}
final GDPermissionUser gdUser = (GDPermissionUser) user;
if (gdUser.getOnlinePlayer() != null) {
return this.hasActiveVisual(gdUser.getOnlinePlayer());
}
return false;
}
public boolean hasActiveVisual(Player player) {
List<UUID> playersWatching = new ArrayList<>(this.playersWatching);
for (UUID playerUniqueId : playersWatching) {
if (player.getUniqueId().equals(playerUniqueId)) {
return true;
}
}
return false;
}
public GDPlayerData getOwnerPlayerData() {
if (this.ownerPlayerData == null && this.ownerUniqueId != null) {
this.ownerPlayerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(this.world.getUID(), this.ownerUniqueId);
@ -377,33 +408,37 @@ public String getFriendlyName() {
}
public Component getFriendlyNameType() {
return this.getFriendlyNameType(false);
return this.getFriendlyNameType(this.type, false);
}
public Component getFriendlyNameType(boolean upper) {
if (this.type == ClaimTypes.ADMIN) {
return this.getFriendlyNameType(this.type, upper);
}
public Component getFriendlyNameType(ClaimType claimType, boolean upper) {
if (claimType == ClaimTypes.ADMIN) {
if (upper) {
return TextComponent.of(this.type.getName().toUpperCase(), TextColor.RED);
return TextComponent.of(claimType.getName().toUpperCase(), TextColor.RED);
}
return TextComponent.of("Admin", TextColor.RED);
}
if (this.type == ClaimTypes.BASIC) {
if (claimType == ClaimTypes.BASIC) {
if (upper) {
return TextComponent.of(this.type.getName().toUpperCase(), TextColor.YELLOW);
return TextComponent.of(claimType.getName().toUpperCase(), TextColor.YELLOW);
}
return TextComponent.of("Basic", TextColor.YELLOW);
}
if (this.type == ClaimTypes.SUBDIVISION) {
if (claimType == ClaimTypes.SUBDIVISION) {
if (upper) {
return TextComponent.of(this.type.getName().toUpperCase(), TextColor.AQUA);
return TextComponent.of(claimType.getName().toUpperCase(), TextColor.AQUA);
}
return TextComponent.of("Subdivision", TextColor.AQUA);
}
if (upper) {
return TextComponent.of(this.type.getName().toUpperCase(), TextColor.GREEN);
return TextComponent.of(claimType.getName().toUpperCase(), TextColor.GREEN);
}
return TextComponent.of("Town", TextColor.GREEN);
}
@ -467,6 +502,11 @@ public Component allowEdit(GDPermissionUser holder, boolean forced) {
return null;
}
// Owners are not trusted while renting
if (!holder.getInternalPlayerData().canIgnoreClaim(this) && this.getEconomyData() != null && this.getEconomyData().isRented() && holder.getUniqueId().equals(this.ownerUniqueId)) {
return TextComponent.of("");
}
if (PermissionUtil.getInstance().holderHasPermission(holder, GDPermissions.COMMAND_DELETE_CLAIMS)) {
return null;
}
@ -481,7 +521,7 @@ public Component allowEdit(GDPermissionUser holder, boolean forced) {
}
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_OWNER_ONLY, ImmutableMap.of(
"player", this.getOwnerName()));
"player", this.getOwnerDisplayName()));
return message;
}
@ -502,7 +542,7 @@ public Component allowGrantPermission(Player player) {
}
final Component reason = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST, ImmutableMap.of(
"player", this.getOwnerName()));
"player", this.getOwnerDisplayName()));
return reason;
}
@ -517,7 +557,7 @@ public Vector3i getGreaterBoundaryCorner() {
}
@Override
public Component getOwnerName() {
public Component getOwnerDisplayName() {
if (this.isAdminClaim() || this.isWilderness()) {
return MessageCache.getInstance().OWNER_ADMIN;
}
@ -526,10 +566,10 @@ public Component getOwnerName() {
return TextComponent.of("[unknown]");
}
return TextComponent.of(this.getOwnerPlayerData().getPlayerName());
return TextComponent.of(this.getOwnerPlayerData().getName());
}
public String getOwnerFriendlyName() {
public String getOwnerName() {
if (this.isAdminClaim()) {
return "administrator";
}
@ -540,15 +580,14 @@ public String getOwnerFriendlyName() {
if (playerData == null) {
return "[unknown]";
}
return playerData.getPlayerName();
return playerData.getName();
}
@Override
public boolean contains(Vector3i pos, boolean excludeChildren) {
return this.contains(pos.getX(), pos.getY(), pos.getZ(), excludeChildren, null, false);
public boolean contains(int x, int y, int z, boolean excludeChildren) {
return this.contains(x, y, z, excludeChildren, null, false);
}
public boolean contains(Vector3i pos, GDPlayerData playerData, boolean useBorderBlockRadius) {
return this.contains(pos.getX(), pos.getY(), pos.getZ(), false, playerData, useBorderBlockRadius);
}
@ -707,14 +746,25 @@ public boolean isInside(Claim claim) {
@Override
public ArrayList<Vector3i> getChunkPositions() {
ArrayList<Vector3i> chunkPositions = new ArrayList<Vector3i>();
final Set<Long> chunkHashes = this.getChunkHashes(true);
for (Long hash : chunkHashes) {
//chunkPositions.add(ChunkPos.)
int smallX = this.lesserBoundaryCorner.getX() >> 4;
int smallZ = this.lesserBoundaryCorner.getZ() >> 4;
int largeX = this.greaterBoundaryCorner.getX() >> 4;
int largeZ = this.greaterBoundaryCorner.getZ() >> 4;
for (int x = smallX; x <= largeX; x++) {
for (int z = smallZ; z <= largeZ; z++) {
chunkPositions.add(new Vector3i(x, 0, z));
}
}
return chunkPositions;
}
public ArrayList<Chunk> getChunks() {
return this.getChunks(false);
}
public ArrayList<Chunk> getChunks(boolean force) {
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
Chunk lesserChunk = this.world
@ -725,7 +775,10 @@ public ArrayList<Chunk> getChunks() {
if (lesserChunk != null && greaterChunk != null) {
for (int x = lesserChunk.getX(); x <= greaterChunk.getX(); x++) {
for (int z = lesserChunk.getZ(); z <= greaterChunk.getZ(); z++) {
Chunk chunk = world.getChunkAt(x, z);
if (!force && !this.world.isChunkLoaded(x, z)) {
continue;
}
final Chunk chunk = this.world.getChunkAt(x, z);
if (chunk != null) {
chunks.add(chunk);
}
@ -859,23 +912,6 @@ public void save() {
GriefDefender.getEventManager().post(postEvent);
}
public boolean isPvpEnabled() {
final boolean isPvPAllowed = this.world.getPVP();
if (isPvPAllowed) {
Tristate value = this.claimData.getPvpOverride();
if (value != Tristate.UNDEFINED) {
return value.asBoolean();
}
}
return isPvPAllowed;
}
public void setPvpOverride(Tristate value) {
this.claimData.setPvpOverride(value);
this.getClaimStorage().save();
}
@Override
public ClaimResult transferOwner(UUID newOwnerID) {
return this.transferOwner(newOwnerID, false, false);
@ -930,7 +966,7 @@ public ClaimResult transferOwner(UUID newOwnerID, boolean checkEconomy, boolean
if (this.isAdminClaim()) {
// convert to basic
this.type = ClaimTypes.BASIC;
this.getVisualizer().setType(ClaimVisual.BASIC);
this.getVisualizer().setType(ClaimVisualTypes.BASIC);
this.claimData.setType(ClaimTypes.BASIC);
}
@ -1202,7 +1238,10 @@ public ClaimResult resize(int x1, int x2, int y1, int y2, int z1, int z2) {
final GDPermissionUser user = root instanceof GDPermissionUser ? (GDPermissionUser) root : null;
final Player player = user != null ? user.getOnlinePlayer() : null;
if (this.cuboid) {
return resizeCuboid(player, minx, miny, minz, maxx, maxy, maxz);
// make sure resize doesn't cross paths
if (minx >= maxx || miny >= maxy || minz >= maxz) {
return new GDClaimResult(this, ClaimResultType.OVERLAPPING_CLAIM);
}
}
Location startCorner = null;
@ -1228,13 +1267,42 @@ public ClaimResult resize(int x1, int x2, int y1, int y2, int z1, int z2) {
endCorner = playerData.endShovelLocation;
}
// Auto-adjust Y levels for 2D claims
if (playerData != null) {
miny = this.getOwnerMinClaimLevel();
}
if (playerData != null) {
maxy = this.getOwnerMaxClaimLevel();
final int minClaimLevel = this.getOwnerMinClaimLevel();
final int maxClaimLevel = this.getOwnerMaxClaimLevel();
if (!this.cuboid) {
// Auto-adjust Y levels for 2D claims
if (playerData != null) {
miny = minClaimLevel;
maxy = maxClaimLevel;
}
} else {
if (playerData != null && playerData.shovelMode != ShovelTypes.ADMIN && miny < minClaimLevel) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_BELOW_LEVEL, ImmutableMap.of(
"limit", minClaimLevel));
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(ClaimResultType.BELOW_MIN_LEVEL);
}
if (playerData != null && playerData.shovelMode != ShovelTypes.ADMIN && maxy > maxClaimLevel) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_ABOVE_LEVEL, ImmutableMap.of(
"limit", maxClaimLevel));
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(ClaimResultType.ABOVE_MAX_LEVEL);
}
// check if child extends past parent limits
if (this.parent != null) {
if (minx < this.parent.getLesserBoundaryCorner().getX() ||
miny < this.parent.getLesserBoundaryCorner().getY() ||
minz < this.parent.getLesserBoundaryCorner().getZ()) {
return new GDClaimResult(this.parent, ClaimResultType.OVERLAPPING_CLAIM);
}
if (maxx > this.parent.getGreaterBoundaryCorner().getX() ||
(this.parent.isCuboid() && maxy > this.parent.getGreaterBoundaryCorner().getY()) ||
maxz > this.parent.getGreaterBoundaryCorner().getZ()) {
return new GDClaimResult(this.parent, ClaimResultType.OVERLAPPING_CLAIM);
}
}
}
Vector3i currentLesserCorner = this.getLesserBoundaryCorner();
Vector3i currentGreaterCorner = this.getGreaterBoundaryCorner();
Vector3i newLesserCorner = new Vector3i(minx, miny, minz);
@ -1246,58 +1314,6 @@ public ClaimResult resize(int x1, int x2, int y1, int y2, int z1, int z2) {
return new GDClaimResult(this, ClaimResultType.CLAIM_EVENT_CANCELLED);
}
// check player has enough claim blocks
if ((this.isBasicClaim() || this.isTown()) && this.claimData.requiresClaimBlocks()) {
final int newCost = BlockUtil.getInstance().getClaimBlockCost(this.world, newLesserCorner, newGreaterCorner, this.cuboid);
final int currentCost = BlockUtil.getInstance().getClaimBlockCost(this.world, currentLesserCorner, currentGreaterCorner, this.cuboid);
if (GriefDefenderPlugin.getInstance().isEconomyModeEnabled()) {
if (!this.vaultProvider.getApi().hasAccount(player)) {
return new GDClaimResult(ClaimResultType.ECONOMY_ACCOUNT_NOT_FOUND);
}
final double requiredFunds = Math.abs((newCost - currentCost) * this.getOwnerEconomyBlockCost());
if (newCost > currentCost) {
final double currentFunds = this.vaultProvider.getApi().getBalance(player);
final EconomyResponse result = this.vaultProvider.getApi().withdrawPlayer(player, requiredFunds);
if (!result.transactionSuccess()) {
Component message = null;
if (player != null) {
message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.ECONOMY_NOT_ENOUGH_FUNDS, ImmutableMap.of(
"balance", this.vaultProvider.getApi().getBalance(player),
"amount", requiredFunds));
GriefDefenderPlugin.sendMessage(player, message);
}
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
return new GDClaimResult(ClaimResultType.ECONOMY_NOT_ENOUGH_FUNDS, message);
}
} else {
final EconomyResponse result = this.vaultProvider.getApi().depositPlayer(player, requiredFunds);
}
} else if (newCost > currentCost) {
final int remainingClaimBlocks = this.ownerPlayerData.getRemainingClaimBlocks() - (newCost - currentCost);
if (remainingClaimBlocks < 0) {
if (player != null) {
if (GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME) {
final double claimableChunks = Math.abs(remainingClaimBlocks / 65536.0);
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_SIZE_NEED_BLOCKS_3D, ImmutableMap.of(
"chunk-amount", Math.round(claimableChunks * 100.0)/100.0,
"block-amount", Math.abs(remainingClaimBlocks))));
} else {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_SIZE_NEED_BLOCKS_2D, ImmutableMap.of(
"block-amount", Math.abs(remainingClaimBlocks))));
}
}
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
this.lesserBoundaryCorner = currentLesserCorner;
this.greaterBoundaryCorner = currentGreaterCorner;
return new GDClaimResult(ClaimResultType.INSUFFICIENT_CLAIM_BLOCKS);
}
}
}
this.lesserBoundaryCorner = newLesserCorner;
this.greaterBoundaryCorner = newGreaterCorner;
@ -1321,7 +1337,60 @@ public ClaimResult resize(int x1, int x2, int y1, int y2, int z1, int z2) {
}
}
// This needs to be adjusted before we check for overlaps
if (!this.cuboid || GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME) {
// check player has enough claim blocks
if ((this.isBasicClaim() || this.isTown()) && this.claimData.requiresClaimBlocks()) {
final int newCost = BlockUtil.getInstance().getClaimBlockCost(this.world, newLesserCorner, newGreaterCorner, this.cuboid);
final int currentCost = BlockUtil.getInstance().getClaimBlockCost(this.world, currentLesserCorner, currentGreaterCorner, this.cuboid);
if (GriefDefenderPlugin.getInstance().isEconomyModeEnabled()) {
if (!this.vaultProvider.getApi().hasAccount(player)) {
return new GDClaimResult(ClaimResultType.ECONOMY_ACCOUNT_NOT_FOUND);
}
final double requiredFunds = Math.abs((newCost - currentCost) * this.getOwnerEconomyBlockCost());
if (newCost > currentCost) {
final double currentFunds = this.vaultProvider.getApi().getBalance(player);
final EconomyResponse economyResponse = EconomyUtil.getInstance().withdrawFunds(player, requiredFunds);
if (!economyResponse.transactionSuccess()) {
Component message = null;
if (player != null) {
message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.ECONOMY_NOT_ENOUGH_FUNDS, ImmutableMap.of(
"balance", this.vaultProvider.getApi().getBalance(player),
"amount", requiredFunds));
GriefDefenderPlugin.sendMessage(player, message);
}
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
return new GDClaimResult(ClaimResultType.ECONOMY_NOT_ENOUGH_FUNDS, message);
}
} else {
final EconomyResponse economyResponse = this.vaultProvider.getApi().depositPlayer(player, requiredFunds);
}
} else if (newCost > currentCost) {
final int remainingClaimBlocks = this.ownerPlayerData.getRemainingClaimBlocks() - (newCost - currentCost);
if (remainingClaimBlocks < 0) {
if (player != null) {
if (GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME) {
final double claimableChunks = Math.abs(remainingClaimBlocks / 65536.0);
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_SIZE_NEED_BLOCKS_3D, ImmutableMap.of(
"chunk-amount", Math.round(claimableChunks * 100.0)/100.0,
"block-amount", Math.abs(remainingClaimBlocks))));
} else {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_SIZE_NEED_BLOCKS_2D, ImmutableMap.of(
"block-amount", Math.abs(remainingClaimBlocks))));
}
}
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
this.lesserBoundaryCorner = currentLesserCorner;
this.greaterBoundaryCorner = currentGreaterCorner;
return new GDClaimResult(ClaimResultType.INSUFFICIENT_CLAIM_BLOCKS);
}
}
}
}
this.lesserBoundaryCorner = newLesserCorner;
this.greaterBoundaryCorner = newGreaterCorner;
GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(this.world.getUID());
@ -1360,133 +1429,6 @@ public ClaimResult resize(int x1, int x2, int y1, int y2, int z1, int z2) {
return new GDClaimResult(this, ClaimResultType.SUCCESS);
}
public ClaimResult resizeCuboid(Player player, int smallX, int smallY, int smallZ, int bigX, int bigY, int bigZ) {
// make sure resize doesn't cross paths
if (smallX >= bigX || smallY >= bigY || smallZ >= bigZ) {
return new GDClaimResult(this, ClaimResultType.OVERLAPPING_CLAIM);
}
Location startCorner = null;
Location endCorner = null;
GDPlayerData playerData = null;
if (player != null) {
playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(this.world, player.getUniqueId());
} else if (!this.isAdminClaim() && this.ownerUniqueId != null) {
playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(this.world, this.ownerUniqueId);
}
if (playerData == null) {
if (GriefDefenderPlugin.getActiveConfig(this.world.getUID()).getConfig().claim.claimAutoSchematicRestore) {
return new GDClaimResult(this, ClaimResultType.FAILURE);
}
startCorner = new Location(this.world, smallX, smallY, smallZ);
endCorner = new Location(this.world, bigX, bigY, bigZ);
} else {
if (!playerData.canIgnoreClaim(this) && GriefDefenderPlugin.getActiveConfig(this.world.getUID()).getConfig().claim.claimAutoSchematicRestore) {
return new GDClaimResult(this, ClaimResultType.FAILURE);
}
startCorner = playerData.lastShovelLocation;
endCorner = playerData.endShovelLocation;
}
GDChangeClaimEvent.Resize event = new GDChangeClaimEvent.Resize(this, startCorner, endCorner);
GriefDefender.getEventManager().post(event);
if (event.cancelled()) {
return new GDClaimResult(this, ClaimResultType.CLAIM_EVENT_CANCELLED);
}
final int minClaimLevel = this.getOwnerMinClaimLevel();
if (playerData != null && playerData.shovelMode != ShovelTypes.ADMIN && smallY < minClaimLevel) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_BELOW_LEVEL, ImmutableMap.of(
"limit", minClaimLevel));
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(ClaimResultType.BELOW_MIN_LEVEL);
}
final int maxClaimLevel = this.getOwnerMaxClaimLevel();
if (playerData != null && playerData.shovelMode != ShovelTypes.ADMIN && bigY > maxClaimLevel) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_ABOVE_LEVEL, ImmutableMap.of(
"limit", maxClaimLevel));
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(ClaimResultType.ABOVE_MAX_LEVEL);
}
// check if child extends past parent limits
if (this.parent != null) {
if (smallX < this.parent.getLesserBoundaryCorner().getX() ||
smallY < this.parent.getLesserBoundaryCorner().getY() ||
smallZ < this.parent.getLesserBoundaryCorner().getZ()) {
return new GDClaimResult(this.parent, ClaimResultType.OVERLAPPING_CLAIM);
}
if (bigX > this.parent.getGreaterBoundaryCorner().getX() ||
(this.parent.isCuboid() && bigY > this.parent.getGreaterBoundaryCorner().getY()) ||
bigZ > this.parent.getGreaterBoundaryCorner().getZ()) {
return new GDClaimResult(this.parent, ClaimResultType.OVERLAPPING_CLAIM);
}
}
Vector3i currentLesserCorner = this.lesserBoundaryCorner;
Vector3i currentGreaterCorner = this.greaterBoundaryCorner;
Vector3i newLesserCorner = new Vector3i(smallX, smallY, smallZ);
Vector3i newGreaterCorner = new Vector3i(bigX, bigY, bigZ);
this.lesserBoundaryCorner = newLesserCorner;
this.greaterBoundaryCorner = newGreaterCorner;
// checkArea refreshes the current chunk hashes so it is important
// to make a copy before making the call
final Set<Long> currentChunkHashes = new HashSet<>(this.chunkHashes);
final ClaimResult result = this.checkArea(true);
if (!result.successful()) {
this.lesserBoundaryCorner = currentLesserCorner;
this.greaterBoundaryCorner = currentGreaterCorner;
return result;
}
if (this.type != ClaimTypes.ADMIN && this.type != ClaimTypes.WILDERNESS) {
ClaimResult claimResult = checkSizeLimits(player, playerData, newLesserCorner, newGreaterCorner);
if (!claimResult.successful()) {
this.lesserBoundaryCorner = currentLesserCorner;
this.greaterBoundaryCorner = currentGreaterCorner;
return claimResult;
}
}
this.lesserBoundaryCorner = newLesserCorner;
this.greaterBoundaryCorner = newGreaterCorner;
// resize validated, remove invalid chunkHashes
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(this.world.getUID());
if (this.parent == null) {
for (Long chunkHash : currentChunkHashes) {
Set<Claim> claimsInChunk = claimWorldManager.getInternalChunksToClaimsMap().get(chunkHash);
if (claimsInChunk != null && claimsInChunk.size() > 0) {
claimsInChunk.remove(this);
}
}
final Set<Long> newChunkHashes = this.getChunkHashes(true);
// add new chunk hashes
for (Long chunkHash : newChunkHashes) {
Set<Claim> claimsInChunk = claimWorldManager.getInternalChunksToClaimsMap().get(chunkHash);
if (claimsInChunk == null) {
claimsInChunk = new HashSet<>();
claimWorldManager.getInternalChunksToClaimsMap().put(chunkHash, claimsInChunk);
}
claimsInChunk.add(this);
}
}
this.claimData.setLesserBoundaryCorner(BlockUtil.getInstance().posToString(this.lesserBoundaryCorner));
this.claimData.setGreaterBoundaryCorner(BlockUtil.getInstance().posToString(this.greaterBoundaryCorner));
this.claimData.setRequiresSave(true);
this.getClaimStorage().save();
if (result.getClaims().size() > 1) {
this.migrateClaims(new ArrayList<>(result.getClaims()));
}
this.resetVisuals();
return new GDClaimResult(this, ClaimResultType.SUCCESS);
}
private ClaimResult checkSizeLimits(Player player, GDPlayerData playerData, Vector3i lesserCorner, Vector3i greaterCorner) {
if (playerData == null) {
return new GDClaimResult(ClaimResultType.SUCCESS);
@ -1742,7 +1684,7 @@ public World getWorld() {
public void setWorld(World world) {
this.world = world;
}
/*@Override
public List<Entity> getEntities() {
Collection<Entity> worldEntityList = Bukkit.getServer().getWorld(this.world.getUID()).getEntities();
List<Entity> entityList = new ArrayList<>();
@ -1753,7 +1695,7 @@ public List<Entity> getEntities() {
}
return entityList;
}*/
}
@Override
public List<UUID> getPlayers() {
@ -1915,7 +1857,7 @@ public ClaimResult changeType(ClaimType type, Optional<UUID> ownerUniqueId, Comm
}
// If switched to admin or new owner, remove from player claim list
if (type == ClaimTypes.ADMIN || !this.ownerUniqueId.equals(newOwnerUUID)) {
if (type == ClaimTypes.ADMIN || (this.ownerUniqueId != null && !this.ownerUniqueId.equals(newOwnerUUID))) {
final Set<Claim> currentPlayerClaims = claimWorldManager.getInternalPlayerClaims(this.ownerUniqueId);
if (currentPlayerClaims != null) {
currentPlayerClaims.remove(this);
@ -1931,7 +1873,7 @@ public ClaimResult changeType(ClaimType type, Optional<UUID> ownerUniqueId, Comm
if (!this.isAdminClaim() && this.ownerPlayerData != null) {
final Player player = Bukkit.getServer().getPlayer(this.ownerUniqueId);
if (player != null) {
this.ownerPlayerData.revertActiveVisual(player);
this.ownerPlayerData.revertClaimVisual(this);
}
}
@ -1941,7 +1883,7 @@ public ClaimResult changeType(ClaimType type, Optional<UUID> ownerUniqueId, Comm
final Player spongePlayer = Bukkit.getServer().getPlayer(playerUniqueId);
final GDPlayerData playerData = claimWorldManager.getOrCreatePlayerData(playerUniqueId);
if (spongePlayer != null) {
playerData.revertActiveVisual(spongePlayer);
playerData.revertClaimVisual(this);
}
}
@ -2000,14 +1942,14 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
if (this.parent == null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
ImmutableMap.of(
"type", this.getFriendlyNameType(true),
"type", this.getFriendlyNameType(type, true),
"target_type", TextComponent.of("WILDERNESS", TextColor.GREEN)));
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
}
if (this.isAdminClaim() && newOwnerUUID == null) {
return new GDClaimResult(ClaimResultType.REQUIRES_OWNER, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_REQUIRES_OWNER,
ImmutableMap.of(
"type", this.getFriendlyNameType(true),
"type", this.getFriendlyNameType(type, true),
"target_type", TextComponent.of("SUBDIVISION", TextColor.AQUA))));
}
} else if (type == ClaimTypes.TOWN) {
@ -2019,7 +1961,7 @@ public ClaimResult validateClaimType(ClaimType type, UUID newOwnerUUID, GDPlayer
if (!isAdmin && user != null && !PermissionUtil.getInstance().holderHasPermission(user, GDPermissions.CLAIM_CREATE_TOWN)) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.RESULT_TYPE_CREATE_DENY,
ImmutableMap.of(
"type", this.getFriendlyNameType(true),
"type", this.getFriendlyNameType(type, true),
"target_type", TextComponent.of("TOWN", TextColor.GREEN)));
return new GDClaimResult(ClaimResultType.WRONG_CLAIM_TYPE, message);
}
@ -2107,6 +2049,11 @@ public boolean isUserTrusted(GDPermissionUser user, TrustType type, Set<Context>
return false;
}
if (forced || !playerData.debugClaimPermissions) {
// Owners are not trusted while renting
if (!playerData.canIgnoreClaim(this) && this.getEconomyData() != null && this.getEconomyData().isRented() && user.getUniqueId().equals(this.ownerUniqueId)) {
return false;
}
if (user.getUniqueId().equals(this.getOwnerUniqueId())) {
return true;
}
@ -2611,7 +2558,7 @@ public List<String> getGroupTrusts(TrustType type) {
}
public Optional<UUID> getEconomyAccountId() {
if (this.vaultProvider == null || this.vaultProvider.getApi() == null || !this.vaultProvider.getApi().hasBankSupport() || this.isAdminClaim() || this.isSubdivision() || !GriefDefenderPlugin.getGlobalConfig().getConfig().claim.bankTaxSystem) {
if (this.vaultProvider == null || this.vaultProvider.getApi() == null || !this.vaultProvider.getApi().hasBankSupport() || this.isAdminClaim() || this.isSubdivision() || !GriefDefenderPlugin.getGlobalConfig().getConfig().economy.bankSystem) {
return Optional.empty();
}
@ -2653,9 +2600,16 @@ public ClaimBuilder() {
}
@Override
public Builder bounds(Vector3i point1, Vector3i point2) {
this.point1 = point1;
this.point2 = point2;
public Builder bounds(int x1, int x2, int y1, int y2, int z1, int z2) {
int minx = Math.min(x1, x2);
int miny = Math.min(y1, y2);
int minz = Math.min(z1, z2);
int maxx = Math.max(x1, x2);
int maxy = Math.max(y1, y2);
int maxz = Math.max(z1, z2);
this.point1 = new Vector3i(minx, miny, minz);
this.point2 = new Vector3i(maxx, maxy, maxz);
return this;
}
@ -2756,8 +2710,8 @@ public Builder greeting(Component greeting) {
}
@Override
public Builder spawnPos(Vector3i spawnPos) {
this.spawnPos = spawnPos;
public Builder spawnPos(int x, int y, int z) {
this.spawnPos = new Vector3i(x, y, z);
return this;
}
@ -2911,7 +2865,7 @@ public ClaimResult build() {
final Economy economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi();
if (!economy.hasAccount(player)) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_PLAYER_NOT_FOUND, ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(claim, ClaimResultType.NOT_ENOUGH_FUNDS, message);
}
@ -2924,7 +2878,7 @@ public ClaimResult build() {
GriefDefenderPlugin.sendMessage(player, message);
return new GDClaimResult(claim, ClaimResultType.NOT_ENOUGH_FUNDS, message);
}
economy.withdrawPlayer(player, townCost);
EconomyUtil.getInstance().withdrawFunds(player, townCost);
}
}
}

View File

@ -39,15 +39,17 @@
import com.griefdefender.api.claim.ClaimResultType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.configuration.ClaimDataConfig;
import com.griefdefender.configuration.ClaimStorageData;
import com.griefdefender.event.GDRemoveClaimEvent;
import com.griefdefender.internal.tracking.PlayerIndexStorage;
import com.griefdefender.internal.tracking.chunk.GDChunk;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.Direction;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
@ -90,7 +92,7 @@ public class GDClaimManager implements ClaimManager {
private Map<Long, Set<Claim>> chunksToClaimsMap = new Long2ObjectOpenHashMap<>(4096);
// Entity Index
public PlayerIndexStorage playerIndexStorage;
private Map<Long, GDChunk> chunksToGpChunks = new Long2ObjectOpenHashMap<>(4096);
private Map<Long, GDChunk> chunksToGDChunks = new Long2ObjectOpenHashMap<>(4096);
private GDClaim theWildernessClaim;
@ -122,16 +124,16 @@ private Set<Claim> createPlayerClaimList(UUID playerUniqueId) {
for (World world : Bukkit.getServer().getWorlds()) {
GDClaimManager claimmanager = DATASTORE.getClaimWorldManager(world.getUID());
for (Claim claim : claimmanager.worldClaims) {
GDClaim gpClaim = (GDClaim) claim;
if (gpClaim.isAdminClaim()) {
GDClaim gdClaim = (GDClaim) claim;
if (gdClaim.isAdminClaim()) {
continue;
}
if (gpClaim.parent != null) {
if (gpClaim.parent.getOwnerUniqueId().equals(playerUniqueId)) {
if (gdClaim.parent != null) {
if (gdClaim.parent.getOwnerUniqueId().equals(playerUniqueId)) {
claimList.add(claim);
}
} else {
if (gpClaim.getOwnerUniqueId().equals(playerUniqueId)) {
if (gdClaim.getOwnerUniqueId().equals(playerUniqueId)) {
claimList.add(claim);
}
}
@ -139,16 +141,16 @@ private Set<Claim> createPlayerClaimList(UUID playerUniqueId) {
}
} else {
for (Claim claim : this.worldClaims) {
GDClaim gpClaim = (GDClaim) claim;
if (gpClaim.isAdminClaim()) {
GDClaim gdClaim = (GDClaim) claim;
if (gdClaim.isAdminClaim()) {
continue;
}
if (gpClaim.parent != null) {
if (gpClaim.parent.getOwnerUniqueId().equals(playerUniqueId)) {
if (gdClaim.parent != null) {
if (gdClaim.parent.getOwnerUniqueId().equals(playerUniqueId)) {
claimList.add(claim);
}
} else {
if (gpClaim.getOwnerUniqueId().equals(playerUniqueId)) {
if (gdClaim.getOwnerUniqueId().equals(playerUniqueId)) {
claimList.add(claim);
}
}
@ -256,7 +258,7 @@ public void removeClaimData(Claim claim) {
@Override
public ClaimResult deleteClaim(Claim claim, boolean deleteChildren) {
GDRemoveClaimEvent event = new GDRemoveClaimEvent(claim);
GDRemoveClaimEvent.Delete event = new GDRemoveClaimEvent.Delete(claim);
GriefDefender.getEventManager().post(event);
if (event.cancelled()) {
return new GDClaimResult(claim, ClaimResultType.CLAIM_EVENT_CANCELLED, event.getMessage().orElse(null));
@ -266,10 +268,10 @@ public ClaimResult deleteClaim(Claim claim, boolean deleteChildren) {
}
public ClaimResult deleteClaimInternal(Claim claim, boolean deleteChildren) {
final GDClaim gpClaim = (GDClaim) claim;
final GDClaim gdClaim = (GDClaim) claim;
Set<Claim> subClaims = claim.getChildren(false);
for (Claim child : subClaims) {
if (deleteChildren || (gpClaim.parent == null && child.isSubdivision())) {
if (deleteChildren || (gdClaim.parent == null && child.isSubdivision())) {
this.deleteClaimInternal(child, true);
continue;
}
@ -302,8 +304,14 @@ public ClaimResult deleteClaimInternal(Claim claim, boolean deleteChildren) {
this.worldClaims.remove(claim);
this.claimUniqueIdMap.remove(claim.getUniqueId());
this.deleteChunkHashes((GDClaim) claim);
if (gpClaim.parent != null) {
gpClaim.parent.children.remove(claim);
if (gdClaim.parent != null) {
gdClaim.parent.children.remove(claim);
}
for (UUID playerUniqueId : gdClaim.playersWatching) {
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(playerUniqueId);
if (user != null && user.getOnlinePlayer() != null) {
user.getInternalPlayerData().revertClaimVisual(gdClaim);
}
}
return DATASTORE.deleteClaimFromStorage((GDClaim) claim);
@ -353,9 +361,6 @@ private void resetPlayerClaimVisuals(Claim claim) {
GDPlayerData playerData = this.getPlayerDataMap().get(claim.getOwnerUniqueId());
if (playerData != null) {
playerData.getInternalClaims().remove(claim);
if (playerData.lastClaim != null) {
playerData.lastClaim.clear();
}
}
// revert visuals for all players watching this claim
@ -364,10 +369,7 @@ private void resetPlayerClaimVisuals(Claim claim) {
Player player = Bukkit.getServer().getPlayer(playerUniqueId);
if (player != null) {
playerData = this.getOrCreatePlayerData(playerUniqueId);
playerData.revertActiveVisual(player);
if (playerData.lastClaim != null) {
playerData.lastClaim.clear();
}
playerData.revertClaimVisual((GDClaim) claim);
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().revertVisuals(player, playerData, claim.getUniqueId());
}
@ -472,10 +474,21 @@ public Map<Long, Set<Claim>> getInternalChunksToClaimsMap() {
public void save() {
for (Claim claim : this.worldClaims) {
GDClaim gpClaim = (GDClaim) claim;
gpClaim.save();
GDClaim gdClaim = (GDClaim) claim;
gdClaim.save();
}
this.getWildernessClaim().save();
for (GDChunk chunk : this.chunksToGDChunks.values()) {
if (!chunk.isDirty()) {
continue;
}
if (chunk.getTrackedShortPlayerPositions().size() > 0) {
chunk.saveChunkTrackingData();
}
}
this.playerIndexStorage.savePlayerDatData();
}
public void unload() {
@ -491,33 +504,34 @@ public void unload() {
}
public Claim getClaimAt(Location location, boolean useBorderBlockRadius) {
return this.getClaimAt(VecHelper.toVector3i(location), null, null, useBorderBlockRadius);
return this.getClaimAt(VecHelper.toVector3i(location), null, useBorderBlockRadius);
}
public Claim getClaimAtPlayer(Location location, GDPlayerData playerData) {
return this.getClaimAt(VecHelper.toVector3i(location), (GDClaim) playerData.lastClaim.get(), playerData, false);
return this.getClaimAt(VecHelper.toVector3i(location), playerData, false);
}
public Claim getClaimAtPlayer(Location location, GDPlayerData playerData, boolean useBorderBlockRadius) {
return this.getClaimAt(VecHelper.toVector3i(location), (GDClaim) playerData.lastClaim.get(), playerData, useBorderBlockRadius);
return this.getClaimAt(VecHelper.toVector3i(location), playerData, useBorderBlockRadius);
}
@Override
public Claim getClaimAt(Vector3i pos) {
return this.getClaimAt(pos, null, null, false);
return this.getClaimAt(pos, null, false);
}
public Claim getClaimAt(Vector3i pos, GDClaim cachedClaim, GDPlayerData playerData, boolean useBorderBlockRadius) {
if (cachedClaim != null && !cachedClaim.isWilderness() && cachedClaim.contains(pos, true)) {
return cachedClaim;
}
@Override
public Claim getClaimAt(int x, int y, int z) {
return this.getClaimAt(new Vector3i(x, y, z), null, false);
}
public Claim getClaimAt(Vector3i pos, GDPlayerData playerData, boolean useBorderBlockRadius) {
Set<Claim> claimsInChunk = this.getInternalChunksToClaimsMap().get(BlockUtil.getInstance().asLong(pos.getX() >> 4, pos.getZ() >> 4));
if (useBorderBlockRadius && (playerData != null && !playerData.bypassBorderCheck)) {
final int borderBlockRadius = GriefDefenderPlugin.getActiveConfig(this.worldUniqueId).getConfig().claim.borderBlockRadius;
// if borderBlockRadius > 0, check surrounding chunks
if (borderBlockRadius > 0) {
for (Direction direction : BlockUtil.getInstance().ORDINAL_SET) {
for (Direction direction : BlockUtil.ORDINAL_SET) {
Vector3i currentPos = pos;
for (int i = 0; i < borderBlockRadius; i++) { // Handle depth
currentPos = BlockUtil.getInstance().getBlockRelative(currentPos, direction);
@ -634,16 +648,16 @@ public UUID getWorldId() {
}
public GDChunk getChunk(Chunk chunk) {
GDChunk gpChunk = this.chunksToGpChunks.get(getChunkKey(chunk));
if (gpChunk == null) {
gpChunk = new GDChunk(chunk);
this.chunksToGpChunks.put(getChunkKey(chunk), gpChunk);
GDChunk gdChunk = this.chunksToGDChunks.get(getChunkKey(chunk));
if (gdChunk == null) {
gdChunk = new GDChunk(chunk);
this.chunksToGDChunks.put(getChunkKey(chunk), gdChunk);
}
return gpChunk;
return gdChunk;
}
public void removeChunk(Chunk chunk) {
this.chunksToGpChunks.remove(getChunkKey(chunk));
this.chunksToGDChunks.remove(getChunkKey(chunk));
}
private long getChunkKey(Chunk chunk) {

View File

@ -54,6 +54,9 @@ public GDClaimType(String id, String name) {
} else if (name.equalsIgnoreCase("town")) {
this.defaultContext = ClaimContexts.TOWN_DEFAULT_CONTEXT;
this.overrideContext = ClaimContexts.TOWN_OVERRIDE_CONTEXT;
} else if (name.equalsIgnoreCase("user")) {
this.defaultContext = ClaimContexts.USER_DEFAULT_CONTEXT;
this.overrideContext = ClaimContexts.USER_OVERRIDE_CONTEXT;
} else if (name.equalsIgnoreCase("wilderness")) {
this.defaultContext = ClaimContexts.WILDERNESS_DEFAULT_CONTEXT;
this.overrideContext = ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT;

View File

@ -56,6 +56,7 @@
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.flag.GDActiveFlagData;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.ui.UIFlagData;
import com.griefdefender.permission.ui.MenuType;
import com.griefdefender.permission.ui.UIHelper;
@ -148,7 +149,11 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
"flag", commandFlag)));
return;
}
if (flag != null && !GDFlags.isFlagEnabled(flag)) {
TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.FLAG_NOT_ENABLED, ImmutableMap.of(
"flag", commandFlag)));
return;
}
if (flag != null && !player.hasPermission(GDPermissions.USER_CLAIM_FLAGS + "." + flag.getName().toLowerCase())) {
TextAdapter.sendComponent(player, MessageCache.getInstance().PERMISSION_FLAG_USE);
return;
@ -170,7 +175,7 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
if (claim != null) {
if (flag == null && value == null && player.hasPermission(GDPermissions.COMMAND_LIST_CLAIM_FLAGS)) {
String defaultGroup = "";
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().entrySet()) {
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getFlagConfig().getConfig().customFlags.getGroups().entrySet()) {
final String permission = groupEntry.getValue().isAdminGroup() ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupEntry.getKey()) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -212,7 +217,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String flagG
TextComponent.Builder flagHeadBuilder = TextComponent.builder()
.append(" Displaying :", TextColor.AQUA);
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups();
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getFlagConfig().getConfig().customFlags.getGroups();
List<String> groups = new ArrayList<>();
for (Map.Entry<String, CustomFlagGroupCategory> flagGroupEntry : flagGroups.entrySet()) {
final CustomFlagGroupCategory flagGroupCat = flagGroupEntry.getValue();
@ -220,7 +225,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String flagG
continue;
}
final String groupName = flagGroupEntry.getKey();
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getFlagConfig().getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupName) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -246,11 +251,27 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String flagG
.build());
}
final Map<String, GDFlagDefinition> definitions = new HashMap<>(flagGroupCat.getFlagDefinitions());
boolean isAdminUser = false;
if (flagGroup.equalsIgnoreCase("user") && src.getOnlinePlayer().hasPermission(GDPermissions.COMMAND_DELETE_ADMIN_CLAIMS)) {
for (String group : groups) {
if (group.equalsIgnoreCase("user")) {
continue;
}
final CustomFlagGroupCategory adminGroup = flagGroups.get(group);
if (adminGroup.isAdminGroup()) {
isAdminUser = true;
if (adminGroup != null) {
definitions.putAll(new HashMap<>(adminGroup.getFlagDefinitions()));
}
}
}
}
List<Component> textComponents = new ArrayList<>();
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
for (GDFlagDefinition customFlag : definitions.values()) {
if (customFlag.isEnabled()) {
Component flagText = TextComponent.builder()
.append(getCustomFlagText(customFlag))
.append(getCustomFlagText(customFlag, isAdminUser))
.append(" ")
.append(this.getCustomClickableText(src, claim, customFlag, flagGroup))
.build();
@ -403,6 +424,10 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
defaultContexts.add(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT);
}
if (!claim.isWilderness() && !claim.isAdminClaim()) {
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());
@ -453,6 +478,9 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
final UIFlagData flagData = mapEntry.getValue();
final Flag flag = flagData.flag;
if (!GDFlags.isFlagEnabled(flag)) {
continue;
}
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
continue;
@ -491,12 +519,12 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
Component footer = null;
if (player.hasPermission(GDPermissions.ADVANCED_FLAGS)) {
footer = TextComponent.builder().append(TextComponent.builder()
.append(TextComponent.of("PRESET").color(TextColor.GRAY)
.append(MessageCache.getInstance().TITLE_PRESET.color(TextColor.GRAY)
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createCustomFlagConsumer(src, claim, lastActivePresetMenu)))))
.build())
.append(" ")
.append(whiteOpenBracket)
.append(TextComponent.of("ADVANCED").color(TextColor.RED))
.append(MessageCache.getInstance().TITLE_ADVANCED.color(TextColor.RED))
.append(whiteCloseBracket)
.build();
if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) {
@ -542,10 +570,10 @@ private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set
}
}
private Component getCustomFlagText(GDFlagDefinition customFlag) {
private Component getCustomFlagText(GDFlagDefinition customFlag, boolean isAdminUser) {
TextComponent definitionType = TextComponent.empty();
TextColor flagColor = TextColor.YELLOW;
if (customFlag.isAdmin()) {
if (customFlag.isAdmin() && !isAdminUser) {
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
definitionType = TextComponent.builder()
@ -571,12 +599,18 @@ private Component getCustomFlagText(GDFlagDefinition customFlag) {
}
}
if (definitionType == TextComponent.empty()) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
TextComponent.Builder builder = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append(MessageCache.getInstance().TITLE_CLAIM.color(TextColor.YELLOW));
if (customFlag.isAdmin() && isAdminUser) {
builder.append("\n")
.append(MessageCache.getInstance().LABEL_GROUP.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("CLAIM", TextColor.YELLOW)
.build();
.append(customFlag.getGroupName().toUpperCase(), TextColor.RED);
}
definitionType = builder.build();
}
final Component baseFlagText = TextComponent.builder()
.append(customFlag.getName(), flagColor)
@ -605,12 +639,11 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
boolean hasEditPermission = true;
Component denyReason = claim.allowEdit(player);
if (denyReason != null) {
hoverBuilder.append(denyReason).append("\n");
hasEditPermission = false;
hasHover = true;
}
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getFlagConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
// check flag perm
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getName())) {
@ -636,8 +669,10 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
definitionContexts.add(claim.getContext());
}
boolean hasOverride = false;
UUID parentInheritUniqueId = null;
Component parentInheritFriendlyType = null;
for (FlagData flagData : customFlag.getFlagData()) {
if (customFlag.isAdmin()) {
if (customFlag.isAdmin() && !flagGroup.equalsIgnoreCase("user")) {
definitionResults.add(this.getSpecificDefinitionResult(claim, customFlag, flagData));
} else {
final GDActiveFlagData activeData = this.getActiveDefinitionResult(claim, customFlag, flagData);
@ -645,6 +680,12 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (activeData.getType() == GDActiveFlagData.Type.OVERRIDE) {
hasOverride = true;
hasEditPermission = false;
} else if (activeData.getType() == GDActiveFlagData.Type.OWNER_OVERRIDE_PARENT_INHERIT || activeData.getType() == GDActiveFlagData.Type.CLAIM_PARENT_INHERIT) {
if (claim.allowEdit(src) != null) {
hasEditPermission = false;
parentInheritUniqueId = activeData.getInheritParentUniqueId();
parentInheritFriendlyType = activeData.getInheritParentFriendlyType();
}
}
}
}
@ -665,7 +706,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (hasEditPermission) {
hoverBuilder.append("Conflict Data : \n");
for (GDActiveFlagData definitionFlagData : definitionResults) {
hoverBuilder.append(definitionFlagData.getComponent())
hoverBuilder.append(definitionFlagData.getComponent(flagGroup))
.append("\n");
}
hasHover = true;
@ -702,13 +743,13 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (!customFlag.getContexts().isEmpty()) {
hoverBuilder.append("\nDefinition Contexts: ");
if (!customFlag.isAdmin()) {
if (!customFlag.isAdmin() || flagGroup.equalsIgnoreCase("user")) {
hoverBuilder.append("gd_claim", TextColor.AQUA)
.append("=", TextColor.WHITE)
.append(claim.getUniqueId().toString(), TextColor.GRAY);
}
for (Context context : customFlag.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
if ((!customFlag.isAdmin() || flagGroup.equalsIgnoreCase("user")) && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
@ -736,7 +777,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
hoverBuilder.append("\nContexts: ");
}
for (Context context : flagData.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
if ((!customFlag.isAdmin() || flagGroup.equalsIgnoreCase("user")) && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
@ -765,6 +806,13 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (hasOverride) {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_OVERRIDE_NO_PERMISSION);
hasHover = true;
} else if (parentInheritUniqueId != null) {
hoverBuilder.append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.FLAG_UI_INHERIT_PARENT,
ImmutableMap.of("name", parentInheritFriendlyType)));
hasHover = true;
} else if (denyReason != null) {
hoverBuilder.append(denyReason);
hasHover = true;
}
}
@ -834,94 +882,128 @@ public GDActiveFlagData getActiveDefinitionResult(GDClaim claim, GDFlagDefinitio
contexts.addAll(flagDefinition.getContexts());
// check if admin definition has gd_claim contex
boolean hasClaimContext = false;
boolean hasOverrideClaimContext = false;
boolean hasDefaultClaimContext = false;
boolean hasOverrideOwnerContext = false;
boolean replaceClaimContext = false;
final Iterator<Context> iterator = contexts.iterator();
Context claimContext = claim.getContext();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!flagDefinition.isAdmin()) {
hasClaimContext = true;
if (context.getKey().contains("gd_claim")) {
if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM_OVERRIDE)) {
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
hasOverrideOwnerContext = true;
}
} else {
iterator.remove();
}
} else {
if (context.getKey().equalsIgnoreCase("gd_claim")) {
if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM)) {
claimContext = context;
hasClaimContext = true;
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
}
} else if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
hasDefaultClaimContext = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
hasOverrideClaimContext = true;
} else if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM_DEFAULT)) {
iterator.remove();
} else if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM_OVERRIDE)) {
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
hasOverrideOwnerContext = true;
}
}
}
}
final Set<Context> filteredContexts = new HashSet<>(contexts);
if (!flagDefinition.isAdmin() || hasClaimContext) {
// First check if this permission has been overridden by admin
// Check override
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getOverrideTypeContext());
contexts.add(claim.getOverrideClaimContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.OVERRIDE);
}
// First check if this permission has been overridden by admin
// Check override
Set<Context> permissionContexts = new HashSet<>(filteredContexts);
permissionContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
permissionContexts.add(claim.getWorldContext());
permissionContexts.add(claim.getOverrideTypeContext());
permissionContexts.addAll(flagData.getContexts());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, GDActiveFlagData.Type.OVERRIDE);
}
// Check claim
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
if (flagDefinition.isAdmin()) {
if (replaceClaimContext) {
contexts.remove(claimContext);
contexts.add(claim.getContext());
} else {
contexts.add(claimContext);
final List<Claim> inheritParents = claim.getInheritedParents();
// Check claim owner override
if (hasOverrideOwnerContext) {
permissionContexts = new HashSet<>(filteredContexts);
permissionContexts.addAll(flagData.getContexts());
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
permissionContexts.add(parent.getOverrideClaimContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, parent.getUniqueId(), parent.getFriendlyNameType(), GDActiveFlagData.Type.OWNER_OVERRIDE_PARENT_INHERIT);
}
} else {
contexts.add(claimContext);
contexts.remove(parent.getOverrideClaimContext());
}
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
permissionContexts.add(claim.getOverrideClaimContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.CLAIM);
}
}
if (!hasClaimContext && !hasOverrideClaimContext) {
// Direct lookup
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, GDActiveFlagData.Type.OWNER_OVERRIDE);
}
}
if (!hasDefaultClaimContext) {
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getDefaultTypeContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
// Check claim
permissionContexts = new HashSet<>(filteredContexts);
permissionContexts.addAll(flagData.getContexts());
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
// check parent context
permissionContexts.add(parent.getContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, parent.getUniqueId(), parent.getFriendlyNameType(), GDActiveFlagData.Type.CLAIM_PARENT_INHERIT);
}
contexts.remove(parent.getContext());
}
return new GDActiveFlagData(flagDefinition, flagData,Tristate.UNDEFINED, contexts, GDActiveFlagData.Type.UNDEFINED);
if (replaceClaimContext) {
permissionContexts.remove(claimContext);
permissionContexts.add(claim.getContext());
} else {
permissionContexts.add(claimContext);
}
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, hasOverrideOwnerContext ? GDActiveFlagData.Type.OWNER_OVERRIDE : GDActiveFlagData.Type.CLAIM);
}
// Check default
permissionContexts = new HashSet<>(filteredContexts);
permissionContexts.addAll(flagData.getContexts());
permissionContexts.remove(claimContext);
// Check default type first
permissionContexts.add(claim.getDefaultTypeContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, GDActiveFlagData.Type.DEFAULT);
}
permissionContexts.remove(claim.getDefaultTypeContext());
if (!claim.isWilderness() && !claim.isAdminClaim()) {
permissionContexts.add(ClaimContexts.USER_DEFAULT_CONTEXT);
}
permissionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
permissionContexts.add(claim.getWorldContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, (GDPermissionHolder) flagDefinition.getSubject(), flagData.getFlag().getPermission(), permissionContexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, permissionContexts, GDActiveFlagData.Type.DEFAULT);
}
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) {
@ -1078,22 +1160,31 @@ private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, G
GDCauseStackManager.getInstance().pushCause(player);
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
boolean addClaimContext = false;
boolean addClaimOverrideContext = false;
final Iterator<Context> iterator = definitionContexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!customFlag.isAdmin()) {
if (context.getKey().contains("gd_claim")) {
if (!customFlag.isAdmin() || (customFlag.isAdmin() && flagGroup.equalsIgnoreCase("user"))) {
if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM_OVERRIDE) && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimOverrideContext = true;
} else if (context.getKey().contains(ContextKeys.CLAIM)) {
iterator.remove();
}
addClaimContext = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim") && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimContext = true;
break;
} else {
if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM) && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimContext = true;
} else if (context.getKey().equalsIgnoreCase(ContextKeys.CLAIM_OVERRIDE) && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimOverrideContext = true;
}
}
}
if (addClaimContext) {
if (addClaimOverrideContext) {
definitionContexts.add(claim.getOverrideClaimContext());
} else if (addClaimContext) {
definitionContexts.add(claim.getContext());
}
for (FlagData flagData : customFlag.getFlagData()) {

View File

@ -59,6 +59,7 @@
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.option.GDOption;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.permission.ui.ClaimClickData;
import com.griefdefender.permission.ui.MenuType;
import com.griefdefender.permission.ui.OptionData;
@ -144,6 +145,11 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
"option", commandOption)));
return;
}
if (option != null && !GDOptions.isOptionEnabled(option)) {
TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.OPTION_NOT_ENABLED, ImmutableMap.of(
"option", commandOption)));
return;
}
if (option == Options.PLAYER_COMMAND_ENTER || option == Options.PLAYER_COMMAND_EXIT) {
if (contexts == null) {
TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.OPTION_REQUIRES_CONTEXTS, ImmutableMap.of(
@ -268,7 +274,7 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy
boolean isAdmin = false;
final Player player = src.getOnlinePlayer();
final GDPlayerData playerData = src.getInternalPlayerData();
final boolean isTaxEnabled = GriefDefenderPlugin.getActiveConfig(player.getWorld()).getConfig().claim.bankTaxSystem;
final boolean isTaxEnabled = GriefDefenderPlugin.getActiveConfig(player.getWorld()).getConfig().economy.taxSystem;
if (player.hasPermission(GDPermissions.DELETE_CLAIM_ADMIN)) {
isAdmin = true;
}
@ -366,6 +372,10 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy
defaultContexts.add(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT);
}
if (!claim.isWilderness() && !claim.isAdminClaim()) {
defaultContexts.add(ClaimContexts.USER_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.USER_OVERRIDE_CONTEXT);
}
defaultContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
overrideContexts.add(claim.getOverrideClaimContext());
@ -385,6 +395,9 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy
if (option.isGlobal() && displayType == MenuType.CLAIM) {
continue;
}
if (!GDOptions.isOptionEnabled(option)) {
continue;
}
// commands are special-cased as they use a List and cannot show up with no data
if (option == Options.PLAYER_COMMAND_ENTER || option == Options.PLAYER_COMMAND_EXIT) {
continue;
@ -445,7 +458,7 @@ protected void showOptionPermissions(GDPermissionUser src, GDClaim claim, MenuTy
for (Entry<String, OptionData> mapEntry : filteredContextMap.entrySet()) {
final OptionData optionData = mapEntry.getValue();
final Option option = optionData.option;
if (option.getName().contains("tax") && !GriefDefenderPlugin.getGlobalConfig().getConfig().claim.bankTaxSystem) {
if (option.getName().contains("tax") && !GriefDefenderPlugin.getGlobalConfig().getConfig().economy.taxSystem) {
continue;
}
if (option.isGlobal() && displayType == MenuType.CLAIM) {
@ -507,7 +520,7 @@ private void addFilteredContexts(GDPermissionUser src, Map<String, OptionData> f
if (option == null) {
continue;
}
if (option.getName().contains("tax") && !GriefDefenderPlugin.getGlobalConfig().getConfig().claim.bankTaxSystem) {
if (option.getName().contains("tax") && !GriefDefenderPlugin.getGlobalConfig().getConfig().economy.taxSystem) {
continue;
}
@ -570,8 +583,7 @@ private Component getClickableOptionComponent(GDPermissionUser src, GDClaim clai
hoverEventText = MessageCache.getInstance().PERMISSION_OPTION_USE;
hasEditPermission = false;
}
}
else {
} else {
if (!player.hasPermission(GDPermissions.USER_CLAIM_OPTIONS +"." + option.getName().toLowerCase())) {
hoverEventText = MessageCache.getInstance().PERMISSION_OPTION_USE;
hasEditPermission = false;
@ -599,12 +611,23 @@ private Component getClickableOptionComponent(GDPermissionUser src, GDClaim clai
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(newOptionValueConsumer(src, claim, option, optionHolder, contexts, displayType, true)))))
.append(currentValue.toLowerCase(), color);
} else {
if (hoverEventText == TextComponent.empty() && hasEditPermission) {
hoverEventText = MessageCache.getInstance().CLAIMINFO_UI_CLICK_TOGGLE;
}
final TextComponent valueNoHover =
TextComponent.builder()
.append(currentValue.toLowerCase(), color).build();
final TextComponent valueHover =
TextComponent.builder()
.append(currentValue.toLowerCase(), color)
.hoverEvent(HoverEvent.showText(
hoverEventText
.append(this.getHoverContextComponent(contexts))))
.build();
builder = TextComponent.builder()
.append(getOptionText(option, contexts))
.append(" ")
.append(TextComponent.builder()
.append(currentValue.toLowerCase(), color)
.hoverEvent(HoverEvent.showText(hoverEventText)));
.append(hoverEventText != TextComponent.empty() ? valueHover : valueNoHover);
}
if (hasEditPermission) {
if (!option.getAllowedType().isAssignableFrom(Integer.class) && !option.getAllowedType().isAssignableFrom(Double.class)) {
@ -642,6 +665,27 @@ private Component getClickableOptionComponent(GDPermissionUser src, GDClaim clai
return builder.build();
}
private Component getHoverContextComponent(Set<Context> contexts) {
if (contexts.isEmpty()) {
return TextComponent.empty();
}
TextComponent.Builder builder = TextComponent.builder()
.append("\n\nContexts: \n");
for (Context context : contexts) {
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
builder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY)
.append("\n");
}
return builder.build();
}
private void appendContexts(TextComponent.Builder builder, Set<Context> contexts) {
// check source/target
Component source = null;
@ -685,11 +729,14 @@ private Consumer<CommandSender> newOptionValueConsumer(GDPermissionUser src, GDC
Tristate value = getMenuTypeValue(TypeToken.of(Tristate.class), currentValue);
if (value == Tristate.TRUE) {
newValue = "false";
} else if (value == Tristate.FALSE) {
} else if (value == Tristate.FALSE && optionHolder.getType() != MenuType.DEFAULT) {
newValue = "undefined";
} else {
newValue = "true";
}
if (displayType == MenuType.CLAIM && optionHolder.getType() == MenuType.DEFAULT && newValue.equalsIgnoreCase(currentValue)) {
newValue = "undefined";
}
}
if (option.getAllowedType().isAssignableFrom(Boolean.class)) {
Boolean value = getMenuTypeValue(TypeToken.of(Boolean.class), currentValue);
@ -771,10 +818,10 @@ private Consumer<CommandSender> newOptionValueConsumer(GDPermissionUser src, GDC
if (option.getAllowedType().isAssignableFrom(Double.class)) {
Double value = getMenuTypeValue(TypeToken.of(Double.class), currentValue);
if (leftArrow) {
if (value == null || value < 1) {
if (value == null || value < 0) {
TextAdapter.sendComponent(src.getOnlinePlayer(), TextComponent.of("This value is NOT defined and cannot go any lower."));
} else {
value -= 1;
value -= 0.1;
if (option == Options.ABANDON_RETURN_RATIO && value <= 0) {
value = null;
} else {
@ -787,10 +834,10 @@ private Consumer<CommandSender> newOptionValueConsumer(GDPermissionUser src, GDC
if (value == null) {
value = 1.0;
} else {
value += 1;
value += 0.1;
}
}
newValue = value == null ? "undefined" :String.valueOf(value);
newValue = value == null ? "undefined" : String.format("%.1f", value);
}
Set<Context> newContexts = new HashSet<>(contexts);

View File

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

View File

@ -135,9 +135,9 @@ public void execute(Player player) {
.append(autoSchematicRestore ? MessageCache.getInstance().SCHEMATIC_ABANDON_RESTORE_WARNING : MessageCache.getInstance().ABANDON_WARNING)
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(player, playerData, claim, this.abandonTopClaim))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, playerData, claim, this.abandonTopClaim), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(player, confirmationText);
@ -175,7 +175,7 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player player,
}
playerData.onClaimDelete();
playerData.revertActiveVisual(player);
playerData.revertClaimVisual(claim);
if (claim.isTown()) {
playerData.inTown = false;

View File

@ -90,9 +90,9 @@ public void execute(Player player) {
.append(autoSchematicRestore ? MessageCache.getInstance().SCHEMATIC_ABANDON_ALL_RESTORE_WARNING : MessageCache.getInstance().ABANDON_ALL_WARNING)
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(user))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(user), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(player, confirmationText);
@ -168,8 +168,6 @@ private static Consumer<CommandSender> createConfirmationConsumer(GDPermissionUs
"amount", remainingBlocks));
TextAdapter.sendComponent(player, message);
}
playerData.revertActiveVisual(player);
}
if (!delayedClaims.isEmpty()) {

View File

@ -48,7 +48,7 @@ public class CommandClaimBank extends BaseCommand {
@Syntax("<withdraw|deposit> <amount>")
@Subcommand("claim bank")
public void execute(Player player, @Optional String[] args) throws CommandException {
if (!GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().claim.bankTaxSystem) {
if (!GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().economy.bankSystem) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().BANK_TAX_SYSTEM_DISABLED);
return;
}

View File

@ -41,6 +41,8 @@
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.util.EconomyUtil;
import net.kyori.text.Component;
import net.kyori.text.adapter.bukkit.TextAdapter;
import net.milkbowl.vault.economy.Economy;
@ -76,21 +78,10 @@ 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);
final double economyBlockSell = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), player, Options.ECONOMY_BLOCK_SELL_RETURN);
if (economyBlockCost == 0 && economyBlockSell == 0) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_BLOCK_BUY_SELL_DISABLED);
return;
}
if (economyBlockCost == 0) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_BLOCK_ONLY_SELL);
return;
}
final double balance = economy.getBalance(player);
if (blockCount == null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_BLOCK_PURCHASE_COST, ImmutableMap.of(
"amount", economyBlockCost,
"amount", "$" + String.format("%.2f", economyBlockCost),
"balance", String.valueOf("$" + balance)));
GriefDefenderPlugin.sendMessage(player, message);
return;
@ -101,8 +92,16 @@ public void execute(Player player, @Optional Integer blockCount) {
}
final double totalCost = blockCount * economyBlockCost;
final EconomyResponse result = economy.withdrawPlayer(player, totalCost);
final int newClaimBlockTotal = playerData.getAccruedClaimBlocks() + blockCount;
if (newClaimBlockTotal > playerData.getMaxAccruedClaimBlocks()) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_BLOCK_PURCHASE_LIMIT, ImmutableMap.of(
"total", newClaimBlockTotal,
"limit", playerData.getMaxAccruedClaimBlocks()));
GriefDefenderPlugin.sendMessage(player, message);
return;
}
final EconomyResponse result = EconomyUtil.getInstance().withdrawFunds(player, totalCost);
if (!result.transactionSuccess()) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_WITHDRAW_ERROR, ImmutableMap.of(
"reason", result.errorMessage));
@ -113,7 +112,7 @@ public void execute(Player player, @Optional Integer blockCount) {
final int bonusTotal = playerData.getBonusClaimBlocks();
playerData.setBonusClaimBlocks(bonusTotal + blockCount);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_BLOCK_PURCHASE_CONFIRMATION, ImmutableMap.of(
"amount", totalCost,
"amount", "$" + String.format("%.2f", totalCost),
"balance", playerData.getRemainingClaimBlocks()));
GriefDefenderPlugin.sendMessage(player, message);
}

View File

@ -45,6 +45,7 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.provider.VaultProvider;
@ -190,12 +191,15 @@ public void execute(Player player, int amount, @Optional String direction) {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.RESIZE_SUCCESS_2D, params));
}
}
playerData.revertActiveVisual(player);
playerData.revertClaimVisual(claim);
claim.getVisualizer().resetVisuals();
claim.getVisualizer().createClaimBlockVisuals(player.getEyeLocation().getBlockY(), player.getLocation(), playerData);
claim.getVisualizer().apply(player);
final GDClaimVisual visual = claim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(player.getEyeLocation().getBlockY(), player.getLocation(), playerData);
}
visual.apply(player);
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().visualizeClaim(claim, player, playerData, false);
GriefDefenderPlugin.getInstance().getWorldEditProvider().displayClaimCUIVisual(claim, player, playerData, false);
}
}
}

View File

@ -49,7 +49,7 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.visual.ClaimVisual;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
@ -149,11 +149,14 @@ public void execute(Player player, int radius, @Optional String type) {
"type", gdClaim.getFriendlyNameType(true)));
GriefDefenderPlugin.sendMessage(player, message);
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().stopVisualDrag(player);
GriefDefenderPlugin.getInstance().getWorldEditProvider().visualizeClaim(gdClaim, player, playerData, false);
GriefDefenderPlugin.getInstance().getWorldEditProvider().stopDragVisual(player);
GriefDefenderPlugin.getInstance().getWorldEditProvider().displayClaimCUIVisual(gdClaim, player, playerData, false);
}
gdClaim.getVisualizer().createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
gdClaim.getVisualizer().apply(player, false);
final GDClaimVisual visual = gdClaim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
}
visual.apply(player, false);
}
}
}

View File

@ -83,12 +83,12 @@ public void execute(Player player) {
final Component confirmationText = TextComponent.builder()
.append(GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_CLAIM_WARNING,
ImmutableMap.of("player", claim.getOwnerName().color(TextColor.AQUA))))
ImmutableMap.of("player", claim.getOwnerDisplayName().color(TextColor.AQUA))))
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(player, claim, deleteTopLevelClaim))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, claim, deleteTopLevelClaim), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(player, confirmationText);
@ -106,7 +106,7 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player player,
}
playerData.onClaimDelete();
playerData.revertActiveVisual(player);
playerData.revertClaimVisual((GDClaim) claim);
if (claim.isTown()) {
playerData.inTown = false;
@ -114,7 +114,7 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player player,
}
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_CLAIM_SUCCESS,
ImmutableMap.of("player", claim.getOwnerName().color(TextColor.AQUA)));
ImmutableMap.of("player", claim.getOwnerDisplayName().color(TextColor.AQUA)));
GriefDefenderPlugin.sendMessage(player, message);
};
}

View File

@ -73,7 +73,9 @@ public void execute(Player src, OfflinePlayer otherPlayer) {
int originalClaimCount = playerData.getInternalClaims().size();
if (originalClaimCount == 0) {
TextAdapter.sendComponent(src, TextComponent.of("Player " + otherPlayer.getName() + " has no claims to delete.", TextColor.RED));
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PLAYER_NO_CLAIMS_TO_DELETE, ImmutableMap.of(
"player", otherPlayer.getName()));
TextAdapter.sendComponent(src, message);
return;
}
@ -82,9 +84,9 @@ public void execute(Player src, OfflinePlayer otherPlayer) {
ImmutableMap.of("player", TextComponent.of(otherPlayer.getName()).color(TextColor.AQUA))))
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(src, otherPlayer, playerData))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, otherPlayer, playerData), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(src, confirmationText);
@ -93,7 +95,7 @@ public void execute(Player src, OfflinePlayer otherPlayer) {
private static Consumer<CommandSender> createConfirmationConsumer(Player src, OfflinePlayer otherPlayer, GDPlayerData playerData) {
return confirm -> {
GDCauseStackManager.getInstance().pushCause(src);
GDRemoveClaimEvent event = new GDRemoveClaimEvent(ImmutableList.copyOf(playerData.getInternalClaims()));
GDRemoveClaimEvent.Delete event = new GDRemoveClaimEvent.Delete(ImmutableList.copyOf(playerData.getInternalClaims()));
GriefDefender.getEventManager().post(event);
GDCauseStackManager.getInstance().popCause();
if (event.cancelled()) {
@ -107,8 +109,6 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player src, Of
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_ALL_PLAYER_SUCCESS, ImmutableMap.of(
"player", TextComponent.of(otherPlayer.getName()).color(TextColor.AQUA)));
GriefDefenderPlugin.sendMessage(src, message);
// revert any current visualization
playerData.revertActiveVisual(src);
}
};
}

View File

@ -65,9 +65,9 @@ public void execute(Player player) {
ImmutableMap.of("type", TextComponent.of("ADMIN").color(TextColor.RED))))
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(player))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(player, confirmationText);
@ -88,7 +88,6 @@ private static Consumer<CommandSender> createConfirmationConsumer(Player player)
ImmutableMap.of("type", TextComponent.of("ADMIN").color(TextColor.RED))));
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
playerData.onClaimDelete();
playerData.revertActiveVisual(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.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.provider.VaultProvider;
@ -190,12 +191,15 @@ public void execute(Player player, int amount, @Optional String direction) {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.RESIZE_SUCCESS_2D, params));
}
}
playerData.revertActiveVisual(player);
playerData.revertClaimVisual(claim);
claim.getVisualizer().resetVisuals();
claim.getVisualizer().createClaimBlockVisuals(player.getEyeLocation().getBlockY(), player.getLocation(), playerData);
claim.getVisualizer().apply(player);
final GDClaimVisual visual = claim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(player.getEyeLocation().getBlockY(), player.getLocation(), playerData);
}
visual.apply(player);
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().visualizeClaim(claim, player, playerData, false);
GriefDefenderPlugin.getInstance().getWorldEditProvider().displayClaimCUIVisual(claim, player, playerData, false);
}
}
}

View File

@ -58,7 +58,7 @@ public void execute(Player src, OfflinePlayer player, @Optional String[] args) t
this.subject = PermissionHolderCache.getInstance().getOrCreateUser(player);
this.friendlySubjectName = player.getName();
if (PermissionUtil.getInstance().getPermissionValue(this.subject, GDPermissions.COMMAND_ADMIN_CLAIMS) == Tristate.TRUE && !src.hasPermission(GDPermissions.SET_ADMIN_FLAGS)) {
if (src.hasPermission(GDPermissions.COMMAND_ADMIN_CLAIMS) && !src.hasPermission(GDPermissions.SET_ADMIN_FLAGS)) {
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().PERMISSION_PLAYER_ADMIN_FLAGS);
return;
}

View File

@ -83,9 +83,9 @@ public void execute(Player player) {
.append(MessageCache.getInstance().FLAG_RESET_WARNING)
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(player, claim))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, claim), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(player, confirmationText);

View File

@ -35,7 +35,6 @@
import com.google.common.reflect.TypeToken;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimResult;
import com.griefdefender.api.claim.ClaimType;
@ -94,12 +93,12 @@ public class CommandClaimInfo extends BaseCommand {
private final int DENY_MESSAGES = 2;
private final int FLAG_OVERRIDES = 3;
private final int INHERIT_PARENT = 4;
private final int PVP_OVERRIDE = 5;
private final int RAID_OVERRIDE = 6;
private final int RESIZABLE = 7;
private final int REQUIRES_CLAIM_BLOCKS = 8;
private final int SIZE_RESTRICTIONS = 9;
private final int FOR_SALE = 10;
private final int RAID_OVERRIDE = 5;
private final int RESIZABLE = 6;
private final int REQUIRES_CLAIM_BLOCKS = 7;
private final int SIZE_RESTRICTIONS = 8;
private final int FOR_SALE = 9;
private final int IS_EXPIRED = 10;
private boolean useTownInfo = false;
public CommandClaimInfo() {
@ -133,7 +132,6 @@ public void execute(CommandSender src, String[] args) {
return;
}
boolean isAdmin = src.hasPermission(GDPermissions.COMMAND_ADMIN_CLAIMS);
final GDPlayerData playerData = player != null ? GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()) : null;
Claim claim = null;
if (claimIdentifier == null) {
@ -185,10 +183,7 @@ public void execute(CommandSender src, String[] args) {
final GDClaim gdClaim = (GDClaim) claim;
final GDPermissionUser owner = PermissionHolderCache.getInstance().getOrCreateUser(claim.getOwnerUniqueId());
final UUID ownerUniqueId = claim.getOwnerUniqueId();
if (!isAdmin) {
isAdmin = playerData.canIgnoreClaim(gdClaim);
}
final boolean isAdmin = gdClaim.allowEdit(player) == null;
// if not owner of claim, validate perms
if (!isAdmin && !player.getUniqueId().equals(claim.getOwnerUniqueId())) {
if (!gdClaim.getInternalClaimData().getContainers().contains(player.getUniqueId())
@ -304,7 +299,7 @@ public void execute(CommandSender src, String[] args) {
Component bankInfo = null;
Component forSaleText = null;
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null) {
if (GriefDefenderPlugin.getActiveConfig(gdClaim.getWorld().getUID()).getConfig().claim.bankTaxSystem) {
if (GriefDefenderPlugin.getActiveConfig(gdClaim.getWorld().getUID()).getConfig().economy.bankSystem) {
bankInfo = TextComponent.builder()
.append(MessageCache.getInstance().CLAIMINFO_UI_BANK_INFO.color(TextColor.GOLD).decoration(TextDecoration.ITALIC, true))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().CLAIMINFO_UI_BANK_INFO))
@ -337,6 +332,15 @@ public void execute(CommandSender src, String[] args) {
.append(MessageCache.getInstance().LABEL_OWNER.color(TextColor.YELLOW))
.append(" : ")
.append(ownerName != null && !claim.isAdminClaim() && !claim.isWilderness() ? ownerName : "administrator", TextColor.GOLD).build();
Component renterLine = null;
if (claim.getEconomyData() != null && claim.getEconomyData().isRented()) {
final UUID uuid = claim.getEconomyData().getRenters().get(0);
final GDPermissionUser renter = PermissionHolderCache.getInstance().getOrCreateUser(uuid);
renterLine = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_RENTER.color(TextColor.YELLOW))
.append(" : ")
.append(renter.getFriendlyName(), TextColor.AQUA).build();
}
Component adminShowText = TextComponent.empty();
Component basicShowText = TextComponent.empty();
Component subdivisionShowText = TextComponent.empty();
@ -471,10 +475,15 @@ public void execute(CommandSender src, String[] args) {
.append(MessageCache.getInstance().LABEL_INHERIT.color(TextColor.YELLOW))
.append(" : ")
.append(getClickableInfoText(src, claim, INHERIT_PARENT, claim.getData().doesInheritParent() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))).build();
Component claimExpired = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_EXPIRED.color(TextColor.YELLOW))
.append(" : ")
.append(claim.getData().isExpired() ? TextComponent.of("YES", TextColor.RED) : TextComponent.of("NO", TextColor.GRAY)).build();
TextComponent.Builder expireBuilder = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_EXPIRED.color(TextColor.YELLOW))
.append(" : ");
if (isAdmin && claim.getData().isExpired()) {
expireBuilder.append(getClickableInfoText(src, claim, IS_EXPIRED, claim.getData().isExpired() ? TextComponent.of("YES", TextColor.RED) : TextComponent.of("NO", TextColor.GRAY)));
} else {
expireBuilder.append(claim.getData().isExpired() ? TextComponent.of("YES", TextColor.RED) : TextComponent.of("NO", TextColor.GRAY));
}
Component claimExpired = expireBuilder.build();
Component claimFarewell = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_FAREWELL.color(TextColor.YELLOW))
.append(" : ")
@ -487,16 +496,6 @@ public void execute(CommandSender src, String[] args) {
.append(MessageCache.getInstance().CLAIMINFO_UI_DENY_MESSAGES.color(TextColor.YELLOW))
.append(" : ")
.append(getClickableInfoText(src, claim, DENY_MESSAGES, claim.getData().allowDenyMessages() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))).build();
Component pvpSetting = TextComponent.of("UNDEFINED", TextColor.GRAY);
if (claim.getData().getPvpOverride() == Tristate.TRUE) {
pvpSetting = TextComponent.of("ON", TextColor.GREEN);
} else if (claim.getData().getPvpOverride() == Tristate.FALSE) {
pvpSetting = TextComponent.of("OFF", TextColor.RED);
}
Component claimPvP = TextComponent.builder()
.append("PvP", TextColor.YELLOW)
.append(" : ")
.append(getClickableInfoText(src, claim, PVP_OVERRIDE, pvpSetting)).build();
Component claimRaid = TextComponent.builder()
.append("Raid", TextColor.YELLOW)
.append(" : ")
@ -580,6 +579,9 @@ public void execute(CommandSender src, String[] args) {
}
textList.add(claimName);
textList.add(ownerLine);
if (claim.getEconomyData() != null && claim.getEconomyData().isRented()) {
textList.add(renterLine);
}
textList.add(claimTypeInfo);
if (!claim.isAdminClaim() && !claim.isWilderness()) {
textList.add(TextComponent.builder()
@ -591,8 +593,6 @@ public void execute(CommandSender src, String[] args) {
}
}
textList.add(TextComponent.builder()
.append(claimPvP)
.append(" ")
.append(claimRaid)
.append(" ")
.append(claimDenyMessages)
@ -790,19 +790,6 @@ private Consumer<CommandSender> createClaimInfoConsumer(CommandSender src, Claim
gpClaim.getInternalClaimData().setRequiresSave(true);
gpClaim.getClaimStorage().save();
break;
case PVP_OVERRIDE :
Tristate value = gpClaim.getInternalClaimData().getPvpOverride();
if (value == Tristate.UNDEFINED) {
gpClaim.getInternalClaimData().setPvpOverride(Tristate.TRUE);
} else if (value == Tristate.TRUE) {
gpClaim.getInternalClaimData().setPvpOverride(Tristate.FALSE);
} else {
gpClaim.getInternalClaimData().setPvpOverride(Tristate.UNDEFINED);
}
gpClaim.getInternalClaimData().setRequiresSave(true);
gpClaim.getClaimStorage().save();
CommandHelper.executeCommand(src, "claiminfo", gpClaim.getUniqueId().toString());
return;
case RAID_OVERRIDE :
GDPermissionHolder holder = null;
final GDPlayerData playerData = ((GDClaim) claim).getOwnerPlayerData();
@ -846,6 +833,13 @@ private Consumer<CommandSender> createClaimInfoConsumer(CommandSender src, Claim
gpClaim.getClaimStorage().save();
CommandHelper.executeCommand(src, "claiminfo", gpClaim.getUniqueId().toString());
return;
case IS_EXPIRED :
boolean isExpired = gpClaim.getInternalClaimData().isExpired();
gpClaim.getInternalClaimData().setExpired(!isExpired);
gpClaim.getInternalClaimData().setRequiresSave(true);
gpClaim.getClaimStorage().save();
CommandHelper.executeCommand(src, "claiminfo", gpClaim.getUniqueId().toString());
return;
default:
}
executeAdminSettings(src, gpClaim);

View File

@ -53,7 +53,7 @@ public void execute(Player player) {
playerData.claimMode = !playerData.claimMode;
playerData.claimSubdividing = null;
if (!playerData.claimMode) {
playerData.revertActiveVisual(player);
playerData.revertAllVisuals();
// check for any active WECUI visuals
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().revertVisuals(player, playerData, null);

View File

@ -45,7 +45,7 @@ public CommandClaimOption() {
super(ClaimSubjectType.GLOBAL);
}
@CommandCompletion("@gdoptions @gddummy")
@CommandCompletion("@gdoptions @gdcontexts @gddummy")
@CommandAlias("cod|claimoption")
@Description("Gets/Sets claim options in the claim you are standing in.")
@Syntax("[<option> <value> [context[key=value]]")

View File

@ -49,16 +49,12 @@ public CommandClaimOptionGroup() {
super(ClaimSubjectType.GROUP);
}
@CommandCompletion("@gdgroups @gdoptions @gddummy")
@CommandCompletion("@gdgroups @gdoptions @gdcontexts @gddummy")
@CommandAlias("cog")
@Description("Gets/Sets option for a group in claim you are standing in.")
@Syntax("<group> <option> <value> [context[key=value]]")
@Subcommand("option group")
public void execute(Player player, String group, @Optional String[] args) throws InvalidCommandArgument {
if (args.length < 2 || args.length > 4) {
throw new InvalidCommandArgument();
}
if (!PermissionUtil.getInstance().hasGroupSubject(group)) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_INVALID_GROUP, ImmutableMap.of(
"group", group));

View File

@ -45,7 +45,7 @@ public CommandClaimOptionPlayer() {
super(ClaimSubjectType.PLAYER);
}
@CommandCompletion("@gdplayers @gdoptions @gddummy")
@CommandCompletion("@gdplayers @gdoptions @gdcontexts @gddummy")
@CommandAlias("cop")
@Description("Gets/Sets option for a player in claim you are standing in.")
@Syntax("<player> <option> <value> [context[key=value]]")

View File

@ -0,0 +1,365 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.command;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.google.common.collect.ImmutableMap;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.api.economy.TransactionType;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.pagination.PaginationList;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.text.action.GDCallbackHolder;
import com.griefdefender.util.ChatCaptureUtil;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PermissionUtil;
import com.griefdefender.util.PlayerUtil;
import com.griefdefender.util.SignUtil;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.event.ClickEvent;
import net.kyori.text.event.HoverEvent;
import net.kyori.text.format.TextColor;
import net.kyori.text.format.TextDecoration;
import net.kyori.text.serializer.plain.PlainComponentSerializer;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@CommandAlias("%griefdefender")
@CommandPermission(GDPermissions.COMMAND_CLAIM_RENT)
public class CommandClaimRent extends BaseCommand {
@CommandCompletion("@gdrentcommands @gddummy")
@CommandAlias("claimrent")
@Description("Used to rent/list claims. \nNote: Requires economy plugin.")
@Syntax("create <rate> [<max_days>]|info|list|cancel]")
@Subcommand("claim rent")
public void execute(Player player, @Optional String[] args) {
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_NOT_INSTALLED);
return;
}
if (!GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().RENT_SYSTEM_DISABLED);
return;
}
final Economy economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi();
if (!economy.hasAccount(player)) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_PLAYER_NOT_FOUND, ImmutableMap.of(
"player", player.getName()));
GriefDefenderPlugin.sendMessage(player, message);
return;
}
if (args.length == 0) {
throw new InvalidCommandArgument();
}
if (args != null && args.length > 0) {
final String subCommand = args[0];
// cancel
if (subCommand.equalsIgnoreCase("cancel")) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
boolean isRenter = false;
for (UUID uuid : claim.getEconomyData().getRenters()) {
if (player.getUniqueId().equals(uuid)) {
isRenter = true;
break;
}
}
if (!playerData.canIgnoreClaim(claim) && !claim.getEconomyData().isForRent() && !isRenter) {
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;
}
EconomyUtil.getInstance().rentCancelConfirmation(player, claim, null);
return;
} else if (subCommand.equalsIgnoreCase("clearbalance")) {
if (args.length != 2) {
return;
}
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
if (playerData.canIgnoreClaim(claim) || player.hasPermission(GDPermissions.COMMAND_DELETE_ADMIN_CLAIMS)) {
final GDPermissionUser renter = PermissionHolderCache.getInstance().getOrCreateUser(args[1]);
if (renter != null) {
claim.getEconomyData().setRentBalance(renter.getUniqueId(), 0);
}
}
} else if (subCommand.equalsIgnoreCase("list")) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
Set<Claim> claimsForRent = new HashSet<>();
GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(player.getWorld().getUID());
for (Claim worldClaim : claimManager.getWorldClaims()) {
if (worldClaim.isWilderness()) {
continue;
}
if (!worldClaim.isAdminClaim() && worldClaim.getEconomyData().isForRent() && worldClaim.getEconomyData().getRentRate() > -1) {
claimsForRent.add(worldClaim);
}
for (Claim child : worldClaim.getChildren(true)) {
if (child.isAdminClaim()) {
continue;
}
if (child.getEconomyData().isForRent() && child.getEconomyData().getRentRate() > -1) {
claimsForRent.add(child);
}
}
}
List<Component> textList = CommandHelper.generateClaimTextListCommand(new ArrayList<Component>(), claimsForRent, player.getWorld().getName(), null, player, CommandHelper.createCommandConsumer(player, "claimrent", ""), false);
Component footer = TextComponent.empty();
int fillSize = 20 - (textList.size() + 2);
if (player.hasPermission(GDPermissions.CHAT_CAPTURE)) {
footer = TextComponent.builder()
.append(ChatCaptureUtil.getInstance().createRecordChatComponent(player, null, playerData, "claimrent"))
.build();
fillSize = 20 - (textList.size() + 3);
}
for (int i = 0; i < fillSize; i++) {
textList.add(TextComponent.of(" "));
}
PaginationList.Builder paginationBuilder = PaginationList.builder()
.title(MessageCache.getInstance().TITLE_RENT).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer);
paginationBuilder.sendTo(player);
return;
} else if (subCommand.equalsIgnoreCase("create") && args.length > 1) {
// create
final String strRate = args[1];
if (strRate.length() < 2) {
// invalid rate
return;
}
if (args.length <= 3) {
// no max
final PaymentType paymentType = SignUtil.getPaymentType(strRate);
if (paymentType == PaymentType.UNDEFINED) {
// invalid
return;
}
Double rate = null;
try {
rate = Double.valueOf(strRate.substring(0, strRate.length() - 1));
} catch (NumberFormatException e) {
return;
}
int rentMin = 0;
int rentMax = 0;
if (args.length == 3) {
rentMin = SignUtil.getRentMinTime(args[2]);
rentMax = SignUtil.getRentMaxTime(args[2]);
}
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
SignUtil.setClaimForRent(claim, player, null, rate, rentMin, rentMax, paymentType);
return;
}
} else if (subCommand.equalsIgnoreCase("info")) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
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<>();
PaymentType paymentType = claim.getEconomyData().getPaymentType();
if (paymentType == PaymentType.UNDEFINED) {
paymentType = PaymentType.DAILY;
}
Component rentRate = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_RATE.color(TextColor.YELLOW))
.append(" : ")
.append("$", TextColor.GOLD)
.append(String.format("%.2f", (claim.getEconomyData().getRentRate())), TextColor.GOLD)
.append("/", TextColor.GOLD)
.append(paymentType == PaymentType.DAILY ? MessageCache.getInstance().LABEL_DAY.color(TextColor.GOLD) : MessageCache.getInstance().LABEL_HOUR.color(TextColor.GOLD))
.build();
Component rentBalance = null;
Component rentStart = null;
Component rentDue = null;
Date rentStartDate = null;
Date rentDueDate = null;
Instant instant = claim.getEconomyData().getRentStartDate();
if (instant != null) {
rentBalance = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_BALANCE.color(TextColor.YELLOW))
.append(" : ")
.append("$" + String.format("%.2f", claim.getEconomyData().getRentBalance(player.getUniqueId())))
.build();
rentStartDate = Date.from(instant);
rentStart = TextComponent.builder()
.append(MessageCache.getInstance().RENT_UI_START_DATE.color(TextColor.YELLOW))
.append(" : ")
.append(rentStartDate == null ? "N/A" : rentStartDate.toString())
.build();
}
if (claim.getEconomyData().getRentPaymentDueDate() != null) {
rentDue= EconomyUtil.getInstance().getUserTimeRemaining(claim.getEconomyData().getRentPaymentDueDate(), MessageCache.getInstance().RENT_UI_NEXT_PAYMENT_DUE_DATE);
}
final String ownerName = PlayerUtil.getInstance().getUserName(ownerUniqueId);
final Component nameComponent = claim.getName().orElse(null);
Component ownerLine = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_OWNER.color(TextColor.YELLOW))
.append(" : ")
.append(ownerName != null && !claim.isAdminClaim() && !claim.isWilderness() ? ownerName : "administrator", TextColor.GOLD)
.build();
Component claimName = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_NAME.color(TextColor.YELLOW))
.append(" : ", TextColor.YELLOW)
.append(claim.getName().orElse(TextComponent.of(claim.getFriendlyName())))
.build();
final int min = claim.getEconomyData().getRentMinTime();
final int max = claim.getEconomyData().getRentMaxTime();
Component maxTime = null;
Component minTime = null;
if (max > 0) {
maxTime = EconomyUtil.getInstance().getUserTimeRemaining(claim.getEconomyData().getRentEndDate(), MessageCache.getInstance().RENT_UI_END_DATE);
}
if (min > 0) {
minTime = TextComponent.builder()
.append(MessageCache.getInstance().RENT_UI_MINIMUM.color(TextColor.YELLOW))
.append(" : ")
.append(String.valueOf(min))
.append(" ")
.append(claim.getEconomyData().getPaymentType() == PaymentType.DAILY ?
(min > 1 ? MessageCache.getInstance().LABEL_DAYS : MessageCache.getInstance().LABEL_DAY) :
(min > 1 ? MessageCache.getInstance().LABEL_HOURS : MessageCache.getInstance().LABEL_HOUR))
.build();
}
Component transactions = null;
if (isAdmin) {
if (claim.getEconomyData().getPaymentTransactions(TransactionType.RENT).isEmpty()) {
transactions = TextComponent.builder()
.append("[")
.append(MessageCache.getInstance().RENT_UI_VIEW_TRANSACTIONS.color(TextColor.AQUA))
.append("]")
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().RENT_UI_NO_TRANSACTIONS))
.build();
} else {
transactions = TextComponent.builder()
.append("[")
.append(MessageCache.getInstance().RENT_UI_VIEW_TRANSACTIONS.color(TextColor.AQUA))
.append("]")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createRentTransactionsConsumer(player, claim, false, false))))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_VIEW_TRANSACTIONS))
.build();
}
}
textList.add(claimName);
textList.add(ownerLine);
textList.add(rentRate);
if (rentStart != null) {
textList.add(rentBalance);
textList.add(rentStart);
textList.add(rentDue);
}
if (minTime != null) {
textList.add(minTime);
}
if (maxTime != null) {
textList.add(maxTime);
}
if (transactions != null) {
textList.add(transactions);
}
Component rentClaim = null;
if (player != null && claim.getEconomyData().isForRent() && !player.getUniqueId().equals(ownerUniqueId) && player.hasPermission(GDPermissions.USER_RENT_BASE)) {
Component rentInfo = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_PRICE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append(String.valueOf(claim.getEconomyData().getRentRate() + " per " + (claim.getEconomyData().getPaymentType() == PaymentType.DAILY ? "day" : "hour")), TextColor.GOLD)
.build();
rentClaim = TextComponent.builder()
.append(TextComponent.builder("[").append(MessageCache.getInstance().RENT_UI_CLICK_RENT.color(TextColor.GREEN)).append("]", TextColor.WHITE).build())
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(EconomyUtil.getInstance().rentClaimConsumerConfirmation(player, claim))))
.hoverEvent(HoverEvent.showText(player.getUniqueId().equals(claim.getOwnerUniqueId()) ? MessageCache.getInstance().CLAIM_OWNER_ALREADY : rentInfo)).build();
textList.add(rentClaim);
}
int fillSize = 20 - (textList.size() + 2);
Component footer = null;
if (player != null && player.hasPermission(GDPermissions.CHAT_CAPTURE)) {
footer = ChatCaptureUtil.getInstance().createRecordChatComponent(player, claim, playerData, "claimrent info");
fillSize = 20 - (textList.size() + 3);
}
for (int i = 0; i < fillSize; i++) {
textList.add(TextComponent.of(" "));
}
Component header = TextComponent.builder()
.append(PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().RENT_UI_INFO_HEADER), TextColor.AQUA)
.build();
PaginationList.Builder paginationBuilder = PaginationList.builder()
.title(header).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(textList).footer(footer);
paginationBuilder.sendTo(player);
}
}
}
}

View File

@ -150,9 +150,9 @@ private static Consumer<CommandSender> displayConfirmationConsumer(CommandSender
return confirm -> {
final Component schematicConfirmationText = TextComponent.builder("")
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(src, claim, schematic))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, claim, schematic), true)))
.hoverEvent(HoverEvent.showText(GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.SCHEMATIC_RESTORE_CONFIRMATION))).build();
TextAdapter.sendComponent(src, schematicConfirmationText);
};

View File

@ -111,9 +111,9 @@ public void execute(Player player, String arg) throws InvalidCommandArgument {
final Component saleConfirmationText = TextComponent.builder("")
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createSaleConfirmationConsumer(player, claim, salePrice))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createSaleConfirmationConsumer(player, claim, salePrice), true)))
.build();
GriefDefenderPlugin.sendMessage(player, saleConfirmationText);
}

View File

@ -87,7 +87,7 @@ public void execute(Player player, @Optional Integer blockCount) {
if (blockCount == null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_BLOCK_PURCHASE_COST,
ImmutableMap.of(
"amount", playerData.getEconomyClaimBlockReturn(),
"amount", "$" + String.format("%.2f", playerData.getEconomyClaimBlockReturn()),
"balance", availableBlocks));
GriefDefenderPlugin.sendMessage(player, message);
return;

View File

@ -45,6 +45,8 @@
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.option.GDOptions;
import net.kyori.text.Component;
import net.kyori.text.serializer.plain.PlainComponentSerializer;
@ -93,7 +95,7 @@ public void execute(Player player, @Optional String claimName, @Optional Offline
if (!srcPlayerData.canIgnoreClaim(claim) && !claim.isUserTrusted(player, TrustTypes.ACCESSOR) && !player.hasPermission(GDPermissions.COMMAND_DELETE_CLAIMS)) {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_ACCESS,
ImmutableMap.of("player", claim.getOwnerName())));
ImmutableMap.of("player", claim.getOwnerDisplayName())));
return;
}
@ -104,7 +106,10 @@ public void execute(Player player, @Optional String claimName, @Optional Offline
}
final Location spawnLocation = new Location(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ());
int teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
int teleportDelay = 0;
if (GDOptions.isOptionEnabled(Options.PLAYER_TELEPORT_DELAY)) {
teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
}
if (teleportDelay > 0) {
srcPlayerData.teleportDelay = teleportDelay + 1;
srcPlayerData.teleportLocation = spawnLocation;

View File

@ -0,0 +1,149 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.command;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import net.kyori.text.Component;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import com.google.common.collect.ImmutableMap;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.economy.TransactionResultType;
import com.griefdefender.api.economy.TransactionType;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.economy.GDPaymentTransaction;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.util.EconomyUtil;
import java.time.Instant;
import java.util.Date;
import org.bukkit.entity.Player;
@CommandAlias("%griefdefender")
@CommandPermission(GDPermissions.COMMAND_CLAIM_TAX)
public class CommandClaimTax extends BaseCommand {
@CommandCompletion("@gdtaxcommands @gddummy")
@CommandAlias("claimtax")
@Description("Used for claim tax management.")
@Syntax("balance|pay <amount>")
@Subcommand("claim tax")
public void execute(Player player, String[] args) throws CommandException {
if (!GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().economy.taxSystem) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TAX_SYSTEM_DISABLED);
return;
}
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_NOT_INSTALLED);
return;
}
if (args.length == 0) {
throw new InvalidCommandArgument();
}
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation());
if (claim.isSubdivision() || claim.isAdminClaim()) {
return;
}
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (!claim.getOwnerUniqueId().equals(player.getUniqueId()) && !playerData.canIgnoreClaim(claim) && claim.allowEdit(player) != null) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().PERMISSION_TAX);
return;
}
final Economy economy = GriefDefenderPlugin.getInstance().getVaultProvider().getApi();
final String command = args[0];
double amount = args.length > 1 ? Double.parseDouble(args[1]) : 0;
if (command.equalsIgnoreCase("balance")) {
final double taxBalance = claim.getEconomyData().getTaxBalance();
Component message = null;
if (taxBalance > 0) {
message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAST_DUE,
ImmutableMap.of(
"balance", taxBalance,
"date", Date.from(claim.getEconomyData().getTaxPastDueDate())));
} else {
message = MessageCache.getInstance().TAX_NO_BALANCE;
}
GriefDefenderPlugin.sendMessage(player, message);
} else if (command.equalsIgnoreCase("pay")) {
final double taxBalance = claim.getEconomyData().getTaxBalance();
if (taxBalance <= 0 || amount <= 0) {
return;
}
if (amount > taxBalance) {
amount = taxBalance;
}
EconomyResponse result = EconomyUtil.getInstance().withdrawFunds(player, amount);
if (result.transactionSuccess()) {
double depositAmount = amount;
depositAmount -= claim.getEconomyData().getTaxBalance();
if (depositAmount >= 0) {
claim.getEconomyData().addPaymentTransaction(new GDPaymentTransaction(TransactionType.TAX, TransactionResultType.SUCCESS, Instant.now(), taxBalance));
claim.getEconomyData().setTaxPastDueDate(null);
claim.getEconomyData().setTaxBalance(0);
claim.getInternalClaimData().setExpired(false);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAID_BALANCE,
ImmutableMap.of(
"amount", taxBalance));
GriefDefenderPlugin.sendMessage(player, message);
return;
} else {
final double newTaxBalance = Math.abs(depositAmount);
claim.getEconomyData().setTaxBalance(newTaxBalance);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAID_PARTIAL,
ImmutableMap.of(
"amount", depositAmount,
"balance", newTaxBalance));
GriefDefenderPlugin.sendMessage(player, message);
return;
}
} else {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAY_NO_FUNDS));
claim.getData().getEconomyData()
.addPaymentTransaction(new GDPaymentTransaction(TransactionType.TAX, TransactionResultType.FAIL, playerData.playerID, Instant.now(), amount));
return;
}
}
}
}

View File

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

View File

@ -31,13 +31,24 @@
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.google.common.collect.ImmutableMap;
import com.griefdefender.GDDebugData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import net.kyori.text.TextComponent;
import net.kyori.text.adapter.bukkit.TextAdapter;
import net.kyori.text.format.TextColor;
import net.kyori.text.serializer.plain.PlainComponentSerializer;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@CommandAlias("%griefdefender")
@ -48,16 +59,21 @@ public class CommandDebug extends BaseCommand {
@Description("Captures all GD actions for debugging purposes.")
@Syntax("<record|paste|on|off> [filter]")
@Subcommand("debug")
public void execute(CommandSender src, String target, @Optional OfflinePlayer targetPlayer) {
public void execute(CommandSender src, String command, @Optional String filter) {
GDDebugData debugData = null;
boolean paste = false;
if (target.equalsIgnoreCase("on")) {
debugData = getOrCreateDebugUser(src, targetPlayer, true);
} else if (target.equalsIgnoreCase("record")) {
debugData = getOrCreateDebugUser(src, targetPlayer, false);
} else if (target.equalsIgnoreCase("paste")) {
boolean verbose = false;
if (command.equalsIgnoreCase("on")) {
verbose = true;
debugData = getOrCreateDebugUser(src, filter, true);
} else if (command.equalsIgnoreCase("record")) {
debugData = getOrCreateDebugUser(src, filter, false);
} else if (command.equalsIgnoreCase("claim")) {
debugData = getOrCreateDebugUser(src, filter, false);
} else if (command.equalsIgnoreCase("paste")) {
paste = true;
} else if (target.equalsIgnoreCase("off")) {
} else if (command.equalsIgnoreCase("off")) {
GriefDefenderPlugin.getInstance().getDebugUserMap().remove(src.getName());
if (GriefDefenderPlugin.getInstance().getDebugUserMap().isEmpty()) {
GriefDefenderPlugin.debugActive = false;
@ -83,33 +99,41 @@ public void execute(CommandSender src, String target, @Optional OfflinePlayer ta
GriefDefenderPlugin.debugActive = false;
}
} else {
TextAdapter.sendComponent(src, TextComponent.builder("")
.append(GriefDefenderPlugin.GD_TEXT)
.append("Debug: ", TextColor.GRAY)
.append("ON", TextColor.GREEN)
.append(" | ")
GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(filter);
TextComponent.Builder builder = TextComponent.builder("")
.append(GriefDefenderPlugin.GD_TEXT)
.append("Debug: ", TextColor.GRAY)
.append("ON", TextColor.GREEN)
.append(" | ")
.append("Record: ", TextColor.GRAY)
.append(debugData.isRecording() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))
.append(" | ")
.append("User: ", TextColor.GRAY)
.append(user == null ? PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().TITLE_ALL) : user.getName(), TextColor.GOLD);
if (filter != null && user == null) {
builder.append(" | ")
.append("Filter: ", TextColor.GRAY)
.append(filter, TextColor.AQUA);
}
if (verbose) {
builder.append(" | ")
.append("Verbose: ", TextColor.GRAY)
.append(!debugData.isRecording() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))
.append(" | ")
.append("Record: ", TextColor.GRAY)
.append(debugData.isRecording() ? TextComponent.of("ON", TextColor.GREEN) : TextComponent.of("OFF", TextColor.RED))
.append(" | ")
.append("User: ", TextColor.GRAY)
.append(targetPlayer == null ? "ALL" : targetPlayer.getName(), TextColor.GOLD)
.build());
.append(TextComponent.of("ON", TextColor.GREEN));
}
TextAdapter.sendComponent(src, builder.build());
GriefDefenderPlugin.getInstance().getDebugUserMap().put(src.getName(), debugData);
}
}
private GDDebugData getOrCreateDebugUser(CommandSender src, OfflinePlayer user, boolean verbose) {
private GDDebugData getOrCreateDebugUser(CommandSender src, String filter, boolean verbose) {
GDDebugData debugData = GriefDefenderPlugin.getInstance().getDebugUserMap().get(src.getName());
if (debugData == null) {
debugData = new GDDebugData(src, user, verbose);
GriefDefenderPlugin.getInstance().getDebugUserMap().put(src.getName(), debugData);
} else {
debugData.setTarget(user);
debugData.setVerbose(verbose);
if (debugData != null) {
debugData.stop();
}
debugData = new GDDebugData(src, filter, verbose);
GriefDefenderPlugin.getInstance().getDebugUserMap().put(src.getName(), debugData);
GriefDefenderPlugin.debugActive = true;
return debugData;
}

View File

@ -10,7 +10,9 @@
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.text.action.GDCallbackHolder;
@ -39,7 +41,13 @@ public class CommandGiveBlocks extends BaseCommand {
@Subcommand("giveblocks")
public void execute(Player src, OfflinePlayer targetPlayer, int amount) {
if (amount <= 0) {
TextAdapter.sendComponent(src, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_INVALID_AMOUNT));
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_AMOUNT,
ImmutableMap.of("amount", TextComponent.of(amount, TextColor.GOLD))));
return;
}
if (targetPlayer.getUniqueId().equals(src.getUniqueId())) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER,
ImmutableMap.of("player", TextComponent.of(src.getName(), TextColor.GOLD))));
return;
}
@ -51,45 +59,70 @@ public void execute(Player src, OfflinePlayer targetPlayer, int amount) {
return;
}
final GDPermissionUser targetUser = PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer);
if ((targetUser.getInternalPlayerData().getAccruedClaimBlocks() + amount) >= targetUser.getInternalPlayerData().getMaxAccruedClaimBlocks()) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PLAYER_ACCRUED_BLOCKS_EXCEEDED,
ImmutableMap.of(
"player", targetPlayer.getName(),
"total", targetUser.getInternalPlayerData().getAccruedClaimBlocks(),
"amount", amount)));
return;
}
final Component confirmationText = TextComponent.builder()
.append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_GIVEBLOCKS_CONFIRMATION,
ImmutableMap.of("player", TextComponent.of(targetPlayer.getName(), TextColor.AQUA),
"amount", TextComponent.of(amount, TextColor.GREEN))))
.append(TextComponent.builder()
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(src, targetPlayer, amount))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, targetUser, amount), true)))
.hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build())
.build();
TextAdapter.sendComponent(src, confirmationText);
}
private static Consumer<CommandSender> createConfirmationConsumer(Player src, OfflinePlayer targetPlayer, int amount) {
private static Consumer<CommandSender> createConfirmationConsumer(Player src, GDPermissionUser targetUser, int amount) {
return confirm -> {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), src.getUniqueId());
final int accruedTotal = playerData.getAccruedClaimBlocks();
final int bonusTotal = playerData.getBonusClaimBlocks();
int availableBlocks = accruedTotal + bonusTotal;
if (amount > availableBlocks) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_GIVEBLOCKS_NOT_ENOUGH,
ImmutableMap.of("amount", TextComponent.of(availableBlocks, TextColor.GOLD))));
return;
}
if ((targetUser.getInternalPlayerData().getAccruedClaimBlocks() + amount) >= targetUser.getInternalPlayerData().getMaxAccruedClaimBlocks()) {
TextAdapter.sendComponent(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PLAYER_ACCRUED_BLOCKS_EXCEEDED,
ImmutableMap.of(
"player", targetUser.getName(),
"total", targetUser.getInternalPlayerData().getAccruedClaimBlocks(),
"amount", amount)));
return;
}
if (bonusTotal >= amount) {
playerData.setBonusClaimBlocks(bonusTotal - amount);
} else if (accruedTotal >= amount) {
playerData.setAccruedClaimBlocks(accruedTotal- amount);
playerData.setAccruedClaimBlocks(accruedTotal - amount);
} else {
int remaining = amount - bonusTotal;
playerData.setBonusClaimBlocks(0);
int newAccrued = accruedTotal - remaining;
playerData.setAccruedClaimBlocks(newAccrued);
}
final GDPlayerData targetPlayerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), targetPlayer.getUniqueId());
targetPlayerData.setBonusClaimBlocks(targetPlayerData.getBonusClaimBlocks() + amount);
targetUser.getInternalPlayerData().setAccruedClaimBlocks(targetUser.getInternalPlayerData().getAccruedClaimBlocks() + amount);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_GIVEBLOCKS_CONFIRMED);
TextAdapter.sendComponent(src, message);
if (targetPlayer.isOnline()) {
if (targetUser.getOnlinePlayer() != null) {
final Component targetMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_GIVEBLOCKS_RECEIVED,
ImmutableMap.of("amount", TextComponent.of(amount, TextColor.GOLD),
"player", TextComponent.of(src.getName(), TextColor.AQUA)));
TextAdapter.sendComponent((Player) targetPlayer, targetMessage);
TextAdapter.sendComponent((Player) targetUser.getOnlinePlayer(), targetMessage);
}
};
}

View File

@ -64,8 +64,12 @@
import com.griefdefender.api.claim.ClaimResult;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.economy.BankTransactionType;
import com.griefdefender.api.economy.PaymentTransaction;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.api.economy.TransactionResultType;
import com.griefdefender.api.economy.TransactionType;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.PermissionResult;
import com.griefdefender.api.permission.ResultTypes;
import com.griefdefender.api.permission.flag.Flag;
@ -78,7 +82,7 @@
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.economy.GDBankTransaction;
import com.griefdefender.economy.GDPaymentTransaction;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.pagination.PaginationList;
import com.griefdefender.internal.registry.BlockTypeRegistryModule;
@ -86,7 +90,7 @@
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.internal.visual.ClaimVisual;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionResult;
@ -96,6 +100,7 @@
import com.griefdefender.permission.ui.MenuType;
import com.griefdefender.permission.ui.UIHelper;
import com.griefdefender.text.action.GDCallbackHolder;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PermissionUtil;
import com.griefdefender.util.PlayerUtil;
import com.griefdefender.util.TaskUtil;
@ -246,6 +251,7 @@ public static PermissionResult applyFlagPermission(CommandSender src, GDPermissi
public static PermissionResult applyFlagPermission(CommandSender src, GDPermissionHolder subject, Claim claim, Flag flag, String target, Tristate value, Set<Context> contexts, MenuType flagType, boolean clicked) {
boolean hasDefaultContext = false;
boolean hasOverrideContext = false;
boolean replaceOverrideContext = false;
Component reason = null;
Iterator<Context> iterator = contexts.iterator();
while (iterator.hasNext()) {
@ -262,9 +268,16 @@ public static PermissionResult applyFlagPermission(CommandSender src, GDPermissi
if (context.getKey().contains("gd_claim_default")) {
hasDefaultContext = true;
} else if (context.getKey().contains("gd_claim_override")) {
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceOverrideContext = true;
}
hasOverrideContext = true;
}
}
if (replaceOverrideContext) {
contexts.add(new Context(ContextKeys.CLAIM_OVERRIDE, claim.getUniqueId().toString()));
}
// Add target context
if (target != null && !target.isEmpty() && !target.equalsIgnoreCase("any")) {
contexts.add(new Context("target", target));
@ -326,7 +339,7 @@ public static PermissionResult applyFlagPermission(CommandSender src, GDPermissi
"permission", flag.getPermission(),
"contexts", getFriendlyContextString(claim, contexts),
"value", getClickableText(src, (GDClaim) claim, subject, contexts, flag, value, flagType).color(TextColor.LIGHT_PURPLE),
"target", "ALL")))
"target", MessageCache.getInstance().TITLE_ALL)))
.build());
}
} else {
@ -528,23 +541,43 @@ public static void showClaims(CommandSender src, Set<Claim> claims, int height,
if (visualizeClaims && src instanceof Player) {
Player player = (Player) src;
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final boolean hideBorders = GriefDefenderPlugin.getInstance().getWorldEditProvider() != null &&
GriefDefenderPlugin.getInstance().getWorldEditProvider().hasCUISupport(player) &&
GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().visual.hideBorders;
if (claims.size() > 1) {
if (height != 0) {
height = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : player.getEyeLocation().getBlockY();
if (!hideBorders) {
if (height != 0) {
height = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : player.getEyeLocation().getBlockY();
}
for (Claim claim : claims) {
GDClaimVisual visualization = GDClaimVisual.fromClaim(claim, playerData.getClaimCreateMode() == CreateModeTypes.VOLUME ? height : player.getEyeLocation().getBlockY(), player.getLocation(), playerData, null);
visualization.apply(player);
}
}
ClaimVisual visualization = ClaimVisual.fromClaims(claims, playerData.getClaimCreateMode() == CreateModeTypes.VOLUME ? height : player.getEyeLocation().getBlockY(), player.getLocation(), playerData, null);
visualization.apply(player);
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().visualizeClaims(claims, player, playerData, true);
}
} else {
for (Claim claim : claims) {
GDClaim gpClaim = (GDClaim) claim;
gpClaim.getVisualizer().createClaimBlockVisuals(height, player.getLocation(), playerData);
gpClaim.getVisualizer().apply(player);
if (!hideBorders) {
for (Claim claim : claims) {
GDClaim gdClaim = (GDClaim) claim;
final GDClaimVisual visual = gdClaim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(height, player.getLocation(), playerData);
}
visual.apply(player);
}
}
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
GriefDefenderPlugin.getInstance().getWorldEditProvider().visualizeClaims(claims, player, playerData, true);
}
}
}
PaginationList.Builder builder = PaginationList.builder().title(MessageCache.getInstance().CLAIMLIST_UI_TITLE.color(TextColor.RED)).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(claimsTextList);
builder.sendTo(src);
if (!claimsTextList.isEmpty()) {
PaginationList.Builder builder = PaginationList.builder().title(MessageCache.getInstance().CLAIMLIST_UI_TITLE.color(TextColor.RED)).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(claimsTextList);
builder.sendTo(src);
}
}
private static Consumer<CommandSender> createShowClaimsConsumer(CommandSender src, Set<Claim> claims, int height, boolean visualizeClaims) {
@ -566,10 +599,12 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
final Player player = src instanceof Player ? (Player) src : null;
for (Claim playerClaim : claimList) {
GDClaim claim = (GDClaim) playerClaim;
if (player != null && !claim.getData().getEconomyData().isForSale() && !claim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
if (player != null && claim.getEconomyData() != null && !claim.getEconomyData().isForSale()
&& !claim.getEconomyData().isForRent() && (claim.allowEdit(player) != null && !claim.isUserTrusted(player, TrustTypes.ACCESSOR))) {
continue;
}
if (!listCommand && !overlap && !listChildren && claim.isSubdivision() && !claim.getData().getEconomyData().isForSale()) {
if (!listCommand && !overlap && !listChildren && (claim.isSubdivision() && claimList.size() > 1)
&& claim.getEconomyData() != null && !claim.getEconomyData().isForSale() && !claim.getEconomyData().isForRent()) {
continue;
}
@ -586,7 +621,7 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
Component ownerLine = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_OWNER.color(TextColor.YELLOW))
.append(" : ", TextColor.WHITE)
.append(claim.getOwnerName().color(TextColor.GOLD))
.append(claim.getOwnerDisplayName().color(TextColor.GOLD))
.append("\n").build();
Component claimTypeInfo = TextComponent.builder("Type").color(TextColor.YELLOW)
.append(" : ", TextColor.WHITE)
@ -653,10 +688,23 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
.append("\n")
.append(MessageCache.getInstance().CLAIMLIST_UI_CLICK_PURCHASE).build();
buyClaim = TextComponent.builder()
.append(claim.getEconomyData().isForSale() ? TextComponent.builder(" [").append(MessageCache.getInstance().LABEL_BUY.color(TextColor.GREEN)).append("]", TextColor.WHITE).build() : TextComponent.empty())
.append(TextComponent.builder(" [").append(MessageCache.getInstance().LABEL_BUY.color(TextColor.GREEN)).append("]", TextColor.WHITE).build())
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(buyClaimConsumerConfirmation(src, claim))))
.hoverEvent(HoverEvent.showText(player.getUniqueId().equals(claim.getOwnerUniqueId()) ? MessageCache.getInstance().CLAIM_OWNER_ALREADY : buyInfo)).build();
}
Component rentClaim = TextComponent.empty();
if (player != null && claim.getEconomyData().isForRent() && player.hasPermission(GDPermissions.USER_RENT_BASE)) {
Component rentInfo = TextComponent.builder()
.append(MessageCache.getInstance().LABEL_PRICE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append(String.valueOf(claim.getEconomyData().getRentRate() + " per " + (claim.getEconomyData().getPaymentType() == PaymentType.DAILY ? "day" : "hour")), TextColor.GOLD)
.append("\n")
.append(MessageCache.getInstance().CLAIMLIST_UI_CLICK_RENT).build();
rentClaim = TextComponent.builder()
.append(TextComponent.builder(" [").append(MessageCache.getInstance().LABEL_RENT.color(TextColor.GREEN)).append("]", TextColor.WHITE).build())
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(EconomyUtil.getInstance().rentClaimConsumerConfirmation(src, claim))))
.hoverEvent(HoverEvent.showText(player.getUniqueId().equals(claim.getOwnerUniqueId()) ? MessageCache.getInstance().CLAIM_OWNER_ALREADY : rentInfo)).build();
}
if (!childrenTextList.isEmpty()) {
Component children = TextComponent.builder("[")
.append(MessageCache.getInstance().LABEL_CHILDREN.color(TextColor.AQUA))
@ -667,28 +715,37 @@ public static List<Component> generateClaimTextList(List<Component> claimsTextLi
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
.append(claimInfoCommandClick)
.append(" : ", TextColor.WHITE)
.append(claim.getOwnerName().color(TextColor.GOLD))
.append(claim.getOwnerDisplayName().color(TextColor.GOLD))
.append(" ")
.append(claimName == TextComponent.empty() ? TextComponent.of("") : claimName)
.append(" ")
.append(children)
.append(" ")
.append(buyClaim)
.append(" ")
.append(rentClaim)
.build());
} else {
claimsTextList.add(TextComponent.builder("")
.append(claimSpawn != null ? claimSpawn.append(TextComponent.of(" ")) : TextComponent.of(""))
.append(claimInfoCommandClick)
.append(" : ", TextColor.WHITE)
.append(claim.getOwnerName().color(TextColor.GOLD))
.append(claim.getOwnerDisplayName().color(TextColor.GOLD))
.append(" ")
.append(claimName == TextComponent.empty() ? TextComponent.of("") : claimName)
.append(buyClaim)
.append(" ")
.append(rentClaim)
.build());
}
}
if (claimsTextList.size() == 0) {
claimsTextList.add(MessageCache.getInstance().CLAIMLIST_UI_NO_CLAIMS_FOUND.color(TextColor.RED));
if (claimsTextList.size() == 0 && player != null) {
final GDPermissionUser srcUser = PermissionHolderCache.getInstance().getOrCreateUser(player);
if (srcUser.getInternalPlayerData().showNoClaimsFoundMessage) {
claimsTextList.add(MessageCache.getInstance().CLAIMLIST_UI_NO_CLAIMS_FOUND.color(TextColor.RED));
} else {
srcUser.getInternalPlayerData().showNoClaimsFoundMessage = true;
}
}
}
return claimsTextList;
@ -726,7 +783,7 @@ public static Consumer<CommandSender> buyClaimConsumerConfirmation(CommandSender
.append("\n[")
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createBuyConsumerConfirmed(src, claim)))).build())
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createBuyConsumerConfirmed(src, claim), true))).build())
.build();
GriefDefenderPlugin.sendMessage(player, buyConfirmationText);
};
@ -757,10 +814,20 @@ private static Consumer<CommandSender> createBuyConsumerConfirmed(CommandSender
return;
}
final double balance = economy.getBalance(player);
if (balance < claim.getEconomyData().getSalePrice()) {
Map<String, Object> params = ImmutableMap.of(
"amount", claim.getEconomyData().getSalePrice(),
"balance", balance,
"amount_required", claim.getEconomyData().getSalePrice() - balance);
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_BUY_NOT_ENOUGH_FUNDS, params));
return;
}
final double salePrice = claim.getEconomyData().getSalePrice();
final EconomyResponse response = economy.depositPlayer(owner.getOfflinePlayer(), salePrice);
if (response.transactionSuccess()) {
final EconomyResponse withdrawResponse = economy.withdrawPlayer(player, salePrice);
final EconomyResponse withdrawResponse = EconomyUtil.getInstance().withdrawFunds(player, salePrice);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_BUY_CONFIRMED,
ImmutableMap.of(
"amount", String.valueOf("$" +salePrice)));
@ -993,10 +1060,10 @@ public static Consumer<CommandSender> createTeleportConsumer(CommandSender src,
return;
}
final double safeY = player.getWorld().getEnvironment() != Environment.NETHER ? player.getWorld().getHighestBlockYAt(location) : location.getBlockY();
final double safeY = location.getWorld().getHighestBlockYAt(location);
location.setY(safeY);
int currentY = location.getBlockY();
while (currentY < player.getWorld().getMaxHeight()) {
while (currentY > 0 && currentY < location.getWorld().getMaxHeight()) {
if (PlayerUtil.getInstance().isSafeLocation(location)) {
if (teleportDelay > 0) {
playerData.teleportDelay = teleportDelay + 1;
@ -1006,7 +1073,11 @@ public static Consumer<CommandSender> createTeleportConsumer(CommandSender src,
player.teleport(location, TeleportCause.PLUGIN);
return;
}
currentY++;
if (location.getWorld().getEnvironment() == Environment.NETHER) {
currentY--;
} else {
currentY++;
}
location.setY(currentY);
}
@ -1049,8 +1120,8 @@ public static void handleBankTransaction(CommandSender src, String[] args, GDCla
"amount", amount));
GriefDefenderPlugin.sendMessage(src, message);
economy.depositPlayer(((Player) src), amount);
claim.getData().getEconomyData().addBankTransaction(
new GDBankTransaction(BankTransactionType.WITHDRAW_SUCCESS, playerData.playerID, Instant.now(), amount));
claim.getData().getEconomyData().addPaymentTransaction(
new GDPaymentTransaction(TransactionType.BANK_WITHDRAW, TransactionResultType.SUCCESS, playerData.playerID, Instant.now(), amount));
} else {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BANK_WITHDRAW_NO_FUNDS,
ImmutableMap.of(
@ -1058,22 +1129,22 @@ public static void handleBankTransaction(CommandSender src, String[] args, GDCla
"amount", amount));
GriefDefenderPlugin.sendMessage(src, message);
claim.getData().getEconomyData()
.addBankTransaction(new GDBankTransaction(BankTransactionType.WITHDRAW_FAIL, playerData.playerID, Instant.now(), amount));
.addPaymentTransaction(new GDPaymentTransaction(TransactionType.BANK_WITHDRAW, TransactionResultType.FAIL, playerData.playerID, Instant.now(), amount));
return;
}
} else if (command.equalsIgnoreCase("deposit")) {
EconomyResponse result = economy.withdrawPlayer(((Player) src), amount);
EconomyResponse result = EconomyUtil.getInstance().withdrawFunds(((Player) src), amount);
if (result.transactionSuccess()) {
double depositAmount = amount;
if (claim.getData().isExpired()) {
final double taxBalance = claim.getEconomyData().getTaxBalance();
depositAmount -= claim.getEconomyData().getTaxBalance();
if (depositAmount >= 0) {
claim.getEconomyData().addBankTransaction(new GDBankTransaction(BankTransactionType.TAX_SUCCESS, Instant.now(), taxBalance));
claim.getEconomyData().addPaymentTransaction(new GDPaymentTransaction(TransactionType.TAX, TransactionResultType.SUCCESS, Instant.now(), taxBalance));
claim.getEconomyData().setTaxPastDueDate(null);
claim.getEconomyData().setTaxBalance(0);
claim.getInternalClaimData().setExpired(false);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_CLAIM_PAID_BALANCE,
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAID_BALANCE,
ImmutableMap.of(
"amount", taxBalance));
GriefDefenderPlugin.sendMessage(src, message);
@ -1083,7 +1154,7 @@ public static void handleBankTransaction(CommandSender src, String[] args, GDCla
} else {
final double newTaxBalance = Math.abs(depositAmount);
claim.getEconomyData().setTaxBalance(newTaxBalance);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_CLAIM_PAID_PARTIAL,
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TAX_PAID_PARTIAL,
ImmutableMap.of(
"amount", depositAmount,
"balance", newTaxBalance));
@ -1095,12 +1166,12 @@ public static void handleBankTransaction(CommandSender src, String[] args, GDCla
"amount", depositAmount));
GriefDefenderPlugin.sendMessage(src, message);
economy.bankDeposit(bankAccount.toString(), depositAmount);
claim.getData().getEconomyData().addBankTransaction(
new GDBankTransaction(BankTransactionType.DEPOSIT_SUCCESS, playerData.playerID, Instant.now(), depositAmount));
claim.getData().getEconomyData().addPaymentTransaction(
new GDPaymentTransaction(TransactionType.BANK_DEPOSIT, TransactionResultType.SUCCESS, playerData.playerID, Instant.now(), depositAmount));
} else {
GriefDefenderPlugin.sendMessage(src, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BANK_WITHDRAW_NO_FUNDS));
claim.getData().getEconomyData()
.addBankTransaction(new GDBankTransaction(BankTransactionType.DEPOSIT_FAIL, playerData.playerID, Instant.now(), amount));
.addPaymentTransaction(new GDPaymentTransaction(TransactionType.BANK_DEPOSIT, TransactionResultType.FAIL, playerData.playerID, Instant.now(), amount));
return;
}
}
@ -1159,7 +1230,7 @@ public static void displayClaimBankInfo(CommandSender player, GDClaim claim, boo
}
final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(claim.getWorld().getUID());
final ZonedDateTime withdrawDate = TaskUtil.getNextTargetZoneDate(activeConfig.getConfig().claim.taxApplyHour, 0, 0);
final ZonedDateTime withdrawDate = TaskUtil.getNextTargetZoneDate(activeConfig.getConfig().economy.taxApplyHour, 0, 0);
Duration duration = Duration.between(Instant.now().truncatedTo(ChronoUnit.SECONDS), withdrawDate.toInstant()) ;
final long s = duration.getSeconds();
final String timeLeft = String.format("%d:%02d:%02d", s / 3600, (s % 3600) / 60, (s % 60));
@ -1191,25 +1262,22 @@ public static void displayClaimBankInfo(CommandSender player, GDClaim claim, boo
public static Consumer<CommandSender> createBankTransactionsConsumer(CommandSender src, GDClaim claim, boolean checkTown, boolean returnToClaimInfo) {
return settings -> {
List<String> bankTransactions = new ArrayList<>(claim.getData().getEconomyData().getBankTransactionLog());
Collections.reverse(bankTransactions);
List<PaymentTransaction> paymentTransactions = claim.getData().getEconomyData().getPaymentTransactions(TransactionType.BANK_DEPOSIT);
List<Component> textList = new ArrayList<>();
textList.add(TextComponent.builder("")
.append("\n[")
.append(MessageCache.getInstance().CLAIMINFO_UI_RETURN_BANKINFO.color(TextColor.AQUA))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(consumer -> { displayClaimBankInfo(src, claim, checkTown, returnToClaimInfo); }))).build());
Gson gson = new Gson();
for (String transaction : bankTransactions) {
GDBankTransaction bankTransaction = gson.fromJson(transaction, GDBankTransaction.class);
final Duration duration = Duration.between(bankTransaction.timestamp, Instant.now().truncatedTo(ChronoUnit.SECONDS)) ;
for (PaymentTransaction transaction : paymentTransactions) {
final Duration duration = Duration.between(transaction.getTimestamp(), Instant.now().truncatedTo(ChronoUnit.SECONDS)) ;
final long s = duration.getSeconds();
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(bankTransaction.source);
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(transaction.getSource().orElse(null));
final String timeLeft = String.format("%dh %02dm %02ds", s / 3600, (s % 3600) / 60, (s % 60)) + " ago";
textList.add(TextComponent.builder("")
.append(bankTransaction.type.name(), getTransactionColor(bankTransaction.type))
.append(transaction.getResultType().name(), getTransactionColor(transaction.getResultType()))
.append(" | ", TextColor.BLUE)
.append(TextComponent.of(String.valueOf(bankTransaction.amount)))
.append(TextComponent.of(String.valueOf(transaction.getAmount())))
.append(" | ", TextColor.BLUE)
.append(timeLeft, TextColor.GRAY)
.append(user == null ? TextComponent.empty() : TextComponent.builder("")
@ -1229,15 +1297,48 @@ public static Consumer<CommandSender> createBankTransactionsConsumer(CommandSend
};
}
public static TextColor getTransactionColor(BankTransactionType type) {
public static Consumer<CommandSender> createRentTransactionsConsumer(CommandSender src, GDClaim claim, boolean checkTown, boolean returnToClaimInfo) {
return settings -> {
List<PaymentTransaction> paymentTransactions = claim.getData().getEconomyData().getPaymentTransactions(TransactionType.RENT);
List<Component> textList = new ArrayList<>();
textList.add(TextComponent.builder("")
.append("\n[")
.append(MessageCache.getInstance().RENT_UI_RETURN_INFO.color(TextColor.AQUA))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claimrent", "info")))).build());
for (PaymentTransaction transaction : paymentTransactions) {
final Duration duration = Duration.between(transaction.getTimestamp(), Instant.now().truncatedTo(ChronoUnit.SECONDS)) ;
final long s = duration.getSeconds();
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(transaction.getSource().orElse(null));
final String timeLeft = String.format("%dh %02dm %02ds", s / 3600, (s % 3600) / 60, (s % 60)) + " ago";
textList.add(TextComponent.builder("")
.append(transaction.getResultType().name(), getTransactionColor(transaction.getResultType()))
.append(" | ", TextColor.BLUE)
.append(TextComponent.of(String.valueOf(transaction.getAmount())))
.append(" | ", TextColor.BLUE)
.append(timeLeft, TextColor.GRAY)
.append(user == null ? TextComponent.empty() : TextComponent.builder("")
.append(" | ", TextColor.BLUE)
.append(user.getName(), TextColor.LIGHT_PURPLE)
.build())
.build());
}
textList.add(TextComponent.builder("")
.append("\n[")
.append(MessageCache.getInstance().RENT_UI_RETURN_INFO.color(TextColor.AQUA))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(src, "claimrent", "info")))).build());
PaginationList.Builder builder = PaginationList.builder()
.title(MessageCache.getInstance().RENT_UI_TITLE_TRANSACTIONS.color(TextColor.AQUA)).padding(TextComponent.builder(" ").decoration(TextDecoration.STRIKETHROUGH, true).build()).contents(textList);
builder.sendTo(src);
};
}
public static TextColor getTransactionColor(TransactionResultType type) {
switch (type) {
case DEPOSIT_SUCCESS :
case TAX_SUCCESS :
case WITHDRAW_SUCCESS :
case SUCCESS :
return TextColor.GREEN;
case DEPOSIT_FAIL :
case TAX_FAIL :
case WITHDRAW_FAIL :
case FAIL :
return TextColor.RED;
default :
return TextColor.GREEN;

View File

@ -16,15 +16,18 @@ public class CommandPagination extends BaseCommand {
@CommandAlias("gd:pagination")
@Description("Used internally by GD for pagination purposes.")
public void execute(CommandSender src, String[] args) throws CommandException {
String id = args[0];
if (args == null || args.length == 0) {
return;
}
final String id = args[0];
final ActivePagination activePagination = GDPaginationHolder.getInstance().getActivePagination(src, id);
if (activePagination == null) {
TextAdapter.sendComponent(src, TextComponent.of("Source " + src.getName() + " has no paginations!", TextColor.RED));
return;
}
String action = args[1];
final String action = args[1];
if (action.equals("page")) {
activePagination.currentPage();
} else if (action.equals("next")) {

View File

@ -211,7 +211,7 @@ public void execute(CommandSender src, @Optional String[] args) throws InvalidCo
.append(subLimitText, TextColor.GREEN)
.build();
claimsTextList.add(claimCreateLimits);
if (GriefDefenderPlugin.getGlobalConfig().getConfig().claim.bankTaxSystem) {
if (GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().economy.taxSystem) {
Component townTaxRate = TextComponent.builder("")
.append("TOWN", TextColor.GRAY)
.append(" : ")

View File

@ -34,13 +34,12 @@
import com.griefdefender.cache.MessageCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.RestoreUtil;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.text.action.GDCallbackHolder;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.adapter.bukkit.TextAdapter;
import net.kyori.text.event.ClickEvent;
import net.kyori.text.event.HoverEvent;
import net.kyori.text.format.TextColor;
@ -82,18 +81,23 @@ private static void displayConfirmationConsumer(CommandSender src, GDClaim claim
final Component schematicConfirmationText = TextComponent.builder("")
.append("Are you sure you want to restore this claim?")
.append("\n[")
.append("Confirm", TextColor.GREEN)
.append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
.append("]\n")
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createConfirmationConsumer(src, claim))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, claim), true)))
.hoverEvent(HoverEvent.showText(TextComponent.of("Clicking confirm will restore ENTIRE claim back to default world gen state. Use cautiously!"))).build();
TextAdapter.sendComponent(src, schematicConfirmationText);
GriefDefenderPlugin.sendMessage(src, schematicConfirmationText);
}
private static Consumer<CommandSender> createConfirmationConsumer(CommandSender src, GDClaim claim) {
return confirm -> {
BlockUtil.getInstance().restoreClaim(claim);
final Component message = MessageCache.getInstance().CLAIM_RESTORE_SUCCESS;
GriefDefenderPlugin.sendMessage(src, message);
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESTORE_IN_PROGRESS);
if (GriefDefenderPlugin.getMajorMinecraftVersion() <= 12 || GriefDefenderPlugin.getInstance().getWorldEditProvider() == null) {
RestoreUtil.getInstance().restoreClaim(claim);
} else {
GriefDefenderPlugin.getInstance().getWorldEditProvider().regenerateClaim(claim);
}
GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESTORE_SUCCESS);
};
}
}

View File

@ -103,7 +103,7 @@ public void execute(Player player, String groupName, String type) {
if(claim.allowGrantPermission(player) != null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST,
ImmutableMap.of(
"owner", claim.getOwnerName()));
"owner", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
return;
}

View File

@ -115,7 +115,7 @@ public void execute(Player player, String target, @Optional String type) {
return;
}
if (user.getUniqueId().equals(player.getUniqueId()) && !playerData.canIgnoreClaim(claim)) {
if (user.getUniqueId().equals(player.getUniqueId()) && !playerData.canIgnoreClaim(claim) && claim.allowEdit(player) != null) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TRUST_SELF);
return;
}
@ -128,7 +128,7 @@ public void execute(Player player, String target, @Optional String type) {
if(claim.allowGrantPermission(player) != null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
return;
}

View File

@ -102,7 +102,7 @@ public void execute(Player player, String target, @Optional String type) {
if(claim.allowGrantPermission(player) != null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
return;
}

View File

@ -127,7 +127,6 @@ public void execute(Player player, String target, @Optional String type) {
return;
}
System.out.println("Removing user " + user.getUniqueId());
final GDClaim gdClaim = (GDClaim) claim;
if (trustType == TrustTypes.NONE) {
this.removeAllUserTrust(gdClaim, user);

View File

@ -96,7 +96,7 @@ public void execute(Player src, String target) {
if(claim.allowGrantPermission(src) != null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(src, message);
return;
}

View File

@ -96,7 +96,7 @@ public void execute(Player src, String target) {
if(claim.allowGrantPermission(src) != null) {
final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.PERMISSION_TRUST,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(src, message);
return;
}

View File

@ -31,7 +31,7 @@
import com.griefdefender.api.data.EconomyData;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.util.BlockUtil;
import net.kyori.text.Component;
import ninja.leaping.configurate.objectmapping.Setting;
@ -78,8 +78,6 @@ public class ClaimDataConfig extends ConfigCategory implements IClaimData {
private boolean allowFlagOverrides = true;
@Setting(value = ClaimStorageData.MAIN_REQUIRES_CLAIM_BLOCKS)
private boolean requiresClaimBlocks = true;
@Setting(value = ClaimStorageData.MAIN_CLAIM_PVP)
private Tristate pvpOverride = Tristate.UNDEFINED;
@Setting(value = ClaimStorageData.MAIN_CLAIM_DATE_CREATED)
private String dateCreated = Instant.now().toString();
@Setting(value = ClaimStorageData.MAIN_CLAIM_DATE_LAST_ACTIVE)
@ -157,11 +155,6 @@ public boolean allowDenyMessages() {
return this.allowDenyMessages;
}
@Override
public Tristate getPvpOverride() {
return this.pvpOverride;
}
@Override
public boolean isResizable() {
return this.isResizable;
@ -300,12 +293,6 @@ public void setCuboid(boolean cuboid) {
this.isCuboid = cuboid;
}
@Override
public void setPvpOverride(Tristate pvp) {
this.requiresSave = true;
this.pvpOverride = pvp;
}
@Override
public void setResizable(boolean resizable) {
this.requiresSave = true;
@ -438,6 +425,13 @@ public void setSpawnPos(Vector3i spawnPos) {
this.claimSpawn = BlockUtil.getInstance().posToString(spawnPos);
}
@Override
public void setSpawnPos(int x, int y, int z) {
this.requiresSave = true;
this.spawnPos = new Vector3i(x, y, z);
this.claimSpawn = BlockUtil.getInstance().posToString(this.spawnPos);
}
@Override
public boolean requiresClaimBlocks() {
return this.requiresClaimBlocks;

View File

@ -61,12 +61,12 @@ public class ClaimStorageData {
public static final String MAIN_CLAIM_TYPE = "claim-type";
public static final String MAIN_CLAIM_CUBOID = "cuboid";
public static final String MAIN_CLAIM_RESIZABLE = "resizable";
public static final String MAIN_CLAIM_PVP = "pvp";
public static final String MAIN_CLAIM_DATE_CREATED = "date-created";
public static final String MAIN_CLAIM_DATE_LAST_ACTIVE = "date-last-active";
public static final String MAIN_CLAIM_MAX_WIDTH = "max-width";
public static final String MAIN_CLAIM_FOR_SALE = "for-sale";
public static final String MAIN_CLAIM_SALE_PRICE = "sale-price";
public static final String MAIN_RENT_PRICE = "rent-price";
public static final String MAIN_SALE_PRICE = "sale-price";
public static final String MAIN_REQUIRES_CLAIM_BLOCKS = "requires-claim-blocks";
public static final String MAIN_SUBDIVISION_UUID = "uuid";
public static final String MAIN_PARENT_CLAIM_UUID = "parent-claim-uuid";
@ -83,6 +83,13 @@ public class ClaimStorageData {
public static final String MAIN_ALLOW_DENY_MESSAGES = "deny-messages";
public static final String MAIN_ALLOW_FLAG_OVERRIDES = "flag-overrides";
public static final String MAIN_ALLOW_CLAIM_EXPIRATION = "claim-expiration";
public static final String MAIN_RENT_BALANCE = "rent-balance";
public static final String MAIN_RENT_PAST_DUE_DATE = "rent-past-due-date";
public static final String MAIN_RENT_START_DATE = "rent-start-date";
public static final String MAIN_RENT_END_DATE = "rent-end-date";
public static final String MAIN_RENT_SIGN_POS = "rent-sign-pos";
public static final String MAIN_SALE_SIGN_POS = "sale-sign-pos";
public static final String MAIN_SALE_END_DATE = "sale-end-date";
public static final String MAIN_TAX_PAST_DUE_DATE = "tax-past-due-date";
public static final String MAIN_TAX_BALANCE = "tax-balance";
// SUB

View File

@ -24,27 +24,75 @@
*/
package com.griefdefender.configuration;
import com.flowpowered.math.vector.Vector3i;
import com.google.gson.Gson;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.data.EconomyData;
import com.griefdefender.api.economy.BankTransaction;
import com.griefdefender.api.economy.PaymentTransaction;
import com.griefdefender.api.economy.TransactionType;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.economy.GDPaymentTransaction;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.TaskUtil;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.Map;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
@ConfigSerializable
public class EconomyDataConfig extends ConfigCategory implements EconomyData {
public GriefDefenderConfig<?> activeConfig;
private Vector3i rentSignVec;
private Vector3i saleSignVec;
private List<PaymentTransaction> bankPaymentTransactions;
private List<PaymentTransaction> rentPaymentTransactions;
private List<PaymentTransaction> taxPaymentTransactions;
@Setting(value = ClaimStorageData.MAIN_CLAIM_FOR_SALE)
private boolean forSale = false;
@Setting(value = ClaimStorageData.MAIN_CLAIM_SALE_PRICE)
@Setting
private boolean forRent = false;
@Setting(value = "rent-balances")
private Map<UUID, Double> rentBalances = new HashMap<>();
@Setting(value = "rent-payment-type")
private PaymentType paymentType = PaymentType.UNDEFINED;
@Setting
private List<UUID> renters = new ArrayList<>();
@Setting(value = "renters-delinquent")
private List<UUID> delinquentRenters = new ArrayList<>();
@Setting(value = "rent-min-time")
private int rentMinTime = 0;
@Setting(value = "rent-max-time")
private int rentMaxTime = 30;
@Setting(value = ClaimStorageData.MAIN_RENT_PRICE)
private double rentRate = 0.0;
@Setting(value = ClaimStorageData.MAIN_RENT_START_DATE)
private String rentStartDate;
@Setting(value = ClaimStorageData.MAIN_RENT_END_DATE)
private String rentEndDate;
@Setting(value = ClaimStorageData.MAIN_RENT_PAST_DUE_DATE)
private String rentPastDueDate;
@Setting(value = ClaimStorageData.MAIN_RENT_SIGN_POS)
private String rentSignPos;
@Setting(value = ClaimStorageData.MAIN_SALE_SIGN_POS)
private String saleSignPos;
@Setting(value = ClaimStorageData.MAIN_SALE_END_DATE)
private String saleEndDate;
@Setting(value = ClaimStorageData.MAIN_SALE_PRICE)
private double salePrice = 0.0;
@Setting(value = ClaimStorageData.MAIN_TAX_BALANCE)
private double taxBalance = 0.0;
@ -52,6 +100,107 @@ public class EconomyDataConfig extends ConfigCategory implements EconomyData {
private String taxPastDueDate;
@Setting
private List<String> bankTransactionLog = new ArrayList<>();
@Setting
private List<String> rentTransactionLog = new ArrayList<>();
@Setting
private List<String> taxTransactionLog = new ArrayList<>();
@Override
public int getRentMaxTime() {
return this.rentMaxTime;
}
@Override
public double getRentRate() {
return this.rentRate;
}
@Override
public Instant getRentPastDueDate() {
if (this.rentPastDueDate == null) {
return null;
}
try {
return (Instant.parse(this.rentPastDueDate));
} catch (DateTimeParseException e) {
return null;
}
}
@Override
public void setRentPastDueDate(Instant date) {
this.rentPastDueDate = date == null ? null : date.toString();
}
@Override
public Instant getRentStartDate() {
if (this.rentStartDate == null) {
return null;
}
try {
return Instant.parse(this.rentStartDate);
} catch (DateTimeParseException e) {
return null;
}
}
@Override
public Instant getRentEndDate() {
if (this.rentEndDate == null) {
return null;
}
try {
return Instant.parse(this.rentEndDate);
} catch (DateTimeParseException e) {
return null;
}
}
@Override
public Instant getRentPaymentDueDate() {
final List<PaymentTransaction> transactions = this.getPaymentTransactions(TransactionType.RENT);
if (transactions.isEmpty()) {
return null;
}
final PaymentTransaction lastTransaction = transactions.get(0);
if (this.paymentType == PaymentType.HOURLY) {
return lastTransaction.getTimestamp().plus(Duration.ofHours(1));
}
if (this.paymentType == PaymentType.DAILY) {
return lastTransaction.getTimestamp().plus(Duration.ofDays(1));
}
final LocalDate localDate = TaskUtil.convertToLocalDate(Date.from(lastTransaction.getTimestamp()));
if (this.paymentType == PaymentType.WEEKLY) {
return TaskUtil.convertToInstant(localDate.plusWeeks(1));
}
return TaskUtil.convertToInstant(localDate.plusMonths(1));
}
@Override
public List<UUID> getRenters() {
return this.renters;
}
@Override
public List<UUID> getDelinquentRenters() {
return this.delinquentRenters;
}
@Override
public int getRentMinTime() {
return this.rentMinTime;
}
@Override
public void setRentMinTime(int min) {
this.rentMinTime = min;
}
@Override
public boolean isForRent() {
return this.forRent;
}
@Override
public boolean isForSale() {
@ -63,6 +212,11 @@ public double getSalePrice() {
return this.salePrice;
}
@Override
public void setForRent(boolean forRent) {
this.forRent = forRent;
}
@Override
public void setForSale(boolean forSale) {
this.forSale = forSale;
@ -79,14 +233,14 @@ public void setTaxBalance(double balance) {
}
@Override
public Optional<Instant> getTaxPastDueDate() {
public Instant getTaxPastDueDate() {
if (this.taxPastDueDate == null) {
return Optional.empty();
return null;
}
try {
return Optional.of(Instant.parse(this.taxPastDueDate));
return Instant.parse(this.taxPastDueDate);
} catch (DateTimeParseException e) {
return Optional.empty();
return null;
}
}
@ -95,26 +249,198 @@ public void setTaxPastDueDate(Instant date) {
this.taxPastDueDate = date == null ? null : date.toString();
}
@Override
public void setRentMaxTime(int max) {
this.rentMaxTime = max;
}
@Override
public void setRentRate(double price) {
this.rentRate = price;
}
@Override
public void setRentStartDate(Instant date) {
this.rentStartDate = date == null ? null : date.toString();
}
@Override
public void setRentEndDate(Instant date) {
this.rentEndDate = date == null ? null : date.toString();
}
@Override
public @Nullable Instant getSaleEndDate() {
if (this.saleEndDate == null) {
return null;
}
try {
return Instant.parse(this.saleEndDate);
} catch (DateTimeParseException e) {
return null;
}
}
@Override
public void setSaleEndDate(Instant date) {
this.saleEndDate = date == null ? null : date.toString();
}
@Override
public void setSalePrice(double price) {
this.salePrice = price;
}
@Override
public List<String> getBankTransactionLog() {
return this.bankTransactionLog;
}
@Override
public void addBankTransaction(BankTransaction transaction) {
if (this.getBankTransactionLog().size() == this.activeConfig.getConfig().claim.bankTransactionLogLimit) {
this.getBankTransactionLog().remove(0);
public @Nullable Vector3i getRentSignPosition() {
if (this.rentSignPos == null) {
return null;
}
this.getBankTransactionLog().add(new Gson().toJson(transaction));
if (this.rentSignVec == null) {
try {
this.rentSignVec = BlockUtil.getInstance().posFromString(this.rentSignPos);
} catch (Exception e) {
e.printStackTrace();
}
}
return this.rentSignVec;
}
@Override
public void clearBankTransactionLog() {
this.bankTransactionLog.clear();
public @Nullable Vector3i getSaleSignPosition() {
if (this.saleSignPos == null) {
return null;
}
if (this.saleSignVec == null) {
try {
this.saleSignVec = BlockUtil.getInstance().posFromString(this.saleSignPos);
} catch (Exception e) {
e.printStackTrace();
}
}
return this.saleSignVec;
}
@Override
public void setRentSignPosition(Vector3i pos) {
if (pos == null) {
this.rentSignPos = null;
return;
}
// force reset of vec
this.rentSignVec = null;
this.rentSignPos = BlockUtil.getInstance().posToString(pos);
}
@Override
public void setSaleSignPosition(Vector3i pos) {
if (pos == null) {
this.saleSignPos = null;
return;
}
// force reset of vec
this.saleSignVec = null;
this.saleSignPos = BlockUtil.getInstance().posToString(pos);
}
@Override
public List<PaymentTransaction> getPaymentTransactions(TransactionType type) {
if (type == TransactionType.RENT) {
if (this.rentPaymentTransactions == null) {
this.rentPaymentTransactions = new ArrayList<>();
for (String transaction : this.rentTransactionLog) {
this.rentPaymentTransactions.add(new Gson().fromJson(transaction, GDPaymentTransaction.class));
}
}
return this.rentPaymentTransactions;
} else if (type == TransactionType.BANK_DEPOSIT || type == TransactionType.BANK_WITHDRAW){
if (this.bankPaymentTransactions == null) {
this.bankPaymentTransactions = new ArrayList<>();
for (String transaction : this.bankTransactionLog) {
this.bankPaymentTransactions.add(new Gson().fromJson(transaction, GDPaymentTransaction.class));
}
}
return this.bankPaymentTransactions;
} else {
if (this.taxPaymentTransactions == null) {
this.taxPaymentTransactions = new ArrayList<>();
for (String transaction : this.taxTransactionLog) {
this.taxPaymentTransactions.add(new Gson().fromJson(transaction, GDPaymentTransaction.class));
}
}
return this.taxPaymentTransactions;
}
}
public List<String> getPaymentTransactionLog(TransactionType type) {
if (type == TransactionType.BANK_DEPOSIT || type == TransactionType.BANK_WITHDRAW) {
return this.bankTransactionLog;
}
if (type == TransactionType.RENT) {
return this.rentTransactionLog;
}
return this.taxTransactionLog;
}
@Override
public void addPaymentTransaction(PaymentTransaction transaction) {
final List<String> transactionLog = this.getPaymentTransactionLog(transaction.getType());
if (transactionLog.size() == GriefDefenderPlugin.getGlobalConfig().getConfig().economy.getTransactionLogLimit(transaction.getType())) {
transactionLog.remove(0);
}
// add new payments to start of list
// oldest payments should always be at end
transactionLog.add(0, new Gson().toJson(transaction));
this.getPaymentTransactions(transaction.getType()).add(0, transaction);
}
@Override
public void clearPaymentTransactions(TransactionType type) {
if (type == TransactionType.RENT) {
this.rentTransactionLog.clear();
this.rentPaymentTransactions.clear();
} else {
this.bankTransactionLog.clear();
this.bankPaymentTransactions.clear();
}
}
@Override
public PaymentType getPaymentType() {
return this.paymentType;
}
@Override
public void setPaymentType(PaymentType type) {
this.paymentType = type;
}
@Override
public boolean isUserRenting(UUID uuid) {
return this.renters.contains(uuid);
}
@Override
public double getRentBalance(UUID uuid) {
final Double balance = this.rentBalances.get(uuid);
if (balance == null) {
return 0;
}
return balance;
}
@Override
public void setRentBalance(UUID uuid, double balance) {
if (balance <= 0) {
this.rentBalances.remove(uuid);
return;
}
this.rentBalances.put(uuid, balance);
}
}

View File

@ -24,15 +24,25 @@
*/
package com.griefdefender.configuration;
import java.util.Map;
import com.google.common.collect.Maps;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory;
import com.griefdefender.configuration.category.DefaultFlagCategory;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class FlagStorage extends ConfigCategory {
@Setting(value = "flag-control", comment = "Controls which flags are enabled.\nNote: Disabling a flag will cause GD to bypass all functionality for it."
+ "\nNote: If you want full protection, it is recommended to keep everything enabled.")
public Map<String, Boolean> control = Maps.newHashMap();
@Setting(value = "default-flags")
public DefaultFlagCategory defaultFlagCategory = new DefaultFlagCategory();
@Setting(value = "custom-flags", comment = "Used to define a group of custom flags for players/admins."
@ -68,4 +78,19 @@ public class FlagStorage extends ConfigCategory {
+ "\nNote: Available contexts are : flag, source, target, state, used_item, item_name"
+ "\nThese contexts may change, See https://github.com/bloodmc/GriefDefender/wiki for latest information.")
public CustomFlagGroupDefinitionCategory customFlags = new CustomFlagGroupDefinitionCategory();
public FlagStorage() {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
this.control.put(flag.getName().toLowerCase(), true);
}
}
public boolean isFlagEnabled(String flag) {
final Boolean result = this.control.get(flag);
if (result == null) {
return false;
}
return result;
}
}

View File

@ -185,19 +185,45 @@ public class MessageStorage {
public static final String ECONOMY_CLAIM_BUY_CONFIRMED = "economy-claim-buy-confirmed";
public static final String ECONOMY_CLAIM_BUY_NOT_ENOUGH_FUNDS = "economy-claim-buy-not-enough-funds";
public static final String ECONOMY_CLAIM_BUY_TRANSFER_CANCELLED = "economy-claim-buy-transfer-cancelled";
public static final String ECONOMY_CLAIM_RENT_CANCEL_CONFIRMATION_BALANCE = "economy-claim-rent-cancel-confirmation-balance";
public static final String ECONOMY_CLAIM_RENT_CONFIRMATION = "economy-claim-rent-confirmation";
public static final String ECONOMY_CLAIM_RENT_CONFIRMATION_MAX = "economy-claim-rent-confirmation-max";
public static final String ECONOMY_CLAIM_RENT_CONFIRMATION_MIN = "economy-claim-rent-confirmation-min";
public static final String ECONOMY_CLAIM_RENT_CONFIRMATION_MIN_MAX = "economy-claim-rent-confirmation-min-max";
public static final String ECONOMY_CLAIM_RENT_CONFIRMED = "economy-claim-rent-confirmed";
public static final String ECONOMY_CLAIM_RENT_INVALID_PRICE = "economy-claim-rent-invalid-price";
public static final String ECONOMY_CLAIM_RENT_NOT_ENOUGH_FUNDS = "economy-claim-rent-not-enough-funds";
public static final String ECONOMY_CLAIM_RENT_PAYMENT_FAILURE = "economy-claim-rent-payment-failure";
public static final String ECONOMY_CLAIM_RENT_PAYMENT_SUCCESS = "economy-claim-rent-payment-success";
public static final String ECONOMY_CLAIM_RENT_RESTORE_CANCEL_CONFIRMATION_BALANCE = "economy-claim-rent-restore-cancel-confirmation-balance";
public static final String ECONOMY_CLAIM_RENTED = "economy-claim-rented";
public static final String ECONOMY_CLAIM_RENTED_ALREADY = "economy-claim-rented-already";
public static final String ECONOMY_CLAIM_RENTED_EXPIRED = "economy-claim-rented-expired";
public static final String ECONOMY_CLAIM_RENTER_CONFIRMATION = "economy-claim-renter-confirmation";
public static final String ECONOMY_CLAIM_RENTER_CONFIRMATION_MAX = "economy-claim-renter-confirmation-max";
public static final String ECONOMY_CLAIM_RENTER_CONFIRMATION_MIN = "economy-claim-renter-confirmation-min";
public static final String ECONOMY_CLAIM_RENTER_CONFIRMATION_MIN_MAX = "economy-claim-renter-confirmation-min-max";
public static final String ECONOMY_CLAIM_RENTER_CONFIRMED = "economy-claim-renter-confirmed";
public static final String ECONOMY_CLAIM_RENTED_TIME_WARNING = "economy-claim-rented-time-warning";
public static final String ECONOMY_CLAIM_RENTED_TIME_WARNING_RESTORE_ = "economy-claim-rented-time-warning-restore";
public static final String ECONOMY_CLAIM_RENTED_NO_CANCEL = "economy-claim-rented-no-cancel";
public static final String ECONOMY_CLAIM_SALE_CONFIRMATION = "economy-claim-sale-confirmation";
public static final String ECONOMY_CLAIM_SALE_CONFIRMED = "economy-claim-sale-confirmed";
public static final String ECONOMY_CLAIM_SALE_INVALID_PRICE = "economy-claim-sale-invalid-price";
public static final String ECONOMY_CLAIM_SOLD = "economy-claim-sold";
public static final String ECONOMY_MODE_BLOCK_SALE_CONFIRMATION = "economy-mode-block-sale-confirmation";
public static final String ECONOMY_MODE_BLOCK_COST_NOT_SET = "economy-mode-block-cost-not-set";
public static final String ECONOMY_MODE_RESIZE_SUCCESS_2D = "economy-mode-resize-success-2d";
public static final String ECONOMY_MODE_RESIZE_SUCCESS_3D = "economy-mode-resize-success-3d";
public static final String ECONOMY_NOT_ENOUGH_FUNDS = "economy-not-enough-funds";
public static final String ECONOMY_PLAYER_NOT_FOUND = "economy-player-not-found";
public static final String ECONOMY_SIGN_RENTED_LINE2 = "economy-sign-rented-line2";
public static final String ECONOMY_SIGN_SOLD_LINE2 = "economy-sign-sold-line2";
public static final String ECONOMY_WITHDRAW_ERROR = "economy-withdraw-error";
public static final String FLAG_INVALID_CONTEXT = "flag-invalid-context";
public static final String FLAG_INVALID_META = "flag-invalid-meta";
public static final String FLAG_INVALID_TARGET = "flag-invalid-target";
public static final String FLAG_NOT_ENABLED = "flag-not-enabled";
public static final String FLAG_NOT_FOUND = "flag-not-found";
public static final String FLAG_NOT_SET = "flag-not-set";
public static final String FLAG_OVERRIDDEN = "flag-overridden";
@ -206,6 +232,7 @@ public class MessageStorage {
public static final String FLAG_UI_CLICK_TOGGLE = "flag-ui-click-toggle";
public static final String FLAG_UI_INHERIT_PARENT = "flag-ui-inherit-parent";
public static final String FLAG_UI_OVERRIDE_PERMISSION = "flag-ui-override-permission";
public static final String OPTION_APPLY_PLAYER_FLY_SPEED = "option-apply-player-fly-speed";
public static final String OPTION_APPLY_PLAYER_GAMEMODE = "option-apply-player-gamemode";
public static final String OPTION_APPLY_PLAYER_WALK_SPEED = "option-apply-player-walk-speed";
public static final String OPTION_APPLY_PLAYER_WEATHER = "option-apply-player-weather";
@ -213,6 +240,7 @@ public class MessageStorage {
public static final String OPTION_INVALID_CONTEXT = "option-invalid-context";
public static final String OPTION_INVALID_TARGET = "option-invalid-target";
public static final String OPTION_INVALID_VALUE = "option-invalid-value";
public static final String OPTION_NOT_ENABLED = "option-not-enabled";
public static final String OPTION_NOT_FOUND = "option-not-found";
public static final String OPTION_NOT_SET = "option-not-set";
public static final String OPTION_OVERRIDE_NOT_SUPPORTED = "option-override-not-supported";
@ -245,6 +273,7 @@ public class MessageStorage {
public static final String PERMISSION_PROTECTED_PORTAL = "permission-protected-portal";
public static final String PERMISSION_TRUST = "permission-trust";
public static final String PLAYER_ACCRUED_BLOCKS_EXCEEDED = "player-accrued-blocks-exceeded";
public static final String PLAYER_NO_CLAIMS_TO_DELETE = "player-no-claims-to-delete";
public static final String PLAYER_REMAINING_BLOCKS_2D = "player-remaining-blocks-2d";
public static final String PLAYER_REMAINING_BLOCKS_3D = "player-remaining-blocks-3d";
public static final String PLAYERINFO_UI_ABANDON_RETURN_RATIO = "playerinfo-ui-abandon-return-ratio";
@ -290,11 +319,13 @@ public class MessageStorage {
public static final String SCHEMATIC_RESTORE_CONFIRMED = "schematic-restore-confirmed";
public static final String SPAWN_SET_SUCCESS = "spawn-set-success";
public static final String SPAWN_TELEPORT = "spawn-teleport";
public static final String TAX_CLAIM_EXPIRED = "tax-claim-expired";
public static final String TAX_CLAIM_PAID_BALANCE = "tax-claim-paid-balance";
public static final String TAX_CLAIM_PAID_PARTIAL = "tax-claim-paid-partial";
public static final String TAX_EXPIRED = "tax-expired";
public static final String TAX_EXPIRED_BANK = "tax-expired-bank";
public static final String TAX_PAID_BALANCE = "tax-paid-balance";
public static final String TAX_PAID_PARTIAL = "tax-paid-partial";
public static final String TAX_INFO = "tax-info";
public static final String TAX_PAST_DUE = "tax-past-due";
public static final String TAX_PAY_NO_FUNDS = "tax-pay-no-funds";
public static final String TELEPORT_CONFIRM = "teleport-confirm";
public static final String TELEPORT_DELAY_NOTICE = "teleport-delay-notice";
public static final String TOOL_NOT_EQUIPPED = "tool-not-equipped";
@ -313,7 +344,7 @@ public class MessageStorage {
public static final String UNTRUST_INDIVIDUAL_ALL_CLAIMS = "untrust-individual-all-claims";
public static final String UNTRUST_INDIVIDUAL_SINGLE_CLAIM = "untrust-individual-single-claim";
public static final String UNTRUST_OWNER = "untrust-owner";
public static final String VISUAL_UPDATE_IN_PROGRESS = "visual-update-in-progress";
@SuppressWarnings({"unchecked", "rawtypes"})
public MessageStorage(Path path) {

View File

@ -24,14 +24,50 @@
*/
package com.griefdefender.configuration;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.DefaultOptionCategory;
import com.griefdefender.registry.OptionRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class OptionStorage extends ConfigCategory {
@Setting(value = "option-control", comment = "Controls which options are enabled.\nNote: To enable an option, set the value to 'true'."
+ "\nSee https://github.com/bloodmc/GriefDefender/wiki/Advanced-Options for info on how each option works.")
private Map<String, Boolean> control = Maps.newHashMap();
@Setting(value = "default-options")
public DefaultOptionCategory defaultOptionCategory = new DefaultOptionCategory();
@Setting(value = "vanilla-fallback-values", comment = "Controls the default vanilla fallback values used to for resetting options such as player walking and flying speed."
+ "\nFor example: If no option value is found for a player, the values set here will be used instead.")
public Map<String, String> vanillaFallbackMap = new HashMap<>();
public OptionStorage() {
for (Option option : OptionRegistryModule.getInstance().getAll()) {
if (!option.getName().contains("player") && !option.getName().contains("spawn") && !option.getName().contains("pvp")) {
continue;
}
this.control.put(option.getName().toLowerCase(), false);
}
this.vanillaFallbackMap.put(Options.PLAYER_FLY_SPEED.getName().toLowerCase(), "0.1");
this.vanillaFallbackMap.put(Options.PLAYER_WALK_SPEED.getName().toLowerCase(), "0.2");
}
public boolean isOptionEnabled(String option) {
final Boolean result = this.control.get(option);
if (result == null) {
return false;
}
return result;
}
}

View File

@ -58,7 +58,7 @@ public List<String> getGlobalTargetBlacklist() {
public BlacklistCategory() {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
this.flagIdBlacklist.put(flag.getId().toLowerCase(), new ArrayList<>());
this.flagIdBlacklist.put(flag.getName().toLowerCase(), new ArrayList<>());
}
this.flagIdBlacklist.put("block-pre", new ArrayList<>());
}

View File

@ -33,13 +33,23 @@
@ConfigSerializable
public class ClaimCategory extends ConfigCategory {
@Setting(value = "explosion-block-surface-blacklist", comment = "A list of source id's that cannot cause explosion damage to blocks above sea level."
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to cause blocks to explode above sea level."
+ "\nNote: This will have higher priority than 'explosion-block' flag.")
public List<String> explosionBlockSurfaceBlacklist = new ArrayList<>();
@Setting(value = "explosion-entity-surface-blacklist", comment = "A list of id's that cannot cause explosion damage to entities above sea level."
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to hurt entities above sea level."
+ "\nNote: This will have higher priority than 'explosion-entity' flag.")
public List<String> explosionEntitySurfaceBlacklist = new ArrayList<>();
@Setting(value = "explosion-cancel-block-limit", comment = "The affected explosion block size limit to cancel events in order to improve performance."
+ "\nEx. If set to '50' and an explosion affects 51+ blocks, the event will cancel when the first protected block is found."
+ "\nNote: To disable, set value to '0'.")
public int explosionCancelBlockLimit = 50;
@Setting(value = "auto-chest-claim-block-radius", comment = "Radius used (in blocks) for auto-created claim when a chest is placed. Set to -1 to disable chest claim creation.")
public int autoChestClaimBlockRadius = 4;
@Setting(value = "border-block-radius", comment = "Set claim border of specified radius (in blocks), centered on claim. If set to 1, adds an additional 1 block protected radius around claim.\n" +
"Note: It is not recommended to set this value too high as performance can degrade due to deeper claim searches.")
public int borderBlockRadius = 0;
@Setting(value = "claim-list-max", comment = "Controls the max displayed claims when using the '/claimlist' command. Default: 200")
public int claimListMax = 200;
@Setting(value = "expiration-cleanup-interval", comment = "The interval in minutes for cleaning up expired claims. Default: 0. Set to 0 to disable.")
public int expirationCleanupInterval = 0;
@Setting(value = "auto-nature-restore", comment = "Whether survival claims will be automatically restored to world generated state when expired. \nNote: This only supports world generated blocks. Consider using 'auto-schematic-restore' if using a custom world.")
@ -66,12 +76,6 @@ public class ClaimCategory extends ConfigCategory {
+ "\nThe wildcard '*' represents zero or more characters."
+ "\nFor more information on usage, see https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/FilenameUtils.html#wildcardMatch(java.lang.String,%20java.lang.String)")
public List<String> reservedClaimNames = new ArrayList<>();
@Setting(value = "bank-tax-system", comment = "Whether to enable the bank/tax system for claims. Set to true to enable.")
public boolean bankTaxSystem = false;
@Setting(value = "tax-apply-hour", comment = "The specific hour in day to apply tax to all claims.")
public int taxApplyHour = 12;
@Setting(value = "bank-transaction-log-limit")
public int bankTransactionLogLimit = 60;
public ClaimCategory() {

View File

@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -33,6 +34,8 @@
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import com.griefdefender.util.PermissionUtil;
@ -85,25 +88,42 @@ public void initDefaults() {
continue;
}
Set<Context> contexts = new HashSet<>(flagDefinition.getContexts());
boolean shouldApply = false;
boolean isOverride = false;
String groupStr = null;
final Iterator<Context> iterator = contexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
shouldApply = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
continue;
}
shouldApply = true;
isOverride = true;
} else if (context.getKey().equalsIgnoreCase("group")) {
groupStr = context.getValue();
}
}
GDPermissionHolder holder = GriefDefenderPlugin.DEFAULT_HOLDER;
if (groupStr != null) {
if (PermissionUtil.getInstance().hasGroupSubject(groupStr)) {
holder = PermissionHolderCache.getInstance().getOrCreateGroup(groupStr);
if (holder == null) {
holder = GriefDefenderPlugin.DEFAULT_HOLDER;
}
}
}
for (FlagData flagData : flagDefinition.getFlagData()) {
Set<Context> permissionContexts = new HashSet<>(contexts);
permissionContexts.addAll(flagData.getContexts());
boolean shouldApply = false;
boolean isOverride = false;
for (Context context : permissionContexts) {
if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
shouldApply = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
shouldApply = true;
isOverride = true;
}
}
if (shouldApply) {
if (isOverride) {
PermissionUtil.getInstance().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
PermissionUtil.getInstance().setPermissionValue(holder, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
} else {
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
PermissionUtil.getInstance().setTransientPermission(holder, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
}
}
}

View File

@ -58,8 +58,8 @@ public DefaultOptionCategory() {
this.defaultUserOptions.put(Options.CHEST_EXPIRATION.getName(), "7");
this.defaultUserOptions.put(Options.CREATE_LIMIT.getName(), "-1");
this.defaultUserOptions.put(Options.CREATE_MODE.getName(), "undefined");
this.defaultUserOptions.put(Options.ECONOMY_BLOCK_COST.getName(), "0.0");
this.defaultUserOptions.put(Options.ECONOMY_BLOCK_SELL_RETURN.getName(), "0.0");
this.defaultUserOptions.put(Options.ECONOMY_BLOCK_COST.getName(), "1.0");
this.defaultUserOptions.put(Options.ECONOMY_BLOCK_SELL_RETURN.getName(), "1.0");
this.defaultUserOptions.put(Options.EXPIRATION.getName(), "14");
this.defaultUserOptions.put(Options.INITIAL_BLOCKS.getName(), "120");
this.defaultUserOptions.put(Options.MAX_ACCRUED_BLOCKS.getName(), Integer.toString(maxAccruedBlocks));
@ -68,12 +68,13 @@ public DefaultOptionCategory() {
this.defaultUserOptions.put(Options.PLAYER_DENY_FLIGHT.getName(), "false");
this.defaultUserOptions.put(Options.PLAYER_DENY_GODMODE.getName(), "false");
this.defaultUserOptions.put(Options.PLAYER_DENY_HUNGER.getName(), "false");
this.defaultUserOptions.put(Options.PLAYER_FLY_SPEED.getName(), "0");
this.defaultUserOptions.put(Options.PLAYER_GAMEMODE.getName(), "undefined");
this.defaultUserOptions.put(Options.PLAYER_HEALTH_REGEN.getName(), "-1.0");
this.defaultUserOptions.put(Options.PLAYER_HEALTH_REGEN.getName(), "0");
this.defaultUserOptions.put(Options.PLAYER_KEEP_INVENTORY.getName(), "undefined");
this.defaultUserOptions.put(Options.PLAYER_KEEP_LEVEL.getName(), "undefined");
this.defaultUserOptions.put(Options.PLAYER_TELEPORT_DELAY.getName(), "0");
this.defaultUserOptions.put(Options.PLAYER_WALK_SPEED.getName(), "-1");
this.defaultUserOptions.put(Options.PLAYER_WALK_SPEED.getName(), "0");
this.defaultUserOptions.put(Options.PLAYER_WEATHER.getName(), "undefined");
this.defaultUserOptions.put(Options.PVP.getName(), "undefined");
this.defaultUserOptions.put(Options.PVP_COMBAT_COMMAND.getName(), "false");
@ -81,10 +82,13 @@ public DefaultOptionCategory() {
this.defaultUserOptions.put(Options.PVP_COMBAT_TIMEOUT.getName(), "15");
this.defaultUserOptions.put(Options.RAID.getName(), "true");
this.defaultUserOptions.put(Options.RADIUS_INSPECT.getName(), "100");
this.defaultUserOptions.put(Options.RENT_EXPIRATION.getName(), "7");
this.defaultUserOptions.put(Options.RENT_EXPIRATION_DAYS_KEEP.getName(), "7");
this.defaultUserOptions.put(Options.RENT_RESTORE.getName(), "false");
this.defaultUserOptions.put(Options.SPAWN_LIMIT.getName(), "-1");
this.defaultUserOptions.put(Options.TAX_EXPIRATION.getName(), "7");
this.defaultUserOptions.put(Options.TAX_EXPIRATION_DAYS_KEEP.getName(), "7");
this.defaultUserOptions.put(Options.TAX_RATE.getName(), "1.0");
this.defaultUserOptions.put(Options.TAX_RATE.getName(), "0.1");
this.defaultBasicOptions.put(Options.MIN_SIZE_X.getName(), "5");
this.defaultBasicOptions.put(Options.MIN_SIZE_Y.getName(), "5");
@ -111,7 +115,7 @@ public DefaultOptionCategory() {
this.defaultTownOptions.put(Options.MAX_SIZE_Z.getName(), "0");
this.defaultTownOptions.put(Options.TAX_EXPIRATION.getName(), "7");
this.defaultTownOptions.put(Options.TAX_EXPIRATION_DAYS_KEEP.getName(), "7");
this.defaultTownOptions.put(Options.TAX_RATE.getName(), "1.0");
this.defaultTownOptions.put(Options.TAX_RATE.getName(), "0.1");
}
public void checkOptions() {

View File

@ -24,6 +24,9 @@
*/
package com.griefdefender.configuration.category;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.economy.TransactionType;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -38,4 +41,65 @@ public class EconomyCategory extends ConfigCategory {
@Setting(value = "use-claim-block-task", comment = "Claim blocks earned will be converted to economy based on 'claim-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.")
public boolean bankSystem = false;
@Setting(value = "tax-system", comment = "Whether to enable the tax system for claims. Set to true to enable.")
public boolean taxSystem = false;
@Setting(value = "bank-transaction-log-limit", comment = "The amount of transactions to keep for history. Default: 60")
public int bankTransactionLogLimit = 60;
@Setting(value = "sell-sign", comment = "Whether sell signs are enabled.")
private boolean sellSignEnabled = false;
@Setting(value = "rent-max-time-limit", comment = "Controls the maximum time limit(hours or days) that a claim owner can have their rental max set to."
+ "\nNote: This only affects claim rentals that have a max specified. If no max is specified by the claim owner, a renter may rent as long as they want.")
public int rentMaxTimeLimit = 100;
@Setting(value = "rent-restore-day-warning", comment = "Controls which day a player should start to receive warnings about their rented claim nearing expiration. "
+ "\nEx. If set to '5', this will begin to send players messaging on login and at the rent apply hour when 5 days are remaining before expiration."
+ "\nNote: This only applies if the owner has 'rent-restore' option enabled and the rent owner sets a max.")
public int rentRestoreDayWarning = 5;
@Setting(value = "rent-schematic-restore-admin", comment = "Controls whether rented admin claims will use a schematic for restoration."
+ "\nNote: If set, the claim will create a schematic on rental start and restore it back when finished."
+ "\nNote: This ONLY applies to rentals with a max date set.")
public boolean rentSchematicRestoreAdmin = false;
@Setting(value = "rent-system", comment = "Controls whether the rent system is enabled. Note: This is currently experimental, use with caution.")
public boolean rentSystem = false;
@Setting(value = "rent-sign", comment = "Whether rent signs are enabled.")
private boolean rentSignEnabled = false;
@Setting(value = "rent-task-interval", comment = "The interval in minutes for checking claim rent payments that are due. Default: 1. Set to 0 to disable.")
public int rentTaskInterval = 1;
@Setting(value = "rent-delinquent-task-apply-hour", comment = "The specific hour in day to attempt to get owed claim rent balances from delinquent renters. Note: This uses military time and accepts values between 0-23. Default: 0")
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 = "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")
public int taxApplyHour = 0;
public int getTransactionLogLimit(TransactionType type) {
if (type == TransactionType.BANK_DEPOSIT || type == TransactionType.BANK_WITHDRAW) {
return this.bankTransactionLogLimit;
}
if (type == TransactionType.RENT) {
return this.rentTransactionLogLimit;
}
return this.taxTransactionLogLimit;
}
public boolean isSellSignEnabled() {
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
return false;
}
return this.sellSignEnabled;
}
public boolean isRentSignEnabled() {
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
return false;
}
return this.rentSignEnabled;
}
}

View File

@ -31,7 +31,7 @@
public class MessageCategory extends ConfigCategory {
@Setting(value = "locale", comment = "Set the locale to use for GD messages. (Default: en_US)\n" +
"Available languages: de_DE, en_US, es_ES, fr_FR, ru_RU. The data is stored under assets in jar.\n" +
"Available languages: de_DE, en_US, es_ES, fr_FR, pl_PL, ru_RU. The data is stored under assets in jar.\n" +
"Note: The language code must be lowercase and the country code must be uppercase.")
public String locale = "en_US";

View File

@ -1,56 +0,0 @@
/*
* 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 com.google.common.collect.Maps;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.Map;
@ConfigSerializable
public class ModuleCategory {
@Setting(value = "protection", comment = "Controls which protection modules are enabled."
+ "\nNote: If you want full protection, it is recommended to keep everything enabled.")
private Map<String, Boolean> protection = Maps.newHashMap();
public ModuleCategory() {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
this.protection.put(flag.getName().toLowerCase(), true);
}
}
public boolean isProtectionModuleEnabled(String flag) {
final Boolean result = this.protection.get(flag);
if (result == null) {
return false;
}
return result;
}
}

View File

@ -22,29 +22,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.internal.registry;
package com.griefdefender.configuration.category;
import com.griefdefender.api.CatalogType;
import org.spongepowered.api.item.ItemType;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
public class GDItemType implements CatalogType {
@ConfigSerializable
public class PvpCategory extends ConfigCategory {
private ItemType type;
@Setting(value = "enabled", comment = "Whether pvp protection is enabled for players.")
public boolean enabled = true;
public GDItemType(ItemType type) {
this.type = type;
}
@Override
public String getName() {
return this.type.getName();
}
public String getId() {
return this.type.getId();
}
public ItemType getType() {
return this.type;
}
@Setting(value = "allow-fly", comment = "Whether flying is allowed during PvP.")
public boolean allowFly = false;
}

View File

@ -36,9 +36,12 @@ public class VisualCategory extends ConfigCategory {
public boolean hideBorders = false;
@Setting(value = "hide-wecui-drag-visuals-2d", comment = "Whether drag visuals should be shown while creating a claim in 2D mode.")
public boolean hideDrag2d = true;
@Setting(value = "client-visuals-per-tick", comment = "The amount of block visuals a client can receive per tick when showing/hiding claims. Default: 12")
public int clientVisualsPerTick = 12;
@Setting(value = "claim-create-block", comment = "The visual block used during claim creation. (Default: minecraft:diamond_block)")
public String claimCreateStartBlock = "minecraft:diamond_block";
@Setting(value = "filler-spacing", comment = "The space between each filler visual block.")
public int fillerSpacing = 10;
@Setting(value = "admin-accent-block", comment = "The visual accent block used for admin claims. (Default: minecraft:pumpkin)")
public String visualAdminAccentBlock = "minecraft:pumpkin";

View File

@ -31,15 +31,19 @@
import java.util.UUID;
import com.google.common.reflect.TypeToken;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.flag.GDFlagData;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.registry.FlagRegistryModule;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
@ -96,6 +100,9 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
switch (key) {
case ContextKeys.SOURCE:
case ContextKeys.TARGET:
if (value.equalsIgnoreCase("any")) {
break;
}
if (!value.contains(":") && !value.contains("#")) {
value = "minecraft:" + value;
}
@ -126,6 +133,7 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
}
Set<Context> contexts = new HashSet<>();
GDPermissionHolder subject = GriefDefenderPlugin.DEFAULT_HOLDER;
if (contextList != null) {
for (String context : contextList) {
final String parts[] = context.split("=");
@ -142,7 +150,7 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
contexts.add(new Context("gd_claim_default", value));
} else if (key.equalsIgnoreCase("override") || key.equalsIgnoreCase("gd_claim_override")) {
if (!value.equalsIgnoreCase("global") && !value.equalsIgnoreCase("basic") && !value.equalsIgnoreCase("admin")
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town") && !value.equalsIgnoreCase("claim")) {
// try UUID
if (value.length() == 36) {
try {
@ -155,13 +163,22 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
}
}
contexts.add(new Context("gd_claim_override", value));
} else if (key.equalsIgnoreCase("group")) {
if (value != null) {
if (PermissionUtil.getInstance().hasGroupSubject(value)) {
subject = PermissionHolderCache.getInstance().getOrCreateGroup(value);
if (subject == null) {
subject = GriefDefenderPlugin.DEFAULT_HOLDER;
}
}
}
} else {
contexts.add(new Context(key, value));
}
}
}
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description, groupName, adminGroup, contexts);
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description, groupName, subject, adminGroup, contexts);
flagDefinition.setIsEnabled(enabled);
flagDefinition.setDefaultValue(Tristate.fromBoolean(defaultValue));
return flagDefinition;

View File

@ -27,6 +27,8 @@
import com.griefdefender.configuration.category.BanCategory;
import com.griefdefender.configuration.category.BlacklistCategory;
import com.griefdefender.configuration.category.ClaimCategory;
import com.griefdefender.configuration.category.EconomyCategory;
import com.griefdefender.configuration.category.PvpCategory;
import com.griefdefender.configuration.category.TownCategory;
import com.griefdefender.configuration.category.VisualCategory;
@ -51,6 +53,12 @@ public class ConfigBase {
@Setting
public ClaimCategory claim = new ClaimCategory();
@Setting
public EconomyCategory economy = new EconomyCategory();
@Setting
public PvpCategory pvp = new PvpCategory();
@Setting
public TownCategory town = new TownCategory();

View File

@ -26,10 +26,8 @@
import com.griefdefender.configuration.category.GuiCategory;
import com.griefdefender.configuration.category.DynmapCategory;
import com.griefdefender.configuration.category.EconomyCategory;
import com.griefdefender.configuration.category.MessageCategory;
import com.griefdefender.configuration.category.MigratorCategory;
import com.griefdefender.configuration.category.ModuleCategory;
import com.griefdefender.configuration.category.PlayerDataCategory;
import com.griefdefender.configuration.category.ThreadCategory;
import com.griefdefender.configuration.category.TownCategory;
@ -40,8 +38,6 @@ public class GlobalConfig extends ConfigBase {
@Setting
public DynmapCategory dynmap = new DynmapCategory();
@Setting
public EconomyCategory economy = new EconomyCategory();
@Setting
public GuiCategory gui = new GuiCategory();
@Setting
public PlayerDataCategory playerdata = new PlayerDataCategory();
@ -51,8 +47,6 @@ public class GlobalConfig extends ConfigBase {
"List of migrators that convert old or other protection data into the current GD claim data format." +
"\nNote: It is recommended to backup data before using.")
public MigratorCategory migrator = new MigratorCategory();
@Setting(value = "modules")
public ModuleCategory modules = new ModuleCategory();
@Setting
public ThreadCategory thread = new ThreadCategory();

View File

@ -0,0 +1,9 @@
package com.griefdefender.economy;
public enum EconomyType {
ALL,
BUY,
SELL,
RENT
}

View File

@ -27,43 +27,52 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.economy.BankTransaction;
import com.griefdefender.api.economy.BankTransactionType;
import com.griefdefender.api.economy.PaymentTransaction;
import com.griefdefender.api.economy.TransactionResultType;
import com.griefdefender.api.economy.TransactionType;
import java.time.Instant;
import java.util.Optional;
import java.util.UUID;
public class GDBankTransaction implements BankTransaction {
public class GDPaymentTransaction implements PaymentTransaction {
public final BankTransactionType type;
public final TransactionType type;
public final TransactionResultType result;
public final UUID source;
public final Instant timestamp;
public final double amount;
public GDBankTransaction(Claim claim, BankTransactionType type, Instant timestamp, double amount) {
this(type, timestamp, amount);
public GDPaymentTransaction(Claim claim, TransactionType type, TransactionResultType result, Instant timestamp, double amount) {
this(type, result, timestamp, amount);
}
public GDBankTransaction(BankTransactionType type, UUID source, Instant timestamp, double amount) {
public GDPaymentTransaction(TransactionType type, TransactionResultType result, UUID source, Instant timestamp, double amount) {
this.type = type;
this.result = result;
this.timestamp = timestamp;
this.amount = amount;
this.source = source;
}
public GDBankTransaction(BankTransactionType type, Instant timestamp, double amount) {
public GDPaymentTransaction(TransactionType type, TransactionResultType result, Instant timestamp, double amount) {
this.type = type;
this.result = result;
this.timestamp = timestamp;
this.amount = amount;
this.source = null;
}
@Override
public BankTransactionType getType() {
public TransactionType getType() {
return this.type;
}
@Override
public TransactionResultType getResultType() {
return this.result;
}
@Override
public Optional<UUID> getSource() {
return Optional.ofNullable(this.source);
@ -79,18 +88,25 @@ public Double getAmount() {
return this.amount;
}
public static class BankTransactionBuilder implements Builder {
public static class PaymentTransactionBuilder implements Builder {
private UUID source;
private double amount;
private BankTransactionType type;
private TransactionType type;
private TransactionResultType result;
@Override
public Builder type(BankTransactionType type) {
public Builder type(TransactionType type) {
this.type = type;
return this;
}
@Override
public Builder result(TransactionResultType result) {
this.result = result;
return this;
}
@Override
public Builder source(UUID source) {
this.source = source;
@ -107,18 +123,19 @@ public Builder amount(double amount) {
public Builder reset() {
this.source = null;
this.amount = 0;
this.type = null;
this.result = null;
return this;
}
@Override
public BankTransaction build() {
public PaymentTransaction build() {
checkNotNull(this.type);
checkNotNull(this.result);
checkNotNull(this.amount);
if (this.source != null) {
return new GDBankTransaction(this.type, this.source, Instant.now(), this.amount);
return new GDPaymentTransaction(this.type, this.result, this.source, Instant.now(), this.amount);
}
return new GDBankTransaction(this.type, Instant.now(), this.amount);
return new GDPaymentTransaction(this.type, this.result, Instant.now(), this.amount);
}
}

View File

@ -67,14 +67,14 @@ public GDCauseStackManager pushCause(Object obj) {
if (obj instanceof OfflinePlayer) {
obj = PermissionHolderCache.getInstance().getOrCreateUser((OfflinePlayer) obj);
}
if (tick_stored == NMSUtil.getInstance().getRunningServerTicks()) {
/*if (tick_stored == NMSUtil.getInstance().getRunningServerTicks()) {
this.cause.push(obj);
return this;
}
}*/
tick_stored = NMSUtil.getInstance().getRunningServerTicks();
this.cached_cause = null;
this.cause.push(obj);
tick_stored = NMSUtil.getInstance().getRunningServerTicks();
return this;
}

View File

@ -71,6 +71,17 @@ public Delete(List<Claim> claims) {
}
}
public static class Expire extends GDRemoveClaimEvent implements RemoveClaimEvent.Expire {
public Expire(Claim claim) {
super(claim);
}
public Expire(List<Claim> claims) {
super(claims);
}
}
@Override
public boolean isRestoring() {
return shouldRestore;

View File

@ -0,0 +1,83 @@
/*
* 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.event;
import com.griefdefender.api.User;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.api.event.RentClaimEvent;
public class GDRentClaimEvent extends GDClaimEvent implements RentClaimEvent {
private final double originalRentRate;
private final double originalRentBalance;
private double rentRate;
private PaymentType paymentType;
private User user;
public GDRentClaimEvent(Claim claim, User user, double rate, double amount) {
super(claim);
this.originalRentRate = rate;
this.originalRentBalance = amount;
this.rentRate = rate;
this.user = user;
this.paymentType = claim.getEconomyData().getPaymentType();
}
@Override
public double getOriginalRentRate() {
return this.originalRentRate;
}
@Override
public double getOriginalRentBalance() {
return this.originalRentBalance;
}
@Override
public double getRentRate() {
return this.rentRate;
}
@Override
public double getRentBalance() {
return this.originalRentBalance + this.rentRate;
}
@Override
public void setRentRate(double newRentRate) {
this.rentRate = newRentRate;
}
@Override
public User getRenter() {
return this.user;
}
@Override
public PaymentType getPaymentType() {
return this.paymentType;
}
}

View File

@ -35,7 +35,9 @@
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimResult;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.claim.ClaimVisualTypes;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.cache.EventResultCache;
@ -46,26 +48,30 @@
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.tracking.chunk.GDChunk;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.internal.visual.ClaimVisual;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.CauseContextHelper;
import com.griefdefender.util.Direction;
import com.griefdefender.util.SignUtil;
import net.kyori.text.Component;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -85,11 +91,15 @@
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class BlockEventHandler implements Listener {
@ -102,6 +112,31 @@ public BlockEventHandler(BaseStorage dataStore) {
this.storage = dataStore;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
if (!GDFlags.INVENTORY_ITEM_MOVE || !GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) {
return;
}
final World world = event.getSource().getLocation().getWorld();
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID()) || GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
return;
}
final Inventory sourceInventory = event.getSource();
final Inventory targetInventory = event.getDestination();
final Location sourceLocation = sourceInventory.getLocation();
final Location targetLocation = targetInventory.getLocation();
final GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(sourceLocation);
final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(targetLocation);
if (sourceClaim.isWilderness() && targetClaim.isWilderness() || (GriefDefenderPlugin.getInstance().getVaultProvider() == null)) {
return;
}
if (sourceClaim.getEconomyData().isRented() || targetClaim.getEconomyData().isRented()) {
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockFadeEvent(BlockFadeEvent event) {
CommonBlockEventHandler.getInstance().handleBlockModify(event, event.getBlock(), event.getNewState());
@ -147,11 +182,11 @@ public void onBlockPistonExtend(BlockPistonExtendEvent event) {
GDClaim targetClaim = null;
if (event.getBlocks().isEmpty()) {
Location location = BlockUtil.getInstance().getBlockRelative(event.getBlock().getLocation(), event.getDirection());
targetClaim = this.storage.getClaimAt(location, targetClaim);
targetClaim = this.storage.getClaimAt(location);
if (targetClaim.isWilderness()) {
// Sticky pistons will attach to next block so we need to check it
location = BlockUtil.getInstance().getBlockRelative(location, event.getDirection());
targetClaim = this.storage.getClaimAt(location, targetClaim);
targetClaim = this.storage.getClaimAt(location);
}
if (handleBlockBreak(event, location, targetClaim, event.getBlock(), location.getBlock(), user, false)) {
@ -163,7 +198,7 @@ public void onBlockPistonExtend(BlockPistonExtendEvent event) {
for (Block block : event.getBlocks()) {
Location location = BlockUtil.getInstance().getBlockRelative(block.getLocation(), event.getDirection());
targetClaim = this.storage.getClaimAt(location, targetClaim);
targetClaim = this.storage.getClaimAt(location);
if (targetClaim.isWilderness()) {
continue;
}
@ -285,7 +320,7 @@ private boolean handleBlockBreak(BlockEvent event, Location location, GDClaim cl
if (sendDenyMessage && user != null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_BUILD,
ImmutableMap.of(
"player", claim.getOwnerName()
"player", claim.getOwnerDisplayName()
));
final Player player = Bukkit.getPlayer(user.getUniqueId());
if (player != null && player.isOnline()) {
@ -366,7 +401,7 @@ public void onBlockNotify(BlockPhysicsEvent event) {
GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world, user.getUniqueId());
GDClaim sourceClaim = null;
if (source != null) {
sourceClaim = this.storage.getClaimAt(sourceLocation, playerData.lastClaim.get());
sourceClaim = this.storage.getClaimAt(sourceLocation);
}
Vector3i pos = VecHelper.toVector3i(location);
GDClaim targetClaim = this.storage.getClaimAt(location);
@ -424,13 +459,24 @@ public void onExplosionEvent(BlockExplodeEvent event) {
GDTimings.EXPLOSION_EVENT.startTiming();
GDClaim targetClaim = null;
final List<Block> filteredLocations = new ArrayList<>();
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
if (!denySurfaceExplosion) {
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
}
for (Block block : event.blockList()) {
final Location location = block.getLocation();
targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location, targetClaim);
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, location.getBlock(), user, true);
targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
if (denySurfaceExplosion && block.getWorld().getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) {
filteredLocations.add(block);
GDPermissionManager.getInstance().processEventLog(event, location, targetClaim, Flags.EXPLOSION_BLOCK.getPermission(), source, block, user, "explosion-surface", Tristate.FALSE);
continue;
}
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
if (result == Tristate.FALSE) {
// Avoid lagging server from large explosions.
if (event.blockList().size() > 100) {
if (event.blockList().size() > cancelBlockLimit) {
event.setCancelled(true);
break;
}
@ -481,7 +527,7 @@ public void onBlockBreak(BlockBreakEvent event) {
if (message == null) {
message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_BUILD,
ImmutableMap.of(
"player", targetClaim.getOwnerName()
"player", targetClaim.getOwnerDisplayName()
));
}
GriefDefenderPlugin.sendClaimDenyMessage(targetClaim, player, message);
@ -611,7 +657,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
// show the player the protected area
GDClaim newClaim = this.storage.getClaimAt(block.getLocation());
ClaimVisual visualization = new ClaimVisual(newClaim, ClaimVisual.BASIC);
GDClaimVisual visualization = new GDClaimVisual(newClaim, ClaimVisualTypes.BASIC);
visualization.createClaimBlockVisuals(blockPos.getY(), player.getLocation(), playerData);
visualization.apply(player);
@ -629,4 +675,77 @@ public void onBlockPlace(BlockPlaceEvent event) {
GDTimings.BLOCK_PLACE_EVENT.stopTiming();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onSignChangeEvent(SignChangeEvent event) {
if (GriefDefenderPlugin.getInstance().getVaultProvider() == null) {
return;
}
final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(event.getBlock().getWorld().getUID());
if (!activeConfig.getConfig().economy.rentSystem || (!activeConfig.getConfig().economy.isRentSignEnabled() && !activeConfig.getConfig().economy.isSellSignEnabled())) {
return;
}
final Sign sign = (Sign) event.getBlock().getState();
final Player player = event.getPlayer();
final GDClaim claim = this.storage.getClaimAt(event.getBlock().getLocation());
if (claim.isWilderness()) {
return;
}
final String[] lines = event.getLines();
final String header = lines[0];
if (header == null || (!header.equalsIgnoreCase("gd") && !header.equalsIgnoreCase("griefdefender"))) {
return;
}
final String line1 = lines[1];
final String line2 = lines[2];
final String line3 = lines[3];
if (line1.equalsIgnoreCase("sell") && activeConfig.getConfig().economy.isSellSignEnabled()) {
if (!player.hasPermission(GDPermissions.USER_SELL_SIGN)) {
return;
}
// handle sell
// check price
Double price = null;
try {
price = Double.valueOf(line2);
} catch (NumberFormatException e) {
return;
}
SignUtil.setClaimForSale(claim, player, sign, price);
} else if (line1.equalsIgnoreCase("rent") && activeConfig.getConfig().economy.isRentSignEnabled()) {
if (!player.hasPermission(GDPermissions.USER_RENT_SIGN)) {
return;
}
Double rate = null;
try {
rate = Double.valueOf(line2.substring(0, line2.length() - 1));
} catch (NumberFormatException e) {
return;
}
int rentMin = 0;
int rentMax = 0;
if (line3 != null) {
rentMin = SignUtil.getRentMinTime(line3);
rentMax = SignUtil.getRentMaxTime(line3);
}
String rentType = line2;
final PaymentType paymentType = SignUtil.getPaymentType(rentType);
if (paymentType == PaymentType.UNDEFINED) {
// invalid
return;
}
SignUtil.setClaimForRent(claim, player, sign, rate, rentMin, rentMax, paymentType);
}
}
}

View File

@ -24,44 +24,44 @@
*/
package com.griefdefender.listener;
import com.flowpowered.math.vector.Vector3i;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.tracking.EntityTracker;
import com.griefdefender.internal.tracking.PlayerTracker;
import com.griefdefender.internal.tracking.chunk.GDChunk;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.tracking.entity.GDEntity;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.CauseContextHelper;
import com.griefdefender.util.Direction;
import org.bukkit.Bukkit;
import com.griefdefender.util.SignUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.UUID;
public class BlockEventTracker implements Listener {
private static Direction[] NOTIFY_DIRECTIONS = {Direction.WEST, Direction.EAST, Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH};
private int lastTick = -1;
private GDChunk cacheChunk = null;
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreakMonitor(BlockBreakEvent event) {
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID());
@ -84,6 +84,40 @@ public void onBlockBurn(BlockBurnEvent event) {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFalling(EntitySpawnEvent event) {
final Entity entity = event.getEntity();
final World world = entity.getWorld();
if (entity instanceof FallingBlock) {
// add owner
final Location location = entity.getLocation();
final Block block = world.getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID());
final GDChunk gdChunk = claimWorldManager.getChunk(location.getChunk());
final UUID ownerUniqueId = gdChunk.getBlockOwnerUUID(block.getLocation());
if (ownerUniqueId != null) {
final GDEntity gdEntity = new GDEntity(event.getEntity().getEntityId());
gdEntity.setOwnerUUID(ownerUniqueId);
gdEntity.setNotifierUUID(ownerUniqueId);
EntityTracker.addTempEntity(gdEntity);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockSpawnFalling(EntityChangeBlockEvent event) {
final Entity entity = event.getEntity();
if (entity instanceof FallingBlock) {
final GDEntity gdEntity = EntityTracker.getCachedEntity(event.getEntity().getEntityId());
if (gdEntity != null) {
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID());
final GDChunk gdChunk = claimWorldManager.getChunk(event.getBlock().getChunk());
gdChunk.addTrackedBlockPosition(event.getBlock(), user.getUniqueId(), PlayerTracker.Type.OWNER);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
//event
@ -109,10 +143,26 @@ public void onBlockPhysicsMonitor(BlockPhysicsEvent event) {
if (targetBlockName.equals("minecraft:observer")) {
return;
}
// Check if sign broke
final Block block = event.getBlock();
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null && (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.isRentSignEnabled() || GriefDefenderPlugin.getGlobalConfig().getConfig().economy.isSellSignEnabled())) {
if (SignUtil.isSign(block) && block.getState().getData() instanceof org.bukkit.material.Sign) {
final org.bukkit.material.Sign sign = (org.bukkit.material.Sign) block.getState().getData();
final BlockFace face = sign.getAttachedFace();
if (face != null) {
final Block attachedBlock = block.getRelative(face);
if (attachedBlock.getType() == Material.AIR && (SignUtil.isRentSign(block) || SignUtil.isSellSign(block))) {
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID());
final Claim claim = claimWorldManager.getClaimAt(block.getLocation(), false);
claim.getEconomyData().setRentSignPosition(null);
}
}
}
}
final Block sourceBlock = NMSUtil.getInstance().getSourceBlock(event);
final Location sourceLocation = sourceBlock != null ? sourceBlock.getLocation() : null;
if (sourceLocation != null && sourceLocation.equals(event.getBlock().getLocation())) {
if (sourceLocation != null && sourceLocation.equals(block.getLocation())) {
return;
}
if (sourceBlock != null) {
@ -122,16 +172,15 @@ public void onBlockPhysicsMonitor(BlockPhysicsEvent event) {
}
}
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID());
final GDChunk gpChunk = claimWorldManager.getChunk(event.getBlock().getChunk());
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(block.getWorld().getUID());
final GDChunk gpChunk = claimWorldManager.getChunk(block.getChunk());
final GDPermissionUser user = CauseContextHelper.getEventUser(sourceLocation);
final UUID uuid = user != null ? user.getUniqueId() : null;
final Vector3i targetPos = VecHelper.toVector3i(event.getBlock().getLocation());
//final Vector3i sourcePos = VecHelper.toVector3i(event.getSourceBlock().getLocation());
//final Location targetLocation = event.getBlock().getLocation();
if (uuid != null) {
gpChunk.addTrackedBlockPosition(targetPos, uuid, PlayerTracker.Type.NOTIFIER);
gpChunk.addTrackedBlockPosition(block, uuid, PlayerTracker.Type.NOTIFIER);
// Bukkit doesn't send surrounding events for performance reasons so we must handle it manually
/*for (Direction direction : NOTIFY_DIRECTIONS) {
final Vector3i directionPos = targetPos.add(direction.asBlockOffset());
@ -140,17 +189,17 @@ public void onBlockPhysicsMonitor(BlockPhysicsEvent event) {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
if (!event.isCancelled()) {
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getClickedBlock().getWorld().getUID());
final GDChunk gpChunk = claimWorldManager.getChunk(event.getClickedBlock().getChunk());
final Vector3i targetPos = VecHelper.toVector3i(event.getClickedBlock().getLocation());
GDCauseStackManager.getInstance().pushCause(event.getPlayer());
gpChunk.addTrackedBlockPosition(event.getClickedBlock(), event.getPlayer().getUniqueId(), PlayerTracker.Type.NOTIFIER);
// We must track the position above clicked to block actions like water flow properly.
final Vector3i blockAbovePos = VecHelper.toVector3i(BlockUtil.getInstance().getBlockRelative(event.getClickedBlock().getLocation(), BlockFace.UP));
gpChunk.addTrackedBlockPosition(blockAbovePos, event.getPlayer().getUniqueId(), PlayerTracker.Type.NOTIFIER);
if (event.getClickedBlock() == null) {
return;
}
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getClickedBlock().getWorld().getUID());
final GDChunk gpChunk = claimWorldManager.getChunk(event.getClickedBlock().getChunk());
GDCauseStackManager.getInstance().pushCause(event.getPlayer());
gpChunk.addTrackedBlockPosition(event.getClickedBlock(), event.getPlayer().getUniqueId(), PlayerTracker.Type.NOTIFIER);
// We must track the position above clicked to block actions like water flow properly.
final Location aboveLocation = BlockUtil.getInstance().getBlockRelative(event.getClickedBlock().getLocation(), BlockFace.UP);
gpChunk.addTrackedBlockPosition(aboveLocation.getBlock(), event.getPlayer().getUniqueId(), PlayerTracker.Type.NOTIFIER);
}
}

View File

@ -38,6 +38,7 @@
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.PaginationUtil;
import net.kyori.text.Component;
@ -174,15 +175,17 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
final int combatTimeRemaining = playerData.getPvpCombatTimeRemaining();
final boolean inPvpCombat = combatTimeRemaining > 0;
final boolean pvpCombatCommand = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), player, Options.PVP_COMBAT_COMMAND);
if (!pvpCombatCommand && inPvpCombat) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PVP_IN_COMBAT_NOT_ALLOWED,
ImmutableMap.of(
"time-remaining", combatTimeRemaining));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.PLAYER_COMMAND_EVENT.stopTiming();
return;
if (GDOptions.isOptionEnabled(Options.PVP_COMBAT_COMMAND)) {
final boolean pvpCombatCommand = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), player, Options.PVP_COMBAT_COMMAND);
if (!pvpCombatCommand && inPvpCombat) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PVP_IN_COMBAT_NOT_ALLOWED,
ImmutableMap.of(
"time-remaining", combatTimeRemaining));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.PLAYER_COMMAND_EVENT.stopTiming();
return;
}
}
String commandBaseTarget = pluginId + ":" + command;
@ -223,7 +226,7 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_BLOCKED,
ImmutableMap.of(
"command", command,
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.PLAYER_COMMAND_EVENT.stopTiming();
@ -254,7 +257,7 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_BLOCKED,
ImmutableMap.of(
"command", command,
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.PLAYER_COMMAND_EVENT.stopTiming();

View File

@ -25,6 +25,7 @@
package com.griefdefender.listener;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -38,8 +39,10 @@
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.flag.GDFlags;
@ -109,7 +112,7 @@ public void handleBlockModify(Event event, Object source, BlockState newState) {
return;
}
if (newState.getBlock().isEmpty()) {
if (newState.getType() == Material.AIR) {
// Block -> Air should always be recorded as break
handleBlockBreak(event, source, newState);
return;
@ -123,6 +126,26 @@ public void handleBlockModify(Event event, Object source, BlockState newState) {
final GDPermissionUser user = GDCauseStackManager.getInstance().getCurrentCause().first(GDPermissionUser.class).orElse(null);
Location location = newState.getLocation();
GDClaim targetClaim = this.storage.getClaimAt(location);
// Workaround for BlockBurnEvent being triggered across blocks
if (event instanceof BlockBurnEvent) {
if (source instanceof Block) {
final Block sourceBlock = (Block) source;
if (sourceBlock.getType() == Material.FIRE) {
if (!sourceBlock.getLocation().equals(newState.getLocation())) {
// use block-spread
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_SPREAD, source, newState, user, TrustTypes.BUILDER, true);
if (result == Tristate.FALSE) {
((Cancellable) event).setCancelled(true);
}
return;
}
}
}
}
if (!(source instanceof Player) && user == null && !NMSUtil.getInstance().isBlockIce(newState.getType())) {
// always allow
return;
}
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_MODIFY, source, newState, user, TrustTypes.BUILDER, true);
if (result == Tristate.FALSE) {
@ -146,15 +169,23 @@ public void handleBlockPlace(Event event, Object source, BlockState newState) {
return;
}
// TODO - remove this when flag definition defaults are finished
if (player == null) {
final GDPermissionUser user = CauseContextHelper.getEventUser(location);
player = user != null ? user.getOnlinePlayer() : null;
if (source instanceof Block && !NMSUtil.getInstance().isBlockSnow(newState.getType())) {
final Block sourceBlock = (Block) source;
if (sourceBlock.isEmpty()) {
// allow air -> block placement
return;
}
}
GDPermissionUser user = player != null ? PermissionHolderCache.getInstance().getOrCreateUser(player.getUniqueId()) : GDCauseStackManager.getInstance().getCurrentCause().first(GDPermissionUser.class).orElse(null);
if (user == null && source != null && source instanceof Block) {
final Block sourceBlock = (Block) source;
user = CauseContextHelper.getEventUser(sourceBlock.getLocation());
}
GDClaim targetClaim = this.storage.getClaimAt(location);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_PLACE, source, newState, player, TrustTypes.BUILDER, true);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_PLACE, source, newState, user, TrustTypes.BUILDER, true);
if (result == Tristate.FALSE) {
((Cancellable) event).setCancelled(true);
}
@ -169,6 +200,13 @@ public void handleBlockBreak(Event event, Object source, BlockState blockState)
return;
}
// Special case
if (source instanceof Block) {
if (NMSUtil.getInstance().isBlockScaffolding(((Block) source))) {
return;
}
}
Player player = source instanceof Player ? (Player) source : null;
final Location location = blockState.getLocation();
if (location == null) {

View File

@ -24,7 +24,6 @@
*/
package com.griefdefender.listener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -38,7 +37,6 @@
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Cancellable;
@ -70,15 +68,15 @@
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDBorderClaimEvent;
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.permission.option.OptionContexts;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.PermissionUtil;
import com.griefdefender.util.PlayerUtil;
import net.kyori.text.Component;
@ -98,12 +96,17 @@ public static CommonEntityEventHandler getInstance() {
}
private final BaseStorage storage;
private boolean isTeleporting = false;
public CommonEntityEventHandler() {
this.storage = GriefDefenderPlugin.getInstance().dataStore;
}
public boolean onEntityMove(Event event, Location fromLocation, Location toLocation, Entity targetEntity){
if (this.isTeleporting) {
return true;
}
final Vector3i fromPos = VecHelper.toVector3i(fromLocation);
final Vector3i toPos = VecHelper.toVector3i(toLocation);
if (fromPos.equals(toPos)) {
@ -115,7 +118,13 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
final Player player = targetEntity instanceof Player ? (Player) targetEntity : null;
final GDPermissionUser user = player != null ? PermissionHolderCache.getInstance().getOrCreateUser(player) : null;
if (user != null) {
if (user != null && user.getOnlinePlayer() != null) {
final boolean preInLiquid = user.getInternalPlayerData().inLiquid;
final boolean inLiquid = user.getOnlinePlayer().getPlayer().getLocation().getBlock().isLiquid();
if (preInLiquid != inLiquid) {
user.getInternalPlayerData().inLiquid = inLiquid;
}
if (user.getInternalPlayerData().teleportDelay > 0) {
if (!toPos.equals(VecHelper.toVector3i(user.getInternalPlayerData().teleportSourceLocation))) {
user.getInternalPlayerData().teleportDelay = 0;
@ -133,8 +142,6 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
return true;
}
GDTimings.ENTITY_MOVE_EVENT.startTiming();
GDClaim fromClaim = null;
GDClaim toClaim = this.storage.getClaimAt(toLocation);
if (user != null) {
@ -143,20 +150,19 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
fromClaim = this.storage.getClaimAt(fromLocation);
}
if (GDFlags.ENTER_CLAIM && !enterBlacklisted && user != null && user.getInternalPlayerData().lastClaim != null) {
final GDClaim lastClaim = (GDClaim) user.getInternalPlayerData().lastClaim.get();
if (lastClaim != null && lastClaim != fromClaim) {
if (GDPermissionManager.getInstance().getFinalPermission(event, toLocation, toClaim, Flags.ENTER_CLAIM, targetEntity, targetEntity, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
Location claimCorner = new Location(toLocation.getWorld(), toClaim.lesserBoundaryCorner.getX(), targetEntity.getLocation().getBlockY(), toClaim.greaterBoundaryCorner.getZ());
targetEntity.teleport(claimCorner);
}
}
}
if (fromClaim == toClaim) {
GDTimings.ENTITY_MOVE_EVENT.stopTiming();
if (user != null) {
this.checkPlayerFlight(user, fromClaim, toClaim);
this.checkPlayerFlySpeed(user, fromClaim, toClaim);
this.checkPlayerGameMode(user, fromClaim, toClaim);
this.checkPlayerGodMode(user, fromClaim, toClaim);
this.checkPlayerWalkSpeed(user, fromClaim, toClaim);
this.checkPlayerWeather(user, fromClaim, toClaim, false);
}
return true;
}
GDTimings.ENTITY_MOVE_EVENT.startTiming();
GDBorderClaimEvent gpEvent = new GDBorderClaimEvent(targetEntity, fromClaim, toClaim);
if (user != null && toClaim.isUserTrusted(user, TrustTypes.ACCESSOR)) {
GriefDefender.getEventManager().post(gpEvent);
@ -164,7 +170,9 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
if (gpEvent.cancelled()) {
if (targetEntity instanceof Vehicle) {
final Vehicle vehicle = (Vehicle) targetEntity;
this.isTeleporting = true;
vehicle.teleport(fromLocation);
this.isTeleporting = false;
GDTimings.ENTITY_MOVE_EVENT.stopTiming();
return false;
}
@ -178,7 +186,6 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
return false;
} else {
final boolean showGpPrefix = GriefDefenderPlugin.getGlobalConfig().getConfig().message.enterExitShowGdPrefix;
user.getInternalPlayerData().lastClaim = new WeakReference<>(toClaim);
TextComponent welcomeMessage = (TextComponent) gpEvent.getEnterMessage().orElse(null);
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty())) {
ChatType chatType = gpEvent.getEnterMessageChatType();
@ -218,6 +225,7 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
}
if (player != null) {
this.checkPlayerFlight(user, fromClaim, toClaim);
this.checkPlayerFlySpeed(user, fromClaim, toClaim);
this.checkPlayerGameMode(user, fromClaim, toClaim);
this.checkPlayerGodMode(user, fromClaim, toClaim);
this.checkPlayerWalkSpeed(user, fromClaim, toClaim);
@ -265,7 +273,9 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
if (targetEntity instanceof Vehicle) {
final Vehicle vehicle = (Vehicle) targetEntity;
this.isTeleporting = true;
vehicle.teleport(fromLocation);
this.isTeleporting = false;
GDTimings.ENTITY_MOVE_EVENT.stopTiming();
return false;
}
@ -279,7 +289,6 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
if (user != null) {
final GDPlayerData playerData = user.getInternalPlayerData();
final boolean showGpPrefix = GriefDefenderPlugin.getGlobalConfig().getConfig().message.enterExitShowGdPrefix;
playerData.lastClaim = new WeakReference<>(toClaim);
Component welcomeMessage = gpEvent.getEnterMessage().orElse(null);
if (welcomeMessage != null && !welcomeMessage.equals(TextComponent.empty())) {
ChatType chatType = gpEvent.getEnterMessageChatType();
@ -320,6 +329,7 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
if (player != null) {
this.checkPlayerFlight(user, fromClaim, toClaim);
this.checkPlayerFlySpeed(user, fromClaim, toClaim);
this.checkPlayerGameMode(user, fromClaim, toClaim);
this.checkPlayerGodMode(user, fromClaim, toClaim);
this.checkPlayerWalkSpeed(user, fromClaim, toClaim);
@ -337,11 +347,17 @@ public boolean onEntityMove(Event event, Location fromLocation, Location toLocat
final static Pattern pattern = Pattern.compile("([^\\s]+)", Pattern.MULTILINE);
private void runPlayerCommands(GDClaim claim, GDPermissionUser user, boolean enter) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_COMMAND_ENTER) && !GDOptions.isOptionEnabled(Options.PLAYER_COMMAND_EXIT)) {
return;
}
List<String> rawCommandList = new ArrayList<>();
Set<Context> contexts = new HashSet<>();
@ -401,7 +417,7 @@ private void runCommand(GDClaim claim, Player player, List<String> rawCommandLis
private String replacePlaceHolders(GDClaim claim, Player player, String command) {
command = command
.replace("%player%", player.getName())
.replace("%owner%", claim.getOwnerFriendlyName())
.replace("%owner%", claim.getOwnerName())
.replace("%uuid%", player.getUniqueId().toString())
.replace("%world%", claim.getWorld().getName())
.replace("%server%", PermissionUtil.getInstance().getServerName())
@ -410,19 +426,31 @@ private String replacePlaceHolders(GDClaim claim, Player player, String command)
}
private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
if (player == null || !player.isFlying()) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_DENY_FLIGHT)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final GameMode gameMode = player.getGameMode();
if (gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR) {
if (gameMode == GameMode.SPECTATOR) {
return;
}
if (fromClaim == toClaim || !player.isFlying()) {
if (gameMode == GameMode.CREATIVE) {
if (playerData.inPvpCombat() && !GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().pvp.allowFly) {
player.setAllowFlight(false);
player.setFlying(false);
playerData.ignoreFallDamage = true;
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().OPTION_APPLY_PLAYER_DENY_FLIGHT);
return;
}
return;
}
@ -441,11 +469,17 @@ private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim
}
private void checkPlayerGodMode(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
if (player == null || !player.isInvulnerable()) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_DENY_GODMODE)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final GameMode gameMode = player.getGameMode();
@ -453,10 +487,6 @@ private void checkPlayerGodMode(GDPermissionUser user, GDClaim fromClaim, GDClai
return;
}
if (fromClaim == toClaim) {
return;
}
final Boolean noGodMode = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), playerData.getSubject(), Options.PLAYER_DENY_GODMODE, toClaim);
final boolean bypassOption = player.hasPermission(GDPermissions.BYPASS_OPTION + "." + Options.PLAYER_DENY_GODMODE.getName().toLowerCase());
if (!bypassOption && noGodMode) {
@ -466,23 +496,31 @@ private void checkPlayerGodMode(GDPermissionUser user, GDClaim fromClaim, GDClai
}
private void checkPlayerGameMode(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (fromClaim == toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_GAMEMODE)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final GameMode currentGameMode = player.getGameMode();
final GameModeType gameModeType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(GameModeType.class), playerData.getSubject(), Options.PLAYER_GAMEMODE, toClaim);
if (gameModeType == GameModeTypes.UNDEFINED && playerData.lastGameMode != GameModeTypes.UNDEFINED) {
player.setGameMode(PlayerUtil.GAMEMODE_MAP.get(playerData.lastGameMode));
return;
}
final boolean bypassOption = player.hasPermission(GDPermissions.BYPASS_OPTION + "." + Options.PLAYER_GAMEMODE.getName().toLowerCase());
if (!bypassOption && gameModeType != null && gameModeType != GameModeTypes.UNDEFINED) {
final GameMode newGameMode = PlayerUtil.GAMEMODE_MAP.get(gameModeType);
if (currentGameMode != newGameMode) {
playerData.lastGameMode = PlayerUtil.GAMEMODE_MAP.inverse().get(gameModeType);
player.setGameMode(newGameMode);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_GAMEMODE,
ImmutableMap.of(
@ -492,22 +530,92 @@ private void checkPlayerGameMode(GDPermissionUser user, GDClaim fromClaim, GDCla
}
}
private void checkPlayerWalkSpeed(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (fromClaim == toClaim) {
private void checkPlayerFlySpeed(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null || !player.isFlying()) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_FLY_SPEED)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final float currentFlySpeed = player.getFlySpeed();
final double flySpeed = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), playerData.getSubject(), Options.PLAYER_FLY_SPEED, toClaim);
if (flySpeed <= 0) {
String configValue = GriefDefenderPlugin.getOptionConfig().getConfig().vanillaFallbackMap.get(Options.PLAYER_FLY_SPEED.getName().toLowerCase());
Double defaultFlySpeed = null;
try {
defaultFlySpeed = Double.parseDouble(configValue);
} catch (Throwable t) {
defaultFlySpeed = 0.1;
}
if (currentFlySpeed != defaultFlySpeed.floatValue()) {
// set back to default
player.setFlySpeed(defaultFlySpeed.floatValue());
if (fromClaim.getWorldUniqueId().equals(toClaim.getWorldUniqueId())) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_FLY_SPEED,
ImmutableMap.of(
"speed", defaultFlySpeed.floatValue()));
GriefDefenderPlugin.sendMessage(player, message);
}
}
return;
}
if (flySpeed > 0) {
if (currentFlySpeed != ((float) flySpeed)) {
player.setFlySpeed((float) flySpeed);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_FLY_SPEED,
ImmutableMap.of(
"speed", flySpeed));
GriefDefenderPlugin.sendMessage(player, message);
}
}
}
private void checkPlayerWalkSpeed(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
if (player == null || player.isFlying()) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_WALK_SPEED)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final float currentWalkSpeed = player.getWalkSpeed();
final double walkSpeed = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), playerData.getSubject(), Options.PLAYER_WALK_SPEED, toClaim);
final boolean bypassOption = player.hasPermission(GDPermissions.BYPASS_OPTION + "." + Options.PLAYER_WALK_SPEED.getName().toLowerCase());
if (!bypassOption && walkSpeed > 0) {
if (walkSpeed <= 0) {
String configValue = GriefDefenderPlugin.getOptionConfig().getConfig().vanillaFallbackMap.get(Options.PLAYER_WALK_SPEED.getName().toLowerCase());
Double defaultWalkSpeed = null;
try {
defaultWalkSpeed = Double.parseDouble(configValue);
} catch (Throwable t) {
defaultWalkSpeed = 0.2;
}
if (currentWalkSpeed != defaultWalkSpeed.floatValue()) {
// set back to default
player.setWalkSpeed(defaultWalkSpeed.floatValue());
if (fromClaim.getWorldUniqueId().equals(toClaim.getWorldUniqueId())) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WALK_SPEED,
ImmutableMap.of(
"speed", defaultWalkSpeed.floatValue()));
GriefDefenderPlugin.sendMessage(player, message);
}
}
return;
}
if (walkSpeed > 0) {
if (currentWalkSpeed != ((float) walkSpeed)) {
player.setWalkSpeed((float) walkSpeed);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WALK_SPEED,
@ -519,30 +627,26 @@ private void checkPlayerWalkSpeed(GDPermissionUser user, GDClaim fromClaim, GDCl
}
public void checkPlayerWeather(GDPermissionUser user, GDClaim fromClaim, GDClaim toClaim, boolean force) {
if (!force && fromClaim == toClaim) {
if (user == null) {
return;
}
final Player player = user.getOnlinePlayer();
if (player == null) {
// Most likely Citizens NPC
return;
}
if (!GDOptions.isOptionEnabled(Options.PLAYER_WEATHER)) {
return;
}
final GDPlayerData playerData = user.getInternalPlayerData();
final WeatherType weatherType = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(WeatherType.class), playerData.getSubject(), Options.PLAYER_WEATHER, toClaim);
if (weatherType != null && weatherType != WeatherTypes.UNDEFINED) {
final org.bukkit.WeatherType currentWeather = player.getPlayerWeather();
player.setPlayerWeather(PlayerUtil.WEATHERTYPE_MAP.get(weatherType));
final org.bukkit.WeatherType newWeather = player.getPlayerWeather();
// TODO - improve so it doesn't spam
/*if (currentWeather != newWeather) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
ImmutableMap.of(
"weather", weatherType.getName()));
GriefDefenderPlugin.sendMessage(player, message);
}*/
if (weatherType == null || weatherType == WeatherTypes.UNDEFINED) {
player.resetPlayerWeather();
return;
}
player.setPlayerWeather(PlayerUtil.WEATHERTYPE_MAP.get(weatherType));
}
public void sendInteractEntityDenyMessage(ItemStack playerItem, Entity entity, GDClaim claim, Player player) {
@ -553,7 +657,7 @@ public void sendInteractEntityDenyMessage(ItemStack playerItem, Entity entity, G
final String entityId = entity.getType().getName() == null ? entity.getType().name().toLowerCase() : entity.getType().getName();
if (playerItem == null || playerItem.getType() == Material.AIR) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ENTITY, ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"entity", entityId));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
} else {

View File

@ -44,19 +44,26 @@
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
import com.griefdefender.internal.registry.GDEntityType;
import com.griefdefender.internal.tracking.EntityTracker;
import com.griefdefender.internal.tracking.entity.GDEntity;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.CauseContextHelper;
import com.griefdefender.util.PlayerUtil;
import net.kyori.text.Component;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.Creeper;
@ -64,6 +71,7 @@
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@ -174,6 +182,9 @@ public void onExplosionPrimeEvent(ExplosionPrimeEvent event) {
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
return;
}
if (event.getEntity() instanceof Creeper) {
return;
}
GDCauseStackManager.getInstance().pushCause(event.getEntity());
GDTimings.ENTITY_EXPLOSION_PRE_EVENT.startTiming();
@ -181,8 +192,6 @@ public void onExplosionPrimeEvent(ExplosionPrimeEvent event) {
GDPermissionUser user = null;
if (gdEntity != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
} else {
user = CauseContextHelper.getEventUser(event.getEntity().getLocation());
}
final Location location = event.getEntity().getLocation();
@ -222,8 +231,6 @@ public void onEntityExplodeEvent(EntityExplodeEvent event) {
GDPermissionUser user = null;
if (gdEntity != null) {
user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
} else {
user = CauseContextHelper.getEventUser(event.getEntity().getLocation());
}
Entity source = event.getEntity();
@ -231,21 +238,27 @@ public void onEntityExplodeEvent(EntityExplodeEvent event) {
return;
}
if (user == null && source instanceof TNTPrimed) {
event.setCancelled(true);
return;
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
if (!denySurfaceExplosion) {
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
}
GDTimings.EXPLOSION_EVENT.startTiming();
GDClaim targetClaim = null;
final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
final List<Block> filteredLocations = new ArrayList<>();
for (Block block : event.blockList()) {
final Location location = block.getLocation();
targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location, targetClaim);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, location.getBlock(), user, true);
targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
if (denySurfaceExplosion && block.getWorld().getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) {
filteredLocations.add(block);
GDPermissionManager.getInstance().processEventLog(event, location, targetClaim, Flags.EXPLOSION_BLOCK.getPermission(), source, block, user, "explosion-surface", Tristate.FALSE);
continue;
}
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
if (result == Tristate.FALSE) {
// Avoid lagging server from large explosions.
if (event.blockList().size() > 100) {
if (event.blockList().size() > cancelBlockLimit) {
event.setCancelled(true);
break;
}
@ -304,7 +317,7 @@ public void onEntityDamage(EntityCombustByEntityEvent event) {
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByBlockEvent event) {
if (event.getCause() == DamageCause.SUFFOCATION) {
if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.DROWNING) {
return;
}
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
@ -362,6 +375,18 @@ public void onEntityDamage(EntityDamageByEntityEvent event) {
}
}
}
// Renter interact check
if (event.getEntity() instanceof LivingEntity) {
final GDClaim claim = this.baseStorage.getClaimAt(event.getEntity().getLocation());
if (claim.getEconomyData() != null && claim.getEconomyData().isRented()) {
for (UUID uuid : claim.getEconomyData().getRenters()) {
if (player.getUniqueId().equals(uuid)) {
// renters can interact with living entities
return;
}
}
}
}
}
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
@ -377,7 +402,7 @@ public void onEntityDamage(EntityDamageEvent event) {
// Ignore as this is handled above
return;
}
if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.SUICIDE) {
if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.DROWNING || event.getCause() == DamageCause.SUICIDE) {
return;
}
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
@ -399,15 +424,21 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
return false;
}
final World world = targetEntity.getWorld();
final Location location = targetEntity.getLocation();
final DamageCause damageCause = source instanceof DamageCause ? (DamageCause) source : null;
if (damageCause != null) {
final Object cause = GDCauseStackManager.getInstance().getCurrentCause().root();
if (cause != GriefDefenderPlugin.getInstance()) {
source = cause;
}
}
// Get proper source block
if (source == null && event instanceof EntityCombustByBlockEvent) {
source = NMSUtil.getInstance().getFlameableBlock(targetEntity);
}
final GDClaim claim = this.baseStorage.getClaimAt(targetEntity.getLocation());
final GDPermissionUser targetUser = targetEntity instanceof Player ? PermissionHolderCache.getInstance().getOrCreateUser((Player) targetEntity) : null;
GDPermissionUser user = null;
@ -447,12 +478,21 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
GDCauseStackManager.getInstance().pushCause(user);
}
}
if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ENTITY_DAMAGE.getName(), source, targetEntity.getWorld().getUID())) {
if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ENTITY_DAMAGE.getName(), source, world.getUID())) {
return false;
}
if (source instanceof Creeper || source instanceof TNTPrimed || (damageCause != null && damageCause == DamageCause.ENTITY_EXPLOSION)) {
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, Flags.EXPLOSION_ENTITY, source, targetEntity, user, true);
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionEntitySurfaceBlacklist.contains(sourceId);
if (!denySurfaceExplosion) {
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionEntitySurfaceBlacklist.contains("any");
}
if (denySurfaceExplosion && world.getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) {
GDPermissionManager.getInstance().processEventLog(event, location, claim, Flags.EXPLOSION_ENTITY.getPermission(), source, targetEntity, user, "explosion-surface", Tristate.FALSE);
return true;
}
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.EXPLOSION_ENTITY, source, targetEntity, user, true);
if (result == Tristate.FALSE) {
return true;
}
@ -462,7 +502,7 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
GDPlayerData playerData = null;
if (user != null) {
playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(targetEntity.getWorld(), user.getUniqueId());
playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world, user.getUniqueId());
if (source instanceof DamageCause && ((DamageCause) source) == DamageCause.FALL) {
if (playerData.ignoreFallDamage) {
playerData.ignoreFallDamage = false;
@ -481,20 +521,21 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
}
// Always allow damage against monsters
if (!GriefDefenderPlugin.isEntityProtected(targetEntity)) {
if (!this.isEntityProtected(targetEntity)) {
GDPermissionManager.getInstance().processEventLog(event, location, claim, flag.getPermission(), source, targetEntity, user, TrustTypes.NONE.getName().toLowerCase(), Tristate.TRUE);
return false;
}
final TrustType trustType = TrustTypes.BUILDER;
if (projectileSource != null && projectileSource instanceof Monster) {
// check monster source damage first
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, projectileSource, targetEntity, user, trustType, true);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, projectileSource, targetEntity, user, trustType, true);
if (result != Tristate.UNDEFINED) {
return !result.asBoolean();
}
}
if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, source, targetEntity, user, trustType, true) == Tristate.FALSE) {
if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, source, targetEntity, user, trustType, true) == Tristate.FALSE) {
if (source != null && source instanceof Player) {
final Player player = (Player) source;
CommonEntityEventHandler.getInstance().sendInteractEntityDenyMessage(NMSUtil.getInstance().getActiveItem(player), targetEntity, claim, player);
@ -503,46 +544,55 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
}
// allow trusted users to attack entities within claim
if (!(targetEntity instanceof Player) && user != null && claim.isUserTrusted(user, TrustTypes.ACCESSOR)) {
if (!(targetEntity instanceof Player) && user != null && claim.isUserTrusted(user, TrustTypes.BUILDER)) {
return false;
}
// Protect owned entities anywhere in world
if (targetEntity instanceof Tameable) {
if (targetEntity instanceof Tameable && GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.protectTamedEntities) {
final UUID targetUniqueId = NMSUtil.getInstance().getTameableOwnerUUID(targetEntity);
if (user != null && user.getUniqueId().equals(targetUniqueId)) {
// allow owners to attack entities they own
return false;
}
return false;
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.ENTITY_DAMAGE, source, targetEntity, user, true);
if (result == Tristate.FALSE) {
return true;
}
}
return false;
}
private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser source, GDPermissionUser target) {
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 GameMode sourceGameMode = sourcePlayer.getGameMode();
if (sourceGameMode == GameMode.CREATIVE && !source.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);
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)) {
source.getInternalPlayerData().lastPvpTimestamp = Instant.now();
target.getInternalPlayerData().lastPvpTimestamp = Instant.now();
GDPermissionManager.getInstance().processEventLog(event, targetPlayer.getLocation(), claim, Flags.ENTITY_DAMAGE.getPermission(), source, targetPlayer, source, "pvp-combat", Tristate.TRUE);
return false;
}
// Check target claim
if (!claim.isPvpEnabled()) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_CLAIM_NOT_ALLOWED);
return true;
}
// Check source claim
final GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(source.getInternalPlayerData(), sourcePlayer.getLocation());
if (!sourceClaim.isPvpEnabled()) {
// 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);
return true;
}
@ -551,16 +601,20 @@ private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser
Tristate targetResult = GDPermissionManager.getInstance().getFinalPermission(event, sourcePlayer.getLocation(), claim, Flags.ENTITY_DAMAGE, targetPlayer, sourcePlayer, targetPlayer, 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);
return 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);
return true;
}
// Check options
sourceResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), source, Options.PVP, claim);
targetResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), target, Options.PVP, claim);
if (GDOptions.isOptionEnabled(Options.PVP)) {
sourceResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), source, Options.PVP, claim);
targetResult = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), target, Options.PVP, claim);
}
if (sourceResult == Tristate.UNDEFINED) {
sourceResult = Tristate.fromBoolean(claim.getWorld().getPVP());
}
@ -569,16 +623,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(), claim, Options.PVP.getPermission(), source, targetPlayer, source, "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);
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);
return false;
}
@ -630,25 +687,60 @@ public void handleEntitySpawn(Event event, Object source, Entity entity) {
return;
}
final boolean isEntityProtected = this.isEntityProtected(entity);
GDTimings.ENTITY_SPAWN_EVENT.startTiming();
GDPermissionUser user = null;
final Object root = GDCauseStackManager.getInstance().getCurrentCause().root();
GDPermissionUser user = root instanceof GDPermissionUser ? (GDPermissionUser) root : null;
if (user == null && source instanceof Player) {
GDCauseStackManager.getInstance().pushCause(source);
// Make sure not to pass trusted user for non-protected entities such as monsters
if (isEntityProtected) {
user = root instanceof GDPermissionUser && isEntityProtected ? (GDPermissionUser) root : null;
if (user == null && source instanceof Player) {
GDCauseStackManager.getInstance().pushCause(source);
}
}
Location sourceLocation = null;
if (source == null) {
source = GDCauseStackManager.getInstance().getCurrentCause().root();
source = root;
if (source instanceof GriefDefenderPlugin) {
source = null;
}
}
if (source != null) {
if (source instanceof CreatureSpawner) {
sourceLocation = ((CreatureSpawner) source).getLocation();
user = CauseContextHelper.getEventUser(sourceLocation);
if (isEntityProtected) {
user = CauseContextHelper.getEventUser(sourceLocation);
}
} else if (source instanceof Player) {
user = PermissionHolderCache.getInstance().getOrCreateUser((Player) source);
if (isEntityProtected) {
user = PermissionHolderCache.getInstance().getOrCreateUser((Player) source);
}
} else if (source instanceof Block) {
sourceLocation = ((Block) source).getLocation();
user = CauseContextHelper.getEventUser(sourceLocation);
if (isEntityProtected) {
user = CauseContextHelper.getEventUser(sourceLocation);
}
// check if claim is rented
if (user != null && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) {
final GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(sourceLocation);
if (user.getUniqueId().equals(sourceClaim.getUniqueId()) && sourceClaim.getEconomyData() != null && sourceClaim.getEconomyData().isRented()) {
boolean rentRestore = false;
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
if (sourceClaim.isAdminClaim()) {
rentRestore = GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSchematicRestoreAdmin;
} else {
rentRestore = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), user, Options.RENT_RESTORE, sourceClaim).booleanValue();
}
}
if (rentRestore) {
((Cancellable) event).setCancelled(true);
GDPermissionManager.getInstance().processEventLog(event, sourceLocation, sourceClaim, Flags.ITEM_SPAWN.getPermission(), source, entity, user, "renter-owner-item-spawn", Tristate.FALSE);
GDTimings.ENTITY_SPAWN_EVENT.stopTiming();
return;
}
}
}
}
}
@ -728,4 +820,30 @@ public void onEntityMount(VehicleEnterEvent event) {
GDTimings.ENTITY_MOUNT_EVENT.stopTiming();
}
private boolean isEntityProtected(Entity entity) {
if (entity.getType() == null) {
if (entity instanceof Monster) {
return false;
}
return true;
}
// ignore monsters
final String name = entity.getType().getName() == null ? entity.getType().name().toLowerCase() : entity.getType().getName();
final GDEntityType type = EntityTypeRegistryModule.getInstance().getById(name).orElse(null);
if (type == null) {
return true;
}
final String creatureType = type.getEnumCreatureTypeId();
if (creatureType == null) {
return true;
}
if (creatureType.contains("monster")) {
return false;
}
return true;
}
}

View File

@ -37,9 +37,11 @@
import com.griefdefender.api.claim.ClaimResultType;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.claim.ClaimVisualTypes;
import com.griefdefender.api.claim.ShovelTypes;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.economy.PaymentType;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.api.permission.option.Options;
@ -49,27 +51,31 @@
import com.griefdefender.claim.GDClaim;
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.command.CommandHelper;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.internal.provider.WorldEditProvider;
import com.griefdefender.internal.provider.GDWorldEditProvider;
import com.griefdefender.internal.provider.WorldGuardProvider;
import com.griefdefender.internal.registry.BlockTypeRegistryModule;
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.internal.visual.ClaimVisual;
import com.griefdefender.internal.visual.GDClaimVisual;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.GDPermissions;
import com.griefdefender.permission.flag.GDFlags;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.provider.VaultProvider;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.text.action.GDCallbackHolder;
import com.griefdefender.util.BlockRay;
import com.griefdefender.util.BlockRayHit;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PaginationUtil;
import com.griefdefender.util.PlayerUtil;
import com.griefdefender.util.SignUtil;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
@ -81,6 +87,7 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Bed;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
@ -120,16 +127,21 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
public class PlayerEventHandler implements Listener {
private final BaseStorage dataStore;
private final WorldEditProvider worldEditProvider;
private final GDWorldEditProvider worldEditProvider;
private boolean lastInteractItemCancelled = false;
public PlayerEventHandler(BaseStorage dataStore) {
@ -147,6 +159,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
return;
}
final boolean checkRestore = GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem && GriefDefenderPlugin.getInstance().getWorldEditProvider() != null;
final UUID worldUniqueId = event.getPlayer().getWorld().getUID();
final UUID playerUniqueId = player.getUniqueId();
final GDClaimManager claimWorldManager = this.dataStore.getClaimWorldManager(worldUniqueId);
@ -158,6 +171,26 @@ public void onPlayerLogin(PlayerLoginEvent event) {
subdivision.getData().setDateLastActive(dateNow);
}
((GDClaim) claim).getInternalClaimData().setRequiresSave(true);
((GDClaim) claim).getInternalClaimData().save();
} else if (checkRestore && claim.getEconomyData() != null && claim.getEconomyData().isRented()) {
for (UUID uuid : claim.getEconomyData().getRenters()) {
if (player.getUniqueId().equals(uuid)) {
// check for rent expiration
final PaymentType paymentType = claim.getEconomyData().getPaymentType();
final int rentMax = claim.getEconomyData().getRentMaxTime();
final Instant rentStart = claim.getEconomyData().getRentStartDate();
if (rentStart != null) {
final Instant endDate = rentStart.plus(rentMax, ChronoUnit.DAYS);
final Duration duration = Duration.between(rentStart, endDate);
if (!duration.isNegative() && duration.toDays() <= GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentRestoreDayWarning) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_RENTED_TIME_WARNING, ImmutableMap.of(
"days", duration.toDays()
));
GriefDefenderPlugin.sendMessage(player, message);
}
}
}
}
}
}
GDTimings.PLAYER_LOGIN_EVENT.stopTiming();
@ -204,7 +237,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
if (playerData.getClaims().isEmpty()) {
this.dataStore.clearCachedPlayerData(player.getWorld().getUID(), playerID);
}
GDCallbackHolder.getInstance().onPlayerDisconnect(player);
GDTimings.PLAYER_QUIT_EVENT.stopTiming();
}
@ -225,8 +258,14 @@ public void onPlayerDeath(PlayerDeathEvent event) {
GDCauseStackManager.getInstance().pushCause(player);
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
final Tristate keepInventory = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), playerData.getSubject(), Options.PLAYER_KEEP_INVENTORY, claim);
final Tristate keepLevel = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), playerData.getSubject(), Options.PLAYER_KEEP_LEVEL, claim);
Tristate keepInventory = Tristate.UNDEFINED;
if (GDOptions.isOptionEnabled(Options.PLAYER_KEEP_INVENTORY)) {
keepInventory = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), playerData.getSubject(), Options.PLAYER_KEEP_INVENTORY, claim);
}
Tristate keepLevel = Tristate.UNDEFINED;
if (GDOptions.isOptionEnabled(Options.PLAYER_KEEP_LEVEL)) {
keepLevel = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Tristate.class), playerData.getSubject(), Options.PLAYER_KEEP_LEVEL, claim);
}
if (keepInventory != Tristate.UNDEFINED) {
event.setKeepInventory(keepInventory.asBoolean());
if (keepInventory == Tristate.TRUE) {
@ -379,7 +418,7 @@ private void onInventoryOpen(Event event, Location location, Object target, Huma
if (result == Tristate.FALSE) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INVENTORY_OPEN,
ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"block", targetId));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
((Cancellable) event).setCancelled(true);
@ -413,7 +452,7 @@ public void onPlayerInteractInventoryClick(InventoryClickEvent event) {
if (result == Tristate.FALSE) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ITEM,
ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"item", ItemTypeRegistryModule.getInstance().getNMSKey(target)));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
event.setCancelled(true);
@ -489,7 +528,7 @@ public void onPlayerInteractItem(PlayerInteractEvent event) {
if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, player, itemInHand, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ITEM,
ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"item", ItemTypeRegistryModule.getInstance().getNMSKey(itemInHand)));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
event.setCancelled(true);
@ -561,7 +600,7 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_ITEM_SECONDARY, player, activeItem, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ITEM,
ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"item", ItemTypeRegistryModule.getInstance().getNMSKey(activeItem)));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
event.setCancelled(true);
@ -615,7 +654,7 @@ public void onPlayerBucketEvent(PlayerBucketEvent event) {
final Object source = player;
final Location location = clickedBlock.getLocation();
final GDClaim claim = this.dataStore.getClaimAt(location);
final TrustType trustType = NMSUtil.getInstance().hasBlockTileEntity(location) ? TrustTypes.CONTAINER : TrustTypes.ACCESSOR;
final TrustType trustType = NMSUtil.getInstance().isTileInventory(location) || clickedBlock != null && clickedBlock.getType() == Material.ENDER_CHEST ? TrustTypes.CONTAINER : TrustTypes.ACCESSOR;
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_BLOCK_SECONDARY, source, clickedBlock, player, trustType, true);
if (result == Tristate.FALSE) {
@ -644,6 +683,7 @@ public void onPlayerBucketEvent(PlayerBucketEvent event) {
}
public void onPlayerInteractBlockPrimary(PlayerInteractEvent event, Player player) {
GDCauseStackManager.getInstance().pushCause(player);
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
@ -676,6 +716,28 @@ public void onPlayerInteractBlockPrimary(PlayerInteractEvent event, Player playe
GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.startTiming();
final GDClaim claim = this.dataStore.getClaimAt(location);
final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(location.getWorld().getUID());
if (activeConfig.getConfig().economy.isSellSignEnabled() || activeConfig.getConfig().economy.isRentSignEnabled()) {
final Sign sign = SignUtil.getSign(location);
if (sign != null) {
if (activeConfig.getConfig().economy.isSellSignEnabled() && SignUtil.isSellSign(sign)) {
if (claim.getEconomyData() != null && claim.getEconomyData().isForSale()) {
event.setCancelled(true);
EconomyUtil.getInstance().sellCancelConfirmation(event.getPlayer(), claim, sign);
GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTiming();
return;
}
} else if (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem && activeConfig.getConfig().economy.isRentSignEnabled() && SignUtil.isRentSign(claim, sign)) {
if ((claim.getEconomyData() != null && claim.getEconomyData().isForRent()) || claim.getEconomyData().isRented() ) {
event.setCancelled(true);
EconomyUtil.getInstance().rentCancelConfirmation(event.getPlayer(), claim, sign);
GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTiming();
return;
}
}
}
}
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_BLOCK_PRIMARY, source, clickedBlock.getState(), player, TrustTypes.BUILDER, true);
if (result == Tristate.FALSE) {
if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.BLOCK_BREAK.toString(), clickedBlock.getState(), player.getWorld().getUID())) {
@ -701,6 +763,7 @@ public void onPlayerInteractBlockPrimary(PlayerInteractEvent event, Player playe
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
final Player player = event.getPlayer();
GDCauseStackManager.getInstance().pushCause(player);
final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
onPlayerInteractBlockPrimary(event, player);
@ -708,17 +771,33 @@ public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
}
final Block clickedBlock = event.getClickedBlock();
final Location location = event.getClickedBlock() != null ? event.getClickedBlock().getLocation() : null;
GDClaim claim = null;
if (location != null) {
claim = this.dataStore.getClaimAt(location);
final Sign sign = SignUtil.getSign(location);
// check sign
if (SignUtil.isSellSign(sign)) {
EconomyUtil.getInstance().buyClaimConsumerConfirmation(player, claim, sign);
return;
}
if (SignUtil.isRentSign(claim, sign)) {
EconomyUtil.getInstance().rentClaimConsumerConfirmation(player, claim, sign);
return;
}
}
BlockState state = null;
if (clickedBlock != null) {
state = clickedBlock.getState();
}
final ItemStack itemInHand = event.getItem();
final boolean hasTileEntity = clickedBlock != null ? NMSUtil.getInstance().hasBlockTileEntity(clickedBlock.getLocation()) : false;
if (hasTileEntity && !(state instanceof Sign)) {
final boolean hasInventory = clickedBlock == null ? false : NMSUtil.getInstance().isTileInventory(location) || clickedBlock.getType() == Material.ENDER_CHEST;
if (hasInventory) {
onInventoryOpen(event, state.getLocation(), state, player);
return;
}
GDCauseStackManager.getInstance().pushCause(player);
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUID())) {
return;
}
@ -728,7 +807,6 @@ public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.startTiming();
final Object source = player;
final Location location = event.getClickedBlock() != null ? event.getClickedBlock().getLocation() : null;
if (NMSUtil.getInstance().isMainHandSlot(event.getHand()) && (playerData.claimMode || (itemInHand != null && GriefDefenderPlugin.getInstance().modificationTool != null && NMSUtil.getInstance().itemsEqual(itemInHand, GriefDefenderPlugin.getInstance().modificationTool)))) {
onPlayerHandleClaimCreateAction(event, clickedBlock, player, itemInHand, playerData);
@ -742,11 +820,8 @@ public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
return;
}
final GDClaim claim = this.dataStore.getClaimAt(location);
TrustType trustType = event.isBlockInHand() && event.getAction() != Action.PHYSICAL ? TrustTypes.BUILDER : TrustTypes.ACCESSOR;
if (clickedBlock != null && clickedBlock.getType().toString().contains("DOOR")) {
trustType = TrustTypes.ACCESSOR;
}
final TrustType trustType = NMSUtil.getInstance().isTileInventory(location) || clickedBlock != null && clickedBlock.getType() == Material.ENDER_CHEST ? TrustTypes.CONTAINER : TrustTypes.ACCESSOR;
if (GDFlags.INTERACT_BLOCK_SECONDARY && playerData != null) {
Flag flag = Flags.INTERACT_BLOCK_SECONDARY;
if (event.getAction() == Action.PHYSICAL) {
@ -816,18 +891,20 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
final Location destination = event.getTo();
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
final GDClaim sourceClaim = this.dataStore.getClaimAtPlayer(playerData, player.getLocation());
// 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();
if (combatTimeRemaining > 0) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PVP_IN_COMBAT_NOT_ALLOWED,
ImmutableMap.of(
"time-remaining", combatTimeRemaining));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.ENTITY_TELEPORT_EVENT.stopTiming();
return;
if (playerData.inPvpCombat() && GDOptions.isOptionEnabled(Options.PVP_COMBAT_TELEPORT)) {
// 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();
if (combatTimeRemaining > 0) {
final Component denyMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PVP_IN_COMBAT_NOT_ALLOWED,
ImmutableMap.of(
"time-remaining", combatTimeRemaining));
GriefDefenderPlugin.sendMessage(player, denyMessage);
event.setCancelled(true);
GDTimings.ENTITY_TELEPORT_EVENT.stopTiming();
return;
}
}
}
@ -841,7 +918,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
if (sourceClaim != null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_PORTAL_EXIT,
ImmutableMap.of(
"player", sourceClaim.getOwnerName()));
"player", sourceClaim.getOwnerDisplayName()));
if (GDFlags.ENTITY_TELEPORT_FROM && !teleportFromBlacklisted && GDPermissionManager.getInstance().getFinalPermission(event, sourceLocation, sourceClaim, Flags.ENTITY_TELEPORT_FROM, type, player, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
if (player != null) {
GriefDefenderPlugin.sendMessage(player, message);
@ -872,7 +949,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
if (toClaim != null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_PORTAL_ENTER,
ImmutableMap.of(
"player", toClaim.getOwnerName()));
"player", toClaim.getOwnerDisplayName()));
if (GDFlags.ENTITY_TELEPORT_TO && !teleportToBlacklisted && GDPermissionManager.getInstance().getFinalPermission(event, destination, toClaim, Flags.ENTITY_TELEPORT_TO, type, player, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
if (player != null) {
GriefDefenderPlugin.sendMessage(player, message);
@ -934,7 +1011,7 @@ public void onPlayerMove(PlayerMoveEvent event){
private void onPlayerHandleClaimCreateAction(PlayerInteractEvent event, Block clickedBlock, Player player, ItemStack itemInHand, GDPlayerData playerData) {
if (player.isSneaking() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
playerData.revertActiveVisual(player);
playerData.revertAllVisuals();
// check for any active WECUI visuals
if (this.worldEditProvider != null) {
this.worldEditProvider.revertVisuals(player, playerData, null);
@ -979,9 +1056,9 @@ private void onPlayerHandleClaimCreateAction(PlayerInteractEvent event, Block cl
if (!claim.isUserTrusted(player, TrustTypes.MANAGER)) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_CLAIMED,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
ClaimVisual claimVisual = new ClaimVisual(claim, ClaimVisual.ERROR);
GDClaimVisual claimVisual = new GDClaimVisual(claim, ClaimVisualTypes.ERROR);
claimVisual.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
claimVisual.apply(player);
GDTimings.PLAYER_HANDLE_SHOVEL_ACTION.stopTiming();
@ -1012,9 +1089,9 @@ private void onPlayerHandleClaimCreateAction(PlayerInteractEvent event, Block cl
if (noEditReason != null) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CREATE_OVERLAP_PLAYER,
ImmutableMap.of(
"player", claim.getOwnerName()));
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
ClaimVisual visualization = new ClaimVisual(claim, ClaimVisual.ERROR);
GDClaimVisual visualization = new GDClaimVisual(claim, ClaimVisualTypes.ERROR);
visualization.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
visualization.apply(player);
Set<Claim> claims = new HashSet<>();
@ -1113,14 +1190,11 @@ private void createClaimStart(PlayerInteractEvent event, Player player, Location
if ((type == ClaimTypes.BASIC || type == ClaimTypes.TOWN) && GriefDefenderPlugin.getGlobalConfig().getConfig().economy.economyMode) {
// Check current economy mode cost
final Double economyBlockCost = playerData.getInternalEconomyBlockCost();
if (economyBlockCost == null || economyBlockCost <= 0) {
GriefDefenderPlugin.sendMessage(player, TextComponent.builder().color(TextColor.RED)
.append("Economy mode is enabled but the current cost for blocks is ")
.append("0", TextColor.GOLD)
.append("\nRaise the value for option 'economy-block-cost' in config or via '")
.append("/gd option claim", TextColor.WHITE)
.append("' command.", TextColor.RED)
.build());
if (economyBlockCost == null || economyBlockCost < 0) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_MODE_BLOCK_COST_NOT_SET,
ImmutableMap.of(
"price", economyBlockCost == null ? "not set" : economyBlockCost));
GriefDefenderPlugin.sendMessage(player, message);
return;
}
}
@ -1138,7 +1212,7 @@ private void createClaimStart(PlayerInteractEvent event, Player player, Location
"item", ItemTypeRegistryModule.getInstance().getNMSKey(event.getItem())));
}
GriefDefenderPlugin.sendMessage(player, message);
ClaimVisual visual = ClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
GDClaimVisual visual = GDClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
visual.apply(player, false);
}
@ -1210,11 +1284,14 @@ private void createClaimFinish(PlayerInteractEvent event, Player player, Locatio
"type", gdClaim.getFriendlyNameType(true)));
GriefDefenderPlugin.sendMessage(player, message);
if (this.worldEditProvider != null) {
this.worldEditProvider.stopVisualDrag(player);
this.worldEditProvider.visualizeClaim(gdClaim, player, playerData, false);
this.worldEditProvider.stopDragVisual(player);
this.worldEditProvider.displayClaimCUIVisual(gdClaim, player, playerData, false);
}
gdClaim.getVisualizer().createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
gdClaim.getVisualizer().apply(player, false);
final GDClaimVisual visual = gdClaim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
}
visual.apply(player, false);
}
}
@ -1253,7 +1330,7 @@ private void createSubdivisionStart(PlayerInteractEvent event, Player player, Lo
GriefDefenderPlugin.sendMessage(player, message);
playerData.lastShovelLocation = location;
playerData.claimSubdividing = claim;
ClaimVisual visualization = ClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
GDClaimVisual visualization = GDClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
visualization.apply(player, false);
}
}
@ -1299,11 +1376,14 @@ private void createSubdivisionFinish(PlayerInteractEvent event, Player player, L
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CREATE_SUCCESS, ImmutableMap.of(
"type", gdClaim.getFriendlyNameType(true)));
GriefDefenderPlugin.sendMessage(player, message);
gdClaim.getVisualizer().createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
gdClaim.getVisualizer().apply(player, false);
final GDClaimVisual visual = gdClaim.getVisualizer();
if (visual.getVisualTransactions().isEmpty()) {
visual.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
}
visual.apply(player, false);
if (this.worldEditProvider != null) {
this.worldEditProvider.stopVisualDrag(player);
this.worldEditProvider.visualizeClaim(gdClaim, player, playerData, false);
this.worldEditProvider.stopDragVisual(player);
this.worldEditProvider.displayClaimCUIVisual(gdClaim, player, playerData, false);
}
}
}
@ -1351,14 +1431,14 @@ private void handleResizeStart(PlayerInteractEvent event, Player player, Locatio
playerData.claimResizing = claim;
playerData.lastShovelLocation = location;
if (this.worldEditProvider != null) {
if (this.worldEditProvider != null && (claim.cuboid || !GriefDefenderPlugin.getGlobalConfig().getConfig().visual.hideDrag2d)) {
final int x = playerData.lastShovelLocation.getBlockX() == claim.lesserBoundaryCorner.getX() ? claim.greaterBoundaryCorner.getX() : claim.lesserBoundaryCorner.getX();
final int y = playerData.lastShovelLocation.getBlockY() == claim.lesserBoundaryCorner.getY() ? claim.greaterBoundaryCorner.getY() : claim.lesserBoundaryCorner.getY();
final int z = playerData.lastShovelLocation.getBlockZ() == claim.lesserBoundaryCorner.getZ() ? claim.greaterBoundaryCorner.getZ() : claim.lesserBoundaryCorner.getZ();
this.worldEditProvider.visualizeClaim(claim, new Vector3i(x, y, z), VecHelper.toVector3i(playerData.lastShovelLocation), player, playerData, false);
this.worldEditProvider.displayClaimCUIVisual(claim, new Vector3i(x, y, z), VecHelper.toVector3i(playerData.lastShovelLocation), player, playerData, false);
}
// Show visual block for resize corner click
ClaimVisual visual = ClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
GDClaimVisual visual = GDClaimVisual.fromClick(location, location.getBlockY(), PlayerUtil.getInstance().getVisualTypeFromShovel(playerData.shovelMode), player, playerData);
visual.apply(player, false);
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().RESIZE_START);
}
@ -1461,12 +1541,13 @@ private void handleResizeFinish(PlayerInteractEvent event, Player player, Locati
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.RESIZE_SUCCESS_2D, params));
}
}
playerData.revertActiveVisual(player);
((GDClaim) claim).getVisualizer().resetVisuals();
((GDClaim) claim).getVisualizer().createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
((GDClaim) claim).getVisualizer().apply(player);
playerData.revertClaimVisual((GDClaim) claim);
final GDClaimVisual visual = ((GDClaim) claim).getVisualizer();
visual.resetVisuals();
visual.createClaimBlockVisuals(location.getBlockY(), player.getLocation(), playerData);
visual.apply(player);
if (this.worldEditProvider != null) {
this.worldEditProvider.visualizeClaim(claim, player, playerData, false);
this.worldEditProvider.displayClaimCUIVisual(claim, player, playerData, false);
}
} else {
if (claimResult.getResultType() == ClaimResultType.OVERLAPPING_CLAIM) {
@ -1488,6 +1569,13 @@ private void handleResizeFinish(PlayerInteractEvent event, Player player, Locati
private boolean investigateClaim(PlayerInteractEvent event, Player player, Block clickedBlock, ItemStack itemInHand) {
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (!playerData.queuedVisuals.isEmpty()) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.VISUAL_UPDATE_IN_PROGRESS,
ImmutableMap.of(
"count", playerData.queuedVisuals.size()));
GriefDefenderPlugin.sendMessage(player, message);
return false;
}
if (playerData.claimMode && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
if (player.isSneaking()) {
return true;
@ -1503,8 +1591,17 @@ private boolean investigateClaim(PlayerInteractEvent event, Player player, Block
GDClaim claim = null;
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR) {
final int maxDistance = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.RADIUS_INSPECT);
claim = this.findNearbyClaim(player, maxDistance);
final boolean hidingVisuals = event.getAction() == Action.LEFT_CLICK_AIR && !playerData.claimMode;
claim = this.findNearbyClaim(player, playerData, maxDistance, hidingVisuals);
if (player.isSneaking()) {
if (!playerData.claimMode && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
if (this.worldEditProvider != null) {
worldEditProvider.revertVisuals(player, playerData, null);
}
playerData.revertAllVisuals();
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
return true;
}
if (!playerData.canIgnoreClaim(claim) && !player.hasPermission(GDPermissions.VISUALIZE_CLAIMS_NEARBY)) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().PERMISSION_VISUAL_CLAIMS_NEARBY);
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
@ -1512,15 +1609,24 @@ private boolean investigateClaim(PlayerInteractEvent event, Player player, Block
}
Location nearbyLocation = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation : player.getLocation();
Set<Claim> claims = BlockUtil.getInstance().getNearbyClaims(nearbyLocation, maxDistance);
Set<Claim> claims = BlockUtil.getInstance().getNearbyClaims(nearbyLocation, maxDistance, true);
List<Claim> visualClaims = new ArrayList<>();
for (Claim nearbyClaim : claims) {
if (!((GDClaim) nearbyClaim).hasActiveVisual(player)) {
visualClaims.add(nearbyClaim);
}
}
int height = (int) (playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : PlayerUtil.getInstance().getEyeHeight(player));
boolean hideBorders = this.worldEditProvider != null &&
this.worldEditProvider.hasCUISupport(player) &&
GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().visual.hideBorders;
if (!hideBorders) {
ClaimVisual visualization = ClaimVisual.fromClaims(claims, PlayerUtil.getInstance().getVisualClaimHeight(playerData, height), player.getLocation(), playerData, null);
visualization.apply(player);
for (Claim visualClaim : visualClaims) {
final GDClaimVisual visual = ((GDClaim) visualClaim).getVisualizer();
visual.createClaimBlockVisuals(playerData.getClaimCreateMode() == CreateModeTypes.VOLUME ? height : PlayerUtil.getInstance().getEyeHeight(player), player.getLocation(), playerData);
visual.apply(player);
}
}
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_SHOW_NEARBY,
@ -1528,11 +1634,9 @@ private boolean investigateClaim(PlayerInteractEvent event, Player player, Block
"amount", claims.size()));
GriefDefenderPlugin.sendMessage(player, message);
if (!claims.isEmpty()) {
if (this.worldEditProvider != null) {
worldEditProvider.revertVisuals(player, playerData, null);
worldEditProvider.visualizeClaims(claims, player, playerData, true);
}
if (this.worldEditProvider != null && !visualClaims.isEmpty()) {
worldEditProvider.visualizeClaims(visualClaims, player, playerData, true);
}
CommandHelper.showClaims(player, claims);
}
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
@ -1540,11 +1644,13 @@ private boolean investigateClaim(PlayerInteractEvent event, Player player, Block
}
if (claim != null && claim.isWilderness()) {
playerData.lastValidInspectLocation = null;
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_NOT_CLAIMED));
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
return false;
}
} else {
claim = this.dataStore.getClaimAtPlayer(clickedBlock.getLocation(), playerData, true);
playerData.lastNonAirInspectLocation = clickedBlock.getLocation();
if (claim.isWilderness()) {
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_NOT_CLAIMED));
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
@ -1552,55 +1658,101 @@ private boolean investigateClaim(PlayerInteractEvent event, Player player, Block
}
}
if (claim.getUniqueId() != playerData.visualClaimId) {
int height = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : clickedBlock.getLocation().getBlockY();
claim.getVisualizer().createClaimBlockVisuals(playerData.getClaimCreateMode() == CreateModeTypes.VOLUME ? height : PlayerUtil.getInstance().getEyeHeight(player), player.getLocation(), playerData);
claim.getVisualizer().apply(player);
// Handle left-click visual revert
if (claim != null && !claim.isWilderness() && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
if (!playerData.claimMode || claim.hasActiveVisual(player)) {
final int maxDistance = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.RADIUS_INSPECT);
if (!((GDClaim) claim).children.isEmpty()) {
claim = this.findNearbyClaim(player, playerData, maxDistance, true);
}
if (!claim.hasActiveVisual(player) && claim.parent != null) {
GDClaim parent = claim.parent;
while (parent != null) {
if (parent.hasActiveVisual(player)) {
claim = parent;
parent = null;
} else {
parent = parent.parent;
}
}
}
if (claim != null && claim.hasActiveVisual(player)) {
playerData.revertClaimVisual(claim);
}
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
return true;
}
}
int height = PlayerUtil.getInstance().getEyeHeight(player);
if (playerData.lastValidInspectLocation != null || (clickedBlock != null && clickedBlock.getLocation() != null)) {
height = playerData.lastValidInspectLocation != null ? playerData.lastValidInspectLocation.getBlockY() : clickedBlock.getLocation().getBlockY();
}
if (claim != null) {
// always show visual borders for resize purposes
final GDClaimVisual visual = claim.getVisualizer();
visual.createClaimBlockVisuals(playerData.getClaimCreateMode() == CreateModeTypes.VOLUME ? height : PlayerUtil.getInstance().getEyeHeight(player), player.getLocation(), playerData);
visual.apply(player);
if (this.worldEditProvider != null) {
worldEditProvider.visualizeClaim(claim, player, playerData, true);
worldEditProvider.displayClaimCUIVisual(claim, player, playerData, true);
}
Set<Claim> claims = new HashSet<>();
claims.add(claim);
playerData.showNoClaimsFoundMessage = false;
CommandHelper.showClaims(player, claims);
Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_CLAIMED,
ImmutableMap.of(
"player", claim.getOwnerDisplayName()));
GriefDefenderPlugin.sendMessage(player, message);
}
Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_CLAIMED,
ImmutableMap.of(
"player", claim.getOwnerName()));
GriefDefenderPlugin.sendMessage(player, message);
GDTimings.PLAYER_INVESTIGATE_CLAIM.stopTiming();
return true;
}
private GDClaim findNearbyClaim(Player player, int maxDistance) {
if (maxDistance <= 0) {
private GDClaim findNearbyClaim(Player player, GDPlayerData playerData, int maxDistance, boolean hidingVisuals) {
if (maxDistance <= 20) {
maxDistance = 100;
}
BlockRay blockRay = BlockRay.from(player).distanceLimit(maxDistance).build();
GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
GDClaim playerClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation());
GDClaim firstClaim = null;
GDClaim claim = null;
int count = 0;
playerData.lastNonAirInspectLocation = null;
playerData.lastValidInspectLocation = null;
while (blockRay.hasNext()) {
BlockRayHit blockRayHit = blockRay.next();
Location location = blockRayHit.getLocation();
claim = this.dataStore.getClaimAt(location);
if (claim != null && !claim.isWilderness() && (playerData.visualBlocks.isEmpty() || (claim.getUniqueId() != playerData.visualClaimId))) {
if (firstClaim == null && !claim.isWilderness()) {
if (hidingVisuals) {
if (claim.hasActiveVisual(player)) {
firstClaim = claim;
}
} else {
firstClaim = claim;
}
}
if (playerData.lastNonAirInspectLocation == null && !location.getBlock().isEmpty()) {
playerData.lastNonAirInspectLocation = location;
}
if (claim != null && !claim.isWilderness() && !playerClaim.getUniqueId().equals(claim.getUniqueId())) {
playerData.lastValidInspectLocation = location;
return claim;
}
final Block block = location.getBlock();
if (!block.isEmpty() && !NMSUtil.getInstance().isBlockTransparent(block)) {
break;
}
count++;
}
if (count == maxDistance) {
GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_TOO_FAR);
} else if (claim != null && claim.isWilderness()){
GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.BLOCK_NOT_CLAIMED));
if (claim == null || claim.isWilderness()) {
if (firstClaim == null) {
return GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(player.getWorld().getUID()).getWildernessClaim();
}
return firstClaim;
}
return claim;
@ -1611,12 +1763,12 @@ private void sendInteractBlockDenyMessage(ItemStack playerItem, Block block, GDC
return;
}
if (claim.getData() != null && claim.getData().isExpired() && GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().claim.bankTaxSystem) {
if (claim.getData() != null && claim.getData().isExpired() && GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()).getConfig().economy.taxSystem) {
playerData.sendTaxExpireMessage(player, claim);
} else if (playerItem == null || playerItem.getType() == Material.AIR) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_BLOCK,
ImmutableMap.of(
"player", claim.getOwnerName(),
"player", claim.getOwnerDisplayName(),
"block", BlockTypeRegistryModule.getInstance().getNMSKey(block)));
GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
} else {

View File

@ -64,7 +64,6 @@ public void onWorldSave(WorldSaveEvent event) {
}
claimWorldManager.save();
claimWorldManager.playerIndexStorage.savePlayerDatData();
GDTimings.WORLD_SAVE_EVENT.stopTiming();
}

View File

@ -37,12 +37,12 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.configuration.ClaimDataConfig;
import com.griefdefender.configuration.ClaimStorageData;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.flag.FlagContexts;
import com.griefdefender.permission.option.OptionContexts;
import com.griefdefender.storage.BaseStorage;
import com.griefdefender.util.BlockUtil;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
@ -342,7 +342,7 @@ private static void migrateGpFlags(World world) {
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.EXPLOSION_ENTITY.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_FALL_DAMAGE :
contexts.add(new Context(ContextKeys.SOURCE, "fall"));
contexts.add(FlagContexts.SOURCE_FALL);
contexts.add(FlagContexts.TARGET_PLAYER);
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_DAMAGE.getPermission(), Tristate.FALSE, contexts);
break;
@ -352,7 +352,7 @@ private static void migrateGpFlags(World world) {
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_DAMAGE.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_FIRE_SPREAD :
contexts.add(new Context(ContextKeys.SOURCE, "fire"));
contexts.add(FlagContexts.SOURCE_FIRE);
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.BLOCK_SPREAD.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_FLIGHT :
@ -384,15 +384,15 @@ private static void migrateGpFlags(World world) {
break;
case FLAG_NO_MOB_DAMAGE :
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(new Context(ContextKeys.TARGET, "#monster"));
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_DAMAGE.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_MOB_SPAWNS :
contexts.add(new Context(ContextKeys.TARGET, "#monster"));
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_SPAWN.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_PLAYER_DAMAGE :
contexts.add(new Context(ContextKeys.TARGET, "player"));
contexts.add(FlagContexts.TARGET_PLAYER);
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_DAMAGE.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_SNOW_FORM :

View File

@ -39,10 +39,10 @@
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.configuration.ClaimDataConfig;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.flag.FlagContexts;
import com.griefdefender.util.BlockUtil;
import net.kyori.text.TextComponent;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;

View File

@ -30,6 +30,7 @@ public class ContextGroupKeys {
public static final String AMBIENT = "#ambient";
public static final String ANIMAL = "#animal";
public static final String AQUATIC = "#aquatic";
public static final String CROPS = "#crops";
public static final String FOOD = "#food";
public static final String MISC = "#misc";
public static final String MONSTER = "#monster";

View File

@ -34,6 +34,7 @@ public class ContextGroups {
public static final Context SOURCE_AMBIENT = new Context(ContextKeys.SOURCE, ContextGroupKeys.AMBIENT);
public static final Context SOURCE_ANIMAL = new Context(ContextKeys.SOURCE, ContextGroupKeys.ANIMAL);
public static final Context SOURCE_AQUATIC = new Context(ContextKeys.SOURCE, ContextGroupKeys.AQUATIC);
public static final Context SOURCE_CROPS = new Context(ContextKeys.SOURCE, ContextGroupKeys.CROPS);
public static final Context SOURCE_MISC = new Context(ContextKeys.SOURCE, ContextGroupKeys.MISC);
public static final Context SOURCE_MONSTER = new Context(ContextKeys.SOURCE, ContextGroupKeys.MONSTER);
public static final Context SOURCE_VEHICLE = new Context(ContextKeys.SOURCE, ContextGroupKeys.VEHICLE);
@ -41,6 +42,7 @@ public class ContextGroups {
public static final Context TARGET_AMBIENT = new Context(ContextKeys.TARGET, ContextGroupKeys.AMBIENT);
public static final Context TARGET_ANIMAL = new Context(ContextKeys.TARGET, ContextGroupKeys.ANIMAL);
public static final Context TARGET_AQUATIC = new Context(ContextKeys.TARGET, ContextGroupKeys.AQUATIC);
public static final Context TARGET_CROPS = new Context(ContextKeys.TARGET, ContextGroupKeys.CROPS);
public static final Context TARGET_MISC = new Context(ContextKeys.TARGET, ContextGroupKeys.MISC);
public static final Context TARGET_MONSTER = new Context(ContextKeys.TARGET, ContextGroupKeys.MONSTER);
public static final Context TARGET_VEHICLE = new Context(ContextKeys.TARGET, ContextGroupKeys.VEHICLE);

View File

@ -57,6 +57,7 @@
import com.griefdefender.cache.MessageCache;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.command.CommandHelper;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.category.BanCategory;
@ -66,8 +67,11 @@
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
import com.griefdefender.internal.registry.GDEntityType;
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.internal.tracking.chunk.GDChunk;
import com.griefdefender.internal.util.NMSUtil;
import com.griefdefender.permission.option.GDOptions;
import com.griefdefender.registry.FlagRegistryModule;
import com.griefdefender.util.EconomyUtil;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.Component;
@ -87,6 +91,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Event;
@ -178,6 +183,8 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
final GDPermissionUser user = permissionHolder instanceof GDPermissionUser ? (GDPermissionUser) permissionHolder : null;
this.eventSubject = user;
this.eventMessage = null;
this.eventSourceId = "none";
this.eventTargetId = "none";
if (permissionHolder != null) {
if (user != null) {
playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(claim.getWorldUniqueId(), user.getUniqueId());
@ -189,10 +196,8 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
// refresh contexts
this.eventContexts = new HashSet<>();
if (user != null) {
if (user.getOnlinePlayer() != null) {
this.addPlayerContexts(user.getOnlinePlayer(), contexts);
}
if (source instanceof Player && flag != Flags.COLLIDE_BLOCK && flag != Flags.COLLIDE_ENTITY) {
this.addPlayerContexts((Player) source, contexts);
}
final Set<Context> sourceContexts = this.getPermissionContexts((GDClaim) claim, source, true);
@ -211,13 +216,13 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
this.eventPlayerData = playerData;
final String targetPermission = flag.getPermission();
if (flag == Flags.ENTITY_SPAWN) {
if (flag == Flags.ENTITY_SPAWN && GDOptions.isOptionEnabled(Options.SPAWN_LIMIT)) {
// Check spawn limit
final int spawnLimit = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), GriefDefenderPlugin.DEFAULT_HOLDER, Options.SPAWN_LIMIT, claim, new HashSet<>(contexts));
if (spawnLimit > -1) {
if (target instanceof Entity) {
final Entity entity = (Entity) target;
final int currentEntityCount = ((GDClaim) claim).countEntities(entity .getType());
final int currentEntityCount = ((GDClaim) claim).countEntities(entity.getType());
if (currentEntityCount >= spawnLimit) {
if (user != null && user.getOnlinePlayer() != null && source == SpawnReason.ENDER_PEARL || source == SpawnReason.SPAWNER_EGG || source == SpawnReason.SPAWNER) {
final String name = entity.getType().getName() == null ? entity.getType().name().toLowerCase() : entity.getType().getName();
@ -242,7 +247,7 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
// First check for claim flag overrides
override = getFlagOverride(claim, permissionHolder == null ? GriefDefenderPlugin.DEFAULT_HOLDER : permissionHolder, playerData, targetPermission);
if (override != Tristate.UNDEFINED) {
return override;
return processResult(claim, targetPermission, type == null ? "none" : type.getName().toLowerCase(), override, user);
}
}
@ -259,6 +264,42 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
}
}
if (user != null) {
// check if rented
if (claim.getEconomyData() != null && claim.getEconomyData().isRented() &&
flag != Flags.COMMAND_EXECUTE &&
flag != Flags.COMMAND_EXECUTE_PVP &&
flag != Flags.ENTER_CLAIM &&
flag != Flags.EXIT_CLAIM &&
flag != Flags.ENTITY_TELEPORT_FROM &&
flag != Flags.ENTITY_TELEPORT_TO &&
flag != Flags.INTERACT_INVENTORY_CLICK) {
if (claim.getOwnerUniqueId() != null && user != null && claim.getOwnerUniqueId().equals(user.getUniqueId())) {
return processResult(claim, targetPermission, "rent-owner-deny", Tristate.FALSE, user);
}
if (EconomyUtil.getInstance().isRenter(claim, user) && (targetPermission.contains("interact") || targetPermission.contains("block"))) {
if ((targetPermission.contains("interact") || targetPermission.contains("block-place"))) {
final boolean hasInventory = NMSUtil.getInstance().isTileInventory(location) || location.getBlock().getType() == Material.ENDER_CHEST;
if (!hasInventory || flag == Flags.BLOCK_PLACE) {
return processResult(claim, targetPermission, "renter-interact", Tristate.TRUE, user);
}
// check entity interactions
if (targetPermission.contains("interact-entity") && target instanceof LivingEntity) {
// Allow interaction with all living entities
return processResult(claim, targetPermission, "renter-interact", Tristate.TRUE, user);
}
}
// Allow renters to break/change their own blocks
final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID());
final GDChunk gdChunk = claimWorldManager.getChunk(location.getBlock().getChunk());
final GDPermissionUser owner = gdChunk.getBlockOwner(location);
if (owner != null && owner.getUniqueId().equals(user.getUniqueId())) {
// allow
return processResult(claim, targetPermission, "renter-owned", Tristate.TRUE, user);
}
}
}
if (type != null) {
if (((GDClaim) claim).isUserTrusted(user, type)) {
return processResult(claim, targetPermission, type.getName().toLowerCase(), Tristate.TRUE, permissionHolder);
@ -304,16 +345,18 @@ private Tristate getUserPermission(GDPermissionHolder holder, Claim claim, Strin
return getFlagDefaultPermission(claim, permission, contexts);
}
return getClaimFlagPermission(claim, permission, contexts);
return getClaimFlagPermission(claim, permission, contexts, inheritParents);
}
private Tristate getClaimFlagPermission(Claim claim, String permission) {
return this.getClaimFlagPermission(claim, permission, new HashSet<>());
return this.getClaimFlagPermission(claim, permission, new HashSet<>(), null);
}
private Tristate getClaimFlagPermission(Claim claim, String permission, Set<Context> contexts) {
private Tristate getClaimFlagPermission(Claim claim, String permission, Set<Context> contexts, List<Claim> inheritParents) {
if (contexts.isEmpty()) {
final List<Claim> inheritParents = claim.getInheritedParents();
if (inheritParents == null) {
inheritParents = claim.getInheritedParents();
}
contexts.addAll(this.eventContexts);
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
@ -346,6 +389,9 @@ private Tristate getFlagDefaultPermission(Claim claim, String permission, Set<Co
}
contexts.remove(claim.getDefaultTypeContext());
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
if (!claim.isWilderness() && !claim.isAdminClaim()) {
contexts.add(ClaimContexts.USER_DEFAULT_CONTEXT);
}
value = PermissionUtil.getInstance().getPermissionValue((GDClaim) claim, GriefDefenderPlugin.DEFAULT_HOLDER, permission, contexts);
if (value != Tristate.UNDEFINED) {
return processResult(claim, permission, value, GriefDefenderPlugin.DEFAULT_HOLDER);
@ -363,37 +409,58 @@ private Tristate getFlagOverride(Claim claim, GDPermissionHolder permissionHolde
Set<Context> contexts = new HashSet<>();
if (claim.isAdminClaim()) {
contexts.add(ClaimContexts.ADMIN_OVERRIDE_CONTEXT);
//contexts.add(claim.world.getContext());
} else if (claim.isTown()) {
contexts.add(ClaimContexts.TOWN_OVERRIDE_CONTEXT);
//contexts.add(claim.world.getContext());
} else if (claim.isBasicClaim()) {
contexts.add(ClaimContexts.BASIC_OVERRIDE_CONTEXT);
//contexts.add(claim.world.getContext());
} else if (claim.isWilderness()) {
contexts.add(ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT);
player = permissionHolder instanceof GDPermissionUser ? ((GDPermissionUser) permissionHolder).getOnlinePlayer() : null;
}
if (!claim.isWilderness() && !claim.isAdminClaim()) {
contexts.add(ClaimContexts.USER_OVERRIDE_CONTEXT);
}
contexts.add(((GDClaim) claim).getWorldContext());
contexts.add(claim.getOverrideClaimContext());
contexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
contexts.addAll(this.eventContexts);
Tristate value = PermissionUtil.getInstance().getPermissionValue((GDClaim) claim, permissionHolder, flagPermission, contexts);
/* if (value == Tristate.UNDEFINED) {
// Check claim specific override
contexts = PermissionUtils.getActiveContexts(subject, playerData, claim);
contexts.add(claim.getContext());
contexts.add(ClaimContexts.CLAIM_OVERRIDE_CONTEXT);
value = subject.getPermissionValue(contexts, flagPermission);
}*/
if (value == Tristate.UNDEFINED) {
// check claim owner parent override
/*final List<Claim> inheritParents = claim.getInheritedParents();
contexts = new HashSet<>();
contexts.add(((GDClaim) claim).getWorldContext());
contexts.addAll(this.eventContexts);
for (Claim parentClaim : inheritParents) {
GDClaim parent = (GDClaim) parentClaim;
// check parent override claim context
contexts.add(parent.getOverrideClaimContext());
value = PermissionUtil.getInstance().getPermissionValue((GDClaim) claim, permissionHolder, flagPermission, contexts);
if (value != Tristate.UNDEFINED) {
if (value == Tristate.FALSE) {
this.eventMessage = MessageCache.getInstance().PERMISSION_OVERRIDE_DENY;
}
return processResult(claim, flagPermission, value, permissionHolder);
}
contexts.remove(parent.getOverrideClaimContext());
}*/
// check claim owner override
contexts = new HashSet<>();
contexts.add(((GDClaim) claim).getWorldContext());
contexts.addAll(this.eventContexts);
contexts.add(claim.getOverrideClaimContext());
value = PermissionUtil.getInstance().getPermissionValue((GDClaim) claim, permissionHolder, flagPermission, contexts);
}
if (value != Tristate.UNDEFINED) {
if (value == Tristate.FALSE) {
this.eventMessage = MessageCache.getInstance().PERMISSION_OVERRIDE_DENY;
}
return processResult(claim, flagPermission, value, permissionHolder);
}
if (permissionHolder != GriefDefenderPlugin.DEFAULT_HOLDER) {
return getFlagOverride(claim, GriefDefenderPlugin.DEFAULT_HOLDER, playerData, flagPermission);
}
@ -439,6 +506,37 @@ public Tristate processResult(Claim claim, String permission, String trust, Tris
return permissionValue;
}
public void processEventLog(Event event, Location location, Claim claim, String permission, Object source, Object target, GDPermissionHolder user, String trust, Tristate value) {
final String sourceId = this.getPermissionIdentifier(source, true);
final String targetId = this.getPermissionIdentifier(target);
final Set<Context> sourceContexts = this.getPermissionContexts((GDClaim) claim, source, true);
if (sourceContexts == null) {
return;
}
final Set<Context> targetContexts = this.getPermissionContexts((GDClaim) claim, target, false);
if (targetContexts == null) {
return;
}
final Set<Context> contexts = new HashSet<>();
contexts.addAll(sourceContexts);
contexts.addAll(targetContexts);
contexts.add(((GDClaim) claim).getWorldContext());
if (GriefDefenderPlugin.debugActive) {
if (user == null) {
final Object root = GDCauseStackManager.getInstance().getCurrentCause().root();
if (source instanceof GDPermissionUser) {
user = (GDPermissionUser) root;
} else {
user = GriefDefenderPlugin.DEFAULT_HOLDER;
}
}
GriefDefenderPlugin.addEventLogEntry(event, claim, location, sourceId, targetId, user, permission, trust.toLowerCase(), value, contexts);
}
}
public String getPermissionIdentifier(Object obj) {
return getPermissionIdentifier(obj, false);
}
@ -447,21 +545,23 @@ public String getPermissionIdentifier(Object obj, boolean isSource) {
if (obj != null) {
if (obj instanceof Entity) {
Entity targetEntity = (Entity) obj;
if (targetEntity instanceof Item) {
return getPermissionIdentifier(((Item) targetEntity).getItemStack(), isSource);
}
if (targetEntity.getType() == null) {
// Plugin sending fake player and violating API contract so just ignore...
return "unknown";
}
final String name = targetEntity.getType().getName() == null ? targetEntity.getType().name().toLowerCase() : targetEntity.getType().getName();
final GDEntityType type = EntityTypeRegistryModule.getInstance().getById(name).orElse(null);
if (type == null) {
// Should never happen
return "unknown";
return name;
}
String id = type.getId();
if (!(targetEntity instanceof Player) && type.getEnumCreatureTypeId() != null) {
id = type.getEnumCreatureTypeId() + "." + type.getName();
}
if (targetEntity instanceof Item) {
id = ((Item) targetEntity).getItemStack().getType().name().toLowerCase();
}
return populateEventSourceTarget(id, isSource);
} else if (obj instanceof Block) {
@ -513,84 +613,91 @@ public String getPermissionIdentifier(Object obj, boolean isSource) {
public Set<Context> getPermissionContexts(GDClaim claim, Object obj, boolean isSource) {
final Set<Context> contexts = new HashSet<>();
if (obj != null) {
if (obj instanceof Entity) {
Entity targetEntity = (Entity) obj;
if (targetEntity instanceof Item) {
return getPermissionContexts(claim, ((Item) targetEntity).getItemStack(), isSource);
}
if (targetEntity.getType() == null) {
// Plugin sending fake player and violating API contract so just ignore...
return contexts;
}
final String name = targetEntity.getType().getName() == null ? targetEntity.getType().name().toLowerCase() : targetEntity.getType().getName();
final GDEntityType type = EntityTypeRegistryModule.getInstance().getById(name).orElse(null);
if (type == null) {
// Should never happen
return contexts;
}
String id = type.getId();
if (!(targetEntity instanceof Player)) {
addCustomEntityTypeContexts(targetEntity, id, contexts, type, isSource);
}
if (this.isObjectIdBanned(claim, id, BanType.ENTITY)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof Block) {
final Block block = (Block) obj;
final String id = BlockTypeRegistryModule.getInstance().getNMSKey(block);
this.addBlockPropertyContexts(contexts, block);
if (this.isObjectIdBanned(claim, id, BanType.BLOCK)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof BlockState) {
final BlockState blockstate = (BlockState) obj;
final String id = BlockTypeRegistryModule.getInstance().getNMSKey(blockstate);
this.addBlockPropertyContexts(contexts, blockstate.getBlock());
if (this.isObjectIdBanned(claim, id, BanType.BLOCK)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof Inventory) {
final String id = ((Inventory) obj).getType().name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof InventoryType) {
final String id = ((InventoryType) obj).name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof ItemStack) {
final ItemStack itemstack = (ItemStack) obj;
if (NMSUtil.getInstance().isItemFood(itemstack)) {
if (isSource) {
contexts.add(ContextGroups.SOURCE_FOOD);
} else {
contexts.add(ContextGroups.TARGET_FOOD);
}
}
String id = ItemTypeRegistryModule.getInstance().getNMSKey(itemstack);
if (this.isObjectIdBanned(claim, id, BanType.ITEM)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof DamageCause) {
final DamageCause damageCause = (DamageCause) obj;
String id = damageCause.name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof SpawnReason) {
return populateEventSourceTargetContext(contexts, "spawnreason:" + ((SpawnReason) obj).name().toLowerCase(), isSource);
} else if (obj instanceof CreatureSpawner) {
final CreatureSpawner spawner = (CreatureSpawner) obj;
return this.getPermissionContexts(claim, spawner.getBlock(), isSource);
} else if (obj instanceof String) {
final String id = obj.toString().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
if (obj == null) {
if (isSource) {
contexts.add(ContextGroups.SOURCE_ALL);
} else {
contexts.add(ContextGroups.TARGET_ALL);
}
return contexts;
}
if (obj instanceof Entity) {
Entity targetEntity = (Entity) obj;
if (targetEntity instanceof Item) {
return getPermissionContexts(claim, ((Item) targetEntity).getItemStack(), isSource);
}
if (targetEntity.getType() == null) {
// Plugin sending fake player and violating API contract so just ignore...
return contexts;
}
final String name = targetEntity.getType().getName() == null ? targetEntity.getType().name().toLowerCase() : targetEntity.getType().getName();
final GDEntityType type = EntityTypeRegistryModule.getInstance().getById(name).orElse(null);
if (type == null) {
// Should never happen
return contexts;
}
String id = type.getId();
if (!(targetEntity instanceof Player)) {
addCustomEntityTypeContexts(targetEntity, id, contexts, type, isSource);
}
if (this.isObjectIdBanned(claim, id, BanType.ENTITY)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof Block) {
final Block block = (Block) obj;
final String id = BlockTypeRegistryModule.getInstance().getNMSKey(block);
this.addBlockContexts(contexts, block, isSource);
if (this.isObjectIdBanned(claim, id, BanType.BLOCK)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof BlockState) {
final BlockState blockstate = (BlockState) obj;
final String id = BlockTypeRegistryModule.getInstance().getNMSKey(blockstate);
this.addBlockContexts(contexts, blockstate.getBlock(), isSource);
if (this.isObjectIdBanned(claim, id, BanType.BLOCK)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof Inventory) {
final String id = ((Inventory) obj).getType().name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof InventoryType) {
final String id = ((InventoryType) obj).name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof ItemStack) {
final ItemStack itemstack = (ItemStack) obj;
if (NMSUtil.getInstance().isItemFood(itemstack)) {
if (isSource) {
contexts.add(ContextGroups.SOURCE_FOOD);
} else {
contexts.add(ContextGroups.TARGET_FOOD);
}
}
String id = ItemTypeRegistryModule.getInstance().getNMSKey(itemstack);
if (this.isObjectIdBanned(claim, id, BanType.ITEM)) {
return null;
}
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof DamageCause) {
final DamageCause damageCause = (DamageCause) obj;
String id = damageCause.name().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
} else if (obj instanceof SpawnReason) {
return populateEventSourceTargetContext(contexts, "spawnreason:" + ((SpawnReason) obj).name().toLowerCase(), isSource);
} else if (obj instanceof CreatureSpawner) {
final CreatureSpawner spawner = (CreatureSpawner) obj;
return this.getPermissionContexts(claim, spawner.getBlock(), isSource);
} else if (obj instanceof String) {
final String id = obj.toString().toLowerCase();
return populateEventSourceTargetContext(contexts, id, isSource);
}
return contexts;
@ -684,7 +791,6 @@ public void addCustomEntityTypeContexts(Entity targetEntity, String id, Set<Cont
return;
}
//contexts.add(new Context(contextKey, "#" + creatureType));
if (creatureType.contains("animal")) {
if (isSource) {
contexts.add(ContextGroups.SOURCE_ANIMAL);
@ -771,69 +877,25 @@ private void addPlayerContexts(Player player, Set<Context> contexts) {
}
}
private Set<Context> addBlockPropertyContexts(Set<Context> contexts, Block block) {
private Set<Context> addBlockContexts(Set<Context> contexts, Block block, boolean isSource) {
Matcher matcher = BLOCKSTATE_PATTERN.matcher(NMSUtil.getInstance().getBlockDataString((Block) block));
if (matcher.find()) {
final String properties[] = matcher.group(0).split(",");
for (String property : properties) {
contexts.add(new Context("state", property.replace("=", ":")));
contexts.add(new Context(ContextKeys.STATE, property.replace("=", ":")));
}
}
if (NMSUtil.getInstance().isBlockCrops(block)) {
if (isSource) {
contexts.add(ContextGroups.SOURCE_CROPS);
} else {
contexts.add(ContextGroups.TARGET_CROPS);
}
}
return contexts;
}
public String getSourcePermission(String flagPermission) {
final int index = flagPermission.indexOf(".source.");
if (index != -1) {
return flagPermission.substring(index + 8);
}
return null;
}
public String getTargetPermission(String flagPermission) {
flagPermission = StringUtils.replace(flagPermission, "griefdefender.flag.", "");
boolean found = false;
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (flagPermission.contains(flag.toString() + ".")) {
found = true;
}
flagPermission = StringUtils.replace(flagPermission, flag.toString() + ".", "");
}
if (!found) {
return null;
}
final int sourceIndex = flagPermission.indexOf(".source.");
if (sourceIndex != -1) {
flagPermission = StringUtils.replace(flagPermission, flagPermission.substring(sourceIndex, flagPermission.length()), "");
}
return flagPermission;
}
// Used for debugging
public String getPermission(Object source, Object target, String flagPermission) {
String sourceId = getPermissionIdentifier(source, true);
String targetPermission = flagPermission;
String targetId = getPermissionIdentifier(target);
if (!targetId.isEmpty()) {
if (!sourceId.isEmpty()) {
// move target meta to end of permission
Matcher m = PATTERN_META.matcher(targetId);
String targetMeta = "";
if (m.find()) {
targetMeta = m.group(0);
targetId = StringUtils.replace(targetId, targetMeta, "");
}
targetPermission += "." + targetId + ".source." + sourceId + targetMeta;
} else {
targetPermission += "." + targetId;
}
}
targetPermission = StringUtils.replace(targetPermission, ":", ".");
return targetPermission;
}
public String getIdentifierWithoutMeta(String targetId) {
Matcher m = PATTERN_META.matcher(targetId);
String targetMeta = "";
@ -859,6 +921,34 @@ private Set<Context> populateEventSourceTargetContext(Set<Context> contexts, Str
contexts.add(new Context("target", this.eventTargetId));
contexts.add(new Context("target", modId + ":any"));
}
return this.populateTagContextsForId(contexts, modId, isSource);
}
public Set<Context> populateTagContextsForId(Set<Context> contexts, String id, boolean isSource) {
if (GriefDefenderPlugin.getInstance().getTagProvider() == null) {
return contexts;
}
final Set<Context> tagContexts = GriefDefenderPlugin.getInstance().getTagProvider().getTagMap().get(id);
if (tagContexts == null) {
return contexts;
}
for (Context context : tagContexts) {
if (isSource) {
contexts.add(new Context(ContextKeys.SOURCE, "#" + context.getKey() + ":" + context.getValue()));
if (context.getKey().equalsIgnoreCase("minecraft")) {
contexts.add(new Context(ContextKeys.SOURCE, "#" + context.getValue()));
}
} else {
contexts.add(new Context(ContextKeys.TARGET, "#" + context.getKey() + ":" + context.getValue()));
if (context.getKey().equalsIgnoreCase("minecraft")) {
contexts.add(new Context(ContextKeys.TARGET, "#" + context.getValue()));
}
}
}
return contexts;
}
@ -982,8 +1072,8 @@ public CompletableFuture<PermissionResult> setPermission(Claim claim, GDPermissi
return result;
}
final Player player = GDCauseStackManager.getInstance().getCurrentCause().first(Player.class).orElse(null);
CommandSender commandSource = player != null ? player : Bukkit.getConsoleSender();
final GDPermissionUser user = GDCauseStackManager.getInstance().getCurrentCause().first(GDPermissionUser.class).orElse(null);
CommandSender commandSource = user != null && user.getOnlinePlayer() != null ? user.getOnlinePlayer() : Bukkit.getConsoleSender();
result.complete(CommandHelper.addFlagPermission(commandSource, subject, claim, flag, target, value, contexts));
return result;
}
@ -1074,49 +1164,89 @@ public <T> T getInternalOptionValue(TypeToken<T> type, GDPermissionHolder holder
PermissionUtil.getInstance().addActiveContexts(contexts, holder, playerData, claim);
}
Set<Context> optionContexts = new HashSet<>(contexts);
if (!option.isGlobal() && (claim != null || claimType != null)) {
// check claim
if (claim != null) {
contexts.add(claim.getContext());
final T value = this.getOptionActualValue(type, holder, option, contexts);
// check override
if (claim.isAdminClaim()) {
optionContexts.add(ClaimContexts.ADMIN_OVERRIDE_CONTEXT);
} else if (claim.isTown()) {
optionContexts.add(ClaimContexts.TOWN_OVERRIDE_CONTEXT);
} else if (claim.isBasicClaim()) {
optionContexts.add(ClaimContexts.BASIC_OVERRIDE_CONTEXT);
} else if (claim.isWilderness()) {
optionContexts.add(ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT);
}
if (!claim.isWilderness() && !claim.isAdminClaim()) {
optionContexts.add(ClaimContexts.USER_OVERRIDE_CONTEXT);
}
optionContexts.add(((GDClaim) claim).getWorldContext());
optionContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
T value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
// check claim owner override
optionContexts = new HashSet<>(contexts);
optionContexts.add(((GDClaim) claim).getWorldContext());
optionContexts.add(claim.getOverrideClaimContext());
value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
optionContexts = new HashSet<>(contexts);
optionContexts.add(claim.getContext());
value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
contexts.remove(claim.getContext());
}
// check claim type
if (claimType != null) {
contexts.add(claimType.getContext());
final T value = this.getOptionActualValue(type, holder, option, contexts);
optionContexts = new HashSet<>(contexts);
optionContexts.add(claimType.getContext());
final T value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
contexts.remove(claimType.getContext());
}
}
optionContexts = new HashSet<>(contexts);
// Check only active contexts
T value = this.getOptionActualValue(type, holder, option, contexts);
T value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
// Check type/global default context
if (claimType != null) {
contexts.add(claimType.getDefaultContext());
if (claim != null) {
optionContexts.add(claim.getDefaultTypeContext());
value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
optionContexts.remove(claim.getDefaultTypeContext());
}
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
value = this.getOptionActualValue(type, holder, option, contexts);
optionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
if (claim != null) {
if (!claim.isWilderness() && !claim.isAdminClaim()) {
optionContexts.add(ClaimContexts.USER_DEFAULT_CONTEXT);
}
}
value = this.getOptionActualValue(type, holder, option, optionContexts);
if (value != null) {
return value;
}
contexts.remove(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
if (claimType != null) {
contexts.remove(claimType.getDefaultContext());
}
// Check global
// Check default holder
if (holder != GriefDefenderPlugin.DEFAULT_HOLDER) {
return getInternalOptionValue(type, GriefDefenderPlugin.DEFAULT_HOLDER, option, claim, claimType, contexts);
}

View File

@ -51,6 +51,7 @@ public class GDPermissions {
public static final String COMMAND_CLAIM_INFO_TELEPORT_BASE = "griefdefender.user.claim.command.info.teleport.base";
public static final String COMMAND_CLAIM_MODE = "griefdefender.user.claim.command.claim-mode";
public static final String COMMAND_CLAIM_OPTIONS_BASE = "griefdefender.user.claim.option.base";
public static final String COMMAND_CLAIM_RENT = "griefdefender.user.claim.command.rent";
public static final String COMMAND_CLAIM_SELL = "griefdefender.user.claim.command.sell";
public static final String COMMAND_CLAIM_SPAWN = "griefdefender.user.claim.command.spawn";
public static final String COMMAND_CLAIM_SET_SPAWN = "griefdefender.user.claim.command.set-spawn";
@ -116,6 +117,11 @@ public class GDPermissions {
public static final String USER_OPTION_PERK_OWNER_FLY_TOWN = "griefdefender.user.option.perk.owner-fly.town";
public static final String OPTION_BASE = "griefdefender";
// Economy
public static final String USER_RENT_BASE = "griefdefender.user.claim.rent.base";
public static final String USER_RENT_SIGN = "griefdefender.user.claim.rent.sign";
public static final String USER_SELL_SIGN = "griefdefender.user.claim.sell.sign";
// Admin
public static final String ADVANCED_FLAGS = "griefdefender.admin.advanced-flags";
public static final String BYPASS_BAN = "griefdefender.admin.bypass.ban";
@ -123,6 +129,7 @@ public class GDPermissions {
public static final String BYPASS_CLAIM_RESIZE = "griefdefender.admin.bypass.override.resize";
public static final String BYPASS_CLAIM_LIMIT = "griefdefender.admin.bypass.override.limit";
public static final String BYPASS_OPTION = "griefdefender.admin.bypass.option";
public static final String BYPASS_PVP_CREATIVE = "griefdefender.admin.bypass.pvp-creative";
public static final String CLAIM_CUBOID_ADMIN = "griefdefender.admin.claim.cuboid";
public static final String CLAIM_RESIZE_ALL = "griefdefender.admin.claim.resize";
public static final String CLAIM_RESIZE_ADMIN = "griefdefender.admin.claim.resize.admin";

View File

@ -29,26 +29,36 @@
public class FlagContexts {
public static final Context SOURCE_PLAYER = new Context(ContextKeys.SOURCE, "minecraft:player");
public static final Context SOURCE_TNT = new Context(ContextKeys.SOURCE, "minecraft:tnt");
public static final Context SOURCE_AIR = new Context(ContextKeys.SOURCE, "minecraft:air");
public static final Context SOURCE_CREEPER = new Context(ContextKeys.SOURCE, "minecraft:creeper");
public static final Context SOURCE_ENDERDRAGON = new Context(ContextKeys.SOURCE, "minecraft:enderdragon");
public static final Context SOURCE_GHAST = new Context(ContextKeys.SOURCE, "minecraft:ghast");
public static final Context SOURCE_ENDERMAN = new Context(ContextKeys.SOURCE, "minecraft:enderman");
public static final Context SOURCE_SNOWMAN = new Context(ContextKeys.SOURCE, "minecraft:snowman");
public static final Context SOURCE_WITHER = new Context(ContextKeys.SOURCE, "minecraft:wither");
public static final Context SOURCE_LAVA_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_WATER_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:lava");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:water");
public static final Context SOURCE_LIGHTNING_BOLT = new Context(ContextKeys.SOURCE, "minecraft:lightning_bolt");
public static final Context SOURCE_FALL = new Context(ContextKeys.SOURCE, "minecraft:fall");
public static final Context SOURCE_FALLING_BLOCK = new Context(ContextKeys.SOURCE, "minecraft:falling_block");
public static final Context SOURCE_FIRE = new Context(ContextKeys.SOURCE, "minecraft:fire");
public static final Context SOURCE_FIRE_TICK = new Context(ContextKeys.SOURCE, "minecraft:fire_tick");
public static final Context SOURCE_FIREWORKS = new Context(ContextKeys.SOURCE, "minecraft:fireworks");
public static final Context SOURCE_GHAST = new Context(ContextKeys.SOURCE, "minecraft:ghast");
public static final Context SOURCE_ICE = new Context(ContextKeys.SOURCE, "minecraft:ice");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:lava");
public static final Context SOURCE_LAVA_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_LIGHTNING_BOLT = new Context(ContextKeys.SOURCE, "minecraft:lightning_bolt");
public static final Context SOURCE_MAGMA_BLOCK = new Context(ContextKeys.SOURCE, "minecraft:magma_block");
public static final Context SOURCE_PISTON = new Context(ContextKeys.SOURCE, "minecraft:piston");
public static final Context SOURCE_VINE = new Context(ContextKeys.SOURCE, "minecraft:vine");
public static final Context SOURCE_PISTON_STICKY = new Context(ContextKeys.SOURCE, "minecraft:sticky_piston");
public static final Context SOURCE_PLAYER = new Context(ContextKeys.SOURCE, "minecraft:player");
public static final Context SOURCE_SNOW = new Context(ContextKeys.SOURCE, "minecraft:snow");
public static final Context SOURCE_SNOW_1_12 = new Context(ContextKeys.SOURCE, "minecraft:snow_layer");
public static final Context SOURCE_SNOWMAN = new Context(ContextKeys.SOURCE, "minecraft:snow_golem");
public static final Context SOURCE_SNOWMAN_1_12 = new Context(ContextKeys.SOURCE, "minecraft:snowman");
public static final Context SOURCE_TNT = new Context(ContextKeys.SOURCE, "minecraft:tnt");
public static final Context SOURCE_TURTLE_EGG = new Context(ContextKeys.SOURCE, "minecraft:turtle_egg");
public static final Context SOURCE_TYPE_MONSTER = new Context(ContextKeys.SOURCE, "#monster");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:water");
public static final Context SOURCE_WATER_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_WITHER = new Context(ContextKeys.SOURCE, "minecraft:wither");
public static final Context SOURCE_VILLAGER = new Context(ContextKeys.SOURCE, "minecraft:villager");
public static final Context SOURCE_VINE = new Context(ContextKeys.SOURCE, "minecraft:vine");
// Block States
public static final Context STATE_FARMLAND_DRY = new Context("state", "moisture:0");
@ -72,14 +82,15 @@ public class FlagContexts {
public static final Context TARGET_PLAYER = new Context(ContextKeys.TARGET, "minecraft:player");
public static final Context TARGET_ICE_FORM = new Context(ContextKeys.TARGET, "minecraft:ice");
public static final Context TARGET_ICE_MELT = new Context(ContextKeys.TARGET, "minecraft:water");
public static final Context TARGET_SNOW_1_12 = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_SNOW = new Context(ContextKeys.TARGET, "minecraft:snow");
public static final Context TARGET_SNOW_1_12 = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_TURTLE_EGG = new Context(ContextKeys.TARGET, "minecraft:turtle_egg");
public static final Context TARGET_VILLAGER = new Context(ContextKeys.TARGET, "minecraft:villager");
public static final Context TARGET_VINE = new Context(ContextKeys.TARGET, "minecraft:vine");
public static final Context TARGET_WATER_BUCKET = new Context(ContextKeys.TARGET, "minecraft:water_bucket");
public static final Context TARGET_XP_ORB = new Context(ContextKeys.TARGET, "minecraft:xp_orb");
public static final Context TARGET_TYPE_ANIMAL = new Context(ContextKeys.TARGET, "#animal");
public static final Context TARGET_TYPE_CROP = new Context(ContextKeys.TARGET, "#crop");
public static final Context TARGET_TYPE_CROP = new Context(ContextKeys.TARGET, "#crops");
public static final Context TARGET_TYPE_AMBIENT = new Context(ContextKeys.TARGET, "#ambient");
public static final Context TARGET_TYPE_AQUATIC = new Context(ContextKeys.TARGET, "#aquatic");
public static final Context TARGET_TYPE_MONSTER = new Context(ContextKeys.TARGET, "#monster");

View File

@ -33,12 +33,16 @@
import net.kyori.text.format.TextDecoration;
import java.util.Set;
import java.util.UUID;
public class GDActiveFlagData {
public enum Type {
CLAIM,
CLAIM_PARENT_INHERIT,
DEFAULT,
OWNER_OVERRIDE,
OWNER_OVERRIDE_PARENT_INHERIT,
OVERRIDE,
UNDEFINED
}
@ -48,6 +52,8 @@ public enum Type {
private final Tristate value;
private final Type type;
private final Set<Context> contexts;
private final Component inheritParentFriendlyType;
private final UUID inheritParentUniqueId;
public GDActiveFlagData(GDFlagDefinition flagDefinition, FlagData flagData, Tristate value, Set<Context> contexts, Type type) {
this.flagDefinition = flagDefinition;
@ -55,6 +61,18 @@ public GDActiveFlagData(GDFlagDefinition flagDefinition, FlagData flagData, Tris
this.value = value;
this.type = type;
this.contexts = contexts;
this.inheritParentFriendlyType = null;
this.inheritParentUniqueId = null;
}
public GDActiveFlagData(GDFlagDefinition flagDefinition, FlagData flagData, Tristate value, Set<Context> contexts, UUID parentUniqueId, Component parentType, Type type) {
this.flagDefinition = flagDefinition;
this.flagData = flagData;
this.value = value;
this.type = type;
this.contexts = contexts;
this.inheritParentFriendlyType = parentType;
this.inheritParentUniqueId = parentUniqueId;
}
public FlagData getFlagData() {
@ -69,9 +87,15 @@ public TextColor getColor() {
if (this.type == Type.CLAIM) {
return TextColor.YELLOW;
}
if (this.type == Type.CLAIM_PARENT_INHERIT) {
return TextColor.AQUA;
}
if (this.type == Type.OVERRIDE) {
return TextColor.RED;
}
if (this.type == Type.OWNER_OVERRIDE_PARENT_INHERIT) {
return TextColor.DARK_RED;
}
if (this.type == Type.DEFAULT) {
return TextColor.LIGHT_PURPLE;
}
@ -82,7 +106,15 @@ public Type getType() {
return this.type;
}
public Component getComponent() {
public UUID getInheritParentUniqueId() {
return this.inheritParentUniqueId;
}
public Component getInheritParentFriendlyType() {
return this.inheritParentFriendlyType;
}
public Component getComponent(String flagGroup) {
String descr = "Active Claim Result: ";
final TextColor valueColor = this.getColor();
TextComponent valueComponent = TextComponent.of(this.value.toString().toLowerCase()).color(valueColor);
@ -101,19 +133,26 @@ public Component getComponent() {
.append(this.flagData.getFlag().getName(), TextColor.GREEN);
if (!this.flagData.getContexts().isEmpty()) {
builder.append("\nContexts: ");
builder.append("\nContexts: \n");
}
final boolean contextNewLine = this.flagDefinition.getFlagData().size() <= 2;
for (Context context : this.contexts) {
if (!this.flagDefinition.isAdmin() && context.getKey().contains("gd_claim")) {
if ((!this.flagDefinition.isAdmin() || flagGroup.equalsIgnoreCase("user")) && context.getKey().contains("gd_claim")) {
continue;
}
builder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
builder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
if (contextNewLine) {
builder.append("\n");
} else {
builder.append(" ");
}
}
return builder.build();

View File

@ -32,6 +32,7 @@
import java.util.Set;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Subject;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flag;
@ -48,29 +49,22 @@ public class GDFlagDefinition implements FlagDefinition {
private boolean adminDefinition = false;
private Set<Context> definitionContexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private Subject subject;
private String displayName;
private String groupName;
private Tristate defaultValue = Tristate.UNDEFINED;
private Component description;
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description, String groupName, boolean isAdmin, Set<Context> contexts) {
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description, String groupName, Subject subject, boolean isAdmin, Set<Context> contexts) {
this.data = flagData;
this.displayName = displayName;
this.description = description;
this.groupName = groupName;
this.definitionContexts = contexts;
this.subject = subject;
this.adminDefinition = isAdmin;
}
public void addFlagData(Flag flag, Set<Context> contexts) {
this.data.add(new GDFlagData(flag, contexts));
}
@Override
public void addFlagData(FlagData flagData) {
this.data.add(new GDFlagData(flagData.getFlag(), flagData.getContexts()));
}
@Override
public List<Flag> getFlags() {
List<Flag> flags = new ArrayList<>();
@ -139,6 +133,11 @@ public Tristate getDefaultValue() {
return this.defaultValue;
}
@Override
public Subject getSubject() {
return this.subject;
}
@Override
public void setDefaultValue(Tristate value) {
this.defaultValue = value;
@ -150,6 +149,7 @@ public static class FlagDefinitionBuilder implements Builder {
private boolean isAdmin = false;
private Set<Context> contexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private Subject subject = GriefDefenderPlugin.DEFAULT_HOLDER;
private String displayName;
private String groupName;
private Tristate defaultValue = Tristate.UNDEFINED;
@ -215,6 +215,12 @@ public Builder description(Component description) {
return this;
}
@Override
public Builder subject(Subject subject) {
this.subject = subject;
return this;
}
@Override
public Builder reset() {
this.enabled = true;
@ -225,6 +231,7 @@ public Builder reset() {
this.groupName = "";
this.defaultValue = Tristate.UNDEFINED;
this.description = TextComponent.empty();
this.subject = GriefDefenderPlugin.DEFAULT_HOLDER;
return this;
}
@ -234,7 +241,7 @@ public FlagDefinition build() {
checkNotNull(this.displayName);
checkNotNull(this.groupName);
checkNotNull(this.description);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description, this.groupName, this.isAdmin, this.contexts);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description, this.groupName, this.subject, this.isAdmin, this.contexts);
definition.setIsEnabled(this.enabled);
definition.setDefaultValue(this.defaultValue);
return definition;

View File

@ -25,6 +25,7 @@
package com.griefdefender.permission.flag;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.Flags;
public class GDFlags {
@ -56,6 +57,7 @@ public class GDFlags {
public static boolean INTERACT_ITEM_SECONDARY;
public static boolean INTERACT_INVENTORY;
public static boolean INTERACT_INVENTORY_CLICK;
public static boolean INVENTORY_ITEM_MOVE;
public static boolean ITEM_DROP;
public static boolean ITEM_PICKUP;
public static boolean ITEM_SPAWN;
@ -67,41 +69,49 @@ public class GDFlags {
public static boolean PROJECTILE_IMPACT_ENTITY;
public static void populateFlagStatus() {
BLOCK_BREAK = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.BLOCK_BREAK.getName());
BLOCK_GROW = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.BLOCK_GROW.getName());
BLOCK_MODIFY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.BLOCK_MODIFY.getName());
BLOCK_PLACE = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.BLOCK_PLACE.getName());
BLOCK_SPREAD = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.BLOCK_SPREAD.getName());
COLLIDE_BLOCK = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.COLLIDE_BLOCK.getName());
COLLIDE_ENTITY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.COLLIDE_ENTITY.getName());
COMMAND_EXECUTE = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.COMMAND_EXECUTE.getName());
COMMAND_EXECUTE_PVP = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.COMMAND_EXECUTE_PVP.getName());
ENTER_CLAIM = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTER_CLAIM.getName());
ENTITY_CHUNK_SPAWN = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_CHUNK_SPAWN.getName());
ENTITY_DAMAGE = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_DAMAGE.getName());
ENTITY_RIDING = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_RIDING.getName());
ENTITY_SPAWN = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_SPAWN.getName());
ENTITY_TELEPORT_FROM = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_TELEPORT_FROM.getName());
ENTITY_TELEPORT_TO = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ENTITY_TELEPORT_TO.getName());
EXIT_CLAIM = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.EXIT_CLAIM.getName());
EXPLOSION_BLOCK = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.EXPLOSION_BLOCK.getName());
EXPLOSION_ENTITY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.EXPLOSION_ENTITY.getName());
INTERACT_BLOCK_PRIMARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_BLOCK_PRIMARY.getName());
INTERACT_BLOCK_SECONDARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_BLOCK_SECONDARY.getName());
INTERACT_ENTITY_PRIMARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_ENTITY_PRIMARY.getName());
INTERACT_ENTITY_SECONDARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_ENTITY_SECONDARY.getName());
INTERACT_INVENTORY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_INVENTORY.getName());
INTERACT_INVENTORY_CLICK = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_INVENTORY_CLICK.getName());
INTERACT_ITEM_PRIMARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_ITEM_PRIMARY.getName());
INTERACT_ITEM_SECONDARY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.INTERACT_ITEM_SECONDARY.getName());
ITEM_DROP = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ITEM_DROP.getName());
ITEM_PICKUP = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ITEM_PICKUP.getName());
ITEM_SPAWN = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ITEM_SPAWN.getName());
ITEM_USE = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.ITEM_USE.getName());
LEAF_DECAY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.LEAF_DECAY.getName());
LIQUID_FLOW = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.LIQUID_FLOW.getName());
PORTAL_USE = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.PORTAL_USE.getName());
PROJECTILE_IMPACT_BLOCK = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.PROJECTILE_IMPACT_BLOCK.getName());
PROJECTILE_IMPACT_ENTITY = GriefDefenderPlugin.getGlobalConfig().getConfig().modules.isProtectionModuleEnabled(Flags.PROJECTILE_IMPACT_ENTITY.getName());
BLOCK_BREAK = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.BLOCK_BREAK.getName());
BLOCK_GROW = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.BLOCK_GROW.getName());
BLOCK_MODIFY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.BLOCK_MODIFY.getName());
BLOCK_PLACE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.BLOCK_PLACE.getName());
BLOCK_SPREAD = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.BLOCK_SPREAD.getName());
COLLIDE_BLOCK = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.COLLIDE_BLOCK.getName());
COLLIDE_ENTITY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.COLLIDE_ENTITY.getName());
COMMAND_EXECUTE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.COMMAND_EXECUTE.getName());
COMMAND_EXECUTE_PVP = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.COMMAND_EXECUTE_PVP.getName());
ENTER_CLAIM = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTER_CLAIM.getName());
ENTITY_CHUNK_SPAWN = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_CHUNK_SPAWN.getName());
ENTITY_DAMAGE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_DAMAGE.getName());
ENTITY_RIDING = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_RIDING.getName());
ENTITY_SPAWN = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_SPAWN.getName());
ENTITY_TELEPORT_FROM = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_TELEPORT_FROM.getName());
ENTITY_TELEPORT_TO = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ENTITY_TELEPORT_TO.getName());
EXIT_CLAIM = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.EXIT_CLAIM.getName());
EXPLOSION_BLOCK = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.EXPLOSION_BLOCK.getName());
EXPLOSION_ENTITY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.EXPLOSION_ENTITY.getName());
INTERACT_BLOCK_PRIMARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_BLOCK_PRIMARY.getName());
INTERACT_BLOCK_SECONDARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_BLOCK_SECONDARY.getName());
INTERACT_ENTITY_PRIMARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_ENTITY_PRIMARY.getName());
INTERACT_ENTITY_SECONDARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_ENTITY_SECONDARY.getName());
INTERACT_INVENTORY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_INVENTORY.getName());
INTERACT_INVENTORY_CLICK = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_INVENTORY_CLICK.getName());
INTERACT_ITEM_PRIMARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_ITEM_PRIMARY.getName());
INTERACT_ITEM_SECONDARY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INTERACT_ITEM_SECONDARY.getName());
INVENTORY_ITEM_MOVE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.INVENTORY_ITEM_MOVE.getName());
ITEM_DROP = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ITEM_DROP.getName());
ITEM_PICKUP = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ITEM_PICKUP.getName());
ITEM_SPAWN = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ITEM_SPAWN.getName());
ITEM_USE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.ITEM_USE.getName());
LEAF_DECAY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.LEAF_DECAY.getName());
LIQUID_FLOW = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.LIQUID_FLOW.getName());
PORTAL_USE = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.PORTAL_USE.getName());
PROJECTILE_IMPACT_BLOCK = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.PROJECTILE_IMPACT_BLOCK.getName());
PROJECTILE_IMPACT_ENTITY = GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(Flags.PROJECTILE_IMPACT_ENTITY.getName());
}
public static boolean isFlagEnabled(Flag flag) {
if (flag == null) {
return false;
}
return GriefDefenderPlugin.getFlagConfig().getConfig().isFlagEnabled(flag.getName().toLowerCase());
}
}

View File

@ -49,12 +49,11 @@ public class GDOption<T> implements Option<T> {
private static final List<String> GLOBAL_OPTIONS = Arrays.asList(
"abandon-return-ratio", "accrued-blocks", "bonus-blocks", "blocks-accrued-per-hour", "chest-expiration", "economy-block-cost",
"economy-block-sell-return", "expiration", "initial-blocks", "max-accrued-blocks", "radius-list",
"radius-list");
"economy-block-sell-return", "expiration", "initial-blocks", "max-accrued-blocks");
private static final List<String> ADMIN_OPTIONS = Arrays.asList(
"player-command", "player-deny-godmode", "player-deny-hunger", "player-gamemode",
"player-command", "player-deny-godmode", "player-deny-hunger", "player-fly-speed", "player-gamemode",
"player-health-regen", "player-keep-inventory", "player-keep-level", "player-walk-speed",
"radius-inspect", "radius-list");
"player-teleport-delay", "radius-inspect", "rent-restore", "spawn-limit");
private final String id;
private final String name;

View File

@ -0,0 +1,82 @@
/*
* 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.permission.option;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.api.permission.option.Options;
public class GDOptions {
public static boolean PLAYER_COMMAND_ENTER;
public static boolean PLAYER_COMMAND_EXIT;
public static boolean PLAYER_DENY_FLIGHT;
public static boolean PLAYER_DENY_GODMODE;
public static boolean PLAYER_DENY_HUNGER;
public static boolean PLAYER_FLY_SPEED;
public static boolean PLAYER_GAMEMODE;
public static boolean PLAYER_HEALTH_REGEN;
public static boolean PLAYER_KEEP_INVENTORY;
public static boolean PLAYER_KEEP_LEVEL;
public static boolean PLAYER_TELEPORT_DELAY;
public static boolean PLAYER_WALK_SPEED;
public static boolean PLAYER_WEATHER;
public static boolean PVP;
public static boolean PVP_COMBAT_COMMAND;
public static boolean PVP_COMBAT_TELEPORT;
public static boolean PVP_COMBAT_TIMEOUT;
public static boolean SPAWN_LIMIT;
public static void populateOptionStatus() {
PLAYER_COMMAND_ENTER = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_COMMAND_ENTER.getName());
PLAYER_COMMAND_EXIT = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_COMMAND_EXIT.getName());
PLAYER_DENY_FLIGHT = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_DENY_FLIGHT.getName());
PLAYER_DENY_GODMODE = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_DENY_GODMODE.getName());
PLAYER_DENY_HUNGER = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_DENY_HUNGER.getName());
PLAYER_FLY_SPEED = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_FLY_SPEED.getName());
PLAYER_GAMEMODE = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_GAMEMODE.getName());
PLAYER_HEALTH_REGEN = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_HEALTH_REGEN.getName());
PLAYER_KEEP_INVENTORY = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_KEEP_INVENTORY.getName());
PLAYER_KEEP_LEVEL = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_KEEP_LEVEL.getName());
PLAYER_TELEPORT_DELAY = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_TELEPORT_DELAY.getName());
PLAYER_WALK_SPEED = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_WALK_SPEED.getName());
PLAYER_WEATHER = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PLAYER_WEATHER.getName());
PVP = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PVP.getName());
PVP_COMBAT_COMMAND = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PVP_COMBAT_COMMAND.getName());
PVP_COMBAT_TELEPORT = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PVP_COMBAT_TELEPORT.getName());
PVP_COMBAT_TIMEOUT = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.PVP_COMBAT_TIMEOUT.getName());
SPAWN_LIMIT = GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(Options.SPAWN_LIMIT.getName());
}
public static boolean isOptionEnabled(Option option) {
if (option == null) {
return false;
}
if (!option.getName().toLowerCase().contains("player") && !option.getName().toLowerCase().contains("spawn") && !option.getName().toLowerCase().contains("pvp")) {
return true;
}
return GriefDefenderPlugin.getOptionConfig().getConfig().isOptionEnabled(option.getName().toLowerCase());
}
}

View File

@ -92,7 +92,7 @@ private String getWindowInfo(Claim claim, AreaMarker marker) {
} else {
info = "<div class=\"regioninfo\">" + this.cfg.infoWindowBasic + "</div>";
}
info = info.replace("%owner%", ((GDClaim) claim).getOwnerFriendlyName());
info = info.replace("%owner%", ((GDClaim) claim).getOwnerName());
info = info.replace("%area%", Integer.toString(claim.getArea()));
info = info.replace("%claimname%",
claim.getData().getName().isPresent()
@ -219,7 +219,7 @@ private void updateClaimMarker(Claim claim, Map<String, AreaMarker> markerMap) {
return;
}
final String worldName = world.getName();
final String owner = ((GDClaim) claim).getOwnerFriendlyName();
final String owner = ((GDClaim) claim).getOwnerName();
if (isVisible((GDClaim) claim, owner, worldName)) {
final Vector3i lesserPos = claim.getLesserBoundaryCorner();
final Vector3i greaterPos = claim.getGreaterBoundaryCorner();
@ -260,7 +260,12 @@ private void updateClaims() {
Map<String, AreaMarker> newmap = new HashMap<String, AreaMarker>();
Bukkit.getServer().getWorlds().stream().map(w -> GriefDefender.getCore().getClaimManager(w.getUID()))
.map(ClaimManager::getWorldClaims).forEach(claims -> {
claims.forEach(claim -> updateClaimMarker(claim, newmap));
for (Claim claim : claims) {
updateClaimMarker(claim, newmap);
for (Claim child : claim.getChildren(true)) {
updateClaimMarker(child, newmap);
}
}
});
for (AreaMarker oldm : this.areaMarkers.values()) {

View File

@ -36,11 +36,11 @@
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.Subject;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.permission.GDPermissionUser;
@ -68,17 +68,17 @@ public String onPlaceholderRequest(Player player, String identifier){
}
@Override
public String onRequest(OfflinePlayer user, String identifier) {
final Player player = user instanceof Player ? (Player) user : null;
final Subject subject = GriefDefender.getCore().getSubject(user.getUniqueId().toString());
public String onRequest(OfflinePlayer offlinePlayer, String identifier) {
final Player player = offlinePlayer instanceof Player ? (Player) offlinePlayer : null;
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(offlinePlayer);
GDPlayerData playerData = null;
Claim claim = null;
if (player != null) {
final World world = player.getWorld();
claim = GriefDefender.getCore().getClaimManager(world.getUID()).getClaimAt(VecHelper.toVector3i(player.getLocation()));
playerData = (GDPlayerData) GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId()).get();
playerData = user.getInternalPlayerData();
} else {
playerData = (GDPlayerData) GriefDefender.getCore().getPlayerData(Bukkit.getWorlds().get(0).getUID(), user.getUniqueId()).get();
playerData = user.getInternalPlayerData();
}
switch (identifier) {
case "claim_admin" :
@ -101,8 +101,13 @@ public String onRequest(OfflinePlayer user, String identifier) {
return this.getAllTownChildrenClaims(playerData, ClaimTypes.BASIC);
case "claims_town_subdivision" :
return this.getAllTownChildrenClaims(playerData, ClaimTypes.SUBDIVISION);
case "claim_for_rent" :
if (claim == null || GriefDefenderPlugin.getInstance().getVaultProvider() == null || claim.getEconomyData() == null) {
return "false";
}
return String.valueOf(claim.getEconomyData().isForRent());
case "claim_for_sale" :
if (claim == null) {
if (claim == null || GriefDefenderPlugin.getInstance().getVaultProvider() == null || claim.getEconomyData() == null) {
return "false";
}
return String.valueOf(claim.getEconomyData().isForSale());
@ -118,7 +123,7 @@ public String onRequest(OfflinePlayer user, String identifier) {
if (claim.isWilderness()) {
return "wilderness";
}
return ((GDClaim) claim).getOwnerFriendlyName();
return ((GDClaim) claim).getOwnerName();
case "claim_trust" :
if (claim == null) {
return "[unknown]";
@ -133,7 +138,7 @@ public String onRequest(OfflinePlayer user, String identifier) {
if (claim == null) {
return "[unknown]";
}
return String.valueOf(PlayerUtil.getInstance().canPlayerPvP((GDClaim) claim, ((GDPermissionUser) subject)));
return String.valueOf(PlayerUtil.getInstance().canPlayerPvP((GDClaim) claim, user));
case "blocks_total" :
final int initial = playerData.getInitialClaimBlocks();
final int accrued = playerData.getAccruedClaimBlocks();

View File

@ -0,0 +1,91 @@
/*
* 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.registry;
import static com.google.common.base.Preconditions.checkNotNull;
import com.griefdefender.api.claim.ClaimVisualType;
import com.griefdefender.api.claim.ClaimVisualTypes;
import com.griefdefender.api.registry.CatalogRegistryModule;
import com.griefdefender.internal.visual.GDClaimVisualType;
import com.griefdefender.util.RegistryHelper;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
public class ClaimVisualTypeRegistryModule implements CatalogRegistryModule<ClaimVisualType> {
private static ClaimVisualTypeRegistryModule instance;
public static ClaimVisualTypeRegistryModule getInstance() {
return instance;
}
private final Map<String, ClaimVisualType> registryMap = new HashMap<>();
@Override
public Optional<ClaimVisualType> getById(String id) {
if (id == null) {
return Optional.empty();
}
if (id.contains("griefdefender.")) {
id = id.replace("griefdefender.", "griefdefender:");
}
if (!id.contains(":")) {
id = "griefdefender:" + id;
}
return Optional.ofNullable(this.registryMap.get(checkNotNull(id)));
}
@Override
public Collection<ClaimVisualType> getAll() {
return this.registryMap.values();
}
@Override
public void registerDefaults() {
RegistryHelper.mapFields(ClaimVisualTypes.class, input -> {
final String name = input.toLowerCase().replace("_", "-");
final String id = "griefdefender:" + name;
final ClaimVisualType type = new GDClaimVisualType(id, name);
this.registryMap.put(id, type);
return type;
});
}
@Override
public void registerCustomType(ClaimVisualType type) {
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
}
static {
instance = new ClaimVisualTypeRegistryModule();
}
}

View File

@ -37,7 +37,6 @@
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.api.registry.CatalogRegistryModule;
import com.griefdefender.cache.MessageCache;
import com.griefdefender.permission.ContextGroupKeys;
import com.griefdefender.permission.flag.FlagContexts;
import java.util.ArrayList;
@ -53,6 +52,7 @@
public class FlagDefinitionRegistryModule implements CatalogRegistryModule<FlagDefinition> {
private static FlagDefinitionRegistryModule instance;
final static Context OWNER_OVERRIDE_CONTEXT = new Context(ContextKeys.CLAIM_OVERRIDE, "claim");
public static FlagDefinitionRegistryModule getInstance() {
return instance;
@ -80,17 +80,67 @@ public Collection<FlagDefinition> getAll() {
@Override
public void registerDefaults() {
List<FlagData> flagData = new ArrayList<>();
Set<Context> definitionContexts = new HashSet<>();
Set<Context> flagContexts = new HashSet<>();
FlagDefinition.Builder definitionBuilder = GriefDefender.getRegistry().createBuilder(FlagDefinition.Builder.class);
FlagData.Builder flagDataBuilder = GriefDefender.getRegistry().createBuilder(FlagData.Builder.class);
// ADMIN
this.registerCustomType(
definitionBuilder
.reset()
.name("ambient-spawn")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_AMBIENT)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("animal-spawn")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_ANIMAL)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("aquatic-spawn")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_AQUATIC)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("chorus-fruit-teleport")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT)
.group("admin")
@ -106,7 +156,7 @@ public void registerDefaults() {
.reset()
.name("creeper-block-explosion")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CREEPER_BLOCK_EXPLOSION)
.group("admin")
@ -122,7 +172,7 @@ public void registerDefaults() {
.reset()
.name("creeper-entity-explosion")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CREEPER_ENTITY_EXPLOSION)
.group("admin")
@ -138,7 +188,7 @@ public void registerDefaults() {
.reset()
.name("exp-drop")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP)
.group("admin")
@ -149,6 +199,22 @@ public void registerDefaults() {
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("fall-entity-damage")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_ENTITY_DAMAGE)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_FALL)
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_FALL);
flagContexts.add(FlagContexts.TARGET_PLAYER);
@ -157,7 +223,7 @@ public void registerDefaults() {
.reset()
.name("fall-player-damage")
.admin(true)
.context(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE)
.group("admin")
@ -168,24 +234,95 @@ public void registerDefaults() {
.build())
.build());
List<FlagData> flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_SPREAD)
.context(FlagContexts.SOURCE_FIRE)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("fire-spread")
.name("falling-block-break")
.admin(true)
.context(ClaimContexts.BASIC_OVERRIDE_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALLING_BLOCK_BREAK)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.BLOCK_BREAK)
.context(FlagContexts.SOURCE_FALLING_BLOCK)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("fire-block-damage")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_BLOCK_DAMAGE)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.BLOCK_MODIFY)
.context(FlagContexts.SOURCE_FIRE)
.build())
.build());
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_FIRE)
.build());
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_FIRE_TICK)
.build());
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_MAGMA_BLOCK)
.build());
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_LAVA)
.build());
} else {
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_LAVA_1_12)
.build());
}
this.registerCustomType(
definitionBuilder
.reset()
.name("fire-entity-damage")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_ENTITY_DAMAGE)
.group("admin")
.flagData(flagData)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("lightning-damage")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_LIGHTNING_BOLT)
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
flagContexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
@ -205,7 +342,7 @@ public void registerDefaults() {
.reset()
.name("monster-animal-damage")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE)
.group("admin")
@ -231,7 +368,7 @@ public void registerDefaults() {
.reset()
.name("monster-player-damage")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE)
.group("admin")
@ -243,7 +380,7 @@ public void registerDefaults() {
.reset()
.name("monster-spawn")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN)
.group("admin")
@ -254,6 +391,29 @@ public void registerDefaults() {
.build())
.build());
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ITEM_SPAWN)
.context(FlagContexts.SOURCE_PISTON)
.build());
flagData.add(flagDataBuilder
.reset()
.flag(Flags.ITEM_SPAWN)
.context(FlagContexts.SOURCE_PISTON_STICKY)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("piston-item-spawn")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTON_ITEM_SPAWN)
.group("admin")
.flagData(flagData)
.build());
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
@ -265,13 +425,23 @@ public void registerDefaults() {
.flag(Flags.BLOCK_PLACE)
.context(FlagContexts.SOURCE_PISTON)
.build());
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_BREAK)
.context(FlagContexts.SOURCE_PISTON_STICKY)
.build());
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_PLACE)
.context(FlagContexts.SOURCE_PISTON_STICKY)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("piston-use")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.context(new Context(ContextKeys.CLAIM, "claim"))
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTON_USE)
.group("admin")
.flagData(flagData)
@ -282,7 +452,7 @@ public void registerDefaults() {
.reset()
.name("player-block-break")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK)
.group("admin")
@ -298,7 +468,7 @@ public void registerDefaults() {
.reset()
.name("player-block-interact")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_INTERACT)
.group("admin")
@ -314,7 +484,7 @@ public void registerDefaults() {
.reset()
.name("player-block-place")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE)
.group("admin")
@ -330,7 +500,7 @@ public void registerDefaults() {
.reset()
.name("player-damage")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_DAMAGE)
.group("admin")
@ -349,7 +519,7 @@ public void registerDefaults() {
.reset()
.name("player-enderpearl-interact")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_ENDERPEARL_INTERACT)
.group("admin")
@ -381,7 +551,7 @@ public void registerDefaults() {
.reset()
.name("player-entity-interact")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT)
.group("admin")
@ -408,12 +578,31 @@ public void registerDefaults() {
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_ITEM_FRAME);
this.registerCustomType(
definitionBuilder
.reset()
.name("player-itemframe-interact")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEMFRAME_INTERACT)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.INTERACT_ENTITY_SECONDARY)
.contexts(flagContexts)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("player-item-drop")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP)
.group("admin")
@ -429,7 +618,7 @@ public void registerDefaults() {
.reset()
.name("player-item-pickup")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP)
.group("admin")
@ -448,7 +637,7 @@ public void registerDefaults() {
.reset()
.name("player-portal-use")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE)
.group("admin")
@ -464,7 +653,7 @@ public void registerDefaults() {
.reset()
.name("player-teleport-from")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM)
.group("admin")
@ -480,7 +669,7 @@ public void registerDefaults() {
.reset()
.name("player-teleport-to")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO)
.group("admin")
@ -491,12 +680,31 @@ public void registerDefaults() {
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_PLAYER);
this.registerCustomType(
definitionBuilder
.reset()
.name("pvp")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP)
.group("admin")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.contexts(flagContexts)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("tnt-block-explosion")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION)
.group("admin")
@ -512,7 +720,7 @@ public void registerDefaults() {
.reset()
.name("tnt-entity-explosion")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION)
.group("admin")
@ -523,12 +731,54 @@ public void registerDefaults() {
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_TURTLE_EGG);
flagContexts.add(FlagContexts.TARGET_AIR);
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_BREAK)
.contexts(flagContexts)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("turtle-egg-hatch")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TURTLE_EGG_HATCH)
.group("admin")
.flagData(flagData)
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_VILLAGER);
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.INTERACT_ENTITY_SECONDARY)
.contexts(flagContexts)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("villager-farm")
.admin(true)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VILLAGER_FARM)
.group("admin")
.flagData(flagData)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("wither-block-break")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK)
.group("admin")
@ -544,7 +794,7 @@ public void registerDefaults() {
.reset()
.name("wither-entity-break")
.admin(true)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE)
.group("admin")
@ -555,6 +805,29 @@ public void registerDefaults() {
.build())
.build());
definitionContexts = new HashSet<>();
definitionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
definitionContexts.add(OWNER_OVERRIDE_CONTEXT);
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_VILLAGER);
flagContexts.add(FlagContexts.TARGET_TYPE_CROP);
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_BREAK)
.contexts(flagContexts)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("villager-farm")
.admin(true)
.contexts(definitionContexts)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VILLAGER_FARM)
.group("admin")
.flagData(flagData)
.build());
// USER
flagContexts = new HashSet<>();
@ -565,7 +838,7 @@ public void registerDefaults() {
.reset()
.name("block-trampling")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING)
.group("user")
@ -595,7 +868,7 @@ public void registerDefaults() {
.reset()
.name("chest-access")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS)
.group("user")
@ -607,8 +880,8 @@ public void registerDefaults() {
.reset()
.name("crop-growth")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH)
.group("user")
.flagData(flagDataBuilder
@ -623,7 +896,7 @@ public void registerDefaults() {
.reset()
.name("damage-animals")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS)
.group("user")
@ -639,7 +912,7 @@ public void registerDefaults() {
.reset()
.name("enderman-grief")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF)
.group("user")
@ -650,20 +923,25 @@ public void registerDefaults() {
.build())
.build());
definitionContexts = new HashSet<>();
definitionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
definitionContexts.add(OWNER_OVERRIDE_CONTEXT);
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.BLOCK_SPREAD)
.context(FlagContexts.SOURCE_FIRE)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("fire-damage")
.name("fire-spread")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.contexts(definitionContexts)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.BLOCK_MODIFY)
.context(FlagContexts.SOURCE_FIRE)
.build())
.flagData(flagData)
.build());
this.registerCustomType(
@ -671,7 +949,7 @@ public void registerDefaults() {
.reset()
.name("grass-growth")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH)
.group("user")
@ -687,7 +965,7 @@ public void registerDefaults() {
.reset()
.name("ice-form")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM)
.group("user")
@ -706,7 +984,7 @@ public void registerDefaults() {
.reset()
.name("ice-melt")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT)
.group("user")
@ -735,7 +1013,7 @@ public void registerDefaults() {
.reset()
.name("lava-flow")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW)
.group("user")
@ -747,7 +1025,7 @@ public void registerDefaults() {
.reset()
.name("leaf-decay")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY)
.group("user")
@ -757,28 +1035,12 @@ public void registerDefaults() {
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("lightning")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.context(FlagContexts.SOURCE_LIGHTNING_BOLT)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("lighter")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER)
.group("user")
@ -794,7 +1056,7 @@ public void registerDefaults() {
.reset()
.name("mushroom-growth")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH)
.group("user")
@ -810,7 +1072,7 @@ public void registerDefaults() {
.reset()
.name("mycelium-spread")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD)
.group("user")
@ -821,25 +1083,6 @@ public void registerDefaults() {
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_PLAYER);
this.registerCustomType(
definitionBuilder
.reset()
.name("pvp")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_DAMAGE)
.contexts(flagContexts)
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
@ -859,7 +1102,7 @@ public void registerDefaults() {
.reset()
.name("ride")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE)
.group("user")
@ -885,17 +1128,22 @@ public void registerDefaults() {
.reset()
.name("sleep")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP)
.group("user")
.flagData(flagData)
.build());
definitionContexts = new HashSet<>();
definitionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
definitionContexts.add(OWNER_OVERRIDE_CONTEXT);
flagContexts = new HashSet<>();
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
flagContexts.add(FlagContexts.SOURCE_AIR);
flagContexts.add(FlagContexts.TARGET_SNOW);
} else {
flagContexts.add(FlagContexts.SOURCE_AIR);
flagContexts.add(FlagContexts.TARGET_SNOW_1_12);
}
this.registerCustomType(
@ -903,7 +1151,7 @@ public void registerDefaults() {
.reset()
.name("snow-fall")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.contexts(definitionContexts)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL)
.group("user")
@ -914,18 +1162,23 @@ public void registerDefaults() {
.build())
.build());
definitionContexts = new HashSet<>();
definitionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
definitionContexts.add(OWNER_OVERRIDE_CONTEXT);
flagContexts = new HashSet<>();
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
flagContexts.add(FlagContexts.TARGET_SNOW);
flagContexts.add(FlagContexts.SOURCE_SNOW);
flagContexts.add(FlagContexts.TARGET_AIR);
} else {
flagContexts.add(FlagContexts.TARGET_SNOW_1_12);
flagContexts.add(FlagContexts.SOURCE_SNOW_1_12);
flagContexts.add(FlagContexts.TARGET_AIR);
}
this.registerCustomType(
definitionBuilder
.reset()
.name("snow-melt")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.contexts(definitionContexts)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT)
.group("user")
@ -936,19 +1189,27 @@ public void registerDefaults() {
.build())
.build());
flagContexts = new HashSet<>();
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
flagContexts.add(FlagContexts.SOURCE_SNOWMAN);
flagContexts.add(FlagContexts.TARGET_SNOW);
} else {
flagContexts.add(FlagContexts.SOURCE_SNOWMAN_1_12);
flagContexts.add(FlagContexts.TARGET_SNOW);
}
this.registerCustomType(
definitionBuilder
.reset()
.name("snowman-trail")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.BLOCK_MODIFY)
.context(FlagContexts.SOURCE_SNOWMAN)
.flag(Flags.BLOCK_PLACE)
.contexts(flagContexts)
.build())
.build());
@ -957,7 +1218,7 @@ public void registerDefaults() {
.reset()
.name("soil-dry")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY)
.group("user")
@ -968,54 +1229,6 @@ public void registerDefaults() {
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("spawn-ambient")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_AMBIENT)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("spawn-animal")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_ANIMAL)
.build())
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("spawn-aquatic")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC)
.group("user")
.flagData(flagDataBuilder
.reset()
.flag(Flags.ENTITY_SPAWN)
.context(FlagContexts.TARGET_TYPE_AQUATIC)
.build())
.build());
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.USED_ITEM_VEHICLE);
@ -1053,19 +1266,42 @@ public void registerDefaults() {
.reset()
.name("vehicle-use")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE)
.group("user")
.flagData(flagData)
.build());
definitionContexts = new HashSet<>();
definitionContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
flagContexts = new HashSet<>();
flagContexts.add(FlagContexts.SOURCE_PLAYER);
flagContexts.add(FlagContexts.TARGET_VILLAGER);
flagData = new ArrayList<>();
flagData.add(flagDataBuilder
.reset()
.flag(Flags.INTERACT_ENTITY_SECONDARY)
.contexts(flagContexts)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("villager-trade")
.admin(false)
.contexts(definitionContexts)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VILLAGER_TRADE)
.group("user")
.flagData(flagData)
.build());
this.registerCustomType(
definitionBuilder
.reset()
.name("vine-growth")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.TRUE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH)
.group("user")
@ -1094,7 +1330,7 @@ public void registerDefaults() {
.reset()
.name("water-flow")
.admin(false)
.context(ClaimContexts.BASIC_DEFAULT_CONTEXT)
.context(ClaimContexts.GLOBAL_DEFAULT_CONTEXT)
.defaultValue(Tristate.FALSE)
.description(MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW)
.group("user")
@ -1104,7 +1340,7 @@ public void registerDefaults() {
@Override
public void registerCustomType(FlagDefinition type) {
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
this.registryMap.put(type.getId().toLowerCase(), type);
}
static {

View File

@ -82,7 +82,7 @@ public void registerDefaults() {
@Override
public void registerCustomType(Flag type) {
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
GriefDefenderPlugin.getInstance().flagConfig.getConfig().defaultFlagCategory.refreshFlags();
GriefDefenderPlugin.getFlagConfig().getConfig().defaultFlagCategory.refreshFlags();
GriefDefenderPlugin.getInstance().dataStore.setDefaultGlobalPermissions();
}

View File

@ -88,50 +88,54 @@ public Map<String, Option> getCustomAdditions() {
@Override
public void registerDefaults() {
this.createKey("griefdefender:abandon-delay", "abandon-delay", Integer.class);
this.createKey("griefdefender:abandon-return-ratio", "abandon-return-ratio", Double.class);
this.createKey("griefdefender:accrued-blocks", "accrued-blocks", Integer.class);
this.createKey("griefdefender:bonus-blocks", "bonus-blocks", Integer.class);
this.createKey("griefdefender:create-limit", "create-limit", Integer.class);
this.createKey("griefdefender:expiration", "expiration", Integer.class);
this.createKey("griefdefender:max-size-x", "max-size-x", Integer.class);
this.createKey("griefdefender:max-size-y", "max-size-y", Integer.class);
this.createKey("griefdefender:max-size-z", "max-size-z", Integer.class);
this.createKey("griefdefender:min-size-x", "min-size-x", Integer.class);
this.createKey("griefdefender:min-size-y", "min-size-y", Integer.class);
this.createKey("griefdefender:min-size-z", "min-size-z", Integer.class);
this.createKey("griefdefender:tax-expiration", "tax-expiration", Integer.class);
this.createKey("griefdefender:tax-expiration-days-keep", "tax-expiration-days-keep", Integer.class);
this.createKey("griefdefender:tax-rate", "tax-rate", Double.class);
this.createKey("griefdefender:blocks-accrued-per-hour", "blocks-accrued-per-hour", Integer.class);
this.createKey("griefdefender:chest-expiration", "chest-expiration", Integer.class);
this.createKey("griefdefender:create-mode", "create-mode", CreateModeType.class);
this.createKey("griefdefender:economy-block-cost", "economy-block-cost", Double.class);
this.createKey("griefdefender:economy-block-sell-return", "economy-block-sell-return", Double.class);
this.createKey("griefdefender:initial-blocks", "initial-blocks", Integer.class);
this.createKey("griefdefender:max-accrued-blocks", "max-accrued-blocks", Integer.class);
this.createKey("griefdefender:max-level", "max-level", Integer.class);
this.createKey("griefdefender:min-level", "min-level", Integer.class);
this.createKey("griefdefender:radius-list", "radius-list", Integer.class);
this.createKey("griefdefender:radius-inspect", "radius-inspect", Integer.class);
this.createKey("griefdefender:raid", "raid", Boolean.class);
this.createKey("griefdefender:spawn-limit", "spawn-limit", Integer.class);
this.createKey("griefdefender:player-command-enter", "player-command-enter", true, List.class);
this.createKey("griefdefender:player-command-exit", "player-command-exit", true, List.class);
this.createKey("griefdefender:player-deny-flight", "player-deny-flight", Boolean.class);
this.createKey("griefdefender:player-deny-godmode", "player-deny-godmode", Boolean.class);
this.createKey("griefdefender:player-deny-hunger", "player-deny-hunger", Boolean.class);
this.createKey("griefdefender:player-gamemode", "player-gamemode", GameModeType.class);
this.createKey("griefdefender:player-health-regen", "player-health-regen", Double.class);
this.createKey("griefdefender:player-keep-inventory", "player-keep-inventory", Tristate.class);
this.createKey("griefdefender:player-keep-level", "player-keep-level", Tristate.class);
this.createKey("griefdefender:player-teleport-delay", "player-teleport-delay", Integer.class);
this.createKey("griefdefender:player-walk-speed", "player-walk-speed", Double.class);
this.createKey("griefdefender:player-weather", "player-weather", WeatherType.class);
this.createKey("griefdefender:pvp", "pvp", Tristate.class);
this.createKey("griefdefender:pvp-combat-command", "pvp-combat-command", Boolean.class);
this.createKey("griefdefender:pvp-combat-teleport", "pvp-combat-teleport", Boolean.class);
this.createKey("griefdefender:pvp-combat-timeout", "pvp-combat-timeout", Integer.class);
this.createKey("griefdefender:abandon-delay", Integer.class);
this.createKey("griefdefender:abandon-return-ratio", Double.class);
this.createKey("griefdefender:accrued-blocks", Integer.class);
this.createKey("griefdefender:blocks-accrued-per-hour", Integer.class);
this.createKey("griefdefender:bonus-blocks", Integer.class);
this.createKey("griefdefender:chest-expiration", Integer.class);
this.createKey("griefdefender:create-limit", Integer.class);
this.createKey("griefdefender:create-mode", CreateModeType.class);
this.createKey("griefdefender:economy-block-cost", Double.class);
this.createKey("griefdefender:economy-block-sell-return", Double.class);
this.createKey("griefdefender:expiration", Integer.class);
this.createKey("griefdefender:initial-blocks", Integer.class);
this.createKey("griefdefender:max-accrued-blocks", Integer.class);
this.createKey("griefdefender:max-level", Integer.class);
this.createKey("griefdefender:max-size-x", Integer.class);
this.createKey("griefdefender:max-size-y", Integer.class);
this.createKey("griefdefender:max-size-z", Integer.class);
this.createKey("griefdefender:min-size-x", Integer.class);
this.createKey("griefdefender:min-size-y", Integer.class);
this.createKey("griefdefender:min-size-z", Integer.class);
this.createKey("griefdefender:min-level", Integer.class);
this.createKey("griefdefender:player-command-enter", true, List.class);
this.createKey("griefdefender:player-command-exit", true, List.class);
this.createKey("griefdefender:player-deny-flight", Boolean.class);
this.createKey("griefdefender:player-deny-godmode", Boolean.class);
this.createKey("griefdefender:player-deny-hunger", Boolean.class);
this.createKey("griefdefender:player-fly-speed", Double.class);
this.createKey("griefdefender:player-gamemode", GameModeType.class);
this.createKey("griefdefender:player-health-regen", Double.class);
this.createKey("griefdefender:player-keep-inventory", Tristate.class);
this.createKey("griefdefender:player-keep-level", Tristate.class);
this.createKey("griefdefender:player-teleport-delay", Integer.class);
this.createKey("griefdefender:player-walk-speed", Double.class);
this.createKey("griefdefender:player-weather", WeatherType.class);
this.createKey("griefdefender:pvp", Tristate.class);
this.createKey("griefdefender:pvp-combat-command", Boolean.class);
this.createKey("griefdefender:pvp-combat-teleport", Boolean.class);
this.createKey("griefdefender:pvp-combat-timeout", Integer.class);
this.createKey("griefdefender:radius-inspect", Integer.class);
this.createKey("griefdefender:raid", Boolean.class);
this.createKey("griefdefender:rent-balance", Double.class);
this.createKey("griefdefender:rent-expiration", Integer.class);
this.createKey("griefdefender:rent-expiration-days-keep", Integer.class);
this.createKey("griefdefender:rent-restore", Boolean.class);
this.createKey("griefdefender:spawn-limit", Integer.class);
this.createKey("griefdefender:tax-expiration", Integer.class);
this.createKey("griefdefender:tax-expiration-days-keep", Integer.class);
this.createKey("griefdefender:tax-rate", Double.class);
RegistryHelper.mapFields(Options.class, input -> {
final String name = input.replace("_", "-");
@ -139,10 +143,18 @@ public void registerDefaults() {
});
}
private void createKey(String id, Class<?> clazz) {
this.createKey(id, id.replace("griefdefender:", ""), false, new HashSet<>(), clazz);
}
private void createKey(String id, String name, Class<?> clazz) {
this.createKey(id, name, false, new HashSet<>(), clazz);
}
private void createKey(String id, boolean multiValued, Class<?> clazz) {
this.createKey(id, id.replace("griefdefender:", ""), multiValued, new HashSet<>(), clazz);
}
private void createKey(String id, String name, boolean multiValued, Class<?> clazz) {
this.createKey(id, name, multiValued, new HashSet<>(), clazz);
}

View File

@ -54,6 +54,7 @@
import com.griefdefender.configuration.type.GlobalConfig;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.event.GDRemoveClaimEvent;
import com.griefdefender.event.GDRemoveClaimEvent.Delete;
import com.griefdefender.internal.util.VecHelper;
import com.griefdefender.migrator.PlayerDataMigrator;
import com.griefdefender.permission.GDPermissionUser;
@ -175,7 +176,7 @@ public ClaimResult deleteAllAdminClaims(CommandSender src, World world) {
}
GDCauseStackManager.getInstance().pushCause(src);
GDRemoveClaimEvent event = new GDRemoveClaimEvent(ImmutableList.copyOf(claimsToDelete));
GDRemoveClaimEvent.Delete event = new GDRemoveClaimEvent.Delete(ImmutableList.copyOf(claimsToDelete));
GriefDefender.getEventManager().post(event);
GDCauseStackManager.getInstance().popCause();
if (event.cancelled()) {
@ -200,6 +201,7 @@ public void abandonClaimsForPlayer(GDPermissionUser user, Set<Claim> claimsToDel
for (Claim claim : claimsToDelete) {
GDClaimManager claimWorldManager = this.claimWorldManagers.get(claim.getWorldUniqueId());
claimWorldManager.deleteClaimInternal(claim, true);
user.getInternalPlayerData().revertClaimVisual((GDClaim) claim);
}
return;
@ -243,24 +245,14 @@ public GDClaim getClaimAtPlayer(GDPlayerData playerData, Location location) {
return (GDClaim) claimManager.getClaimAtPlayer(location, playerData);
}
public GDClaim getClaimAtPlayer(Location location, GDPlayerData playerData, boolean useBorderBlockRadius) {
public GDClaim getClaimAtPlayer(Location location, GDPlayerData playerData, boolean useBorderBlockRadius) {
GDClaimManager claimManager = this.getClaimWorldManager(location.getWorld().getUID());
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), null, playerData, useBorderBlockRadius);
}
public GDClaim getClaimAtPlayer(Location location, GDClaim cachedClaim, GDPlayerData playerData, boolean useBorderBlockRadius) {
GDClaimManager claimManager = this.getClaimWorldManager(location.getWorld().getUID());
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), cachedClaim, playerData, useBorderBlockRadius);
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), playerData, useBorderBlockRadius);
}
public GDClaim getClaimAt(Location location) {
GDClaimManager claimManager = this.getClaimWorldManager(location.getWorld().getUID());
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), null, null, false);
}
public GDClaim getClaimAt(Location location, GDClaim cachedClaim) {
GDClaimManager claimManager = this.getClaimWorldManager(location.getWorld().getUID());
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), cachedClaim, null, false);
return (GDClaim) claimManager.getClaimAt(VecHelper.toVector3i(location), null, false);
}
public GDPlayerData getPlayerData(World world, UUID playerUniqueId) {
@ -322,8 +314,8 @@ public void setDefaultGlobalPermissions() {
// Admin defaults
Set<Context> contexts = new HashSet<>();
contexts.add(ClaimContexts.ADMIN_DEFAULT_CONTEXT);
final FlagConfig flagConfig = GriefDefenderPlugin.getInstance().flagConfig;
final OptionConfig optionConfig = GriefDefenderPlugin.getInstance().optionConfig;
final FlagConfig flagConfig = GriefDefenderPlugin.getFlagConfig();
final OptionConfig optionConfig = GriefDefenderPlugin.getOptionConfig();
final Map<String, Boolean> adminDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.ADMIN.getName().toLowerCase());
if (adminDefaultFlags != null && !adminDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, adminDefaultFlags);

View File

@ -450,7 +450,9 @@ public ClaimResult writeClaimToStorage(GDClaim claim) {
public ClaimResult deleteClaimFromStorage(GDClaim claim) {
final GDPlayerData ownerData = claim.getOwnerPlayerData();
try {
Files.delete(claim.getClaimStorage().filePath);
if (claim.getClaimStorage().filePath.toFile().exists()) {
Files.delete(claim.getClaimStorage().filePath);
}
if (GriefDefenderPlugin.getInstance().getWorldEditProvider() != null) {
final Path schematicPath = GriefDefenderPlugin.getInstance().getWorldEditProvider().getSchematicWorldMap().get(claim.getWorldUniqueId());
if (schematicPath != null && Files.exists(schematicPath.resolve(claim.getUniqueId().toString()))) {
@ -469,7 +471,7 @@ public ClaimResult deleteClaimFromStorage(GDClaim claim) {
PermissionUtil.getInstance().clearPermissions((GDClaim) claim);
return new GDClaimResult(claim, ClaimResultType.SUCCESS);
} catch (IOException e) {
} catch (Throwable e) {
e.printStackTrace();
GriefDefenderPlugin.getInstance().getLogger().severe("Error: Unable to delete claim file \"" + claim.getClaimStorage().filePath + "\".");
}

View File

@ -35,7 +35,7 @@
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.internal.util.BlockUtil;
import com.griefdefender.internal.util.RestoreUtil;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.util.PermissionUtil;
@ -91,7 +91,7 @@ public void run() {
Instant claimLastActive = claim.getInternalClaimData().getDateLastActive();
final int claimExpirationChest = playerData.getChestClaimExpiration();
if (claim.getArea() <= areaOfDefaultClaim && claimExpirationChest > 0) {
if (claim.getClaimBlocks() <= areaOfDefaultClaim && claimExpirationChest > 0) {
if (claimLastActive.plus(Duration.ofDays(claimExpirationChest))
.isBefore(Instant.now())) {
playerData.useRestoreSchematic = schematicRestore;
@ -103,10 +103,16 @@ public void run() {
"uuid", claim.getUniqueId().toString()));
GriefDefenderPlugin.getInstance().getLogger().info(PlainComponentSerializer.INSTANCE.serialize(message));
if (!schematicRestore && activeConfig.getConfig().claim.claimAutoNatureRestore) {
BlockUtil.getInstance().restoreClaim(claim);
if (GriefDefenderPlugin.getMajorMinecraftVersion() <= 12 || GriefDefenderPlugin.getInstance().getWorldEditProvider() == null) {
RestoreUtil.getInstance().restoreClaim(claim);
} else {
GriefDefenderPlugin.getInstance().getWorldEditProvider().regenerateClaim(claim);
}
}
// remove all context permissions
PermissionUtil.getInstance().clearPermissions(claim);
}
return;
continue;
}
if (!claim.isBasicClaim()) {
@ -118,11 +124,11 @@ public void run() {
final Instant localNow = Instant.now();
final boolean claimNotActive = claimLastActive.plus(Duration.ofDays(optionClaimExpirationBasic)).isBefore(localNow);
if (!claimNotActive) {
final boolean taxEnabled = activeConfig.getConfig().claim.bankTaxSystem;
final boolean taxEnabled = activeConfig.getConfig().economy.taxSystem;
if (!taxEnabled || !claim.getData().isExpired()) {
continue;
}
final Instant taxPastDueDate = claim.getEconomyData().getTaxPastDueDate().orElse(null);
final Instant taxPastDueDate = claim.getEconomyData().getTaxPastDueDate();
if (taxPastDueDate == null) {
continue;
}
@ -143,7 +149,7 @@ public void run() {
"uuid", claim.getUniqueId().toString()));
GriefDefenderPlugin.getInstance().getLogger().info(PlainComponentSerializer.INSTANCE.serialize(message));
if (!schematicRestore && activeConfig.getConfig().claim.claimAutoNatureRestore) {
BlockUtil.getInstance().restoreClaim(claim);
RestoreUtil.getInstance().restoreClaim(claim);
}
}
}

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