mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-27 13:07:24 +01:00
Added ItemTags Support; Removed compiling
This commit is contained in:
parent
72514750d5
commit
0ba461f16f
@ -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.*:
|
||||
|
@ -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<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) {
|
||||
|
||||
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)");
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
|
||||
getServer().getPluginManager().registerEvents(new ItemCustomNameListener(), this);
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
|
||||
|
||||
}
|
||||
|
||||
|
17
src/de/epiceric/shopchest/event/ItemCustomNameListener.java
Normal file
17
src/de/epiceric/shopchest/event/ItemCustomNameListener.java
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,6 @@ public class RegenerateShopItem implements Listener {
|
||||
|
||||
public RegenerateShopItem() {}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onItemDespawn(ItemDespawnEvent e) {
|
||||
Item item = e.getEntity();
|
||||
@ -25,5 +23,4 @@ public class RegenerateShopItem implements Listener {
|
||||
if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user