diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/OpenCommand.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/OpenCommand.java index b22e88a..e671351 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/OpenCommand.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/OpenCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 GeorgH93 + * Copyright (C) 2022 GeorgH93 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ public class OpenCommand extends MinepacksCommand public OpenCommand(Minepacks plugin) { - super(plugin, "open", plugin.getLanguage().getTranslated("Commands.Description.Backpack"), Permissions.USE, true, plugin.getLanguage().getCommandAliases("Open")); + super(plugin, "open", plugin.getLanguage().getTranslated("Commands.Description.Backpack"), Permissions.USE, false, plugin.getLanguage().getCommandAliases("Open")); this.plugin = plugin; messageCooldown = plugin.getLanguage().getMessage("Ingame.Open.Cooldown").replaceAll("\\{TimeLeft}", "%1\\$.1f").replaceAll("\\{TimeSpanLeft}", "%2\\$s"); @@ -68,6 +68,11 @@ public OpenCommand(Minepacks plugin) @Override public void execute(@NotNull CommandSender sender, @NotNull String main, @NotNull String s1, @NotNull String[] args) { + if (!(sender instanceof Player)) + { + handleOpenFromConsole(sender, args); + return; + } Player player = (Player) sender; if(args.length == 0) { @@ -111,6 +116,26 @@ public void execute(@NotNull CommandSender sender, @NotNull String main, @NotNul } } + void handleOpenFromConsole(final @NotNull CommandSender sender, final @NotNull String[] names) + { + int opened = 0; + List notOnline = new ArrayList<>(names.length); + for(String name : names) + { + Player target = Bukkit.getPlayer(name); + if (target == null) + { + notOnline.add(name); + } + else if (target.hasPermission(Permissions.USE)) + { + opened++; + plugin.openBackpack(target, target, true); + } + } + sender.sendMessage("Opened backpack of " + opened + " players." + (notOnline.isEmpty() ? "" : " Not online: " + String.join(", ", notOnline))); + } + @Override public List tabComplete(@NotNull CommandSender commandSender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String[] args) { diff --git a/pom.xml b/pom.xml index 83f397d..c34e7f0 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ pom - 2.4.6.1 + 2.4.7-RC1 UTF-8 UTF-8