mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-25 11:46:45 +01:00
CommandManager updated to v2
This commit is contained in:
parent
8d2f36bbdf
commit
1a9520033a
@ -19,5 +19,7 @@
|
|||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Lib1" level="project" />
|
<orderEntry type="library" name="Lib1" level="project" />
|
||||||
<orderEntry type="library" name="spigot-1.132" level="project" />
|
<orderEntry type="library" name="spigot-1.132" level="project" />
|
||||||
|
<orderEntry type="library" name="spigot-1.13.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Lib" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -22,5 +22,7 @@
|
|||||||
<orderEntry type="library" name="spigot-1.131" level="project" />
|
<orderEntry type="library" name="spigot-1.131" level="project" />
|
||||||
<orderEntry type="library" name="spigot-1.132" level="project" />
|
<orderEntry type="library" name="spigot-1.132" level="project" />
|
||||||
<orderEntry type="module" module-name="EpicHoppers-API" />
|
<orderEntry type="module" module-name="EpicHoppers-API" />
|
||||||
|
<orderEntry type="library" name="spigot-1.13.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Lib" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -66,6 +66,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
|||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
private HopperManager hopperManager;
|
private HopperManager hopperManager;
|
||||||
|
private CommandManager commandManager;
|
||||||
private LevelManager levelManager;
|
private LevelManager levelManager;
|
||||||
private BoostManager boostManager;
|
private BoostManager boostManager;
|
||||||
private PlayerDataManager playerDataManager;
|
private PlayerDataManager playerDataManager;
|
||||||
@ -107,19 +108,20 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
|||||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
||||||
|
|
||||||
settingsManager = new SettingsManager(this);
|
settingsManager = new SettingsManager(this);
|
||||||
boostManager = new BoostManager();
|
|
||||||
setupConfig();
|
setupConfig();
|
||||||
enchantmentHandler = new EnchantmentHandler();
|
enchantmentHandler = new EnchantmentHandler();
|
||||||
playerDataManager = new PlayerDataManager();
|
|
||||||
|
|
||||||
// Locales
|
// Locales
|
||||||
Locale.init(this);
|
Locale.init(this);
|
||||||
Locale.saveDefaultLocale("en_US");
|
Locale.saveDefaultLocale("en_US");
|
||||||
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
||||||
|
|
||||||
loadLevelManager();
|
|
||||||
|
|
||||||
hopperManager = new EHopperManager();
|
hopperManager = new EHopperManager();
|
||||||
|
playerDataManager = new PlayerDataManager();
|
||||||
|
boostManager = new BoostManager();
|
||||||
|
this.commandManager = new CommandManager(this);
|
||||||
|
|
||||||
|
loadLevelManager();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register hoppers into HopperManger from configuration
|
* Register hoppers into HopperManger from configuration
|
||||||
@ -197,9 +199,6 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
|||||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||||
pluginManager.registerEvents(new InventoryListeners(this), this);
|
pluginManager.registerEvents(new InventoryListeners(this), this);
|
||||||
|
|
||||||
// Command registration
|
|
||||||
this.getCommand("EpicHoppers").setExecutor(new CommandManager(this));
|
|
||||||
|
|
||||||
// Register default hooks
|
// Register default hooks
|
||||||
if (pluginManager.isPluginEnabled("ASkyBlock")) this.register(HookASkyBlock::new);
|
if (pluginManager.isPluginEnabled("ASkyBlock")) this.register(HookASkyBlock::new);
|
||||||
if (pluginManager.isPluginEnabled("FactionsFramework")) this.register(HookFactions::new);
|
if (pluginManager.isPluginEnabled("FactionsFramework")) this.register(HookFactions::new);
|
||||||
@ -435,6 +434,10 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
|||||||
return boostManager;
|
return boostManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandManager getCommandManager() {
|
||||||
|
return commandManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LevelManager getLevelManager() {
|
public LevelManager getLevelManager() {
|
||||||
return levelManager;
|
return levelManager;
|
||||||
|
@ -5,30 +5,37 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
public abstract class AbstractCommand {
|
public abstract class AbstractCommand {
|
||||||
|
|
||||||
private final AbstractCommand parent;
|
public enum ReturnType { SUCCESS, FAILURE, SYNTAX_ERROR }
|
||||||
|
|
||||||
private final String permissionNode;
|
private final AbstractCommand parent;
|
||||||
|
|
||||||
private final String command;
|
private final String command;
|
||||||
|
|
||||||
protected AbstractCommand(String command, String permissionNode, AbstractCommand parent) {
|
private final boolean noConsole;
|
||||||
|
|
||||||
|
protected AbstractCommand(String command, AbstractCommand parent, boolean noConsole) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.permissionNode = permissionNode;
|
this.noConsole = noConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractCommand getParent() {
|
public AbstractCommand getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getCommand() {
|
public String getCommand() {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionNode() {
|
public boolean isNoConsole() {
|
||||||
return permissionNode;
|
return noConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args);
|
protected abstract ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args);
|
||||||
|
|
||||||
|
public abstract String getPermissionNode();
|
||||||
|
|
||||||
|
public abstract String getSyntax();
|
||||||
|
|
||||||
|
public abstract String getDescription();
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,10 @@ import com.songoda.epichoppers.command.commands.*;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandManager implements CommandExecutor {
|
public class CommandManager implements CommandExecutor {
|
||||||
@ -19,6 +21,8 @@ public class CommandManager implements CommandExecutor {
|
|||||||
public CommandManager(EpicHoppersPlugin instance) {
|
public CommandManager(EpicHoppersPlugin instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
|
|
||||||
|
instance.getCommand("EpicHoppers").setExecutor(this);
|
||||||
|
|
||||||
AbstractCommand commandEpicHoppers = addCommand(new CommandEpicHoppers());
|
AbstractCommand commandEpicHoppers = addCommand(new CommandEpicHoppers());
|
||||||
|
|
||||||
addCommand(new CommandReload(commandEpicHoppers));
|
addCommand(new CommandReload(commandEpicHoppers));
|
||||||
@ -38,13 +42,13 @@ public class CommandManager implements CommandExecutor {
|
|||||||
for (AbstractCommand abstractCommand : commands) {
|
for (AbstractCommand abstractCommand : commands) {
|
||||||
if (abstractCommand.getCommand().equalsIgnoreCase(command.getName())) {
|
if (abstractCommand.getCommand().equalsIgnoreCase(command.getName())) {
|
||||||
if (strings.length == 0) {
|
if (strings.length == 0) {
|
||||||
processPerms(abstractCommand, commandSender, strings);
|
processRequirements(abstractCommand, commandSender, strings);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) {
|
} else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) {
|
||||||
String cmd = strings[0];
|
String cmd = strings[0];
|
||||||
if (cmd.equalsIgnoreCase(abstractCommand.getCommand())) {
|
if (cmd.equalsIgnoreCase(abstractCommand.getCommand())) {
|
||||||
processPerms(abstractCommand, commandSender, strings);
|
processRequirements(abstractCommand, commandSender, strings);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,12 +57,23 @@ public class CommandManager implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processPerms(AbstractCommand command, CommandSender sender, String[] strings) {
|
private void processRequirements(AbstractCommand command, CommandSender sender, String[] strings) {
|
||||||
|
if (!(sender instanceof Player) && command.isNoConsole()) {
|
||||||
|
sender.sendMessage("You must be a player to use this command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||||
command.runCommand(instance, sender, strings);
|
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
|
||||||
|
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
|
||||||
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cInvalid Syntax!"));
|
||||||
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
sender.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AbstractCommand> getCommands() {
|
||||||
|
return Collections.unmodifiableList(commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,19 +10,38 @@ import org.bukkit.entity.Player;
|
|||||||
public class CommandBook extends AbstractCommand {
|
public class CommandBook extends AbstractCommand {
|
||||||
|
|
||||||
public CommandBook(AbstractCommand parent) {
|
public CommandBook(AbstractCommand parent) {
|
||||||
super("book", "epichoppers.admin", parent);
|
super("book", parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player) {
|
||||||
((Player) sender).getInventory().addItem(instance.enchantmentHandler.getbook());
|
((Player) sender).getInventory().addItem(instance.enchantmentHandler.getbook());
|
||||||
|
return ReturnType.SUCCESS;
|
||||||
|
}
|
||||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat username does not exist, or the user is not online!"));
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat username does not exist, or the user is not online!"));
|
||||||
|
return ReturnType.FAILURE;
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(instance.enchantmentHandler.getbook());
|
Bukkit.getPlayerExact(args[1]).getInventory().addItem(instance.enchantmentHandler.getbook());
|
||||||
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return ReturnType.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "epichoppers.admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/eh book [player]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Gives Sync Touch book to you or a player.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,20 @@ import java.util.Date;
|
|||||||
public class CommandBoost extends AbstractCommand {
|
public class CommandBoost extends AbstractCommand {
|
||||||
|
|
||||||
public CommandBoost(AbstractCommand parent) {
|
public CommandBoost(AbstractCommand parent) {
|
||||||
super("boost", "epichoppers.admin", parent);
|
super("boost", parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
if (args.length >= 3) {
|
if (args.length < 3) {
|
||||||
|
return ReturnType.SYNTAX_ERROR;
|
||||||
|
}
|
||||||
if (Bukkit.getPlayer(args[1]) == null) {
|
if (Bukkit.getPlayer(args[1]) == null) {
|
||||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&cThat player does not exist..."));
|
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&cThat player does not exist..."));
|
||||||
|
return ReturnType.FAILURE;
|
||||||
} else if (!AMath.isInt(args[2])) {
|
} else if (!AMath.isInt(args[2])) {
|
||||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&6" + args[2] + " &7is not a number..."));
|
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&6" + args[2] + " &7is not a number..."));
|
||||||
|
return ReturnType.FAILURE;
|
||||||
} else {
|
} else {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
@ -50,7 +54,7 @@ public class CommandBoost extends AbstractCommand {
|
|||||||
time = " &7for &6" + arr2[1] + " years&7.";
|
time = " &7for &6" + arr2[1] + " years&7.";
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7" + args[3] + " &7is invalid."));
|
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7" + args[3] + " &7is invalid."));
|
||||||
return true;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.add(Calendar.YEAR, 10);
|
c.add(Calendar.YEAR, 10);
|
||||||
@ -60,9 +64,21 @@ public class CommandBoost extends AbstractCommand {
|
|||||||
instance.getBoostManager().addBoostToPlayer(boostData);
|
instance.getBoostManager().addBoostToPlayer(boostData);
|
||||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Successfully boosted &6" + Bukkit.getPlayer(args[1]).getName() + "'s &7hoppers transfer rates by &6" + args[2] + "x" + time));
|
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Successfully boosted &6" + Bukkit.getPlayer(args[1]).getName() + "'s &7hoppers transfer rates by &6" + args[2] + "x" + time));
|
||||||
}
|
}
|
||||||
} else {
|
return ReturnType.FAILURE;
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7Syntax error..."));
|
}
|
||||||
}
|
|
||||||
return false;
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "epichoppers.admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/es boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "This allows you to boost a players hoppers be a multiplier (Put 2 for double, 3 for triple and so on).";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,25 +8,37 @@ import org.bukkit.command.CommandSender;
|
|||||||
public class CommandEpicHoppers extends AbstractCommand {
|
public class CommandEpicHoppers extends AbstractCommand {
|
||||||
|
|
||||||
public CommandEpicHoppers() {
|
public CommandEpicHoppers() {
|
||||||
super("EpicHoppers", null, null);
|
super("EpicHoppers", null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(TextComponent.formatText("&f>>&m------------&6&l EpicHoppers Help &f&m------------&f<<"));
|
sender.sendMessage(TextComponent.formatText("&f>>&m------------&6&l EpicHoppers Help &f&m------------&f<<"));
|
||||||
sender.sendMessage(TextComponent.formatText(" &7Version " + instance.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
sender.sendMessage(TextComponent.formatText(" &7Version " + instance.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||||
|
|
||||||
sender.sendMessage(TextComponent.formatText("&6/EpicHoppers&7 - Displays this page."));
|
for (AbstractCommand command : instance.getCommandManager().getCommands()) {
|
||||||
if (sender.hasPermission("epichoppers.admin")) {
|
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||||
sender.sendMessage(TextComponent.formatText("&6/eh reload &7Reload the Configuration and Language files."));
|
sender.sendMessage(TextComponent.formatText("&6" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||||
sender.sendMessage(TextComponent.formatText("&6/eh book [player]&7- Gives Sync Touch book to you or a player."));
|
}
|
||||||
sender.sendMessage(TextComponent.formatText("&6/eh give [player] [level]&7 - Give a leveled hopper to a player."));
|
|
||||||
sender.sendMessage(TextComponent.formatText("&6/eh settings&7 - Edit the EpicHoppers Settings."));
|
|
||||||
sender.sendMessage(TextComponent.formatText("&6/es boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]&7 - This allows you to boost a players hoppers be a multiplier (Put 2 for double, 3 for triple and so on)."));
|
|
||||||
}
|
}
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
|
|
||||||
return false;
|
return ReturnType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/EpicHoppers";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Displays this page.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,22 +11,28 @@ import org.bukkit.entity.Player;
|
|||||||
public class CommandGive extends AbstractCommand {
|
public class CommandGive extends AbstractCommand {
|
||||||
|
|
||||||
public CommandGive(AbstractCommand parent) {
|
public CommandGive(AbstractCommand parent) {
|
||||||
super("give", "epichoppers.admin", parent);
|
super("give", parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
if (args.length >= 1) {
|
if (args.length <= 2) {
|
||||||
|
return ReturnType.SYNTAX_ERROR;
|
||||||
|
}
|
||||||
|
if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||||
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat username does not exist, or the user is not online!"));
|
||||||
|
return ReturnType.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
Level level = instance.getLevelManager().getLowestLevel();
|
Level level = instance.getLevelManager().getLowestLevel();
|
||||||
Player player;
|
Player player;
|
||||||
if (args.length != 1 && Bukkit.getPlayer(args[1]) == null) {
|
if (args.length != 1 && Bukkit.getPlayer(args[1]) == null) {
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat player does not exist or is currently offline."));
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat player does not exist or is currently offline."));
|
||||||
return true;
|
return ReturnType.FAILURE;
|
||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cYou need to be a player to give a hopper to yourself."));
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cYou need to be a player to give a hopper to yourself."));
|
||||||
return true;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
} else {
|
} else {
|
||||||
@ -36,16 +42,28 @@ public class CommandGive extends AbstractCommand {
|
|||||||
|
|
||||||
if (args.length >= 3 && !instance.getLevelManager().isLevel(Integer.parseInt(args[2]))) {
|
if (args.length >= 3 && !instance.getLevelManager().isLevel(Integer.parseInt(args[2]))) {
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cNot a valid level... The current valid levels are: &4" + instance.getLevelManager().getLowestLevel().getLevel() + "-" + instance.getLevelManager().getHighestLevel().getLevel() + "&c."));
|
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cNot a valid level... The current valid levels are: &4" + instance.getLevelManager().getLowestLevel().getLevel() + "-" + instance.getLevelManager().getHighestLevel().getLevel() + "&c."));
|
||||||
return true;
|
return ReturnType.FAILURE;
|
||||||
} else if (args.length != 1) {
|
} else if (args.length != 1) {
|
||||||
level = instance.getLevelManager().getLevel(Integer.parseInt(args[2]));
|
level = instance.getLevelManager().getLevel(Integer.parseInt(args[2]));
|
||||||
}
|
}
|
||||||
player.getInventory().addItem(instance.newHopperItem(level));
|
player.getInventory().addItem(instance.newHopperItem(level));
|
||||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("command.give.success", level.getLevel()));
|
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("command.give.success", level.getLevel()));
|
||||||
|
|
||||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
return ReturnType.SUCCESS;
|
||||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cThat username does not exist, or the user is not online!"));
|
}
|
||||||
}
|
|
||||||
return false;
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "epichoppers.admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/eh give [player] [level]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Give a leveled hopper to a player.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,28 @@ import org.bukkit.command.CommandSender;
|
|||||||
public class CommandReload extends AbstractCommand {
|
public class CommandReload extends AbstractCommand {
|
||||||
|
|
||||||
public CommandReload(AbstractCommand parent) {
|
public CommandReload(AbstractCommand parent) {
|
||||||
super("reload", "epichoppers.admin", parent);
|
super("reload", parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
instance.reload();
|
instance.reload();
|
||||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
||||||
return false;
|
return ReturnType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "epichoppers.admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/eh reload";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Reload the Configuration and Language files.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,28 @@ import org.bukkit.entity.Player;
|
|||||||
public class CommandSettings extends AbstractCommand {
|
public class CommandSettings extends AbstractCommand {
|
||||||
|
|
||||||
public CommandSettings(AbstractCommand parent) {
|
public CommandSettings(AbstractCommand parent) {
|
||||||
super("settings", "epichoppers.admin", parent);
|
super("settings", parent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
protected ReturnType runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
instance.getSettingsManager().openSettingsManager(p);
|
instance.getSettingsManager().openSettingsManager(p);
|
||||||
return false;
|
return ReturnType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermissionNode() {
|
||||||
|
return "epichoppers.admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyntax() {
|
||||||
|
return "/eh settings";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Edit the EpicHoppers Settings.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user