mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-02-16 20:01:42 +01:00
Removed legacy synccraft perms.
implemented proper packaging. Implemented new command System. Continued documentation.
This commit is contained in:
parent
ae737e1264
commit
08001075a3
@ -19,13 +19,42 @@ public interface LevelManager {
|
||||
*/
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak);
|
||||
|
||||
/**
|
||||
* Get {@link Level} by corresponding integer value.
|
||||
*
|
||||
* @param level the integer level
|
||||
* @return level object
|
||||
*/
|
||||
Level getLevel(int level);
|
||||
|
||||
/**
|
||||
* Get the lowest {@link Level} in the LevelManager.
|
||||
*
|
||||
* @return lowest level
|
||||
*/
|
||||
Level getLowestLevel();
|
||||
|
||||
|
||||
/**
|
||||
* Get the highest {@link Level} in the LevelManager.
|
||||
*
|
||||
* @return high level
|
||||
*/
|
||||
Level getHighestLevel();
|
||||
|
||||
/**
|
||||
* Whether or not this level exists.
|
||||
*
|
||||
* @param level the integer level
|
||||
* @return true if a level, false otherwise
|
||||
*/
|
||||
boolean isLevel(int level);
|
||||
|
||||
/**
|
||||
* Get a unmodifiable map of the current level registered
|
||||
* in the manager.
|
||||
*
|
||||
* @return map of levels.
|
||||
*/
|
||||
Map<Integer, Level> getLevels();
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||
import com.songoda.epichoppers.api.utils.ClaimableProtectionPluginHook;
|
||||
import com.songoda.epichoppers.api.utils.ProtectionPluginHook;
|
||||
import com.songoda.epichoppers.events.*;
|
||||
import com.songoda.epichoppers.command.CommandManager;
|
||||
import com.songoda.epichoppers.listeners.*;
|
||||
import com.songoda.epichoppers.handlers.*;
|
||||
import com.songoda.epichoppers.hooks.*;
|
||||
import com.songoda.epichoppers.hopper.EFilter;
|
||||
@ -44,7 +45,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
private List<ProtectionPluginHook> protectionHooks = new ArrayList<>();
|
||||
private ClaimableProtectionPluginHook factionsHook, townyHook, aSkyblockHook, uSkyblockHook;
|
||||
|
||||
public SettingsManager settingsManager;
|
||||
private SettingsManager settingsManager;
|
||||
|
||||
public References references = null;
|
||||
private ConfigWrapper hooksFile = new ConfigWrapper(this, "", "hooks.yml");
|
||||
@ -89,40 +90,40 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
* Register hoppers into HopperManger from configuration
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (dataFile.getConfig().contains("data.sync")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getBlock() == null) return;
|
||||
if (dataFile.getConfig().contains("data.sync")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getBlock() == null) return;
|
||||
|
||||
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
||||
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
||||
|
||||
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
||||
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
||||
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
||||
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
||||
|
||||
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
||||
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
||||
|
||||
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
||||
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
||||
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
||||
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
||||
|
||||
List<ItemStack> whiteList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
||||
List<ItemStack> blackList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
||||
List<ItemStack> voidList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
||||
List<ItemStack> whiteList = (ArrayList<ItemStack>) dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
||||
List<ItemStack> blackList = (ArrayList<ItemStack>) dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
||||
List<ItemStack> voidList = (ArrayList<ItemStack>) dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
||||
|
||||
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||
|
||||
EFilter filter = new EFilter();
|
||||
EFilter filter = new EFilter();
|
||||
|
||||
filter.setWhiteList(whiteList);
|
||||
filter.setBlackList(blackList);
|
||||
filter.setVoidList(voidList);
|
||||
filter.setEndPoint(black);
|
||||
filter.setWhiteList(whiteList);
|
||||
filter.setBlackList(blackList);
|
||||
filter.setVoidList(voidList);
|
||||
filter.setEndPoint(black);
|
||||
|
||||
EHopper hopper = new EHopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
EHopper hopper = new EHopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
|
||||
hopperManager.addHopper(location, hopper);
|
||||
hopperManager.addHopper(location, hopper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, 10);
|
||||
|
||||
@ -136,13 +137,14 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
|
||||
this.getCommand("EpicHoppers").setExecutor(new CommandHandler(this));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new HopperListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
|
||||
|
||||
// Command registration
|
||||
this.getCommand("EpicHoppers").setExecutor(new CommandManager(this));
|
||||
|
||||
|
||||
|
||||
// Register default hooks
|
||||
@ -182,7 +184,8 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
* Dump HopperManager to file.
|
||||
*/
|
||||
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
||||
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null) continue;
|
||||
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null)
|
||||
continue;
|
||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(hopper.getLocation());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".level", hopper.getLevel().getLevel());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".block", hopper.getSyncedBlock() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getSyncedBlock().getLocation()));
|
||||
@ -204,7 +207,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
((ELevelManager)levelManager).clear();
|
||||
((ELevelManager) levelManager).clear();
|
||||
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
||||
@ -304,7 +307,6 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Level getLevelFromItem(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
@ -342,6 +344,10 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
return hopperManager;
|
||||
}
|
||||
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return playerDataManager;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.songoda.epichoppers.command;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public abstract class AbstractCommand {
|
||||
|
||||
private final AbstractCommand parent;
|
||||
|
||||
private final String permissionNode;
|
||||
|
||||
private final String command;
|
||||
|
||||
protected AbstractCommand(String command, String permissionNode, AbstractCommand parent) {
|
||||
this.command = command;
|
||||
this.parent = parent;
|
||||
this.permissionNode = permissionNode;
|
||||
}
|
||||
|
||||
public AbstractCommand getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public String getPermissionNode() {
|
||||
return permissionNode;
|
||||
}
|
||||
|
||||
protected abstract boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.songoda.epichoppers.command;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epichoppers.command.commands.CommandReload;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.command.commands.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private EpicHoppersPlugin instance;
|
||||
|
||||
private List<AbstractCommand> commands = new ArrayList<>();
|
||||
|
||||
public CommandManager(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
|
||||
AbstractCommand commandEpicHoppers = addCommand(new CommandEpicHoppers());
|
||||
|
||||
addCommand(new CommandReload(commandEpicHoppers));
|
||||
addCommand(new CommandSettings(commandEpicHoppers));
|
||||
addCommand(new CommandGive(commandEpicHoppers));
|
||||
}
|
||||
|
||||
private AbstractCommand addCommand(AbstractCommand abstractCommand) {
|
||||
commands.add(abstractCommand);
|
||||
return abstractCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
for (AbstractCommand abstractCommand : commands) {
|
||||
if (abstractCommand.getCommand().equalsIgnoreCase(command.getName())) {
|
||||
if (strings.length == 0) {
|
||||
processPerms(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
} else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) {
|
||||
String cmd = strings[0];
|
||||
if (cmd.equalsIgnoreCase(abstractCommand.getCommand())) {
|
||||
processPerms(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processPerms(AbstractCommand command, CommandSender sender, String[] strings) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
command.runCommand(instance, sender, strings);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.songoda.epichoppers.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandBook extends AbstractCommand {
|
||||
|
||||
public CommandBook(AbstractCommand parent) {
|
||||
super("reload", "epichoppers.admin", parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player)
|
||||
((Player) sender).getInventory().addItem(instance.enchantmentHandler.getbook());
|
||||
} 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!"));
|
||||
} else {
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(instance.enchantmentHandler.getbook());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.songoda.epichoppers.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.command.AbstractCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandEpicHoppers extends AbstractCommand {
|
||||
|
||||
public CommandEpicHoppers() {
|
||||
super("EpicHoppers", null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(TextComponent.formatText("&f>>&m------------&6&l EpicHoppers Help &f&m------------&f<<"));
|
||||
sender.sendMessage(TextComponent.formatText(" &7" + instance.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||
|
||||
sender.sendMessage(TextComponent.formatText("&6/EpicHoppers&7 - Displays this page."));
|
||||
if (sender.hasPermission("epichoppers.admin")) {
|
||||
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("");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.songoda.epichoppers.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
|
||||
public CommandGive(AbstractCommand parent) {
|
||||
super("give", "epichoppers.admin", parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||
if (args.length >= 1) {
|
||||
|
||||
Level level = instance.getLevelManager().getLowestLevel();
|
||||
Player player;
|
||||
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."));
|
||||
return true;
|
||||
} else if (args.length == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cYou need to be a player to give a hopper to yourself."));
|
||||
return true;
|
||||
}
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
|
||||
|
||||
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."));
|
||||
return true;
|
||||
} else if (args.length != 1) {
|
||||
level = instance.getLevelManager().getLevel(Integer.parseInt(args[2]));
|
||||
}
|
||||
player.getInventory().addItem(instance.newHopperItem(level));
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("command.give.success", level.getLevel()));
|
||||
|
||||
} 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!"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.songoda.epichoppers.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epichoppers.command.AbstractCommand;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
public CommandReload(AbstractCommand parent) {
|
||||
super("reload", "epichoppers.admin", parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||
instance.reload();
|
||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.songoda.epichoppers.command.commands;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.command.AbstractCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
public CommandSettings(AbstractCommand parent) {
|
||||
super("settings", "epichoppers.admin", parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runCommand(EpicHoppersPlugin instance, CommandSender sender, String... args) {
|
||||
Player p = (Player) sender;
|
||||
instance.getSettingsManager().openSettingsManager(p);
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
private final EpicHoppersPlugin plugin;
|
||||
|
||||
public CommandHandler(final EpicHoppersPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
try {
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&7" + plugin.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH help &7Displays this page."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH give [player] [level] &7Give a leveled hopper to a player."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH book [player] &7Gives Sync Touch book to you or a player."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH settings &7Edit the EpicHoppers Settings."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH reload &7Reloads Configuration and Language files."));
|
||||
sender.sendMessage("");
|
||||
} else if (args[0].equalsIgnoreCase("book")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player)
|
||||
((Player) sender).getInventory().addItem(plugin.enchantmentHandler.getbook());
|
||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||
} else {
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(plugin.enchantmentHandler.getbook());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("give")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 1) {
|
||||
|
||||
Level level = plugin.getLevelManager().getLowestLevel();
|
||||
Player player;
|
||||
if (args.length != 1 && Bukkit.getPlayer(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat player does not exist or is currently offline."));
|
||||
return true;
|
||||
} else if (args.length == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cYou need to be a player to give a hopper to yourself."));
|
||||
return true;
|
||||
}
|
||||
player = (Player)sender;
|
||||
} else {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
|
||||
|
||||
if (args.length >= 3 && !plugin.getLevelManager().isLevel(Integer.parseInt(args[2]))) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cNot a valid level... The current valid levels are: &4" + plugin.getLevelManager().getLowestLevel().getLevel() + "-" + plugin.getLevelManager().getHighestLevel().getLevel() + "&c."));
|
||||
return true;
|
||||
} else if (args.length != 1){
|
||||
level = plugin.getLevelManager().getLevel(Integer.parseInt(args[2]));
|
||||
}
|
||||
player.getInventory().addItem(plugin.newHopperItem(level));
|
||||
player.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("command.give.success", level.getLevel()));
|
||||
|
||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
plugin.reload();
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&8Configuration and Language files reloaded."));
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
if (args[0].equalsIgnoreCase("settings")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
Player p = (Player) sender;
|
||||
plugin.settingsManager.openSettingsManager(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epichoppers.events;
|
||||
package com.songoda.epichoppers.listeners;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
@ -1,9 +1,8 @@
|
||||
package com.songoda.epichoppers.events;
|
||||
package com.songoda.epichoppers.listeners;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.EHopper;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import org.bukkit.Location;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epichoppers.events;
|
||||
package com.songoda.epichoppers.listeners;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epichoppers.events;
|
||||
package com.songoda.epichoppers.listeners;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
@ -10,5 +10,5 @@ commands:
|
||||
epichoppers:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [eh, synccraft]
|
||||
aliases: [eh]
|
||||
usage: /eh
|
Loading…
Reference in New Issue
Block a user