mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Removed some unnecessary extra lines
This commit is contained in:
parent
558741e587
commit
5f5fd05e6c
@ -42,54 +42,33 @@ public class Commands extends BukkitCommand {
|
|||||||
register.invoke(cmdmap, command.getName(),command);
|
register.invoke(cmdmap, command.getName(),command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
if (sender instanceof Player) {
|
|
||||||
|
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
|
||||||
sendBasicHelpMessage(p);
|
sendBasicHelpMessage(p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("create")) {
|
if (args[0].equalsIgnoreCase("create")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.create")) {
|
if (perm.has(p, "shopchest.create")) {
|
||||||
|
|
||||||
if (args.length == 4) {
|
if (args.length == 4) {
|
||||||
|
|
||||||
create(args, ShopType.NORMAL, p);
|
create(args, ShopType.NORMAL, p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
} else if (args.length == 5) {
|
} else if (args.length == 5) {
|
||||||
|
|
||||||
if (args[4].equalsIgnoreCase("infinite")) {
|
if (args[4].equalsIgnoreCase("infinite")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.create.infinite")) {
|
if (perm.has(p, "shopchest.create.infinite")) {
|
||||||
|
|
||||||
create(args, ShopType.INFINITE, p);
|
create(args, ShopType.INFINITE, p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
p.sendMessage(Config.noPermission_createInfinite());
|
p.sendMessage(Config.noPermission_createInfinite());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (args[4].equalsIgnoreCase("normal")){
|
} else if (args[4].equalsIgnoreCase("normal")){
|
||||||
|
|
||||||
create(args, ShopType.NORMAL, p);
|
create(args, ShopType.NORMAL, p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (args[4].equalsIgnoreCase("admin")) {
|
} else if (args[4].equalsIgnoreCase("admin")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.create.admin")) {
|
if (perm.has(p, "shopchest.create.admin")) {
|
||||||
create(args, ShopType.ADMIN, p);
|
create(args, ShopType.ADMIN, p);
|
||||||
return true;
|
return true;
|
||||||
@ -97,41 +76,25 @@ public class Commands extends BukkitCommand {
|
|||||||
p.sendMessage(Config.noPermission_createAdmin());
|
p.sendMessage(Config.noPermission_createAdmin());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
sendBasicHelpMessage(p);
|
sendBasicHelpMessage(p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
sendBasicHelpMessage(p);
|
sendBasicHelpMessage(p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
p.sendMessage(Config.noPermission_create());
|
p.sendMessage(Config.noPermission_create());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
|
|
||||||
remove(p);
|
remove(p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("info")) {
|
} else if (args[0].equalsIgnoreCase("info")) {
|
||||||
|
|
||||||
info(p);
|
info(p);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.reload")) {
|
if (perm.has(p, "shopchest.reload")) {
|
||||||
reload(p);
|
reload(p);
|
||||||
return true;
|
return true;
|
||||||
@ -139,9 +102,7 @@ public class Commands extends BukkitCommand {
|
|||||||
p.sendMessage(Config.noPermission_reload());
|
p.sendMessage(Config.noPermission_reload());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("update")) {
|
} else if (args[0].equalsIgnoreCase("update")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.update")) {
|
if (perm.has(p, "shopchest.update")) {
|
||||||
checkUpdates(p);
|
checkUpdates(p);
|
||||||
return true;
|
return true;
|
||||||
@ -149,37 +110,29 @@ public class Commands extends BukkitCommand {
|
|||||||
p.sendMessage(Config.noPermission_update());
|
p.sendMessage(Config.noPermission_update());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("limits")) {
|
} else if (args[0].equalsIgnoreCase("limits")) {
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.limits")) {
|
if (perm.has(p, "shopchest.limits")) {
|
||||||
p.sendMessage(Config.occupied_shop_slots(ShopUtils.getShopLimit(p), ShopUtils.getShopAmount(p)));
|
p.sendMessage(Config.occupied_shop_slots(ShopUtils.getShopLimit(p), ShopUtils.getShopAmount(p)));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_limits());
|
p.sendMessage(Config.noPermission_limits());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sendBasicHelpMessage(p);
|
sendBasicHelpMessage(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Only players can execute this command.");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Only players can execute this command.");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkUpdates(Player player) {
|
private void checkUpdates(Player player) {
|
||||||
|
|
||||||
player.sendMessage(Config.checking_update());
|
player.sendMessage(Config.checking_update());
|
||||||
|
|
||||||
UpdateChecker uc = new UpdateChecker(ShopChest.getInstance(), ShopChest.getInstance().getDescription().getWebsite());
|
UpdateChecker uc = new UpdateChecker(ShopChest.getInstance(), ShopChest.getInstance().getDescription().getWebsite());
|
||||||
@ -220,9 +173,7 @@ public class Commands extends BukkitCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reload(Player player) {
|
private void reload(Player player) {
|
||||||
|
ShopChest.utils.reload(player);
|
||||||
ShopChest.utils.reload(player);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create(String[] args, ShopType shopType, Player p) {
|
private void create(String[] args, ShopType shopType, Player p) {
|
||||||
@ -311,7 +262,6 @@ public class Commands extends BukkitCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(p.getItemInHand().getType(), amount, p.getItemInHand().getDurability());
|
ItemStack itemStack = new ItemStack(p.getItemInHand().getType(), amount, p.getItemInHand().getDurability());
|
||||||
itemStack.setItemMeta(p.getItemInHand().getItemMeta());
|
itemStack.setItemMeta(p.getItemInHand().getItemMeta());
|
||||||
@ -339,14 +289,12 @@ public class Commands extends BukkitCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendBasicHelpMessage(Player player) {
|
private void sendBasicHelpMessage(Player player) {
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " create <amount> <buy-price> <sell-price> [infinite|normal|admin] - " + Config.cmdDesc_create());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " create <amount> <buy-price> <sell-price> [infinite|normal|admin] - " + Config.cmdDesc_create());
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " remove - " + Config.cmdDesc_remove());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " remove - " + Config.cmdDesc_remove());
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " info - " + Config.cmdDesc_info());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " info - " + Config.cmdDesc_info());
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " reload - " + Config.cmdDesc_reload());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " reload - " + Config.cmdDesc_reload());
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " update - " + Config.cmdDesc_update());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " update - " + Config.cmdDesc_update());
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " limits - " + Config.cmdDesc_limits());
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " limits - " + Config.cmdDesc_limits());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ public class ShopChest extends JavaPlugin{
|
|||||||
|
|
||||||
|
|
||||||
private boolean setupEconomy() {
|
private boolean setupEconomy() {
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -84,8 +83,7 @@ public class ShopChest extends JavaPlugin{
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
@ -144,7 +142,6 @@ public class ShopChest extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -259,19 +256,15 @@ public class ShopChest extends JavaPlugin{
|
|||||||
getServer().getPluginManager().registerEvents(new ItemCustomNameListener(), this);
|
getServer().getPluginManager().registerEvents(new ItemCustomNameListener(), this);
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
|
if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
utils.removeShops();
|
utils.removeShops();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeShops() {
|
private void initializeShops() {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int id = 1; id < sqlite.getHighestID() + 1; id++) {
|
for (int id = 1; id < sqlite.getHighestID() + 1; id++) {
|
||||||
@ -290,7 +283,6 @@ public class ShopChest extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Initialized " + String.valueOf(count) + " Shops");
|
logger.info("Initialized " + String.valueOf(count) + " Shops");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(InputStream in, File file) {
|
public static void copy(InputStream in, File file) {
|
||||||
@ -298,9 +290,11 @@ public class ShopChest extends JavaPlugin{
|
|||||||
OutputStream out = new FileOutputStream(file);
|
OutputStream out = new FileOutputStream(file);
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
while((len=in.read(buf))>0){
|
while((len=in.read(buf))>0){
|
||||||
out.write(buf,0,len);
|
out.write(buf,0,len);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
in.close();
|
in.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user