1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Fixed a permissions issue with /sf charge

This commit is contained in:
TheBusyBiscuit 2021-05-19 17:36:10 +02:00
parent 2e5bedc932
commit e4225d7aec
16 changed files with 61 additions and 3 deletions

View File

@ -35,6 +35,7 @@
* Fixed #3064
* Fixed #2964
* Fixed #2979
* Fixed a permissions issue with `/sf charge`
## Release Candidate 23 (19 May 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#23

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@ -11,10 +13,22 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack;
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
/**
* This command that allows for backpack retrieval in the event they are lost.
* The command accepts a name and id, if those match up it spawns a Medium Backpack
* with the correct lore set in the sender's inventory.
*
* @author Sfiguz7
*
* @see RestoredBackpack
*
*/
class BackpackCommand extends SubCommand {
@ParametersAreNonnullByDefault
BackpackCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "backpack", false);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -19,6 +21,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
*/
class ChargeCommand extends SubCommand {
@ParametersAreNonnullByDefault
ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "charge", false);
}
@ -31,10 +34,11 @@ class ChargeCommand extends SubCommand {
@Override
public void onExecute(CommandSender sender, String[] args) {
if (sender instanceof Player) {
if (sender.hasPermission("slimefun.charge.command")) {
if (sender.hasPermission("slimefun.command.charge")) {
Player p = (Player) sender;
ItemStack item = p.getInventory().getItemInMainHand();
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
if (slimefunItem instanceof Rechargeable) {
Rechargeable rechargeableItem = (Rechargeable) slimefunItem;
rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item));

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -10,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class CheatCommand extends SubCommand {
@ParametersAreNonnullByDefault
CheatCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "cheat", false);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -10,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class DebugFishCommand extends SubCommand {
@ParametersAreNonnullByDefault
DebugFishCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "debug_fish", true);
}

View File

@ -16,12 +16,15 @@ import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import javax.annotation.ParametersAreNonnullByDefault;
class GiveCommand extends SubCommand {
private static final String PLACEHOLDER_PLAYER = "%player%";
private static final String PLACEHOLDER_ITEM = "%item%";
private static final String PLACEHOLDER_AMOUNT = "%amount%";
@ParametersAreNonnullByDefault
GiveCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "give", false);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -11,6 +13,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class GuideCommand extends SubCommand {
@ParametersAreNonnullByDefault
GuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "guide", false);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
@ -8,6 +10,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class HelpCommand extends SubCommand {
@ParametersAreNonnullByDefault
HelpCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "help", false);
}

View File

@ -13,6 +13,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class OpenGuideCommand extends SubCommand {
@ParametersAreNonnullByDefault
OpenGuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "open_guide", false);
}

View File

@ -3,6 +3,9 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Optional;
import java.util.function.UnaryOperator;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,6 +21,7 @@ class ResearchCommand extends SubCommand {
private static final String PLACEHOLDER_PLAYER = "%player%";
private static final String PLACEHOLDER_RESEARCH = "%research%";
@ParametersAreNonnullByDefault
ResearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "research", false);
}
@ -57,6 +61,7 @@ class ResearchCommand extends SubCommand {
}
}
@ParametersAreNonnullByDefault
private void giveResearch(CommandSender sender, Player p, String input) {
Optional<Research> research = getResearchFromString(input);
@ -70,6 +75,7 @@ class ResearchCommand extends SubCommand {
}
}
@ParametersAreNonnullByDefault
private void researchAll(CommandSender sender, PlayerProfile profile, Player p) {
for (Research res : SlimefunPlugin.getRegistry().getResearches()) {
if (!profile.hasUnlocked(res)) {
@ -80,6 +86,7 @@ class ResearchCommand extends SubCommand {
}
}
@ParametersAreNonnullByDefault
private void reset(PlayerProfile profile, Player p) {
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
profile.setResearched(research, false);
@ -88,7 +95,8 @@ class ResearchCommand extends SubCommand {
SlimefunPlugin.getLocalization().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()));
}
private Optional<Research> getResearchFromString(String input) {
@Nonnull
private Optional<Research> getResearchFromString(@Nonnull String input) {
if (!input.contains(":")) {
return Optional.empty();
}

View File

@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Arrays;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -14,6 +16,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class SearchCommand extends SubCommand {
@ParametersAreNonnullByDefault
SearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "search", false);
}

View File

@ -4,6 +4,8 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nonnull;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -20,7 +22,8 @@ public final class SlimefunSubCommands {
private SlimefunSubCommands() {}
public static Collection<SubCommand> getAllCommands(SlimefunCommand cmd) {
@Nonnull
public static Collection<SubCommand> getAllCommands(@Nonnull SlimefunCommand cmd) {
SlimefunPlugin plugin = cmd.getPlugin();
List<SubCommand> commands = new LinkedList<>();

View File

@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Optional;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
@ -14,6 +16,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class StatsCommand extends SubCommand {
@ParametersAreNonnullByDefault
StatsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "stats", false);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.BlockFace;
@ -12,6 +14,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class TeleporterCommand extends SubCommand {
@ParametersAreNonnullByDefault
TeleporterCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "teleporter", false);
}

View File

@ -24,6 +24,7 @@ class TimingsCommand extends SubCommand {
private static final String FLAG_PREFIX = "--";
private final Set<String> flags = new HashSet<>(Arrays.asList("verbose"));
@ParametersAreNonnullByDefault
TimingsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "timings", false);
}

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -29,6 +30,7 @@ import net.md_5.bungee.api.chat.hover.content.Text;
*/
class VersionsCommand extends SubCommand {
@ParametersAreNonnullByDefault
VersionsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd, "versions", false);
}