mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-06 19:18:07 +01:00
Add ShortcutCommand
This commit is contained in:
parent
52e10672d0
commit
0fc18aca2b
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.Command;
|
||||
|
||||
import at.pcgamingfreaks.Command.HelpData;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.ItemShortcut;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Permissions;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ShortcutCommand extends MinepacksCommand
|
||||
{
|
||||
private final ItemShortcut itemShortcut;
|
||||
|
||||
public ShortcutCommand(Minepacks plugin, final @NotNull ItemShortcut itemShortcut)
|
||||
{
|
||||
super(plugin, "shortcut", plugin.getLanguage().getTranslated("Commands.Description.Shortcut"), Permissions.USE, true, plugin.getLanguage().getCommandAliases("Shortcut"));
|
||||
this.itemShortcut = itemShortcut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String[] args)
|
||||
{
|
||||
itemShortcut.addItem((Player) sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String[] args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<HelpData> getHelp(@NotNull CommandSender requester)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -91,7 +91,7 @@ public boolean isItemShortcut(final @Nullable ItemStack stack)
|
||||
return itemDisplayName != null && itemNameNoReset.equals(itemDisplayName.replace(ChatColor.RESET.toString(), ""));
|
||||
}
|
||||
|
||||
private void addItem(Player player)
|
||||
public void addItem(Player player)
|
||||
{
|
||||
if(player.hasPermission(Permissions.USE))
|
||||
{
|
||||
|
@ -27,6 +27,7 @@
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.*;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Command.CommandManager;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Command.InventoryClearCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Command.ShortcutCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Config;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Database;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Language;
|
||||
@ -220,6 +221,7 @@ private void load()
|
||||
{
|
||||
shortcut = new ItemShortcut(this);
|
||||
pluginManager.registerEvents(shortcut, this);
|
||||
commandManager.registerSubCommand(new ShortcutCommand(this, shortcut));
|
||||
}
|
||||
else shortcut = null;
|
||||
if(config.isWorldWhitelistMode()) pluginManager.registerEvents(new WorldBlacklistUpdater(this), this);
|
||||
|
Loading…
Reference in New Issue
Block a user