Automated code cleanup by IntelliJ IDEA

As I Switched from Eclipse to IntelliJ IDEA, I also had to add a few
entries to the .gitignore file.
This commit is contained in:
Eric 2016-05-28 15:47:57 +02:00
parent 5bb4169c80
commit 543da0682b
42 changed files with 3889 additions and 3658 deletions

3
.gitignore vendored
View File

@ -1,4 +1,7 @@
/bin/
/out/
/.idea/
/.settings/
.classpath
.project
ShopChest.iml

View File

@ -1,17 +1,5 @@
package de.epiceric.shopchest;
import java.lang.reflect.Method;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import de.epiceric.shopchest.interfaces.Utils;
@ -23,6 +11,18 @@ import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.UpdateChecker;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Method;
import java.util.List;
public class Commands extends BukkitCommand {
@ -145,12 +145,23 @@ public class Commands extends BukkitCommand {
JsonBuilder jb;
switch (Utils.getVersion(plugin.getServer())) {
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)); break;
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)); break;
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)); break;
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)); break;
case "v1_9_R2": jb = new JsonBuilder_1_9_R2(Config.update_available(ShopChest.latestVersion)); break;
default: return;
case "v1_8_R1":
jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion));
break;
case "v1_8_R2":
jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion));
break;
case "v1_8_R3":
jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion));
break;
case "v1_9_R1":
jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion));
break;
case "v1_9_R2":
jb = new JsonBuilder_1_9_R2(Config.update_available(ShopChest.latestVersion));
break;
default:
return;
}
jb.sendJson(player);

View File

