diff --git a/bukkit/src/main/java/com/griefdefender/GDPlayerData.java b/bukkit/src/main/java/com/griefdefender/GDPlayerData.java index be42772..6b6216c 100644 --- a/bukkit/src/main/java/com/griefdefender/GDPlayerData.java +++ b/bukkit/src/main/java/com/griefdefender/GDPlayerData.java @@ -686,6 +686,8 @@ public boolean inPvpCombat(World world) { public void onDisconnect() { this.visualBlocks.clear(); + this.claimMode = false; + this.lastShovelLocation = null; this.eventResultCache = null; this.claimResizing = null; this.claimSubdividing = null; diff --git a/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java b/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java index 62fae4f..9f5c22a 100644 --- a/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java +++ b/bukkit/src/main/java/com/griefdefender/command/ClaimFlagBase.java @@ -908,17 +908,16 @@ private Consumer createCustomFlagConsumer(GDPermissionUser src, G } else { newValue = Tristate.UNDEFINED; } - - PermissionResult result = null; - for (Flag flag : customFlag.getFlags()) { - GDFlagPermissionEvent.Set event = new GDFlagPermissionEvent.Set(this.subject, flagData.getFlag(), newValue, newContexts); - GriefDefender.getEventManager().post(event); - if (event.cancelled()) { - return; - } - result = GriefDefenderPlugin.getInstance().getPermissionProvider().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flag, newValue, newContexts); + PermissionResult result = null; + final Flag flag = flagData.getFlag(); + GDFlagPermissionEvent.Set event = new GDFlagPermissionEvent.Set(this.subject, flagData.getFlag(), newValue, newContexts); + GriefDefender.getEventManager().post(event); + if (event.cancelled()) { + return; } + + result = GriefDefenderPlugin.getInstance().getPermissionProvider().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flag, newValue, newContexts); } GDCauseStackManager.getInstance().popCause(); showCustomFlags(src, claim, displayType); diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimExpand.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimExpand.java index 4ea3329..206bf0e 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimExpand.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimExpand.java @@ -95,10 +95,8 @@ public void execute(Player player, int amount, @Optional String direction) { return; } - System.out.println("PLAYER IS FACING " + face); final Vector3i lesser = claim.lesserBoundaryCorner; final Vector3i greater = claim.greaterBoundaryCorner; - System.out.println("CURRENT CORNERS lesser = " + lesser + ", greater = " + greater); Vector3i point1 = null; Vector3i point2 = null; if (face == BlockFace.EAST) { diff --git a/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java b/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java index c65b16d..b77a606 100644 --- a/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java +++ b/bukkit/src/main/java/com/griefdefender/command/CommandClaimList.java @@ -44,6 +44,7 @@ import com.griefdefender.api.claim.TrustTypes; 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; @@ -92,8 +93,14 @@ public CommandClaimList(ClaimType type) { @Syntax("[| ]") @Description("List information about a player's claim blocks and claims.") @Subcommand("claim list") - public void execute(Player src, @Optional OfflinePlayer targetPlayer, @Optional World world) { + public void execute(Player src, @Optional String targetPlayer, @Optional World world) { final GDPermissionUser user = targetPlayer == null ? PermissionHolderCache.getInstance().getOrCreateUser(src) : PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer); + if (user == null) { + GriefDefenderPlugin.sendMessage(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER, + ImmutableMap.of( + "player", targetPlayer))); + return; + } if (world == null) { world = src.getWorld(); } @@ -105,6 +112,7 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU List claimsTextList = new ArrayList<>(); Set claims = new HashSet<>(); final String worldName = worldUniqueId == null ? "" : Bukkit.getWorld(worldUniqueId).getName(); + final boolean otherUser = !src.getUniqueId().equals(user.getUniqueId()); for (World world : Bukkit.getServer().getWorlds()) { if (type != null && !world.getUID().equals(worldUniqueId)) { continue; @@ -113,7 +121,7 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU // load the target player's data final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world, user.getUniqueId()); Set claimList = null; - if (type == null) { + if (type == null || otherUser) { claimList = playerData.getClaims(); } else { claimList = claimWorldManager.getWorldClaims(); @@ -124,22 +132,17 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU continue; } - final boolean isUserTrusted = claim.isUserTrusted(user.getUniqueId(), TrustTypes.ACCESSOR); + if (((GDClaim) claim).allowEdit(src) != null && !claim.isUserTrusted(src.getUniqueId(), TrustTypes.ACCESSOR)) { + continue; + } if (type == null) { - if (isUserTrusted) { - System.out.println("Adding claim UUID " + claim.getUniqueId()); - claims.add(claim); - } + claims.add(claim); } else { if (claim.getType() == type) { - if (isUserTrusted) { - System.out.println("2Adding claim UUID " + claim.getUniqueId()); - claims.add(claim); - } + claims.add(claim); } else if (type == ClaimTypes.SUBDIVISION) { for (Claim child : claim.getChildren(true)) { if (child.getType() == type) { - System.out.println("FOUND CHILD " + child); claims.add(child); } } @@ -172,8 +175,8 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU .append(type == null ? TextComponent.builder("") .append(whiteOpenBracket) - .append(MessageCache.getInstance().TITLE_OWN.color(TextColor.GOLD)) - .append(whiteCloseBracket).build() : MessageCache.getInstance().TITLE_OWN.color(TextColor.GRAY)) + .append(otherUser ? TextComponent.of(user.getFriendlyName()).color(TextColor.GOLD) : MessageCache.getInstance().TITLE_OWN.color(TextColor.GOLD)) + .append(whiteCloseBracket).build() : otherUser ? TextComponent.of(user.getFriendlyName()).color(TextColor.GRAY) : MessageCache.getInstance().TITLE_OWN.color(TextColor.GRAY)) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimListConsumer(src, user, null, worldUniqueId)))) .hoverEvent(HoverEvent.showText(ownedShowText)).build(); Component adminTypeText = TextComponent.builder("") @@ -209,13 +212,13 @@ private void showClaimList(Player src, GDPermissionUser user, ClaimType type, UU .append(MessageCache.getInstance().LABEL_DISPLAYING.color(TextColor.AQUA)) .append(" : ", TextColor.AQUA) .append(ownedTypeText) - .append(" ") - .append(adminTypeText) - .append(" ") + .append(" ") + .append(otherUser ? TextComponent.of("") : adminTypeText) + .append(otherUser ? "" : " ") .append(basicTypeText) - .append(" ") + .append(" ") .append(subTypeText) - .append(" ") + .append(" ") .append(townTypeText).build(); final int fillSize = 20 - (claimsTextList.size() + 2); for (int i = 0; i < fillSize; i++) { diff --git a/bukkit/src/main/java/com/griefdefender/listener/PlayerEventHandler.java b/bukkit/src/main/java/com/griefdefender/listener/PlayerEventHandler.java index 8ea8661..19ee561 100644 --- a/bukkit/src/main/java/com/griefdefender/listener/PlayerEventHandler.java +++ b/bukkit/src/main/java/com/griefdefender/listener/PlayerEventHandler.java @@ -715,7 +715,7 @@ public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) { final Object source = player; final Location location = event.getClickedBlock() != null ? event.getClickedBlock().getLocation() : null; - if (event.getHand() == EquipmentSlot.HAND && (playerData.claimMode || (itemInHand != null && GriefDefenderPlugin.getInstance().modificationTool != null && NMSUtil.getInstance().itemsEqual(itemInHand, GriefDefenderPlugin.getInstance().modificationTool)))) { + 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); // avoid changing blocks after using a shovel event.setUseInteractedBlock(Result.DENY); @@ -1416,7 +1416,7 @@ 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.claimMode && event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (playerData.claimMode && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) { // claim mode inspects with left-click return false; } diff --git a/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java b/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java index 27b39dc..b9066b6 100644 --- a/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java +++ b/bukkit/src/main/java/com/griefdefender/permission/GDPermissionManager.java @@ -518,6 +518,11 @@ public Set getPermissionContexts(GDClaim claim, Object obj, boolean isS 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) { diff --git a/bukkit/src/main/java/com/griefdefender/provider/LuckPermsProvider.java b/bukkit/src/main/java/com/griefdefender/provider/LuckPermsProvider.java index d597687..d2c4f7b 100644 --- a/bukkit/src/main/java/com/griefdefender/provider/LuckPermsProvider.java +++ b/bukkit/src/main/java/com/griefdefender/provider/LuckPermsProvider.java @@ -320,12 +320,12 @@ public void clearPermissions(GDPermissionHolder holder, Set contexts) { } public boolean holderHasPermission(GDPermissionHolder holder, String permission) { - Node node = this.luckPermsApi.getNodeFactory().newBuilder(permission).build(); final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder); if (permissionHolder == null) { return false; } - return permissionHolder.hasPermission(node) == me.lucko.luckperms.api.Tristate.TRUE; + + return permissionHolder.getCachedData().getPermissionData(Contexts.allowAll()).getPermissionValue(permission) == me.lucko.luckperms.api.Tristate.TRUE; } public Map getPermissions(GDPermissionHolder holder, Set contexts) { diff --git a/bukkit/src/main/java/com/griefdefender/storage/BaseStorage.java b/bukkit/src/main/java/com/griefdefender/storage/BaseStorage.java index 4e38a7e..387576d 100644 --- a/bukkit/src/main/java/com/griefdefender/storage/BaseStorage.java +++ b/bukkit/src/main/java/com/griefdefender/storage/BaseStorage.java @@ -380,6 +380,7 @@ public void setDefaultGlobalPermissions() { } private void setDefaultFlags(Set contexts, Map defaultFlags) { + final boolean defaultWildernessValue = contexts.contains(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT); GriefDefenderPlugin.getInstance().executor.execute(() -> { for (Map.Entry mapEntry : defaultFlags.entrySet()) { final Flag flag = FlagRegistryModule.getInstance().getById(mapEntry.getKey()).orElse(null); @@ -394,13 +395,13 @@ private void setDefaultFlags(Set contexts, Map default contexts.remove(FlagContexts.TARGET_TYPE_MONSTER); // deny item frame damage by default contexts.add(FlagContexts.TARGET_ITEM_FRAME); - PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, GDPermissions.FLAG_BASE + "." + mapEntry.getKey(), false, contexts); + PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, GDPermissions.FLAG_BASE + "." + mapEntry.getKey(), defaultWildernessValue, contexts); contexts.remove(FlagContexts.TARGET_ITEM_FRAME); } if (flag == Flags.INTERACT_ENTITY_SECONDARY) { // deny item frame rotation by default contexts.add(FlagContexts.TARGET_ITEM_FRAME); - PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, GDPermissions.FLAG_BASE + "." + mapEntry.getKey(), false, contexts); + PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, GDPermissions.FLAG_BASE + "." + mapEntry.getKey(), defaultWildernessValue, contexts); contexts.remove(FlagContexts.TARGET_ITEM_FRAME); } } diff --git a/bukkit/src/main/resources/1.12.2.json b/bukkit/src/main/resources/1.12.2.json index ea2cc4b..84b164d 100644 --- a/bukkit/src/main/resources/1.12.2.json +++ b/bukkit/src/main/resources/1.12.2.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.12.2", - "sha1": "1e2864c2f4f191a91ec94a457b7c23b67cc3cad8", - "path": "com/griefdefender/adapter/1.12.2-SNAPSHOT/adapter-1.12.2-20190825.074610-19.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.12.2-SNAPSHOT/adapter-1.12.2-20190825.074610-19.jar" + "sha1": "c17a212f288203daca365bd2f03253a2af35c751", + "path": "com/griefdefender/adapter/1.12.2-SNAPSHOT/adapter-1.12.2-20191007.192753-20.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.12.2-SNAPSHOT/adapter-1.12.2-20191007.192753-20.jar" }, { "name": "com.griefdefender:api:1.0.0", diff --git a/bukkit/src/main/resources/1.13.2.json b/bukkit/src/main/resources/1.13.2.json index dc3dfd9..6827c58 100644 --- a/bukkit/src/main/resources/1.13.2.json +++ b/bukkit/src/main/resources/1.13.2.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.13.2", - "sha1": "2edc122ff64351cd85a8b1d509f25dbca3abdfea", - "path": "com/griefdefender/adapter/1.13.2-SNAPSHOT/adapter-1.13.2-20190825.074424-18.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.13.2-SNAPSHOT/adapter-1.13.2-20190825.074424-18.jar" + "sha1": "d39aacdde1b7c0017e69b033f572f735bcc721cb", + "path": "com/griefdefender/adapter/1.13.2-SNAPSHOT/adapter-1.13.2-20191007.192614-19.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.13.2-SNAPSHOT/adapter-1.13.2-20191007.192614-19.jar" }, { "name": "com.griefdefender:api:1.0.0", diff --git a/bukkit/src/main/resources/1.14.2.json b/bukkit/src/main/resources/1.14.2.json index 166613b..4abf50b 100644 --- a/bukkit/src/main/resources/1.14.2.json +++ b/bukkit/src/main/resources/1.14.2.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.14.2", - "sha1": "cfc9fb3065a7c135f064a57fcd1c444a1ec3e828", - "path": "com/griefdefender/adapter/1.14.2-SNAPSHOT/adapter-1.14.2-20190825.074341-18.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.2-SNAPSHOT/adapter-1.14.2-20190825.074341-18.jar" + "sha1": "c1e110c74824f314c46b31de7cc0817f223b3322", + "path": "com/griefdefender/adapter/1.14.2-SNAPSHOT/adapter-1.14.2-20191007.192516-19.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.2-SNAPSHOT/adapter-1.14.2-20191007.192516-19.jar" }, { "name": "com.griefdefender:api:1.0.0", diff --git a/bukkit/src/main/resources/1.14.3.json b/bukkit/src/main/resources/1.14.3.json index 73d8c41..be40e26 100644 --- a/bukkit/src/main/resources/1.14.3.json +++ b/bukkit/src/main/resources/1.14.3.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.14.3", - "sha1": "263ac2510d35b21493cb0d7247bee0f3536f6bc5", - "path": "com/griefdefender/adapter/1.14.3-SNAPSHOT/adapter-1.14.3-20190825.074256-19.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.3-SNAPSHOT/adapter-1.14.3-20190825.074256-19.jar" + "sha1": "6827e0ded527dfe912f9949e29fa28c09a302c0a", + "path": "com/griefdefender/adapter/1.14.3-SNAPSHOT/adapter-1.14.3-20191007.192429-20.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.3-SNAPSHOT/adapter-1.14.3-20191007.192429-20.jar" }, { "name": "com.griefdefender:api:1.0.0", diff --git a/bukkit/src/main/resources/1.14.4.json b/bukkit/src/main/resources/1.14.4.json index 101eb23..5485ddf 100644 --- a/bukkit/src/main/resources/1.14.4.json +++ b/bukkit/src/main/resources/1.14.4.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.14.4", - "sha1": "35fdaf76357368ae604a38ecfaca60b128922318", - "path": "com/griefdefender/adapter/1.14.4-SNAPSHOT/adapter-1.14.4-20190825.074211-16.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.4-SNAPSHOT/adapter-1.14.4-20190825.074211-16.jar" + "sha1": "e2ca45c14cc84384cdd465105e629f97c38bfb3a", + "path": "com/griefdefender/adapter/1.14.4-SNAPSHOT/adapter-1.14.4-20191007.192349-18.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.14.4-SNAPSHOT/adapter-1.14.4-20191007.192349-18.jar" }, { "name": "com.griefdefender:api:1.0.0", diff --git a/bukkit/src/main/resources/1.8.8.json b/bukkit/src/main/resources/1.8.8.json index f6529eb..4055c68 100644 --- a/bukkit/src/main/resources/1.8.8.json +++ b/bukkit/src/main/resources/1.8.8.json @@ -3,9 +3,9 @@ "libraries": [ { "name": "com.griefdefender:adapter:1.8.8", - "sha1": "880f48231949acb4941024b7836c4bcbba10da49", - "path": "com/griefdefender/adapter/1.8.8-SNAPSHOT/adapter-1.8.8-20190825.074658-19.jar", - "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.8.8-SNAPSHOT/adapter-1.8.8-20190825.074658-19.jar" + "sha1": "fb0b9235fb0d18bab3b63fa56207d156c40faf6e", + "path": "com/griefdefender/adapter/1.8.8-SNAPSHOT/adapter-1.8.8-20191007.192948-20.jar", + "url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/adapter/1.8.8-SNAPSHOT/adapter-1.8.8-20191007.192948-20.jar" }, { "name": "com.griefdefender:api:1.0.0",