Deny teleport to non-trusted users if no permission.

* Allow teleports to non-trusted if claim is for sale and they have
permission to teleport.
This commit is contained in:
bloodshot 2019-12-31 12:37:33 -05:00
parent 0ec94bb2cb
commit 039087cac7
2 changed files with 32 additions and 8 deletions

View File

@ -989,15 +989,27 @@ public static Consumer<CommandSender> createTeleportConsumer(CommandSender src,
return;
}
Player player = (Player) src;
GDClaim gpClaim = (GDClaim) claim;
GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
if (!playerData.canIgnoreClaim(gpClaim) && !playerData.canManageAdminClaims) {
GDClaim gdClaim = (GDClaim) claim;
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
if (!playerData.canIgnoreClaim(gdClaim) && !playerData.canManageAdminClaims) {
// if not owner of claim, validate perms
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS) && !gpClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
if (!gdClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
if (GriefDefenderPlugin.getInstance().getVaultProvider() != null) {
// Allow non-trusted to TP to claims for sale
if (!gdClaim.getEconomyData().isForSale()) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
} else {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
}
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;

View File

@ -1000,15 +1000,27 @@ public static Consumer<CommandSource> createTeleportConsumer(CommandSource src,
return;
}
Player player = (Player) src;
GDClaim gpClaim = (GDClaim) claim;
GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
if (!playerData.canIgnoreClaim(gpClaim) && !playerData.canManageAdminClaims) {
GDClaim gdClaim = (GDClaim) claim;
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
if (!playerData.canIgnoreClaim(gdClaim) && !playerData.canManageAdminClaims) {
// if not owner of claim, validate perms
if (!player.getUniqueId().equals(claim.getOwnerUniqueId())) {
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS) && !gpClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_OTHERS)) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
if (!gdClaim.isUserTrusted(player, TrustTypes.ACCESSOR)) {
if (GriefDefenderPlugin.getInstance().economyService.isPresent()) {
// Allow non-trusted to TP to claims for sale
if (!gdClaim.getEconomyData().isForSale()) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
} else {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;
}
}
} else if (!player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_TELEPORT_BASE)) {
TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIMINFO_UI_TELEPORT_FEATURE.color(TextColor.RED));
return;