@ -1,37 +1,16 @@
package de.epiceric.shopchest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.event.InteractShop;
import de.epiceric.shopchest.event.ItemCustomNameListener;
import de.epiceric.shopchest.event.NotifyUpdate;
import de.epiceric.shopchest.event.ProtectChest;
import de.epiceric.shopchest.event.RegenerateShopItem;
import de.epiceric.shopchest.event.RegenerateShopItemAfterRemove;
import de.epiceric.shopchest.event.UpdateHolograms;
import de.epiceric.shopchest.event.*;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
import de.epiceric.shopchest.interfaces.utils.*;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.shop.Shop.ShopType;
import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
import de.epiceric.shopchest.utils.Metrics;
import de.epiceric.shopchest.utils.Metrics.Graph;
import de.epiceric.shopchest.utils.Metrics.Plotter;
@ -40,30 +19,51 @@ import de.epiceric.shopchest.utils.UpdateChecker;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.ArrayList;
import java.util.logging.Logger;
public class ShopChest extends JavaPlugin {
private static ShopChest instance;
public static Statement statement;
public static Logger logger;
public static Economy econ = null;
public static Permission perm = null;
public static LWC lwc = null;
public static boolean lockette = false;
public static SQLite sqlite;
public static boolean isUpdateNeeded = false;
public static String latestVersion = "";
public static String downloadLink = "";
public static String[] broadcast = null;
public static Utils utils;
private static ShopChest instance;
public static ShopChest getInstance() {
return instance;
}
public static void copy(InputStream in, File file) {
try {
OutputStream out = new FileOutputStream(file);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
@ -74,14 +74,12 @@ public class ShopChest extends JavaPlugin{
return econ != null;
}
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
perm = rsp.getProvider();
return perm != null;
}
@Override
public void onEnable() {
logger = getLogger();
@ -159,11 +157,21 @@ public class ShopChest extends JavaPlugin{
switch (Utils.getVersion(getServer())) {
case "v1_8_R1": utils = new Utils_1_8_R1(); break;
case "v1_8_R2": utils = new Utils_1_8_R2(); break;
case "v1_8_R3": utils = new Utils_1_8_R3(); break;
case "v1_9_R1": utils = new Utils_1_9_R1(); break;
case "v1_9_R2": utils = new Utils_1_9_R2(); break;
case "v1_8_R1":
utils = new Utils_1_8_R1();
break;
case "v1_8_R2":
utils = new Utils_1_8_R2();
break;
case "v1_8_R3":
utils = new Utils_1_8_R3();
break;
case "v1_9_R1":
utils = new Utils_1_9_R1();
break;
case "v1_9_R2":
utils = new Utils_1_9_R2();
break;
default:
logger.severe("Incompatible Server Version: " + Utils.getVersion(getServer()) + "!");
getServer().getPluginManager().disablePlugin(this);
@ -203,12 +211,23 @@ public class ShopChest extends JavaPlugin{
if (p.isOp() || perm.has(p, "shopchest.notification.update")) {
JsonBuilder jb;
switch (Utils.getVersion(getServer())) {
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(latestVersion)); break;
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(latestVersion)); break;
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(latestVersion)); break;
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(latestVersion)); break;
case "v1_9_R2": jb = new JsonBuilder_1_9_R2(Config.update_available(latestVersion)); break;
default: return;
case "v1_8_R1":
jb = new JsonBuilder_1_8_R1(Config.update_available(latestVersion));
break;
case "v1_8_R2":
jb = new JsonBuilder_1_8_R2(Config.update_available(latestVersion));
break;
case "v1_8_R3":
jb = new JsonBuilder_1_8_R3(Config.update_available(latestVersion));
break;
case "v1_9_R1":
jb = new JsonBuilder_1_9_R1(Config.update_available(latestVersion));
break;
case "v1_9_R2":
jb = new JsonBuilder_1_9_R2(Config.update_available(latestVersion));
break;
default:
return;
}
jb.sendJson(p);
}
@ -245,7 +264,11 @@ public class ShopChest extends JavaPlugin{
File itemNamesFile = new File(getDataFolder(), "item_names.txt");
if (!itemNamesFile.exists())
try {itemNamesFile.createNewFile();} catch (IOException e) {e.printStackTrace();}
try {
itemNamesFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
copy(getResource("item_names.txt"), itemNamesFile);
@ -265,10 +288,10 @@ public class ShopChest extends JavaPlugin{
getServer().getPluginManager().registerEvents(new ProtectChest(), 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
public void onDisable() {
utils.removeShops();
@ -295,22 +318,5 @@ public class ShopChest extends JavaPlugin{
logger.info("Initialized " + String.valueOf(count) + " Shops");
}
public static void copy(InputStream in, File file) {
try {
OutputStream out = new FileOutputStream(file);
byte[] buf = new byte[1024];
int len;
while((len=in.read(buf))>0){
out.write(buf,0,len);
}
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,79 +1,251 @@
package de.epiceric.shopchest.config;
import de.epiceric.shopchest.ShopChest;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import de.epiceric.shopchest.ShopChest;
public class Config {
private static ShopChest plugin = ShopChest.getInstance();
public static Set<String> minimum_prices() {return (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);}
public static Set<String> shopLimits_group() {return (plugin.getConfig().getConfigurationSection("shop-limits.group") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.group").getKeys(true);}
public static Set<String> shopLimits_player() {return (plugin.getConfig().getConfigurationSection("shop-limits.player") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.player").getKeys(true);}
public static Set<String> minimum_prices() {
return (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);
}
public static List<String> blacklist() {return (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");};
public static Set<String> shopLimits_group() {
return (plugin.getConfig().getConfigurationSection("shop-limits.group") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.group").getKeys(true);
}
public static boolean buy_greater_or_equal_sell() {return plugin.getConfig().getBoolean("buy-greater-or-equal-sell");}
public static boolean hopper_protection() {return plugin.getConfig().getBoolean("hopper-protection");}
public static boolean explosion_protection() {return plugin.getConfig().getBoolean("explosion-protection)");}
public static boolean enable_broadcast() {return plugin.getConfig().getBoolean("enable-broadcast");}
public static Set<String> shopLimits_player() {
return (plugin.getConfig().getConfigurationSection("shop-limits.player") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.player").getKeys(true);
}
public static double maximal_distance() {return plugin.getConfig().getDouble("maximal-distance");}
public static int default_limit() {return plugin.getConfig().getInt("shop-limits.default");}
public static List<String> blacklist() {
return (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
}
public static String main_command_name() { return plugin.getConfig().getString("main-command-name");}
public static String currency_symbol() { return plugin.getConfig().getString("currency-symbol").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String shop_created() { return plugin.getConfig().getString("messages.shop-created").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String chest_already_shop() { return plugin.getConfig().getString("messages.chest-already-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String shop_removed() { return plugin.getConfig().getString("messages.shop-removed").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String chest_no_shop() { return plugin.getConfig().getString("messages.chest-no-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String block_no_chest() { return plugin.getConfig().getString("messages.block-no-chest").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String not_enough_inventory_space() { return plugin.getConfig().getString("messages.not-enough-inventory-space").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String chest_not_enough_inventory_space() { return plugin.getConfig().getString("messages.chest-not-enough-inventory-space").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String not_enough_money() { return plugin.getConfig().getString("messages.not-enough-money").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String not_enough_items() { return plugin.getConfig().getString("messages.not-enough-items").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String vendor_not_enough_money() { return plugin.getConfig().getString("messages.vendor-not-enough-money").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String out_of_stock() { return plugin.getConfig().getString("messages.out-of-stock").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String amount_and_price_not_number() { return plugin.getConfig().getString("messages.amount-and-price-not-number").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String no_item_in_hand() { return plugin.getConfig().getString("messages.no-item-in-hand").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String click_chest_to_create() { return plugin.getConfig().getString("messages.click-chest-to-create-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String click_chest_to_remove() { return plugin.getConfig().getString("messages.click-chest-to-remove-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String click_chest_for_info() { return plugin.getConfig().getString("messages.click-chest-for-info").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_create() { return plugin.getConfig().getString("messages.command-description.create").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_remove() { return plugin.getConfig().getString("messages.command-description.remove").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_info() { return plugin.getConfig().getString("messages.command-description.info").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_reload() { return plugin.getConfig().getString("messages.command-description.reload").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_update() { return plugin.getConfig().getString("messages.command-description.update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cmdDesc_limits() { return plugin.getConfig().getString("messages.command-description.limits").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String shopInfo_isInfinite() { return plugin.getConfig().getString("messages.shop-info.is-infinite").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");};
public static String shopInfo_isNormal() { return plugin.getConfig().getString("messages.shop-info.is-normal").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");};
public static String shopInfo_isAdmin() { return plugin.getConfig().getString("messages.shop-info.is-admin").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");};
public static String noPermission_create() { return plugin.getConfig().getString("messages.no-permission.create").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_createInfinite() { return plugin.getConfig().getString("messages.no-permission.create-infinite").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_createAdmin() { return plugin.getConfig().getString("messages.no-permission.create-admin").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_openOthers() { return plugin.getConfig().getString("messages.no-permission.open-others").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_removeOthers() { return plugin.getConfig().getString("messages.no-permission.remove-others").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_buy() { return plugin.getConfig().getString("messages.no-permission.buy").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_sell() { return plugin.getConfig().getString("messages.no-permission.sell").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_reload() { return plugin.getConfig().getString("messages.no-permission.reload").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_update() { return plugin.getConfig().getString("messages.no-permission.update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String noPermission_limits() { return plugin.getConfig().getString("messages.no-permission.limits").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cannot_break_shop() { return plugin.getConfig().getString("messages.cannot-break-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cannot_sell_broken_item() { return plugin.getConfig().getString("messages.cannot-sell-broken-item").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String disabled() {return plugin.getConfig().getString("messages.shop-info.disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String buy_and_sell_disabled() {return plugin.getConfig().getString("messages.buy-and-sell-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String selling_disabled() {return plugin.getConfig().getString("messages.selling-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String buying_disabled() {return plugin.getConfig().getString("messages.buying-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String checking_update() {return plugin.getConfig().getString("messages.update.checking").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String no_new_update() {return plugin.getConfig().getString("messages.update.no-update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String click_to_download() {return plugin.getConfig().getString("messages.update.click-to-download").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String update_check_error() {return plugin.getConfig().getString("messages.update.error").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String cannot_sell_item() {return plugin.getConfig().getString("messages.cannot-sell-item").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static String none() {return plugin.getConfig().getString("messages.shop-info.none").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");}
public static boolean buy_greater_or_equal_sell() {
return plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
}
public static boolean hopper_protection() {
return plugin.getConfig().getBoolean("hopper-protection");
}
public static boolean explosion_protection() {
return plugin.getConfig().getBoolean("explosion-protection)");
}
public static boolean enable_broadcast() {
return plugin.getConfig().getBoolean("enable-broadcast");
}
public static double maximal_distance() {
return plugin.getConfig().getDouble("maximal-distance");
}
public static int default_limit() {
return plugin.getConfig().getInt("shop-limits.default");
}
public static String main_command_name() {
return plugin.getConfig().getString("main-command-name");
}
public static String currency_symbol() {
return plugin.getConfig().getString("currency-symbol").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String shop_created() {
return plugin.getConfig().getString("messages.shop-created").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String chest_already_shop() {
return plugin.getConfig().getString("messages.chest-already-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String shop_removed() {
return plugin.getConfig().getString("messages.shop-removed").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String chest_no_shop() {
return plugin.getConfig().getString("messages.chest-no-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String block_no_chest() {
return plugin.getConfig().getString("messages.block-no-chest").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String not_enough_inventory_space() {
return plugin.getConfig().getString("messages.not-enough-inventory-space").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String chest_not_enough_inventory_space() {
return plugin.getConfig().getString("messages.chest-not-enough-inventory-space").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String not_enough_money() {
return plugin.getConfig().getString("messages.not-enough-money").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String not_enough_items() {
return plugin.getConfig().getString("messages.not-enough-items").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String vendor_not_enough_money() {
return plugin.getConfig().getString("messages.vendor-not-enough-money").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String out_of_stock() {
return plugin.getConfig().getString("messages.out-of-stock").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String amount_and_price_not_number() {
return plugin.getConfig().getString("messages.amount-and-price-not-number").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String no_item_in_hand() {
return plugin.getConfig().getString("messages.no-item-in-hand").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String click_chest_to_create() {
return plugin.getConfig().getString("messages.click-chest-to-create-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String click_chest_to_remove() {
return plugin.getConfig().getString("messages.click-chest-to-remove-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String click_chest_for_info() {
return plugin.getConfig().getString("messages.click-chest-for-info").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_create() {
return plugin.getConfig().getString("messages.command-description.create").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_remove() {
return plugin.getConfig().getString("messages.command-description.remove").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_info() {
return plugin.getConfig().getString("messages.command-description.info").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_reload() {
return plugin.getConfig().getString("messages.command-description.reload").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_update() {
return plugin.getConfig().getString("messages.command-description.update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cmdDesc_limits() {
return plugin.getConfig().getString("messages.command-description.limits").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String shopInfo_isInfinite() {
return plugin.getConfig().getString("messages.shop-info.is-infinite").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String shopInfo_isNormal() {
return plugin.getConfig().getString("messages.shop-info.is-normal").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String shopInfo_isAdmin() {
return plugin.getConfig().getString("messages.shop-info.is-admin").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_create() {
return plugin.getConfig().getString("messages.no-permission.create").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_createInfinite() {
return plugin.getConfig().getString("messages.no-permission.create-infinite").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_createAdmin() {
return plugin.getConfig().getString("messages.no-permission.create-admin").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_openOthers() {
return plugin.getConfig().getString("messages.no-permission.open-others").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_removeOthers() {
return plugin.getConfig().getString("messages.no-permission.remove-others").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_buy() {
return plugin.getConfig().getString("messages.no-permission.buy").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_sell() {
return plugin.getConfig().getString("messages.no-permission.sell").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_reload() {
return plugin.getConfig().getString("messages.no-permission.reload").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_update() {
return plugin.getConfig().getString("messages.no-permission.update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String noPermission_limits() {
return plugin.getConfig().getString("messages.no-permission.limits").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cannot_break_shop() {
return plugin.getConfig().getString("messages.cannot-break-shop").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cannot_sell_broken_item() {
return plugin.getConfig().getString("messages.cannot-sell-broken-item").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String disabled() {
return plugin.getConfig().getString("messages.shop-info.disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String buy_and_sell_disabled() {
return plugin.getConfig().getString("messages.buy-and-sell-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String selling_disabled() {
return plugin.getConfig().getString("messages.selling-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String buying_disabled() {
return plugin.getConfig().getString("messages.buying-disabled").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String checking_update() {
return plugin.getConfig().getString("messages.update.checking").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String no_new_update() {
return plugin.getConfig().getString("messages.update.no-update").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String click_to_download() {
return plugin.getConfig().getString("messages.update.click-to-download").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String update_check_error() {
return plugin.getConfig().getString("messages.update.error").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String cannot_sell_item() {
return plugin.getConfig().getString("messages.cannot-sell-item").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String none() {
return plugin.getConfig().getString("messages.shop-info.none").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
}
public static String limit_reached(int limit) {
return plugin.getConfig().getString("messages.shop-limit-reached").replace(Regex.limit, String.valueOf(limit)).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");

View File

@ -1,8 +1,16 @@
package de.epiceric.shopchest.event;
import java.util.HashMap;
import java.util.Map;
import com.griefcraft.model.Protection;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.shop.Shop.ShopType;
import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.utils.*;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -20,22 +28,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.yi.acru.bukkit.Lockette.Lockette;
import com.griefcraft.model.Protection;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.shop.Shop.ShopType;
import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.utils.ArrowEffectNames;
import de.epiceric.shopchest.utils.ClickType;
import de.epiceric.shopchest.utils.EnchantmentNames;
import de.epiceric.shopchest.utils.ItemNames;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.interfaces.Utils;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.permission.Permission;
import java.util.HashMap;
import java.util.Map;
public class InteractShop implements Listener {
@ -194,7 +188,6 @@ public class InteractShop implements Listener{
}
} else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
if (ShopUtils.isShop(b.getLocation())) {
@ -402,13 +395,15 @@ public class InteractShop implements Listener{
if (leftAmount > 0) {
ItemStack boughtProduct = new ItemStack(product.clone().getType(), 1, product.clone().getDurability());
boughtProduct.setItemMeta(product.clone().getItemMeta());
if (shop.getShopType() == ShopType.NORMAL) c.getInventory().removeItem(boughtProduct);
if (shop.getShopType() == ShopType.NORMAL)
c.getInventory().removeItem(boughtProduct);
if (slot != 40) {
inventory.addItem(boughtProduct);
} else {
ItemStack is = new ItemStack(boughtProduct);
int amount = 0;
if (inventory.getItem(40) != null) amount = inventory.getItem(40).getAmount();
if (inventory.getItem(40) != null)
amount = inventory.getItem(40).getAmount();
is.setAmount(amount + 1);
inventory.setItem(40, is);
}
@ -416,7 +411,8 @@ public class InteractShop implements Listener{
leftAmount--;
} else if (leftAmount == 0) {
executor.sendMessage(Config.buy_success(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), shop.getVendor().getName()));
if (shop.getVendor().isOnline()) shop.getVendor().getPlayer().sendMessage(Config.someone_bought(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName()));
if (shop.getVendor().isOnline())
shop.getVendor().getPlayer().sendMessage(Config.someone_bought(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName()));
return;
}
}
@ -530,7 +526,8 @@ public class InteractShop implements Listener{
executor.updateInventory();
}
executor.sendMessage(Config.sell_success(product.getAmount(), ItemNames.lookup(product), shop.getSellPrice(), shop.getVendor().getName()));
if (shop.getVendor().isOnline()) shop.getVendor().getPlayer().sendMessage(Config.someone_sold(product.getAmount(), ItemNames.lookup(product), shop.getSellPrice(), executor.getName()));
if (shop.getVendor().isOnline())
shop.getVendor().getPlayer().sendMessage(Config.someone_sold(product.getAmount(), ItemNames.lookup(product), shop.getSellPrice(), executor.getName()));
} else {
executor.sendMessage(Config.error_occurred(r2.errorMessage));
}
@ -581,7 +578,8 @@ public class InteractShop implements Listener{
executor.updateInventory();
}
executor.sendMessage(Config.sell_success(product.getAmount(), ItemNames.lookup(product), shop.getSellPrice(), shop.getVendor().getName()));
if (shop.getVendor().isOnline()) shop.getVendor().getPlayer().sendMessage(Config.someone_sold(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName()));
if (shop.getVendor().isOnline())
shop.getVendor().getPlayer().sendMessage(Config.someone_sold(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName()));
} else {
executor.sendMessage(Config.error_occurred(r2.errorMessage));
}

View File

@ -1,22 +1,22 @@
package de.epiceric.shopchest.event;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.milkbowl.vault.permission.Permission;
public class NotifyUpdate implements Listener {
private Permission perm = ShopChest.perm;
public NotifyUpdate() {}
public NotifyUpdate() {
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
@ -28,12 +28,23 @@ public class NotifyUpdate implements Listener {
JsonBuilder jb;
switch (Utils.getVersion(ShopChest.getInstance().getServer())) {
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)); break;
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)); break;
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)); break;
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)); break;
case "v1_9_R2": jb = new JsonBuilder_1_9_R2(Config.update_available(ShopChest.latestVersion)); break;
default: return;
case "v1_8_R1":
jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion));
break;
case "v1_8_R2":
jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion));
break;
case "v1_8_R3":
jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion));
break;
case "v1_9_R1":
jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion));
break;
case "v1_9_R2":
jb = new JsonBuilder_1_9_R2(Config.update_available(ShopChest.latestVersion));
break;
default:
return;
}
jb.sendJson(p);
}

View File

@ -1,7 +1,9 @@
package de.epiceric.shopchest.event;
import java.util.ArrayList;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
@ -17,14 +19,12 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import java.util.ArrayList;
public class ProtectChest implements Listener {
public ProtectChest() {}
public ProtectChest() {
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {

View File

@ -12,7 +12,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
public class RegenerateShopItem implements Listener {
public RegenerateShopItem() {}
public RegenerateShopItem() {
}
@EventHandler(priority = EventPriority.HIGH)
public void onItemDespawn(ItemDespawnEvent e) {

View File

@ -1,10 +1,10 @@
package de.epiceric.shopchest.event;
import de.epiceric.shopchest.ShopChest;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import de.epiceric.shopchest.ShopChest;
public class RegenerateShopItemAfterRemove implements Listener {

View File

@ -1,18 +1,18 @@
package de.epiceric.shopchest.event;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
public class UpdateHolograms implements Listener {
public UpdateHolograms() {}
public UpdateHolograms() {
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {

View File

@ -1,17 +1,21 @@
package de.epiceric.shopchest.interfaces;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import java.util.List;
public interface Hologram {
public Location getLocation();
public List<?> getEntities();
public void showPlayer(OfflinePlayer p);
public void hidePlayer(OfflinePlayer p);
public boolean isVisible(OfflinePlayer p);
}

View File

@ -5,6 +5,22 @@ import org.bukkit.entity.Player;
public interface JsonBuilder {
public JsonBuilder parse(String text);
public JsonBuilder withText(String text);
public JsonBuilder withColor(ChatColor color);
public JsonBuilder withColor(String color);
public JsonBuilder withClickEvent(ClickAction action, String value);
public JsonBuilder withHoverEvent(HoverAction action, String value);
public String toString();
public void sendJson(Player p);
public enum ClickAction {
RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL
}
@ -13,13 +29,4 @@ public interface JsonBuilder {
SHOW_TEXT
}
public JsonBuilder parse(String text);
public JsonBuilder withText(String text);
public JsonBuilder withColor(ChatColor color);
public JsonBuilder withColor(String color);
public JsonBuilder withClickEvent(ClickAction action, String value);
public JsonBuilder withHoverEvent(HoverAction action, String value);
public String toString();
public void sendJson(Player p);
}

View File

@ -11,10 +11,6 @@ import org.bukkit.inventory.meta.ItemMeta;
public abstract class Utils {
public abstract void reload(Player p);
public abstract void removeShops();
public static int getAmount(Inventory inventory, Material type, short damage, ItemMeta itemMeta) {
ItemStack[] items = inventory.getContents();
int amount = 0;
@ -59,6 +55,9 @@ public abstract class Utils {
return config.getItemStack("i", null);
}
public abstract void reload(Player p);
public abstract void removeShops();
}

View File

@ -1,27 +1,25 @@
package de.epiceric.shopchest.interfaces.hologram;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import de.epiceric.shopchest.interfaces.Hologram;
import net.minecraft.server.v1_8_R1.EntityArmorStand;
import net.minecraft.server.v1_8_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R1.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hologram_1_8_R1 implements Hologram {
int count;
private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
private String[] text;
private Location location;
private double DISTANCE = 0.25D;
int count;
private HashMap<OfflinePlayer, Boolean> visible = new HashMap<OfflinePlayer, Boolean>();
public Hologram_1_8_R1(String[] text, Location location) {
@ -63,7 +61,8 @@ public class Hologram_1_8_R1 implements Hologram {
}
public boolean isVisible(OfflinePlayer p) {
if (visible.containsKey(p)) return visible.get(p); else return false;
if (visible.containsKey(p)) return visible.get(p);
else return false;
}
private void create() {

View File

@ -1,27 +1,25 @@
package de.epiceric.shopchest.interfaces.hologram;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import de.epiceric.shopchest.interfaces.Hologram;
import net.minecraft.server.v1_8_R2.EntityArmorStand;
import net.minecraft.server.v1_8_R2.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R2.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hologram_1_8_R2 implements Hologram {
int count;
private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
private String[] text;
private Location location;
private double DISTANCE = 0.25D;
int count;
private HashMap<OfflinePlayer, Boolean> visible = new HashMap<OfflinePlayer, Boolean>();
public Hologram_1_8_R2(String[] text, Location location) {
@ -63,7 +61,8 @@ public class Hologram_1_8_R2 implements Hologram {
}
public boolean isVisible(OfflinePlayer p) {
if (visible.containsKey(p)) return visible.get(p); else return false;
if (visible.containsKey(p)) return visible.get(p);
else return false;
}
private void create() {

View File

@ -1,27 +1,25 @@
package de.epiceric.shopchest.interfaces.hologram;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import de.epiceric.shopchest.interfaces.Hologram;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hologram_1_8_R3 implements Hologram {
int count;
private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
private String[] text;
private Location location;
private double DISTANCE = 0.25D;
int count;
private HashMap<OfflinePlayer, Boolean> visible = new HashMap<OfflinePlayer, Boolean>();
public Hologram_1_8_R3(String[] text, Location location) {
@ -63,7 +61,8 @@ public class Hologram_1_8_R3 implements Hologram {
}
public boolean isVisible(OfflinePlayer p) {
if (visible.containsKey(p)) return visible.get(p); else return false;
if (visible.containsKey(p)) return visible.get(p);
else return false;
}
private void create() {

View File

@ -1,27 +1,25 @@
package de.epiceric.shopchest.interfaces.hologram;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import de.epiceric.shopchest.interfaces.Hologram;
import net.minecraft.server.v1_9_R1.EntityArmorStand;
import net.minecraft.server.v1_9_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_9_R1.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hologram_1_9_R1 implements Hologram {
int count;
private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
private String[] text;
private Location location;
private double DISTANCE = 0.25D;
int count;
private HashMap<OfflinePlayer, Boolean> visible = new HashMap<OfflinePlayer, Boolean>();
public Hologram_1_9_R1(String[] text, Location location) {
@ -63,7 +61,8 @@ public class Hologram_1_9_R1 implements Hologram {
}
public boolean isVisible(OfflinePlayer p) {
if (visible.containsKey(p)) return visible.get(p); else return false;
if (visible.containsKey(p)) return visible.get(p);
else return false;
}
private void create() {

View File

@ -1,27 +1,25 @@
package de.epiceric.shopchest.interfaces.hologram;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import de.epiceric.shopchest.interfaces.Hologram;
import net.minecraft.server.v1_9_R2.EntityArmorStand;
import net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_9_R2.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hologram_1_9_R2 implements Hologram {
int count;
private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
private String[] text;
private Location location;
private double DISTANCE = 0.25D;
int count;
private HashMap<OfflinePlayer, Boolean> visible = new HashMap<OfflinePlayer, Boolean>();
public Hologram_1_9_R2(String[] text, Location location) {
@ -63,7 +61,8 @@ public class Hologram_1_9_R2 implements Hologram {
}
public boolean isVisible(OfflinePlayer p) {
if (visible.containsKey(p)) return visible.get(p); else return false;
if (visible.containsKey(p)) return visible.get(p);
else return false;
}
private void create() {

View File

@ -1,18 +1,17 @@
package de.epiceric.shopchest.interfaces.jsonbuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.minecraft.server.v1_8_R1.ChatSerializer;
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class JsonBuilder_1_8_R1 implements JsonBuilder {
@ -29,8 +28,8 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
@Override
public JsonBuilder_1_8_R1 parse(String text) {
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "§$1");
String regex = "[&<EFBFBD>]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "<EFBFBD>$1");
if (!Pattern.compile(regex).matcher(text).find()) {
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
return this;
@ -41,8 +40,9 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
for (String word : words) {
try {
if (index != words[0].length())
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch(Exception e){}
withText(word).withColor("<EFBFBD>" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch (Exception e) {
}
index += word.length() + 2;
}
return this;
@ -94,7 +94,8 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
public String toString() {
if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
extras.remove(0);;
extras.remove(0);
;
for (String extra : extras)
text = text + extra + ",";
text = text.substring(0, text.length() - 1) + "]}";

View File

@ -1,18 +1,17 @@
package de.epiceric.shopchest.interfaces.jsonbuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class JsonBuilder_1_8_R2 implements JsonBuilder {
@ -29,8 +28,8 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
@Override
public JsonBuilder_1_8_R2 parse(String text) {
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "§$1");
String regex = "[&<EFBFBD>]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "<EFBFBD>$1");
if (!Pattern.compile(regex).matcher(text).find()) {
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
return this;
@ -41,8 +40,9 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
for (String word : words) {
try {
if (index != words[0].length())
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch(Exception e){}
withText(word).withColor("<EFBFBD>" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch (Exception e) {
}
index += word.length() + 2;
}
return this;
@ -94,7 +94,8 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
public String toString() {
if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
extras.remove(0);;
extras.remove(0);
;
for (String extra : extras)
text = text + extra + ",";
text = text.substring(0, text.length() - 1) + "]}";

View File

@ -1,18 +1,17 @@
package de.epiceric.shopchest.interfaces.jsonbuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class JsonBuilder_1_8_R3 implements JsonBuilder {
@ -29,8 +28,8 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
@Override
public JsonBuilder_1_8_R3 parse(String text) {
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "§$1");
String regex = "[&<EFBFBD>]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "<EFBFBD>$1");
if (!Pattern.compile(regex).matcher(text).find()) {
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
return this;
@ -41,8 +40,9 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
for (String word : words) {
try {
if (index != words[0].length())
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch(Exception e){}
withText(word).withColor("<EFBFBD>" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch (Exception e) {
}
index += word.length() + 2;
}
return this;
@ -94,7 +94,8 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
public String toString() {
if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
extras.remove(0);;
extras.remove(0);
;
for (String extra : extras)
text = text + extra + ",";
text = text.substring(0, text.length() - 1) + "]}";

View File

@ -1,18 +1,17 @@
package de.epiceric.shopchest.interfaces.jsonbuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_9_R1.PacketPlayOutChat;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class JsonBuilder_1_9_R1 implements JsonBuilder {
@ -29,8 +28,8 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
@Override
public JsonBuilder_1_9_R1 parse(String text) {
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "§$1");
String regex = "[&<EFBFBD>]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "<EFBFBD>$1");
if (!Pattern.compile(regex).matcher(text).find()) {
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
return this;
@ -41,8 +40,9 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
for (String word : words) {
try {
if (index != words[0].length())
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch(Exception e){}
withText(word).withColor("<EFBFBD>" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch (Exception e) {
}
index += word.length() + 2;
}
return this;
@ -94,7 +94,8 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
public String toString() {
if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
extras.remove(0);;
extras.remove(0);
;
for (String extra : extras)
text = text + extra + ",";
text = text.substring(0, text.length() - 1) + "]}";

View File

@ -1,18 +1,17 @@
package de.epiceric.shopchest.interfaces.jsonbuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.JsonBuilder;
import net.minecraft.server.v1_9_R2.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_9_R2.PacketPlayOutChat;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class JsonBuilder_1_9_R2 implements JsonBuilder {
@ -29,8 +28,8 @@ public class JsonBuilder_1_9_R2 implements JsonBuilder {
@Override
public JsonBuilder_1_9_R2 parse(String text) {
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "§$1");
String regex = "[&<EFBFBD>]{1}([a-fA-Fl-oL-O0-9]){1}";
text = text.replaceAll(regex, "<EFBFBD>$1");
if (!Pattern.compile(regex).matcher(text).find()) {
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
return this;
@ -41,8 +40,9 @@ public class JsonBuilder_1_9_R2 implements JsonBuilder {
for (String word : words) {
try {
if (index != words[0].length())
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch(Exception e){}
withText(word).withColor("<EFBFBD>" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
} catch (Exception e) {
}
index += word.length() + 2;
}
return this;
@ -94,7 +94,8 @@ public class JsonBuilder_1_9_R2 implements JsonBuilder {
public String toString() {
if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
extras.remove(0);;
extras.remove(0);
;
for (String extra : extras)
text = text + extra + ",";
text = text.substring(0, text.length() - 1) + "]}";

View File

@ -1,15 +1,15 @@
package de.epiceric.shopchest.interfaces.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import net.minecraft.server.v1_8_R1.EntityArmorStand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
public class Utils_1_8_R1 extends Utils {
@ -81,5 +81,4 @@ public class Utils_1_8_R1 extends Utils {
}
}

View File

@ -1,9 +1,5 @@
package de.epiceric.shopchest.interfaces.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Hologram;
@ -11,6 +7,9 @@ import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import net.minecraft.server.v1_8_R2.EntityArmorStand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
public class Utils_1_8_R2 extends Utils {
@ -84,5 +83,4 @@ public class Utils_1_8_R2 extends Utils {
}
}

View File

@ -1,15 +1,15 @@
package de.epiceric.shopchest.interfaces.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
public class Utils_1_8_R3 extends Utils {
@ -82,5 +82,4 @@ public class Utils_1_8_R3 extends Utils {
}
}

View File

@ -1,15 +1,15 @@
package de.epiceric.shopchest.interfaces.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import net.minecraft.server.v1_9_R1.EntityArmorStand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
public class Utils_1_9_R1 extends Utils {
@ -82,5 +82,4 @@ public class Utils_1_9_R1 extends Utils {
}
}

View File

@ -1,15 +1,15 @@
package de.epiceric.shopchest.interfaces.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ShopUtils;
import net.minecraft.server.v1_9_R2.EntityArmorStand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
public class Utils_1_9_R2 extends Utils {
@ -82,5 +82,4 @@ public class Utils_1_9_R2 extends Utils {
}
}

View File

@ -1,8 +1,11 @@
package de.epiceric.shopchest.shop;
import java.util.ArrayList;
import java.util.UUID;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.hologram.*;
import de.epiceric.shopchest.utils.ItemNames;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -17,21 +20,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Hologram;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.interfaces.hologram.*;
import de.epiceric.shopchest.utils.ItemNames;
import java.util.ArrayList;
import java.util.UUID;
public class Shop {
public enum ShopType {
NORMAL,
INFINITE,
ADMIN;
}
private ShopChest plugin;
private OfflinePlayer vendor;
private ItemStack product;
@ -41,7 +34,6 @@ public class Shop {
private double buyPrice;
private double sellPrice;
private ShopType shopType;
public Shop(ShopChest plugin, OfflinePlayer vendor, ItemStack product, Location location, double buyPrice, double sellPrice, ShopType shopType) {
this.plugin = plugin;
this.vendor = vendor;
@ -130,14 +122,18 @@ public class Shop {
if (b.getLocation().equals(r.getLocation())) {
if (r.getX() != l.getX()) holoLocation = new Location(b.getWorld(), b.getX(), b.getY() - 0.6, b.getZ() + 0.5);
else if (r.getZ() != l.getZ()) holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ());
if (r.getX() != l.getX())
holoLocation = new Location(b.getWorld(), b.getX(), b.getY() - 0.6, b.getZ() + 0.5);
else if (r.getZ() != l.getZ())
holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ());
else holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ() + 0.5);
} else {
if (r.getX() != l.getX()) holoLocation = new Location(b.getWorld(), b.getX() + 1, b.getY() - 0.6, b.getZ() + 0.5);
else if (r.getZ() != l.getZ()) holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ() + 1);
if (r.getX() != l.getX())
holoLocation = new Location(b.getWorld(), b.getX() + 1, b.getY() - 0.6, b.getZ() + 0.5);
else if (r.getZ() != l.getZ())
holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ() + 1);
else holoLocation = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.6, b.getZ() + 0.5);
}
@ -152,12 +148,23 @@ public class Shop {
else holoText[1] = Config.hologram_buy_sell(buyPrice, sellPrice);
switch (Utils.getVersion(plugin.getServer())) {
case "v1_8_R1": hologram = new Hologram_1_8_R1(holoText, holoLocation); break;
case "v1_8_R2": hologram = new Hologram_1_8_R2(holoText, holoLocation); break;
case "v1_8_R3": hologram = new Hologram_1_8_R3(holoText, holoLocation); break;
case "v1_9_R1": hologram = new Hologram_1_9_R1(holoText, holoLocation); break;
case "v1_9_R2": hologram = new Hologram_1_9_R2(holoText, holoLocation); break;
default: return;
case "v1_8_R1":
hologram = new Hologram_1_8_R1(holoText, holoLocation);
break;
case "v1_8_R2":
hologram = new Hologram_1_8_R2(holoText, holoLocation);
break;
case "v1_8_R3":
hologram = new Hologram_1_8_R3(holoText, holoLocation);
break;
case "v1_9_R1":
hologram = new Hologram_1_9_R1(holoText, holoLocation);
break;
case "v1_9_R2":
hologram = new Hologram_1_9_R2(holoText, holoLocation);
break;
default:
return;
}
}
@ -198,4 +205,10 @@ public class Shop {
return item != null;
}
public enum ShopType {
NORMAL,
INFINITE,
ADMIN;
}
}

View File

@ -1,24 +1,19 @@
package de.epiceric.shopchest.sql;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.inventory.ItemStack;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.shop.Shop.ShopType;
import de.epiceric.shopchest.utils.ShopUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.inventory.ItemStack;
import java.sql.*;
import java.util.UUID;
import java.util.logging.Level;
public abstract class Database {
@ -35,12 +30,8 @@ public abstract class Database {
"`shoptype` varchar(32) NOT NULL," +
"PRIMARY KEY (`id`)" +
");";
ShopChest plugin;
Connection connection;
// The name of the table we created back in SQLite class.
public String table = "shop_list";
public String world = "";
public String vendor = "";
public ItemStack product = null;
@ -48,6 +39,8 @@ public abstract class Database {
public double buyPrice = 0;
public double sellPrice = 0;
public ShopType shopType = ShopType.NORMAL;
ShopChest plugin;
Connection connection;
public Database(ShopChest instance) {
plugin = instance;

View File

@ -1,13 +1,14 @@
package de.epiceric.shopchest.sql;
import java.util.logging.Level;
import de.epiceric.shopchest.ShopChest;
import java.util.logging.Level;
public class Error {
public static void execute(ShopChest plugin, Exception ex) {
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
}
public static void close(ShopChest plugin, Exception ex) {
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
}

View File

@ -4,12 +4,15 @@ public class Errors {
public static String sqlConnectionExecute() {
return "Couldn't execute MySQL statement: ";
}
public static String sqlConnectionClose() {
return "Failed to close MySQL connection: ";
}
public static String noSQLConnection() {
return "Unable to retreive MYSQL connection: ";
}
public static String noTableFound() {
return "Database Error: No Table Found";
}

View File

@ -1,5 +1,7 @@
package de.epiceric.shopchest.sql;
import de.epiceric.shopchest.ShopChest;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
@ -8,8 +10,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import de.epiceric.shopchest.ShopChest;
public class SQLite extends Database {
String dbname;

View File

@ -1,11 +1,10 @@
package de.epiceric.shopchest.utils;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class ArrowEffectNames {
@ -42,28 +41,64 @@ public class ArrowEffectNames {
if (meta.getBasePotionData().isUpgraded()) {
name += " II";
switch (meta.getBasePotionData().getType()) {
case JUMP: name += " (0:11)"; break;
case SPEED: name += " (0:11)"; break;
case POISON: name += " (0:02)"; break;
case REGEN: name += " (0:02)"; break;
case STRENGTH: name += " (0:11)"; break;
default: break;
case JUMP:
name += " (0:11)";
break;
case SPEED:
name += " (0:11)";
break;
case POISON:
name += " (0:02)";
break;
case REGEN:
name += " (0:02)";
break;
case STRENGTH:
name += " (0:11)";
break;
default:
break;
}
} else {
switch (meta.getBasePotionData().getType()) {
case FIRE_RESISTANCE: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case INVISIBILITY: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case JUMP: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case LUCK: name += " (0:37)"; break;
case NIGHT_VISION: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case POISON: name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:11" : "0:05") + ")"; break;
case REGEN: name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:11" : "0:05") + ")"; break;
case SLOWNESS: name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:30" : "0:11") + ")"; break;
case SPEED: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case STRENGTH: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case WATER_BREATHING: name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")"; break;
case WEAKNESS: name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:30" : "0:11") + ")"; break;
default: break;
case FIRE_RESISTANCE:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case INVISIBILITY:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case JUMP:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case LUCK:
name += " (0:37)";
break;
case NIGHT_VISION:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case POISON:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:11" : "0:05") + ")";
break;
case REGEN:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:11" : "0:05") + ")";
break;
case SLOWNESS:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:30" : "0:11") + ")";
break;
case SPEED:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case STRENGTH:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case WATER_BREATHING:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "1:00" : "0:22") + ")";
break;
case WEAKNESS:
name += " (" + ((meta.getBasePotionData().isExtended()) ? "0:30" : "0:11") + ")";
break;
default:
break;
}
}

View File

@ -1,15 +1,29 @@
package de.epiceric.shopchest.utils;
import java.util.HashMap;
import de.epiceric.shopchest.shop.Shop.ShopType;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import de.epiceric.shopchest.shop.Shop.ShopType;
import java.util.HashMap;
public class ClickType {
private static HashMap<OfflinePlayer, ClickType> playerClickType = new HashMap<>();
private EnumClickType enumClickType;
private ItemStack product;
private double buyPrice;
private double sellPrice;
private ShopType shopType;
public ClickType(EnumClickType enumClickType) {
this.enumClickType = enumClickType;
}
public ClickType(EnumClickType enumClickType, ItemStack product, double buyPrice, double sellPrice, ShopType shopType) {
this.enumClickType = enumClickType;
this.product = product;
this.sellPrice = sellPrice;
this.buyPrice = buyPrice;
this.shopType = shopType;
}
public static ClickType getPlayerClickType(OfflinePlayer player) {
if (playerClickType.containsKey(player))
@ -26,28 +40,6 @@ public class ClickType {
playerClickType.put(player, clickType);
}
public enum EnumClickType {
CREATE, REMOVE, INFO;
}
private EnumClickType enumClickType;
private ItemStack product;
private double buyPrice;
private double sellPrice;
private ShopType shopType;
public ClickType(EnumClickType enumClickType) {
this.enumClickType = enumClickType;
}
public ClickType(EnumClickType enumClickType, ItemStack product, double buyPrice, double sellPrice, ShopType shopType) {
this.enumClickType = enumClickType;
this.product = product;
this.sellPrice = sellPrice;
this.buyPrice = buyPrice;
this.shopType = shopType;
}
public EnumClickType getClickType() {
return enumClickType;
}
@ -68,4 +60,8 @@ public class ClickType {
return shopType;
}
public enum EnumClickType {
CREATE, REMOVE, INFO;
}
}

View File

@ -1,12 +1,11 @@
package de.epiceric.shopchest.utils;
import com.google.common.collect.ImmutableMap;
import org.bukkit.enchantments.Enchantment;
import java.util.LinkedHashMap;
import java.util.Map;
import org.bukkit.enchantments.Enchantment;
import com.google.common.collect.ImmutableMap;
public class EnchantmentNames {
private static final Map<String, String> enchMap = ImmutableMap.<String, String>builder()

View File

@ -1,7 +1,6 @@
package de.epiceric.shopchest.utils;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang.WordUtils;
import org.bukkit.DyeColor;
import org.bukkit.Material;
@ -10,7 +9,7 @@ import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class ItemNames {

View File

@ -36,25 +36,13 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.lang.reflect.Method;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
@ -147,6 +135,121 @@ public class Metrics {
debug = configuration.getBoolean("debug", false);
}
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) try {
gzos.close();
} catch (IOException ignore) {
}
}
return baos.toByteArray();
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
* website. Plotters can be added to the graph object returned.
@ -510,31 +613,6 @@ public class Metrics {
}
}
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) try {
gzos.close();
} catch (IOException ignore) {
}
}
return baos.toByteArray();
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
@ -549,96 +627,6 @@ public class Metrics {
}
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/**
* Represents a custom graph on the website
*/

View File

@ -1,10 +1,9 @@
package de.epiceric.shopchest.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -14,10 +13,10 @@ import org.bukkit.block.DoubleChest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.interfaces.Utils;
import de.epiceric.shopchest.shop.Shop;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class ShopUtils {

View File

@ -1,24 +1,16 @@
package de.epiceric.shopchest.utils;
import de.epiceric.shopchest.ShopChest;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import de.epiceric.shopchest.ShopChest;
public class UpdateChecker {
public enum UpdateCheckerResult {
TRUE,
FALSE,
ERROR;
}
private ShopChest plugin;
private String url;
private String version;
private String link;
public UpdateChecker(ShopChest plugin, String url) {
this.plugin = plugin;
this.url = url;
@ -58,7 +50,8 @@ public class UpdateChecker {
if (!broadcast.equals("/"))
return messages;
} catch (Exception | Error e) {}
} catch (Exception | Error e) {
}
return null;
}
@ -71,5 +64,11 @@ public class UpdateChecker {
return link;
}
public enum UpdateCheckerResult {
TRUE,
FALSE,
ERROR;
}
}