This commit is contained in:
James Peters 2020-12-30 16:27:14 +00:00
parent 83840b8dba
commit 08940e7ef9
7 changed files with 394 additions and 271 deletions

View File

@ -45,6 +45,11 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
</repositories>
<dependencies>
@ -68,7 +73,15 @@
<version>1.2.3-SNAPSHOT</version>
</dependency>
<!-- <dependency>-->
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>fr.minuskube.inv</groupId>-->
<!-- <artifactId>smart-invs</artifactId>-->
<!-- <version>1.2.7</version>-->
@ -86,6 +99,16 @@
<version>master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId> <!-- Don't forget to replace this -->
<version>0.5.0-SNAPSHOT</version> <!-- Replace this as well -->
<!-- Example Platform/Version
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
-->
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
@ -175,6 +198,14 @@
<pattern>com.github.WesJD.AnvilGUI</pattern>
<shadedPattern>com.jamesdpeters.minecraft.chests</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>com.jamesdpeters.minecraft.chests.acf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>com.jamesdpeters.minecraft.chests.locales</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>

View File

@ -1,5 +1,6 @@
package com.jamesdpeters.minecraft.chests;
import co.aikar.commands.PaperCommandManager;
import com.jamesdpeters.minecraft.chests.api.ApiSpecific;
import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand;
import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand;
@ -98,10 +99,31 @@ public class ChestsPlusPlus extends JavaPlugin {
Api.register(this);
ApiSpecific.init();
PaperCommandManager manager = new PaperCommandManager(this);
manager.registerCommand(new ChestLinkCommand());
manager.registerCommand(new AutoCraftCommand());
manager.registerCommand(new ChestsPlusPlusCommand());
//Register commands
new ChestLinkCommand().register(this);
new AutoCraftCommand().register(this);
new ChestsPlusPlusCommand().register(this);
// new ChestLinkCommand().register(this);
// new AutoCraftCommand().register(this);
// new ChestsPlusPlusCommand().register(this);
// SimpleCommandMap commandMap = new SimpleCommandMap(getServer());
// Check for disabled aliases
// PluginConfig.DISABLED_ALIASES.get().forEach(alias -> {
// getDescription().getCommands().forEach((commandName, map) -> {
// PluginCommand command = getCommand(commandName);
// List<String> aliases = command.getAliases();
// // Check if command contains the alias before removing.
// if(aliases.contains(alias)) {
// System.out.println("Removed command? : "+command.unregister(commandMap));
// aliases.remove(alias);
// command.setAliases(aliases);
// command.register(commandMap);
// }
// });
// });
//Load storage
SpigotConfig.load(this);

View File

@ -1,29 +1,27 @@
package com.jamesdpeters.minecraft.chests.commands;
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.annotation.CatchUnknown;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.HelpCommand;
import co.aikar.commands.annotation.Subcommand;
import com.jamesdpeters.minecraft.chests.lang.Message;
import com.jamesdpeters.minecraft.chests.menus.ChestLinkMenu;
import com.jamesdpeters.minecraft.chests.menus.PartyMenu;
import com.jamesdpeters.minecraft.chests.misc.Messages;
import com.jamesdpeters.minecraft.chests.misc.Permissions;
import com.jamesdpeters.minecraft.chests.misc.Utils;
import com.jamesdpeters.minecraft.chests.serialize.Config;
import com.jamesdpeters.minecraft.chests.sort.SortMethod;
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ChestLinkCommand extends ServerCommand {
@CommandAlias("chestlink|cl")
public class ChestLinkCommand extends BaseCommand {
private enum OPTIONS {
ADD("/chestlink add <group>", Message.COMMAND_CHESTLINK_ADD.getString()),
@ -57,264 +55,287 @@ public class ChestLinkCommand extends ServerCommand {
}
@Override
public String getCommandName() {
return "chestlink";
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only a player can use this command");
return false;
}
Player player = (Player) sender;
if (args != null && args.length > 0) {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case HELP:
for (OPTIONS option : OPTIONS.values()) {
if (!option.equals(OPTIONS.HELP)) {
player.sendMessage(ChatColor.RED + option.commandHelp);
player.sendMessage(ChatColor.WHITE + option.description);
}
}
return true;
case ADD:
if (args.length > 1) {
if (sender.hasPermission(Permissions.ADD) && !Utils.isBlacklistedWorld(player.getWorld())) {
Block targetBlock = player.getTargetBlockExact(5);
if (targetBlock != null)
Config.getChestLink().createStorage(player, targetBlock, args[1], true);
else Config.getChestLink().getMessages().mustLookAtBlock(player);
return true;
} else {
Messages.NO_PERMISSION(player);
return true;
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.ADD.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.ADD.description);
return true;
}
case OPEN:
if (args.length > 1) {
if (sender.hasPermission(Permissions.OPEN) && sender.hasPermission(Permissions.OPEN_REMOTE) && !Utils.isBlacklistedWorld(player.getWorld())) {
ChestLinkStorage invs;
if (args[1].contains(":")) {
invs = Config.getChestLink().getStorage(player, args[1]);
} else {
invs = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
}
if (invs != null) Utils.openChestInventory(player, invs.getInventory());
return true;
} else {
Messages.NO_PERMISSION(player);
return true;
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.OPEN.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.OPEN.description);
return true;
}
case MENU:
if (sender.hasPermission(Permissions.MENU) && !Utils.isBlacklistedWorld(player.getWorld())) {
ChestLinkMenu.getMenu(player).open(player);
return true;
} else {
Messages.NO_PERMISSION(player);
return true;
}
case LIST:
Config.getChestLink().getMessages().listStorageGroups(player);
return true;
case REMOVE:
if (args.length > 1) {
if (sender.hasPermission(Permissions.REMOVE)) {
Config.getChestLink().removeStorage(player, args[1]);
return true;
} else {
Messages.NO_PERMISSION(player);
return true;
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.REMOVE.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.REMOVE.description);
return true;
}
case SORT:
if (args.length > 1) {
if (sender.hasPermission(Permissions.SORT)) {
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
if (storage != null) {
storage.setSortMethod(Enum.valueOf(SortMethod.class, args[2]));
storage.sort();
Messages.SORT(player, storage);
}
return true;
} else {
Messages.NO_PERMISSION(player);
return true;
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.SORT.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.SORT.description);
return true;
}
case MEMBER:
return memberCommand(args, sender);
case SETPUBLIC: {
if (args.length > 2) {
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
if (storage != null) {
boolean setpublic = Boolean.parseBoolean(args[2]);
storage.setPublic(setpublic);
storage.getStorageType().getMessages().setPublic(player, storage);
return true;
} else {
Bukkit.broadcastMessage("Storage null");
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.SETPUBLIC.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.SETPUBLIC.description);
return true;
}
}
case RENAME: {
if (args.length > 2) {
String group = args[1];
String newIdentifier = args[2];
if (!Config.getChestLink().renameStorage(player, group, newIdentifier)) {
player.sendMessage(ChatColor.RED + OPTIONS.RENAME.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.RENAME.description);
}
return true;
}
}
case PARTY:
PartyMenu.getMenu(player).getMenu().open(player);
return true;
}
} catch (IllegalArgumentException exception) {
return false;
@Subcommand("help")
@CatchUnknown @Default
@HelpCommand
public void doHelp(CommandIssuer issuer, String... args) {
for (OPTIONS option : OPTIONS.values()) {
if (!option.equals(OPTIONS.HELP)) {
issuer.sendMessage(ChatColor.RED + option.commandHelp);
issuer.sendMessage(ChatColor.WHITE + option.description);
}
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if ((sender instanceof Player)) {
Player player = (Player) sender;
if (args.length == 1) {
return OPTIONS.valuesList;
}
if (args.length == 2) {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case ADD:
case OPEN:
return Config.getChestLink().getOpenableStorageList(player, args[1]);
case REMOVE:
case SORT:
case RENAME:
return Config.getChestLink().getStorageList(player, args[1]);
case MEMBER:
return Stream.of("add", "remove", "list", "add-to-all", "remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
}
} catch (IllegalArgumentException ignored) {
}
}
if (args.length == 3) {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case MEMBER:
if (args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
if (args[1].equals("remove-from-all"))
return Utils.filterList(Utils.getAllPlayers(), args[2]);
return Config.getChestLink().getStorageList(player, args[2]);
case SORT:
return SortMethod.valuesList;
}
} catch (IllegalArgumentException ignored) {
}
}
if (args.length == 4) {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case MEMBER:
return Utils.filterList(Utils.getAllPlayers(), args[3]);
}
} catch (IllegalArgumentException ignored) {
}
}
return Collections.singletonList("");
@Subcommand("add")
@CommandPermission(Permissions.ADD)
public static void add(Player player, String... args){
if (!Utils.isBlacklistedWorld(player.getWorld())) {
Block targetBlock = player.getTargetBlockExact(5);
if (targetBlock != null)
Config.getChestLink().createStorage(player, targetBlock, args[1], true);
else Config.getChestLink().getMessages().mustLookAtBlock(player);
}
return null;
}
private static boolean memberCommand(String[] args, CommandSender sender) {
Player player = (Player) sender;
if (args.length > 3) {
if (sender.hasPermission(Permissions.MEMBER)) {
if (args[1].equals("add")) {
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
if (storage != null && storage.addMember(toAdd))
storage.getStorageType().getMessages().addedMember(player, storage, args[3]);
else Config.getChestLink().getMessages().unableToAddMember(player, args[3]);
});
return true;
} else if (args[1].equals("remove")) {
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
if (storage != null && storage.removeMember(toAdd))
storage.getStorageType().getMessages().removedMember(player, storage, args[3]);
else Config.getChestLink().getMessages().unableToRemoveMember(player, args[3]);
});
return true;
} else {
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
}
} else {
Messages.NO_PERMISSION(player);
}
return true;
} else if (args.length > 2) {
if (sender.hasPermission(Permissions.MEMBER)) {
if (args[1].equals("list")) {
ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
if (storage != null) {
storage.getStorageType().getMessages().listMembers(player, storage);
return true;
}
} else if (args[1].equals("add-to-all")) {
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.addMember(toAdd));
Config.getChestLink().getMessages().addMemberToAll(player, toAdd);
});
return true;
} else if (args[1].equals("remove-from-all")) {
Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.removeMember(toAdd));
Config.getChestLink().getMessages().removeMemberFromAll(player, toAdd);
});
return true;
}
}
} else {
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
return true;
}
return false;
}
// @Override
// public String getCommandName() {
// return "chestlink";
// }
//
// @Override
// public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// if (!(sender instanceof Player)) {
// sender.sendMessage("Only a player can use this command");
// return false;
// }
//
// Player player = (Player) sender;
// if (args != null && args.length > 0) {
// try {
// switch (OPTIONS.valueOf(args[0].toUpperCase())) {
// case HELP:
// for (OPTIONS option : OPTIONS.values()) {
// if (!option.equals(OPTIONS.HELP)) {
// player.sendMessage(ChatColor.RED + option.commandHelp);
// player.sendMessage(ChatColor.WHITE + option.description);
// }
// }
// return true;
// case ADD:
// if (args.length > 1) {
// if (sender.hasPermission(Permissions.ADD) && !Utils.isBlacklistedWorld(player.getWorld())) {
// Block targetBlock = player.getTargetBlockExact(5);
// if (targetBlock != null)
// Config.getChestLink().createStorage(player, targetBlock, args[1], true);
// else Config.getChestLink().getMessages().mustLookAtBlock(player);
// return true;
// } else {
// Messages.NO_PERMISSION(player);
// return true;
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.ADD.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.ADD.description);
// return true;
// }
// case OPEN:
// if (args.length > 1) {
// if (sender.hasPermission(Permissions.OPEN) && sender.hasPermission(Permissions.OPEN_REMOTE) && !Utils.isBlacklistedWorld(player.getWorld())) {
// ChestLinkStorage invs;
// if (args[1].contains(":")) {
// invs = Config.getChestLink().getStorage(player, args[1]);
// } else {
// invs = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
// }
// if (invs != null) Utils.openChestInventory(player, invs.getInventory());
// return true;
// } else {
// Messages.NO_PERMISSION(player);
// return true;
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.OPEN.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.OPEN.description);
// return true;
// }
// case MENU:
// if (sender.hasPermission(Permissions.MENU) && !Utils.isBlacklistedWorld(player.getWorld())) {
// ChestLinkMenu.getMenu(player).open(player);
// return true;
// } else {
// Messages.NO_PERMISSION(player);
// return true;
// }
// case LIST:
// Config.getChestLink().getMessages().listStorageGroups(player);
// return true;
// case REMOVE:
// if (args.length > 1) {
// if (sender.hasPermission(Permissions.REMOVE)) {
// Config.getChestLink().removeStorage(player, args[1]);
// return true;
// } else {
// Messages.NO_PERMISSION(player);
// return true;
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.REMOVE.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.REMOVE.description);
// return true;
// }
// case SORT:
// if (args.length > 1) {
// if (sender.hasPermission(Permissions.SORT)) {
// ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
// if (storage != null) {
// storage.setSortMethod(Enum.valueOf(SortMethod.class, args[2]));
// storage.sort();
// Messages.SORT(player, storage);
// }
// return true;
// } else {
// Messages.NO_PERMISSION(player);
// return true;
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.SORT.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.SORT.description);
// return true;
// }
// case MEMBER:
// return memberCommand(args, sender);
// case SETPUBLIC: {
// if (args.length > 2) {
// ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[1]);
// if (storage != null) {
// boolean setpublic = Boolean.parseBoolean(args[2]);
// storage.setPublic(setpublic);
// storage.getStorageType().getMessages().setPublic(player, storage);
// return true;
// } else {
// Bukkit.broadcastMessage("Storage null");
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.SETPUBLIC.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.SETPUBLIC.description);
// return true;
// }
// }
// case RENAME: {
// if (args.length > 2) {
// String group = args[1];
// String newIdentifier = args[2];
// if (!Config.getChestLink().renameStorage(player, group, newIdentifier)) {
// player.sendMessage(ChatColor.RED + OPTIONS.RENAME.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.RENAME.description);
// }
// return true;
// }
// }
// case PARTY:
// PartyMenu.getMenu(player).getMenu().open(player);
// return true;
// }
// } catch (IllegalArgumentException exception) {
// return false;
// }
// }
//
// return false;
// }
//
// @Override
// public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
// if ((sender instanceof Player)) {
// Player player = (Player) sender;
//
// if (args.length == 1) {
// return OPTIONS.valuesList;
// }
// if (args.length == 2) {
// try {
// switch (OPTIONS.valueOf(args[0].toUpperCase())) {
// case ADD:
// case OPEN:
// return Config.getChestLink().getOpenableStorageList(player, args[1]);
// case REMOVE:
// case SORT:
// case RENAME:
// return Config.getChestLink().getStorageList(player, args[1]);
// case MEMBER:
// return Stream.of("add", "remove", "list", "add-to-all", "remove-from-all").filter(s -> s.contains(args[1])).collect(Collectors.toList());
// }
// } catch (IllegalArgumentException ignored) {
// }
// }
// if (args.length == 3) {
// try {
// switch (OPTIONS.valueOf(args[0].toUpperCase())) {
// case MEMBER:
// if (args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
// if (args[1].equals("remove-from-all"))
// return Utils.filterList(Utils.getAllPlayers(), args[2]);
// return Config.getChestLink().getStorageList(player, args[2]);
// case SORT:
// return SortMethod.valuesList;
// }
// } catch (IllegalArgumentException ignored) {
// }
// }
// if (args.length == 4) {
// try {
// switch (OPTIONS.valueOf(args[0].toUpperCase())) {
// case MEMBER:
// return Utils.filterList(Utils.getAllPlayers(), args[3]);
// }
// } catch (IllegalArgumentException ignored) {
// }
// }
// return Collections.singletonList("");
// }
// return null;
// }
//
// private static boolean memberCommand(String[] args, CommandSender sender) {
// Player player = (Player) sender;
// if (args.length > 3) {
// if (sender.hasPermission(Permissions.MEMBER)) {
// if (args[1].equals("add")) {
// Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
// OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
// ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
// if (storage != null && storage.addMember(toAdd))
// storage.getStorageType().getMessages().addedMember(player, storage, args[3]);
// else Config.getChestLink().getMessages().unableToAddMember(player, args[3]);
// });
// return true;
// } else if (args[1].equals("remove")) {
// Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
// OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[3]);
// ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
// if (storage != null && storage.removeMember(toAdd))
// storage.getStorageType().getMessages().removedMember(player, storage, args[3]);
// else Config.getChestLink().getMessages().unableToRemoveMember(player, args[3]);
// });
// return true;
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
// }
// } else {
// Messages.NO_PERMISSION(player);
// }
// return true;
// } else if (args.length > 2) {
// if (sender.hasPermission(Permissions.MEMBER)) {
// if (args[1].equals("list")) {
// ChestLinkStorage storage = Config.getChestLink().getStorage(player.getUniqueId(), args[2]);
// if (storage != null) {
// storage.getStorageType().getMessages().listMembers(player, storage);
// return true;
// }
// } else if (args[1].equals("add-to-all")) {
// Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
// OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
// Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.addMember(toAdd));
// Config.getChestLink().getMessages().addMemberToAll(player, toAdd);
// });
// return true;
// } else if (args[1].equals("remove-from-all")) {
// Bukkit.getScheduler().runTaskAsynchronously(ChestsPlusPlus.PLUGIN, () -> {
// OfflinePlayer toAdd = Bukkit.getOfflinePlayer(args[2]);
// Config.getChestLink().getStorageMap(player.getUniqueId()).forEach((s, storage) -> storage.removeMember(toAdd));
// Config.getChestLink().getMessages().removeMemberFromAll(player, toAdd);
// });
// return true;
// }
// }
// } else {
// player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.commandHelp);
// player.sendMessage(ChatColor.RED + OPTIONS.MEMBER.description);
// return true;
// }
// return false;
// }
}

