Added ItemTags Support; Removed compiling

This commit is contained in:
Eric 2015-09-09 12:27:23 +02:00
parent 72514750d5
commit 0ba461f16f
6 changed files with 23 additions and 83 deletions

View File

@ -2,11 +2,12 @@
name: ShopChest name: ShopChest
main: de.epiceric.shopchest.ShopChest main: de.epiceric.shopchest.ShopChest
version: 1.5.5 version: 1.5.6
author: EpicEric author: EpicEric
website: https://www.spigotmc.org/resources/shopchest.11431/ website: https://www.spigotmc.org/resources/shopchest.11431/
depend: [Vault] depend: [Vault]
softdepend: [ClearLag, LWC, Lockette] softdepend: [ClearLag, LWC, Lockette]
loadbefore: [ItemTags]
permissions: permissions:
shopchest.*: shopchest.*:

View File

@ -1,22 +1,13 @@
package de.epiceric.shopchest; package de.epiceric.shopchest;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.List; import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; 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_R1;
import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R2; import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R2;
import de.epiceric.shopchest.interfaces.jsonbuilder.JsonBuilder_R3; 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;
import de.epiceric.shopchest.utils.ClickType.EnumClickType; import de.epiceric.shopchest.utils.ClickType.EnumClickType;
import de.epiceric.shopchest.utils.ShopUtils; import de.epiceric.shopchest.utils.ShopUtils;
@ -161,12 +151,6 @@ public class Commands extends BukkitCommand {
p.sendMessage(Config.noPermission_limits()); p.sendMessage(Config.noPermission_limits());
} }
} else if (args[0].equalsIgnoreCase("compile")){
if (perm.has(p, "shopchest.compile")) {
compile(p);
}
} else { } else {
sendBasicHelpMessage(p); sendBasicHelpMessage(p);
return true; 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<String> 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) { private void checkUpdates(Player player) {
player.sendMessage(Config.checking_update()); 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() + " 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());
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name() + " compile - Compile shops.yml to shops.db (Highly Recommended)");
} }

View File

@ -20,6 +20,7 @@ import com.griefcraft.lwc.LWCPlugin;
import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.event.InteractShop; import de.epiceric.shopchest.event.InteractShop;
import de.epiceric.shopchest.event.ItemCustomNameListener;
import de.epiceric.shopchest.event.NotifyUpdate; import de.epiceric.shopchest.event.NotifyUpdate;
import de.epiceric.shopchest.event.ProtectChest; import de.epiceric.shopchest.event.ProtectChest;
import de.epiceric.shopchest.event.RegenerateShopItem; 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 InteractShop(this), this);
getServer().getPluginManager().registerEvents(new NotifyUpdate(), this); getServer().getPluginManager().registerEvents(new NotifyUpdate(), this);
getServer().getPluginManager().registerEvents(new ProtectChest(), 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); if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
} }

View File

@ -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);
}
}
}

View File

@ -9,11 +9,9 @@ import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
public class RegenerateShopItem implements Listener { public class RegenerateShopItem implements Listener {
public RegenerateShopItem() {} public RegenerateShopItem() {}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onItemDespawn(ItemDespawnEvent e) { public void onItemDespawn(ItemDespawnEvent e) {
Item item = e.getEntity(); Item item = e.getEntity();
@ -24,6 +22,5 @@ public class RegenerateShopItem implements Listener {
public void onPlayerPickUpItem(PlayerPickupItemEvent e) { public void onPlayerPickUpItem(PlayerPickupItemEvent e) {
if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true); if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true);
} }
} }

View File

@ -4,7 +4,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;