diff --git a/plugin.yml b/plugin.yml index 080335c..0e4c645 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,11 +2,12 @@ name: ShopChest main: de.epiceric.shopchest.ShopChest -version: 1.5.5 +version: 1.5.6 author: EpicEric website: https://www.spigotmc.org/resources/shopchest.11431/ depend: [Vault] softdepend: [ClearLag, LWC, Lockette] +loadbefore: [ItemTags] permissions: shopchest.*: diff --git a/src/de/epiceric/shopchest/Commands.java b/src/de/epiceric/shopchest/Commands.java index 9b3281a..45b2605 100644 --- a/src/de/epiceric/shopchest/Commands.java +++ b/src/de/epiceric/shopchest/Commands.java @@ -1,22 +1,13 @@ package de.epiceric.shopchest; -import java.io.File; -import java.io.IOException; import java.lang.reflect.Method; -import java.nio.file.Files; import java.util.List; -import java.util.Set; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -29,7 +20,6 @@ import de.epiceric.shopchest.interfaces.Utils; import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R1; import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R2; import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R3; -import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.utils.ClickType; import de.epiceric.shopchest.utils.ClickType.EnumClickType; import de.epiceric.shopchest.utils.ShopUtils; @@ -161,12 +151,6 @@ public class Commands extends BukkitCommand { p.sendMessage(Config.noPermission_limits()); } - } else if (args[0].equalsIgnoreCase("compile")){ - - if (perm.has(p, "shopchest.compile")) { - compile(p); - } - } else { sendBasicHelpMessage(p); return true; @@ -186,65 +170,6 @@ public class Commands extends BukkitCommand { } - private void compile(Player player) { - - player.sendMessage(" "); - player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Starting Compilation..."); - player.sendMessage(ChatColor.GOLD + "This command will be removed in the next update. Be sure to compile the shops in this version!"); - player.sendMessage(ChatColor.GOLD + "Please execute this command only once or the whole plugin will get messed up and all shops must be deleted!"); - - File shopChestDataFolder = new File(plugin.getDataFolder(), "data"); - if (!shopChestDataFolder.exists()) { - player.sendMessage(ChatColor.RED + "Cannot find shops.yml file."); - player.sendMessage(ChatColor.RED + "Be sure it's located in \"/plugins/ShopChest/data/shops.yml\""); - player.sendMessage(" "); - return; - } - - File shopChestsFile = new File(shopChestDataFolder, "shops.yml"); - if (!shopChestsFile.exists()) { - player.sendMessage(ChatColor.RED + "Cannot find shops.yml file."); - player.sendMessage(ChatColor.RED + "Be sure it's located in \"/plugins/ShopChest/data/shops.yml\""); - player.sendMessage(" "); - return; - } - - YamlConfiguration shopChests = YamlConfiguration.loadConfiguration(shopChestsFile); - - Set keys = shopChests.getKeys(false); - - for (String key : keys) { - - OfflinePlayer vendor = shopChests.getOfflinePlayer(key + ".vendor"); - int locationX = shopChests.getInt(key + ".location.x"); - int locationY = shopChests.getInt(key + ".location.y"); - int locationZ = shopChests.getInt(key + ".location.z"); - World locationWorld = plugin.getServer().getWorld(shopChests.getString(key + ".location.world")); - Location location = new Location(locationWorld, locationX, locationY, locationZ); - ItemStack product = shopChests.getItemStack(key + ".product"); - double buyPrice = shopChests.getDouble(key + ".price.buy"); - double sellPrice = shopChests.getDouble(key + ".price.sell"); - boolean infinite = shopChests.getBoolean(key + ".infinite"); - - ShopChest.sqlite.addShop(new Shop(plugin, vendor, product, location, buyPrice, sellPrice, infinite)); - - } - - - player.sendMessage(ChatColor.GREEN + "Successfully compiled " + String.valueOf(keys.size()) + " Shops."); - - try { - Files.delete(shopChestsFile.toPath()); - Files.delete(shopChestDataFolder.toPath()); - player.sendMessage(ChatColor.GREEN + "Successfully deleted data folder."); - } catch (IOException e) { - player.sendMessage(ChatColor.RED + "Could not delete data folder. You may delete it yourself."); - } - - player.sendMessage(" "); - - } - private void checkUpdates(Player player) { player.sendMessage(Config.checking_update()); @@ -384,7 +309,6 @@ public class Commands extends BukkitCommand { 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() + " limits - " + Config.cmdDesc_limits()); - player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " compile - Compile shops.yml to shops.db (Highly Recommended)"); } diff --git a/src/de/epiceric/shopchest/ShopChest.java b/src/de/epiceric/shopchest/ShopChest.java index fd3fa6b..e1143a2 100644 --- a/src/de/epiceric/shopchest/ShopChest.java +++ b/src/de/epiceric/shopchest/ShopChest.java @@ -20,6 +20,7 @@ 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; @@ -192,8 +193,9 @@ public class ShopChest extends JavaPlugin{ getServer().getPluginManager().registerEvents(new InteractShop(this), this); getServer().getPluginManager().registerEvents(new NotifyUpdate(), this); getServer().getPluginManager().registerEvents(new ProtectChest(), this); + getServer().getPluginManager().registerEvents(new ItemCustomNameListener(), this); + if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this); - } diff --git a/src/de/epiceric/shopchest/event/ItemCustomNameListener.java b/src/de/epiceric/shopchest/event/ItemCustomNameListener.java new file mode 100644 index 0000000..0a18432 --- /dev/null +++ b/src/de/epiceric/shopchest/event/ItemCustomNameListener.java @@ -0,0 +1,17 @@ +package de.epiceric.shopchest.event; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ItemSpawnEvent; + +public class ItemCustomNameListener implements Listener { + + @EventHandler(priority=EventPriority.HIGH) + public void onItemSpawn(ItemSpawnEvent e) { + if (e.getEntity().hasMetadata("shopItem")) { + e.getEntity().setCustomNameVisible(false); + } + } + +} diff --git a/src/de/epiceric/shopchest/event/RegenerateShopItem.java b/src/de/epiceric/shopchest/event/RegenerateShopItem.java index a584cb0..363d83f 100644 --- a/src/de/epiceric/shopchest/event/RegenerateShopItem.java +++ b/src/de/epiceric/shopchest/event/RegenerateShopItem.java @@ -9,11 +9,9 @@ import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.player.PlayerPickupItemEvent; public class RegenerateShopItem implements Listener { - + public RegenerateShopItem() {} - - @EventHandler(priority = EventPriority.HIGH) public void onItemDespawn(ItemDespawnEvent e) { Item item = e.getEntity(); @@ -24,6 +22,5 @@ public class RegenerateShopItem implements Listener { public void onPlayerPickUpItem(PlayerPickupItemEvent e) { if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true); } - } diff --git a/src/de/epiceric/shopchest/sql/Database.java b/src/de/epiceric/shopchest/sql/Database.java index ffece94..6cff066 100644 --- a/src/de/epiceric/shopchest/sql/Database.java +++ b/src/de/epiceric/shopchest/sql/Database.java @@ -4,7 +4,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.UUID; import java.util.logging.Level;