View File

@ -1,18 +1,20 @@
package com.jamesdpeters.minecraft.chests.commands;
import co.aikar.commands.BaseCommand;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class ServerCommand implements CommandExecutor, TabCompleter {
public abstract class ServerCommand extends BaseCommand implements CommandExecutor, TabCompleter {
/**
* @param plugin Registers command to given plugin.
*/
public void register(JavaPlugin plugin) {
PluginCommand command = plugin.getCommand(getCommandName());
if (command != null) {
if(command != null) {
command.setExecutor(this);
command.setTabCompleter(this);
}

View File

@ -0,0 +1,41 @@
package com.jamesdpeters.minecraft.chests.filters;
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class ExtraTag implements Tag<Material> {
public static final Tag<Material> DYES = new ExtraTag("dyes", Material.BLACK_DYE, Material.RED_DYE, Material.GREEN_DYE, Material.BROWN_DYE, Material.BLUE_DYE, Material.PURPLE_DYE, Material.CYAN_DYE, Material.LIGHT_GRAY_DYE, Material.GRAY_DYE, Material.PINK_DYE, Material.LIME_DYE, Material.YELLOW_DYE, Material.LIGHT_BLUE_DYE, Material.MAGENTA_DYE, Material.ORANGE_DYE, Material.WHITE_DYE);
public static final Tag<Material> BEDS = new ExtraTag("beds", Material.BLACK_BED, Material.RED_BED, Material.GREEN_BED, Material.BROWN_BED, Material.BLUE_BED, Material.PURPLE_BED, Material.CYAN_BED, Material.LIGHT_GRAY_BED, Material.GRAY_BED, Material.PINK_BED, Material.LIME_BED, Material.YELLOW_BED, Material.LIGHT_BLUE_BED, Material.MAGENTA_BED, Material.ORANGE_BED, Material.WHITE_BED);
NamespacedKey namespacedKey;
Set<Material> values;
public ExtraTag(String tag, Material... materials){
namespacedKey = new NamespacedKey(ChestsPlusPlus.PLUGIN, tag);
values = new HashSet<>(Arrays.asList(materials));
}
@Override
public boolean isTagged(@NotNull Material item) {
return values.contains(item);
}
@Override
public Set<Material> getValues() {
return values;
}
@Override
public NamespacedKey getKey() {
return namespacedKey;
}
}

View File

@ -59,6 +59,8 @@ public class ItemTypeUtil {
tags.add(Tag.ITEMS_MUSIC_DISCS);
tags.add(Tag.ITEMS_COALS);
tags.add(Tag.ITEMS_ARROWS);
tags.add(ExtraTag.DYES);
}
public static boolean isSimilarTag(ItemStack is1, ItemStack is2){

View File

@ -5,6 +5,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -39,6 +40,9 @@ public class PluginConfig {
public final static ListValue<String> WORLD_BLACKLIST = new ListValue<>("world-blacklist", String.class, Collections.singletonList(""));
public final static Value<String> LANG_FILE = new Value<>("language-file", String.class, "default");
public final static ListValue<String> DISABLED_ALIASES = new ListValue<>("disabled-aliases", String.class, Arrays.asList("#cl", "#ac"));
/**
* Loads this @{@link Plugin}'s Config and adds default values if they don't exist.
*