admin unlock items

This commit is contained in:
Flemmli97 2021-06-09 14:45:08 +02:00
parent efee056fd5
commit f61069674c
4 changed files with 22 additions and 3 deletions

View File

@ -55,7 +55,8 @@ public class CommandClaim {
.then(CommandManager.literal("addClaim").requires(src -> CommandPermission.perm(src, CommandPermission.claimCreate)).then(CommandManager.argument("from", BlockPosArgumentType.blockPos()).then(CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(CommandClaim::addClaim))))
.then(CommandManager.literal("menu").requires(src -> CommandPermission.perm(src, CommandPermission.cmdMenu)).executes(CommandClaim::openMenu))
.then(CommandManager.literal("trapped").requires(src -> CommandPermission.perm(src, CommandPermission.cmdTrapped)).executes(CommandClaim::trapped))
.then(CommandManager.literal("unlockDrops").executes(CommandClaim::unlockDrops))
.then(CommandManager.literal("unlockDrops").executes(CommandClaim::unlockDrops)
.then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).requires(src -> CommandPermission.perm(src, CommandPermission.cmdUnlockAll, true)).executes(CommandClaim::unlockDropsPlayers)))
.then(CommandManager.literal("personalGroups").requires(src -> CommandPermission.perm(src, CommandPermission.cmdPGroup)).executes(CommandClaim::openPersonalGroups))
.then(CommandManager.literal("claimInfo").requires(src -> CommandPermission.perm(src, CommandPermission.cmdInfo)).executes(CommandClaim::claimInfo))
.then(CommandManager.literal("transferClaim").requires(src -> CommandPermission.perm(src, CommandPermission.cmdTransfer)).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).executes(CommandClaim::transferClaim)))
@ -214,6 +215,21 @@ public class CommandClaim {
return Command.SINGLE_SUCCESS;
}
private static int unlockDropsPlayers(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Collection<GameProfile> profs = GameProfileArgumentType.getProfileArgument(context, "players");
List<String> success = new ArrayList<>();
for (GameProfile prof : profs) {
ServerPlayerEntity player = context.getSource().getMinecraftServer().getPlayerManager().getPlayer(prof.getId());
if (player != null) {
PlayerClaimData data = PlayerClaimData.get(player);
data.unlockDeathItems();
success.add(prof.getName());
}
}
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDropsMulti, success), Formatting.GOLD), false);
return Command.SINGLE_SUCCESS;
}
private static int openPersonalGroups(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();
PersonalGroupScreenHandler.openGroupMenu(player);

View File

@ -15,7 +15,7 @@ public class LangCommands {
map.put("deleteAll", new String[]{"deleteAll", "Deletes all your claims (you need to double type to confirm it so no accidents)."});
map.put("deleteSubClaim", new String[]{"deleteSubClaim", "Deletes the current subclaim."});
map.put("deleteAllSubClaims", new String[]{"deleteAllSubClaims", "Deletes all subclaim of the current claim."});
map.put("list", new String[]{"list", "Lists all claims you have. If op also gives ability to list other players claims."});
map.put("list", new String[]{"list <player>", "Lists all claims you have. If op also gives ability to list other players claims."});
map.put("switchMode", new String[]{"switchMode", "Switch between normal and subclaim mode."});
map.put("group", new String[]{"group (add | remove <name>) | (players add | remove <player> [overwrite])", "- Adds/removes the group with that name. Also editable via the claim menu.", "- Adds/remove a player to the group. If overwrite then will overwrite the players current group else does nothing. Also editable via the claim menu."});
map.put("transferClaim", new String[]{"transferClaim <player>", "Gives ownership of the claim to the specified player. Only works if you're the claim owner."});
@ -25,7 +25,7 @@ public class LangCommands {
map.put("sellBlocks", new String[]{"sellBlocks <amount>", "Sells <amount> claimblocks. Needs gunpowder currency installed."});
map.put("buyBlocks", new String[]{"buyBlocks <amount>", "Buys <amount> claimblocks. Needs gunpowder currency installed."});
map.put("trapped", new String[]{"trapped", "If in a claim not owned by the player attempts to teleport the player out of it after 5 seconds."});
map.put("unlockDrops", new String[]{"unlockDrops", "Unlocks dropped items from death so other players can pick them up too."});
map.put("unlockDrops", new String[]{"unlockDrops <players>", "Unlocks dropped items from death so other players can pick them up too. Or all of the given players (needs OP)"});
map.put("reload", new String[]{"reload", "Reloads the config ingame."});
map.put("adminMode", new String[]{"adminMode", "Switches to admin mode ignoring all claims."});

View File

@ -126,6 +126,7 @@ public class LangConfig {
public String unlockDropsCmd = "Your deathitems are protected. Use %s to unlock them for other players";
public String unlockDrops = "Your deathitems are now unlocked for %s ticks";
public String unlockDropsMulti = "Unlocked drops for %s";
public LangCommands cmdLang = new LangCommands();

View File

@ -40,6 +40,8 @@ public class CommandPermission {
public static final String cmdSell = "flan.command.buy";
public static final String cmdBuy = "flan.command.sell";
public static final String cmdUnlockAll = "flan.command.unlock.all";
public static boolean perm(CommandSource src, String perm) {
return perm(src, perm, false);
}