mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2025-01-04 19:08:39 +01:00
Fix claimlist command when passing target player.
* Add new permission 'griefdefender.user.claim.command.list.others' to control whether a player can use target argument. * Change permission 'griefdefender.user.claim.command.list' to 'griefdefender.user.claim.command.list.base' to account for others addition. bukkit: * Remove call to Bukkit.getOfflinePlayer(name) as it would return a UUID for any name passed to it.
This commit is contained in:
parent
a09628a05b
commit
84fdbd2de0
@ -87,11 +87,7 @@ public GDPermissionUser getOrCreateUser(String username) {
|
||||
if (uuid != null) {
|
||||
return this.getOrCreateUser(uuid);
|
||||
}
|
||||
// check Bukkit
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(username);
|
||||
if (player != null) {
|
||||
return this.getOrCreateUser(player);
|
||||
}
|
||||
// Avoid checking Bukkit.getOfflinePlayer(name) as it will create a UUID for anything passed
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
import com.griefdefender.util.PaginationUtil;
|
||||
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;
|
||||
@ -74,7 +75,7 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_LIST)
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_LIST_BASE)
|
||||
public class CommandClaimList extends BaseCommand {
|
||||
|
||||
private final ClaimType forcedType;
|
||||
@ -95,7 +96,18 @@ public CommandClaimList(ClaimType type) {
|
||||
@Description("List information about a player's claim blocks and claims.")
|
||||
@Subcommand("claim list")
|
||||
public void execute(Player src, @Optional String targetPlayer, @Optional World world) {
|
||||
final GDPermissionUser user = targetPlayer == null ? PermissionHolderCache.getInstance().getOrCreateUser(src) : PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer);
|
||||
GDPermissionUser user = null;
|
||||
// check target player
|
||||
if (targetPlayer != null) {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer);
|
||||
if (user != null && user.getOnlinePlayer() != src && !src.hasPermission(GDPermissions.COMMAND_CLAIM_LIST_OTHERS)) {
|
||||
TextAdapter.sendComponent(src, MessageCache.getInstance().PERMISSION_PLAYER_VIEW_OTHERS);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(src);
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
GriefDefenderPlugin.sendMessage(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER,
|
||||
ImmutableMap.of(
|
||||
|
@ -35,7 +35,8 @@ public class GDPermissions {
|
||||
public static final String COMMAND_ABANDON_ALL_CLAIMS = "griefdefender.user.claim.command.abandon-all";
|
||||
public static final String COMMAND_ABANDON_TOP_LEVEL_CLAIM = "griefdefender.user.claim.command.abandon-top-level";
|
||||
public static final String COMMAND_CUBOID_CLAIMS = "griefdefender.user.claim.command.cuboid";
|
||||
public static final String COMMAND_CLAIM_LIST = "griefdefender.user.claim.command.list";
|
||||
public static final String COMMAND_CLAIM_LIST_BASE = "griefdefender.user.claim.command.list.base";
|
||||
public static final String COMMAND_CLAIM_LIST_OTHERS = "griefdefender.user.claim.command.list.others";
|
||||
public static final String COMMAND_BASIC_MODE = "griefdefender.user.claim.command.basic-mode";
|
||||
public static final String COMMAND_GIVE_BLOCKS = "griefdefender.user.claim.command.give.blocks";
|
||||
public static final String COMMAND_GIVE_BOOK = "griefdefender.user.claim.command.give.book";
|
||||
|
@ -54,6 +54,7 @@
|
||||
import com.griefdefender.util.PaginationUtil;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.adapter.spongeapi.TextAdapter;
|
||||
import net.kyori.text.event.ClickEvent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
@ -73,7 +74,7 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@CommandAlias("%griefdefender")
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_LIST)
|
||||
@CommandPermission(GDPermissions.COMMAND_CLAIM_LIST_BASE)
|
||||
public class CommandClaimList extends BaseCommand {
|
||||
|
||||
private final ClaimType forcedType;
|
||||
@ -94,7 +95,18 @@ public CommandClaimList(ClaimType type) {
|
||||
@Description("List information about a player's claim blocks and claims.")
|
||||
@Subcommand("claim list")
|
||||
public void execute(Player src, @Optional User targetPlayer, @Optional World world) {
|
||||
final GDPermissionUser user = targetPlayer == null ? PermissionHolderCache.getInstance().getOrCreateUser(src) : PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer);
|
||||
GDPermissionUser user = null;
|
||||
// check target player
|
||||
if (targetPlayer != null) {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(targetPlayer);
|
||||
if (user != null && user.getOnlinePlayer() != src && !src.hasPermission(GDPermissions.COMMAND_CLAIM_LIST_OTHERS)) {
|
||||
TextAdapter.sendComponent(src, MessageCache.getInstance().PERMISSION_PLAYER_VIEW_OTHERS);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
user = PermissionHolderCache.getInstance().getOrCreateUser(src);
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
GriefDefenderPlugin.sendMessage(src, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_PLAYER,
|
||||
ImmutableMap.of(
|
||||
|
@ -35,7 +35,8 @@ public class GDPermissions {
|
||||
public static final String COMMAND_ABANDON_ALL_CLAIMS = "griefdefender.user.claim.command.abandon-all";
|
||||
public static final String COMMAND_ABANDON_TOP_LEVEL_CLAIM = "griefdefender.user.claim.command.abandon-top-level";
|
||||
public static final String COMMAND_CUBOID_CLAIMS = "griefdefender.user.claim.command.cuboid";
|
||||
public static final String COMMAND_CLAIM_LIST = "griefdefender.user.claim.command.list";
|
||||
public static final String COMMAND_CLAIM_LIST_BASE = "griefdefender.user.claim.command.list.base";
|
||||
public static final String COMMAND_CLAIM_LIST_OTHERS = "griefdefender.user.claim.command.list.others";
|
||||
public static final String COMMAND_BASIC_MODE = "griefdefender.user.claim.command.basic-mode";
|
||||
public static final String COMMAND_GIVE_BLOCKS = "griefdefender.user.claim.command.give.blocks";
|
||||
public static final String COMMAND_GIVE_BOOK = "griefdefender.user.claim.command.give.book";
|
||||
|
Loading…
Reference in New Issue
Block a user