More stability fixes for 1.2.2.

* Fix inspection tool interact on right-click when targetting a block.
* Fix custom flags being applied twice.
* Fix entity type NPE.
* Fix /claimlist user trust.
* Fix /claimlist usage with player name.
* Fix LP provider hasPermission check.
* Fix item frame transient defaults in wilderness.
This commit is contained in:
bloodshot 2019-10-09 16:28:35 -04:00
parent d92365e50a
commit 7d6654aa39
14 changed files with 62 additions and 54 deletions

View File

@ -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;

View File

@ -908,17 +908,16 @@ private Consumer<CommandSender> 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);

View File

@ -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) {

View File

@ -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("[<player>|<player> <world>]")
@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<Component> claimsTextList = new ArrayList<>();
Set<Claim> 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<Claim> 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++) {

View File

@ -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;
}

View File

@ -518,6 +518,11 @@ public Set<Context> 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) {

View File

@ -320,12 +320,12 @@ public void clearPermissions(GDPermissionHolder holder, Set<Context> 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<String, Boolean> getPermissions(GDPermissionHolder holder, Set<Context> contexts) {

View File

@ -380,6 +380,7 @@ public void setDefaultGlobalPermissions() {
}
private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> defaultFlags) {
final boolean defaultWildernessValue = contexts.contains(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
GriefDefenderPlugin.getInstance().executor.execute(() -> {
for (Map.Entry<String, Boolean> mapEntry : defaultFlags.entrySet()) {
final Flag flag = FlagRegistryModule.getInstance().getById(mapEntry.getKey()).orElse(null);
@ -394,13 +395,13 @@ private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> 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);
}
}

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",