mirror of
				https://e.coding.net/circlecloud/QuickShop.git
				synced 2025-11-03 17:56:41 +00:00 
			
		
		
		
	conver command and complete info command ...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
		@@ -1,588 +0,0 @@
 | 
			
		||||
package org.maxgamer.QuickShop.Command;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.Chunk;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.configuration.ConfigurationSection;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
 | 
			
		||||
import org.bukkit.util.BlockIterator;
 | 
			
		||||
import org.maxgamer.QuickShop.QuickShop;
 | 
			
		||||
import org.maxgamer.QuickShop.Database.Database;
 | 
			
		||||
import org.maxgamer.QuickShop.Database.MySQLCore;
 | 
			
		||||
import org.maxgamer.QuickShop.Database.SQLiteCore;
 | 
			
		||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
 | 
			
		||||
import org.maxgamer.QuickShop.Shop.Shop;
 | 
			
		||||
import org.maxgamer.QuickShop.Shop.ShopChunk;
 | 
			
		||||
import org.maxgamer.QuickShop.Shop.ShopType;
 | 
			
		||||
import org.maxgamer.QuickShop.Util.MsgUtil;
 | 
			
		||||
 | 
			
		||||
public class QS implements CommandExecutor {
 | 
			
		||||
	QuickShop plugin;
 | 
			
		||||
 | 
			
		||||
	public QS(final QuickShop plugin) {
 | 
			
		||||
		this.plugin = plugin;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns loc with modified pitch/yaw angles so it faces lookat
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param loc
 | 
			
		||||
	 *            The location a players head is
 | 
			
		||||
	 * @param lookat
 | 
			
		||||
	 *            The location they should be looking
 | 
			
		||||
	 * @return The location the player should be facing to have their crosshairs
 | 
			
		||||
	 *         on the location lookAt Kudos to bergerkiller for most of this
 | 
			
		||||
	 *         function
 | 
			
		||||
	 */
 | 
			
		||||
	public Location lookAt(Location loc, final Location lookat) {
 | 
			
		||||
		// Clone the loc to prevent applied changes to the input loc
 | 
			
		||||
		loc = loc.clone();
 | 
			
		||||
		// Values of change in distance (make it relative)
 | 
			
		||||
		final double dx = lookat.getX() - loc.getX();
 | 
			
		||||
		final double dy = lookat.getY() - loc.getY();
 | 
			
		||||
		final double dz = lookat.getZ() - loc.getZ();
 | 
			
		||||
		// Set yaw
 | 
			
		||||
		if (dx != 0) {
 | 
			
		||||
			// Set yaw start value based on dx
 | 
			
		||||
			if (dx < 0) {
 | 
			
		||||
				loc.setYaw((float) (1.5 * Math.PI));
 | 
			
		||||
			} else {
 | 
			
		||||
				loc.setYaw((float) (0.5 * Math.PI));
 | 
			
		||||
			}
 | 
			
		||||
			loc.setYaw(loc.getYaw() - (float) Math.atan(dz / dx));
 | 
			
		||||
		} else if (dz < 0) {
 | 
			
		||||
			loc.setYaw((float) Math.PI);
 | 
			
		||||
		}
 | 
			
		||||
		// Get the distance from dx/dz
 | 
			
		||||
		final double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
 | 
			
		||||
		final float pitch = (float) -Math.atan(dy / dxz);
 | 
			
		||||
		// Set values, convert to degrees
 | 
			
		||||
		// Minecraft yaw (vertical) angles are inverted (negative)
 | 
			
		||||
		loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI + 360);
 | 
			
		||||
		// But pitch angles are normal
 | 
			
		||||
		loc.setPitch(pitch * 180f / (float) Math.PI);
 | 
			
		||||
		return loc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
 | 
			
		||||
		if (args.length > 0) {
 | 
			
		||||
			final String subArg = args[0].toLowerCase();
 | 
			
		||||
			if (subArg.equals("unlimited")) {
 | 
			
		||||
				setUnlimited(sender);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("setowner")) {
 | 
			
		||||
				setOwner(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("find")) {
 | 
			
		||||
				find(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.startsWith("buy")) {
 | 
			
		||||
				setBuy(sender);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.startsWith("sell")) {
 | 
			
		||||
				setSell(sender);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.startsWith("price")) {
 | 
			
		||||
				setPrice(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("remove")) {
 | 
			
		||||
				remove(sender, args);
 | 
			
		||||
			} else if (subArg.equals("refill")) {
 | 
			
		||||
				refill(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("empty")) {
 | 
			
		||||
				empty(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("clean")) {
 | 
			
		||||
				clean(sender);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("reload")) {
 | 
			
		||||
				reload(sender);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("export")) {
 | 
			
		||||
				export(sender, args);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else if (subArg.equals("info")) {
 | 
			
		||||
				if (sender.hasPermission("quickshop.info")) {
 | 
			
		||||
					int buying, selling, doubles, chunks, worlds;
 | 
			
		||||
					buying = selling = doubles = chunks = worlds = 0;
 | 
			
		||||
					int nostock = 0;
 | 
			
		||||
					for (final HashMap<ShopChunk, HashMap<Location, Shop>> inWorld : plugin.getShopManager().getShops().values()) {
 | 
			
		||||
						worlds++;
 | 
			
		||||
						for (final HashMap<Location, Shop> inChunk : inWorld.values()) {
 | 
			
		||||
							chunks++;
 | 
			
		||||
							for (final Shop shop : inChunk.values()) {
 | 
			
		||||
								if (shop.isBuying()) {
 | 
			
		||||
									buying++;
 | 
			
		||||
								} else if (shop.isSelling()) {
 | 
			
		||||
									selling++;
 | 
			
		||||
								}
 | 
			
		||||
								if (shop instanceof ContainerShop && ((ContainerShop) shop).isDoubleShop()) {
 | 
			
		||||
									doubles++;
 | 
			
		||||
								} else if (shop.isSelling() && shop.getRemainingStock() == 0) {
 | 
			
		||||
									nostock++;
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					sender.sendMessage(ChatColor.RED + "QuickShop Statistics...");
 | 
			
		||||
					sender.sendMessage(ChatColor.GREEN + "" + (buying + selling) + " shops in " + chunks + " chunks spread over " + worlds + " worlds.");
 | 
			
		||||
					sender.sendMessage(ChatColor.GREEN + "" + doubles + " double shops. ");
 | 
			
		||||
					sender.sendMessage(ChatColor.GREEN + "" + nostock + " selling shops (excluding doubles) which will be removed by /qs clean.");
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			// Invalid arg given
 | 
			
		||||
			sendHelp(sender);
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		// No args given
 | 
			
		||||
		sendHelp(sender);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void sendHelp(final CommandSender s) {
 | 
			
		||||
		s.sendMessage(MsgUtil.p("command.description.title"));
 | 
			
		||||
		if (s.hasPermission("quickshop.unlimited")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs unlimited" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.unlimited"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.setowner")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs setowner <player>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.setowner"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.create.buy")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs buy" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.buy"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.create.sell")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs sell" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.sell"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.create.changeprice")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs price" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.price"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.clean")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs clean" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.clean"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.find")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs find <item>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.find"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.refill")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs refill <amount>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.refill"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.empty")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs empty" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.empty"));
 | 
			
		||||
		}
 | 
			
		||||
		if (s.hasPermission("quickshop.export")) {
 | 
			
		||||
			s.sendMessage(ChatColor.GREEN + "/qs export mysql|sqlite" + ChatColor.YELLOW + " - Exports the database to SQLite or MySQL");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void clean(final CommandSender sender) {
 | 
			
		||||
		if (sender.hasPermission("quickshop.clean")) {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("command.cleaning"));
 | 
			
		||||
			final Iterator<Shop> shIt = plugin.getShopManager().getShopIterator();
 | 
			
		||||
			int i = 0;
 | 
			
		||||
			while (shIt.hasNext()) {
 | 
			
		||||
				final Shop shop = shIt.next();
 | 
			
		||||
 | 
			
		||||
				try {
 | 
			
		||||
					if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
 | 
			
		||||
						final ContainerShop cs = (ContainerShop) shop;
 | 
			
		||||
						if (cs.isDoubleShop()) {
 | 
			
		||||
							continue;
 | 
			
		||||
						}
 | 
			
		||||
						shIt.remove(); // Is selling, but has no stock, and is a chest shop, but is not a double shop. Can be deleted safely.
 | 
			
		||||
						i++;
 | 
			
		||||
					}
 | 
			
		||||
				} catch (final IllegalStateException e) {
 | 
			
		||||
					shIt.remove(); // The shop is not there anymore, remove it
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			MsgUtil.clean();
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("command.cleaned", "" + i));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void empty(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.refill")) {
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null) {
 | 
			
		||||
					if (shop instanceof ContainerShop) {
 | 
			
		||||
						final ContainerShop cs = (ContainerShop) shop;
 | 
			
		||||
						cs.getInventory().clear();
 | 
			
		||||
						sender.sendMessage(MsgUtil.p("empty-success"));
 | 
			
		||||
						return;
 | 
			
		||||
					} else {
 | 
			
		||||
						sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		} else {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void export(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (args.length < 2) {
 | 
			
		||||
			sender.sendMessage(ChatColor.RED + "Usage: /qs export mysql|sqlite");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		final String type = args[1].toLowerCase();
 | 
			
		||||
		if (type.startsWith("mysql")) {
 | 
			
		||||
			if (plugin.getDB().getCore() instanceof MySQLCore) {
 | 
			
		||||
				sender.sendMessage(ChatColor.RED + "Database is already MySQL");
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final ConfigurationSection cfg = plugin.getConfig().getConfigurationSection("database");
 | 
			
		||||
			final String host = cfg.getString("host");
 | 
			
		||||
			final String port = cfg.getString("port");
 | 
			
		||||
			final String user = cfg.getString("user");
 | 
			
		||||
			final String pass = cfg.getString("password");
 | 
			
		||||
			final String name = cfg.getString("database");
 | 
			
		||||
			final MySQLCore core = new MySQLCore(host, user, pass, name, port);
 | 
			
		||||
			Database target;
 | 
			
		||||
			try {
 | 
			
		||||
				target = new Database(core);
 | 
			
		||||
				QuickShop.instance.getDB().copyTo(target);
 | 
			
		||||
				sender.sendMessage(ChatColor.GREEN + "Success - Exported to MySQL " + user + "@" + host + "." + name);
 | 
			
		||||
			} catch (final Exception e) {
 | 
			
		||||
				e.printStackTrace();
 | 
			
		||||
				sender.sendMessage(ChatColor.RED + "Failed to export to MySQL " + user + "@" + host + "." + name + ChatColor.DARK_RED + " Reason: " + e.getMessage());
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (type.startsWith("sql") || type.contains("file")) {
 | 
			
		||||
			if (plugin.getDB().getCore() instanceof SQLiteCore) {
 | 
			
		||||
				sender.sendMessage(ChatColor.RED + "Database is already SQLite");
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final File file = new File(plugin.getDataFolder(), "shops.db");
 | 
			
		||||
			if (file.exists()) {
 | 
			
		||||
				if (file.delete() == false) {
 | 
			
		||||
					sender.sendMessage(ChatColor.RED + "Warning: Failed to delete old shops.db file. This may cause errors.");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			final SQLiteCore core = new SQLiteCore(file);
 | 
			
		||||
			try {
 | 
			
		||||
				final Database target = new Database(core);
 | 
			
		||||
				QuickShop.instance.getDB().copyTo(target);
 | 
			
		||||
				sender.sendMessage(ChatColor.GREEN + "Success - Exported to SQLite: " + file.toString());
 | 
			
		||||
			} catch (final Exception e) {
 | 
			
		||||
				e.printStackTrace();
 | 
			
		||||
				sender.sendMessage(ChatColor.RED + "Failed to export to SQLite: " + file.toString() + " Reason: " + e.getMessage());
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(ChatColor.RED + "No target given. Usage: /qs export mysql|sqlite");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void find(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.find")) {
 | 
			
		||||
			if (args.length < 2) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("command.no-type-given"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final StringBuilder sb = new StringBuilder(args[1]);
 | 
			
		||||
			for (int i = 2; i < args.length; i++) {
 | 
			
		||||
				sb.append(" " + args[i]);
 | 
			
		||||
			}
 | 
			
		||||
			String lookFor = sb.toString();
 | 
			
		||||
			lookFor = lookFor.toLowerCase();
 | 
			
		||||
			final Player p = (Player) sender;
 | 
			
		||||
			final Location loc = p.getEyeLocation().clone();
 | 
			
		||||
			final double minDistance = plugin.getConfig().getInt("shop.find-distance");
 | 
			
		||||
			double minDistanceSquared = minDistance * minDistance;
 | 
			
		||||
			final int chunkRadius = (int) minDistance / 16 + 1;
 | 
			
		||||
			Shop closest = null;
 | 
			
		||||
			final Chunk c = loc.getChunk();
 | 
			
		||||
			for (int x = -chunkRadius + c.getX(); x < chunkRadius + c.getX(); x++) {
 | 
			
		||||
				for (int z = -chunkRadius + c.getZ(); z < chunkRadius + c.getZ(); z++) {
 | 
			
		||||
					final Chunk d = c.getWorld().getChunkAt(x, z);
 | 
			
		||||
					final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(d);
 | 
			
		||||
					if (inChunk == null) {
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
					for (final Shop shop : inChunk.values()) {
 | 
			
		||||
						if (shop.getDataName().toLowerCase().contains(lookFor) && shop.getLocation().distanceSquared(loc) < minDistanceSquared) {
 | 
			
		||||
							closest = shop;
 | 
			
		||||
							minDistanceSquared = shop.getLocation().distanceSquared(loc);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (closest == null) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("no-nearby-shop", args[1]));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final Location lookat = closest.getLocation().clone().add(0.5, 0.5, 0.5);
 | 
			
		||||
			// Hack fix to make /qs find not used by /back
 | 
			
		||||
			p.teleport(this.lookAt(loc, lookat).add(0, -1.62, 0), TeleportCause.UNKNOWN);
 | 
			
		||||
			p.sendMessage(MsgUtil.p("nearby-shop-this-way", "" + (int) Math.floor(Math.sqrt(minDistanceSquared))));
 | 
			
		||||
			return;
 | 
			
		||||
		} else {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void refill(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.refill")) {
 | 
			
		||||
			if (args.length < 2) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("command.no-amount-given"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			int add;
 | 
			
		||||
			try {
 | 
			
		||||
				add = Integer.parseInt(args[1]);
 | 
			
		||||
			} catch (final NumberFormatException e) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("thats-not-a-number"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null) {
 | 
			
		||||
					shop.add(shop.getItem(), add);
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("refill-success"));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		} else {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void reload(final CommandSender sender) {
 | 
			
		||||
		if (sender.hasPermission("quickshop.reload")) {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("command.reloading"));
 | 
			
		||||
			Bukkit.getPluginManager().disablePlugin(plugin);
 | 
			
		||||
			Bukkit.getPluginManager().enablePlugin(plugin);
 | 
			
		||||
			plugin.reloadConfig();
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void remove(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player == false) {
 | 
			
		||||
			sender.sendMessage(ChatColor.RED + "Only players may use that command.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (!sender.hasPermission("quickshop.delete")) {
 | 
			
		||||
			sender.sendMessage(ChatColor.RED + "You do not have permission to use that command. Try break the shop instead?");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		final Player p = (Player) sender;
 | 
			
		||||
		final BlockIterator bIt = new BlockIterator(p, 10);
 | 
			
		||||
		while (bIt.hasNext()) {
 | 
			
		||||
			final Block b = bIt.next();
 | 
			
		||||
			final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
			if (shop != null) {
 | 
			
		||||
				if (shop.getOwner().equals(p.getName())) {
 | 
			
		||||
					shop.delete();
 | 
			
		||||
					sender.sendMessage(ChatColor.GREEN + "Success. Deleted shop.");
 | 
			
		||||
				} else {
 | 
			
		||||
					p.sendMessage(ChatColor.RED + "That's not your shop!");
 | 
			
		||||
				}
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		p.sendMessage(ChatColor.RED + "No shop found!");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void setBuy(final CommandSender sender) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.create.buy")) {
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null && shop.getOwner().equals(((Player) sender).getName())) {
 | 
			
		||||
					shop.setShopType(ShopType.BUYING);
 | 
			
		||||
					shop.setSignText();
 | 
			
		||||
					shop.update();
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName()));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	private void setOwner(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.setowner")) {
 | 
			
		||||
			if (args.length < 2) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("command.no-owner-given"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null) {
 | 
			
		||||
					final OfflinePlayer p = this.plugin.getServer().getOfflinePlayer(args[1]);
 | 
			
		||||
					shop.setOwner(p.getName());
 | 
			
		||||
					shop.update();
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("command.new-owner", this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		} else {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	private void setPrice(final CommandSender sender, final String[] args) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.create.changeprice")) {
 | 
			
		||||
			final Player p = (Player) sender;
 | 
			
		||||
			if (args.length < 2) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("no-price-given"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			double price;
 | 
			
		||||
			try {
 | 
			
		||||
				price = Double.parseDouble(args[1]);
 | 
			
		||||
			} catch (final NumberFormatException e) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("thats-not-a-number"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			if (price < 0.01) {
 | 
			
		||||
				sender.sendMessage(MsgUtil.p("price-too-cheap"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			double fee = 0;
 | 
			
		||||
			if (plugin.getConfigManager().isPriceChangeRequiresFee()) {
 | 
			
		||||
				fee = plugin.getConfigManager().getFeeForPriceChange();
 | 
			
		||||
				if (fee > 0 && plugin.getEcon().getBalance(p.getName()) < fee) {
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator(p, 10);
 | 
			
		||||
			// Loop through every block they're looking at upto 10 blocks away
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null && (shop.getOwner().equals(((Player) sender).getUniqueId()) || sender.hasPermission("quickshop.other.price"))) {
 | 
			
		||||
					if (shop.getPrice() == price) {
 | 
			
		||||
						// Stop here if there isn't a price change
 | 
			
		||||
						sender.sendMessage(MsgUtil.p("no-price-change"));
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
					if (fee > 0) {
 | 
			
		||||
						if (!plugin.getEcon().withdraw(p.getName(), fee)) {
 | 
			
		||||
							sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
 | 
			
		||||
							return;
 | 
			
		||||
						}
 | 
			
		||||
						sender.sendMessage(MsgUtil.p("fee-charged-for-price-change", plugin.getEcon().format(fee)));
 | 
			
		||||
						plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), fee);
 | 
			
		||||
					}
 | 
			
		||||
					// Update the shop
 | 
			
		||||
					shop.setPrice(price);
 | 
			
		||||
					shop.setSignText();
 | 
			
		||||
					shop.update();
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("price-is-now", plugin.getEcon().format(shop.getPrice())));
 | 
			
		||||
					// Chest shops can be double shops.
 | 
			
		||||
					if (shop instanceof ContainerShop) {
 | 
			
		||||
						final ContainerShop cs = (ContainerShop) shop;
 | 
			
		||||
						if (cs.isDoubleShop()) {
 | 
			
		||||
							final Shop nextTo = cs.getAttachedShop();
 | 
			
		||||
							if (cs.isSelling()) {
 | 
			
		||||
								if (cs.getPrice() < nextTo.getPrice()) {
 | 
			
		||||
									sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
 | 
			
		||||
								}
 | 
			
		||||
							} else {
 | 
			
		||||
								// Buying
 | 
			
		||||
								if (cs.getPrice() > nextTo.getPrice()) {
 | 
			
		||||
									sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void setSell(final CommandSender sender) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.create.sell")) {
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null && shop.getOwner().equals(((Player) sender).getUniqueId())) {
 | 
			
		||||
					shop.setShopType(ShopType.SELLING);
 | 
			
		||||
					shop.setSignText();
 | 
			
		||||
					shop.update();
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName()));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void setUnlimited(final CommandSender sender) {
 | 
			
		||||
		if (sender instanceof Player && sender.hasPermission("quickshop.unlimited")) {
 | 
			
		||||
			final BlockIterator bIt = new BlockIterator((Player) sender, 10);
 | 
			
		||||
			while (bIt.hasNext()) {
 | 
			
		||||
				final Block b = bIt.next();
 | 
			
		||||
				final Shop shop = plugin.getShopManager().getShop(b.getLocation());
 | 
			
		||||
				if (shop != null) {
 | 
			
		||||
					shop.setUnlimited(!shop.isUnlimited());
 | 
			
		||||
					shop.update();
 | 
			
		||||
					sender.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "无限模式" : "有限模式")));
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
 | 
			
		||||
			return;
 | 
			
		||||
		} else {
 | 
			
		||||
			sender.sendMessage(MsgUtil.p("no-permission"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,45 @@
 | 
			
		||||
package org.maxgamer.QuickShop.Command;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandException;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.maxgamer.QuickShop.QuickShop;
 | 
			
		||||
 | 
			
		||||
import cn.citycraft.PluginHelper.commands.DefaultCommand;
 | 
			
		||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
 | 
			
		||||
 | 
			
		||||
public class QuickShopCommands implements CommandExecutor, DefaultCommand {
 | 
			
		||||
	HandlerSubCommand hsc;
 | 
			
		||||
	QuickShop plugin;
 | 
			
		||||
 | 
			
		||||
	public QuickShopCommands(final QuickShop plugin) {
 | 
			
		||||
		this.plugin = plugin;
 | 
			
		||||
		hsc = new HandlerSubCommand(plugin);
 | 
			
		||||
		hsc.setDefaultCommand(this);
 | 
			
		||||
		hsc.registerCommand(new CommandClean(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandEmpty(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandExport(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandFind(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandInfo(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandPrice(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandRefill(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandReload(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandRemove(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandBuy(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandSetOwner(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandSell(plugin));
 | 
			
		||||
		hsc.registerCommand(new CommandUnlimited(plugin));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void defaultexecute(final CommandSender sender, final Command command, final String label) throws CommandException {
 | 
			
		||||
		hsc.sendHelp(sender, label);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
 | 
			
		||||
		return hsc.onCommand(sender, cmd, label, args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -43,7 +43,7 @@ public class PlayerListener implements Listener {
 | 
			
		||||
	public void onClick(final PlayerInteractEvent e) {
 | 
			
		||||
		final Block b = e.getClickedBlock();
 | 
			
		||||
		final Player p = e.getPlayer();
 | 
			
		||||
		if (e.getAction() != Action.LEFT_CLICK_BLOCK || (e.getMaterial() == plugin.getConfigManager().getSuperItem() && b.getType() != Material.WALL_SIGN)) {
 | 
			
		||||
		if (e.getAction() != Action.LEFT_CLICK_BLOCK || (e.getMaterial() == plugin.getConfigManager().getSuperItem() && b.getType() == Material.WALL_SIGN)) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (!Util.canBeShop(b) || plugin.getConfigManager().isSneak() != p.isSneaking()) {
 | 
			
		||||
@@ -125,14 +125,11 @@ public class PlayerListener implements Listener {
 | 
			
		||||
		}, 60);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@EventHandler(priority = EventPriority.HIGH)
 | 
			
		||||
	/**
 | 
			
		||||
	 * Waits for a player to move too far from a shop, then cancels the menu.
 | 
			
		||||
	 */
 | 
			
		||||
	@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
			
		||||
	public void onMove(final PlayerMoveEvent e) {
 | 
			
		||||
		if (e.isCancelled()) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		final Info info = plugin.getShopManager().getActions().get(e.getPlayer().getName());
 | 
			
		||||
		if (info != null) {
 | 
			
		||||
			final Player p = e.getPlayer();
 | 
			
		||||
@@ -191,7 +188,7 @@ public class PlayerListener implements Listener {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@EventHandler
 | 
			
		||||
	@EventHandler(ignoreCancelled = true)
 | 
			
		||||
	public void onTeleport(final PlayerTeleportEvent e) {
 | 
			
		||||
		final PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
 | 
			
		||||
		onMove(me);
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.plugin.PluginManager;
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
			
		||||
import org.bukkit.scheduler.BukkitTask;
 | 
			
		||||
import org.maxgamer.QuickShop.Command.QS;
 | 
			
		||||
import org.maxgamer.QuickShop.Command.QuickShopCommands;
 | 
			
		||||
import org.maxgamer.QuickShop.Config.ConfigManager;
 | 
			
		||||
import org.maxgamer.QuickShop.Config.ItemConfig;
 | 
			
		||||
import org.maxgamer.QuickShop.Database.Database;
 | 
			
		||||
@@ -59,26 +59,26 @@ public class QuickShop extends JavaPlugin {
 | 
			
		||||
	public static QuickShop instance;
 | 
			
		||||
	/** The plugin default config */
 | 
			
		||||
	public FileConfig config;
 | 
			
		||||
	/** The economy we hook into for transactions */
 | 
			
		||||
	private Economy economy;
 | 
			
		||||
	/** The Shop Manager used to store shops */
 | 
			
		||||
	private ShopManager shopManager;
 | 
			
		||||
	/** The Config Manager used to read config */
 | 
			
		||||
	private ConfigManager configManager;
 | 
			
		||||
	/** The database for storing all our data for persistence */
 | 
			
		||||
	private Database database;
 | 
			
		||||
 | 
			
		||||
	// Listeners - We decide which one to use at runtime
 | 
			
		||||
	private ChatListener chatListener;
 | 
			
		||||
	// private HeroChatListener heroChatListener;
 | 
			
		||||
	// Listeners (These don't)
 | 
			
		||||
	private final BlockListener blockListener = new BlockListener(this);
 | 
			
		||||
	private final PlayerListener playerListener = new PlayerListener(this);
 | 
			
		||||
	private final ProtectListener protectListener = new ProtectListener(this);
 | 
			
		||||
	// Listeners - We decide which one to use at runtime
 | 
			
		||||
	private ChatListener chatListener;
 | 
			
		||||
	private final ChunkListener chunkListener = new ChunkListener(this);
 | 
			
		||||
	private final WorldListener worldListener = new WorldListener(this);
 | 
			
		||||
	/** The Config Manager used to read config */
 | 
			
		||||
	private ConfigManager configManager;
 | 
			
		||||
 | 
			
		||||
	/** The database for storing all our data for persistence */
 | 
			
		||||
	private Database database;
 | 
			
		||||
	/** The economy we hook into for transactions */
 | 
			
		||||
	private Economy economy;
 | 
			
		||||
	private BukkitTask itemWatcherTask;
 | 
			
		||||
	private LogWatcher logWatcher;
 | 
			
		||||
	private final PlayerListener playerListener = new PlayerListener(this);
 | 
			
		||||
	private final ProtectListener protectListener = new ProtectListener(this);
 | 
			
		||||
	/** The Shop Manager used to store shops */
 | 
			
		||||
	private ShopManager shopManager;
 | 
			
		||||
	private final WorldListener worldListener = new WorldListener(this);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Prints debug information if QuickShop is configured to do so.
 | 
			
		||||
@@ -194,7 +194,6 @@ public class QuickShop extends JavaPlugin {
 | 
			
		||||
		try {
 | 
			
		||||
			this.database.getConnection().close();
 | 
			
		||||
		} catch (final SQLException e) {
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
		}
 | 
			
		||||
		configManager.getWarnings().clear();
 | 
			
		||||
	}
 | 
			
		||||
@@ -337,7 +336,7 @@ public class QuickShop extends JavaPlugin {
 | 
			
		||||
		this.chatListener = new ChatListener(this);
 | 
			
		||||
		Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
 | 
			
		||||
		// Command handlers
 | 
			
		||||
		final QS commandExecutor = new QS(this);
 | 
			
		||||
		final QuickShopCommands commandExecutor = new QuickShopCommands(this);
 | 
			
		||||
		getCommand("qs").setExecutor(commandExecutor);
 | 
			
		||||
		if (configManager.getFindDistance() > 100) {
 | 
			
		||||
			getLogger().warning("商店查找半径过大 可能导致服务器Lag! 推荐使用低于 100 的配置!");
 | 
			
		||||
 
 | 
			
		||||
@@ -55,14 +55,13 @@ public class ShopManager {
 | 
			
		||||
			}
 | 
			
		||||
			final int max = plugin.getShopLimit(p);
 | 
			
		||||
			if (owned + 1 > max) {
 | 
			
		||||
				p.sendMessage(ChatColor.RED + "您已经创建了 " + owned + "/" + max + " 个商店!");
 | 
			
		||||
				p.sendMessage(MsgUtil.p("you-cant-create-more-shop", owned));
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		final PlayerInteractEvent pie = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, new ItemStack(Material.AIR), b, bf); // PIE = PlayerInteractEvent - What else?
 | 
			
		||||
		Bukkit.getPluginManager().callEvent(pie);
 | 
			
		||||
		pie.getPlayer().closeInventory(); // If the player has chat open, this
 | 
			
		||||
											// will close their chat.
 | 
			
		||||
		pie.getPlayer().closeInventory(); // If the player has chat open, this will close their chat.
 | 
			
		||||
		if (pie.isCancelled()) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,7 @@ public class MsgUtil {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static String p(final String loc, final String... args) {
 | 
			
		||||
	public static String p(final String loc, final Object... args) {
 | 
			
		||||
		String raw = messages.getString(loc);
 | 
			
		||||
		if (raw == null || raw.isEmpty()) {
 | 
			
		||||
			return "语言文件词条丢失: " + loc;
 | 
			
		||||
@@ -95,7 +95,7 @@ public class MsgUtil {
 | 
			
		||||
			return raw;
 | 
			
		||||
		}
 | 
			
		||||
		for (int i = 0; i < args.length; i++) {
 | 
			
		||||
			raw = raw.replace("{" + i + "}", args[i] == null ? "null" : args[i]);
 | 
			
		||||
			raw = raw.replace("{" + i + "}", args[i] == null ? "null" : args[i].toString());
 | 
			
		||||
		}
 | 
			
		||||
		return raw;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -173,23 +173,6 @@ public class Util {
 | 
			
		||||
			name = name.substring(0, 16);
 | 
			
		||||
		}
 | 
			
		||||
		return name;
 | 
			
		||||
		// final String[] nameParts = name.split("_");
 | 
			
		||||
		// if (nameParts.length == 1) {
 | 
			
		||||
		// return firstUppercase(nameParts[0]);
 | 
			
		||||
		// }
 | 
			
		||||
		//
 | 
			
		||||
		// for (int i = 0; i < nameParts.length - 1; i++) {
 | 
			
		||||
		// final int length = StringUtils.join(nameParts).length();
 | 
			
		||||
		// if (length > 16) {
 | 
			
		||||
		// nameParts[i] = nameParts[i].substring(0, 1) + ".";
 | 
			
		||||
		// } else {
 | 
			
		||||
		// nameParts[i] = firstUppercase(nameParts[i]);
 | 
			
		||||
		// }
 | 
			
		||||
		// }
 | 
			
		||||
		//
 | 
			
		||||
		// nameParts[nameParts.length - 1] = firstUppercase(nameParts[nameParts.length - 1]);
 | 
			
		||||
		//
 | 
			
		||||
		// return StringUtils.join(nameParts);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,99 +1,101 @@
 | 
			
		||||
# Colors:
 | 
			
		||||
# &0-9, &a-f
 | 
			
		||||
# {0}, {1}, {2}, etc are variables. You can swap them around, but adding a new variable won't work. Removing them will work
 | 
			
		||||
Version: 1.1
 | 
			
		||||
Version: 1.2
 | 
			
		||||
 | 
			
		||||
not-looking-at-shop: "&c没找到快捷商店. 你必须看着那个箱子."
 | 
			
		||||
no-permission: "&4你没有此命令的权限."
 | 
			
		||||
no-creative-break: "&c你不能在创造模式中打破其他玩家的商店,请使用生存模式."
 | 
			
		||||
no-double-chests: "&c你没有权限创建一个大箱子商店,请使用一个箱子."
 | 
			
		||||
shop-already-owned: "&c这已经是一个箱子了."
 | 
			
		||||
chest-was-removed: "&c商店已被移除."
 | 
			
		||||
price-too-cheap: "&c商品价格不能低于 &e{0}"
 | 
			
		||||
no-price-change: "&c商店价格未改变!"
 | 
			
		||||
you-cant-afford-a-new-shop: "&c创建一个新的商店需要花费 {0} 你没有足够的钱!."
 | 
			
		||||
you-cant-afford-to-change-price: "&c改变商店的价格需要花费 {0} 你没有足够的钱!."
 | 
			
		||||
success-created-shop: "&a成功创建商店."
 | 
			
		||||
success-removed-shop: "&a成功移除商店."
 | 
			
		||||
shops-arent-locked: "&c注意!商店还没有被保护! 请用木牌锁锁上箱子保护你的商店!"
 | 
			
		||||
shop-creation-cancelled: "&c取消创建商店."
 | 
			
		||||
shop-purchase-cancelled: "&c取消购买."
 | 
			
		||||
shop-stock-too-low: "&c商店库存仅剩 {0} {1} "
 | 
			
		||||
you-cant-afford-to-buy: "&c此商品需要 {0}, 但是你只有 {1}"
 | 
			
		||||
negative-amount: "&c警告, 不能交易负数物品."
 | 
			
		||||
player-bought-from-your-store: "&c{0} 购买了 {1} {2} 从你的商店."
 | 
			
		||||
shop-out-of-stock: "&5你在 {0}, {1}, {2} 的商店, {3} 库存不足了"
 | 
			
		||||
shop-has-no-space: "&c商店只能收购 {0} more {1}."
 | 
			
		||||
you-dont-have-that-many-items: "&c你只有 {0} {1}."
 | 
			
		||||
the-owner-cant-afford-to-buy-from-you: "&c此商品出售价格为 {0} 但是所有者只有 {1}"
 | 
			
		||||
player-sold-to-your-store: "&a{0} 出售 {1} 个 {2} 到你的商店."
 | 
			
		||||
shop-out-of-space: "&5你在 {0}, {1}, {2}, 的商店库存满了."
 | 
			
		||||
fee-charged-for-price-change: "&a你只付了 &c{0}&a 改变了商品价格." 
 | 
			
		||||
price-is-now: "&a此商店目前的价格为 &e{0}"
 | 
			
		||||
thats-not-a-number: "&4错误参数:请输入一个数字!"
 | 
			
		||||
no-price-given: "&c请设置一个价格."
 | 
			
		||||
average-price-nearby: "&a附近平均价格: &e{0}"
 | 
			
		||||
shop-has-changed: "&c你点击的商店已经改变!"
 | 
			
		||||
nearby-shop-this-way: "&a商店距离你 {0} 个方块."
 | 
			
		||||
no-nearby-shop: "&c附近未找到 {0} 商店."
 | 
			
		||||
buying-more-than-selling: "&4警告: 你购买的物品将比收购的物品多!"
 | 
			
		||||
not-enough-space: "&c你没有足够的空间装{0}!"
 | 
			
		||||
refill-success: "&a库存补充成功"
 | 
			
		||||
empty-success: "&a库存清理成功"
 | 
			
		||||
not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个箱子.'
 | 
			
		||||
no-permission: '&4你没有此命令的权限.'
 | 
			
		||||
no-creative-break: '&c你不能在创造模式中打破其他玩家的商店,请使用生存模式.'
 | 
			
		||||
no-double-chests: '&c你没有权限创建一个大箱子商店,请使用一个箱子.'
 | 
			
		||||
shop-already-owned: '&c这已经是一个箱子了.'
 | 
			
		||||
chest-was-removed: '&c商店已被移除.'
 | 
			
		||||
price-too-cheap: '&c商品价格不能低于 &e{0}'
 | 
			
		||||
no-price-change: '&c商店价格未改变!'
 | 
			
		||||
you-cant-create-more-shop: '&c您已经创建了 {0} 个商店 无法建造更多商店!'
 | 
			
		||||
you-cant-afford-a-new-shop: '&c创建一个新的商店需要花费 {0} 你没有足够的钱!.'
 | 
			
		||||
you-cant-afford-to-change-price: '&c改变商店的价格需要花费 {0} 你没有足够的钱!.'
 | 
			
		||||
success-created-shop: '&a成功创建商店.'
 | 
			
		||||
success-removed-shop: '&c成功移除商店.'
 | 
			
		||||
shops-arent-locked: '&c注意!商店还没有被保护! 请用木牌锁锁上箱子保护你的商店!'
 | 
			
		||||
shop-creation-cancelled: '&c取消创建商店.'
 | 
			
		||||
shop-purchase-cancelled: '&c取消购买.'
 | 
			
		||||
shop-stock-too-low: '&c商店库存仅剩 {0} {1} '
 | 
			
		||||
you-cant-afford-to-buy: '&c此商品需要 {0}, 但是你只有 {1}'
 | 
			
		||||
negative-amount: '&c警告, 错误的物品数量.'
 | 
			
		||||
player-bought-from-your-store: '&d{0} 购买了 {1} {2} 从你的商店.'
 | 
			
		||||
shop-out-of-stock: '&5你在 {0}, {1}, {2} 的商店, {3} 库存不足了'
 | 
			
		||||
shop-has-no-space: '&c商店只能收购 {0} more {1}.'
 | 
			
		||||
you-dont-have-that-many-items: '&c你只有 {0} {1}.'
 | 
			
		||||
the-owner-cant-afford-to-buy-from-you: '&c此商品出售价格为 {0} 但是所有者只有 {1}'
 | 
			
		||||
player-sold-to-your-store: '&a{0} 出售 {1} 个 {2} 到你的商店.'
 | 
			
		||||
shop-out-of-space: '&5你在 {0}, {1}, {2}, 的商店库存满了.'
 | 
			
		||||
fee-charged-for-price-change: '&a你只付了 &c{0}&a 改变了商品价格.'
 | 
			
		||||
price-is-now: '&a此商店目前的价格为 &e{0}'
 | 
			
		||||
thats-not-a-number: '&4错误参数:请输入一个数字!'
 | 
			
		||||
no-price-given: '&c请设置一个价格.'
 | 
			
		||||
average-price-nearby: '&a附近平均价格: &e{0}'
 | 
			
		||||
shop-has-changed: '&c你点击的商店已经改变!'
 | 
			
		||||
nearby-shop-this-way: '&a商店距离你 {0} 个方块.'
 | 
			
		||||
no-nearby-shop: '&c附近未找到 {0} 商店.'
 | 
			
		||||
buying-more-than-selling: '&4警告: 你购买的物品超出了商店的库存!'
 | 
			
		||||
not-enough-space: '&c你没有足够的空间装{0}!'
 | 
			
		||||
refill-success: '&a库存补充成功'
 | 
			
		||||
empty-success: '&a库存清理成功'
 | 
			
		||||
 | 
			
		||||
menu:
 | 
			
		||||
    successful-purchase: "&a商品购买成功:"
 | 
			
		||||
    successfully-sold: "&a商品出售成功:"
 | 
			
		||||
    item-name-and-price: "&d交易成功 &e{0} &a件 &e{1}&b(查看详情) &a商品 &b金额 &e{2}"
 | 
			
		||||
    
 | 
			
		||||
    shop-information: "&a商店信息:"
 | 
			
		||||
    owner: "&a所有者: {0}"
 | 
			
		||||
    item: "&a物品: &e{0} &b(查看详情)"
 | 
			
		||||
    space: "&aSpace: &e{0}"
 | 
			
		||||
    stock: "&a库存: &e{0}"
 | 
			
		||||
    price-per: "&a单价: &e{1}元"
 | 
			
		||||
    total-value-of-chest: "&a所有存货总价格: &c{0}元"
 | 
			
		||||
    damage-percent-remaining: "&a耐久剩余: &e{0}."
 | 
			
		||||
    this-shop-is-buying: "&a此商店只 &d购买&a 物品."
 | 
			
		||||
    this-shop-is-selling: "&a此商店只 &b出售&a 商品."
 | 
			
		||||
    
 | 
			
		||||
bypassing-lock: "&c无视快捷商店锁!"
 | 
			
		||||
that-is-locked: "&c此快捷商店已上锁."
 | 
			
		||||
 | 
			
		||||
how-many-buy: "&a请输入 &b购买商品数量&a 在聊天栏."
 | 
			
		||||
how-many-sell: "&a请输入 &d出售商品数量&a 在聊天栏. 你目前有 &e{0}&a 件物品"
 | 
			
		||||
 | 
			
		||||
not-allowed-to-create: "&c你不能在这里创建商店."
 | 
			
		||||
blacklisted-item: "&c此物品在快捷商店黑名单内. 你不能出售它"
 | 
			
		||||
how-much-to-trade-for: "&a请输入物品 &e{0}&a 的价格在聊天栏开始&c出售商品."
 | 
			
		||||
  successful-purchase: '&a商品购买成功:'
 | 
			
		||||
  successfully-sold: '&a商品出售成功:'
 | 
			
		||||
  item-name-and-price: '&d交易成功 &e{0} &a件 &e{1}&b(查看详情) &a商品 &b金额 &e{2}'
 | 
			
		||||
  shop-information: '&a商店信息:'
 | 
			
		||||
  owner: '&a所有者: {0}'
 | 
			
		||||
  item: '&a物品: &e{0} &b(查看详情)'
 | 
			
		||||
  space: '&aSpace: &e{0}'
 | 
			
		||||
  stock: '&a库存: &e{0}'
 | 
			
		||||
  price-per: '&a单价: &e{1}元'
 | 
			
		||||
  total-value-of-chest: '&a所有存货总价格: &c{0}元'
 | 
			
		||||
  damage-percent-remaining: '&a耐久剩余: &e{0}.'
 | 
			
		||||
  this-shop-is-buying: '&a此商店只 &d购买&a 物品.'
 | 
			
		||||
  this-shop-is-selling: '&a此商店只 &b出售&a 商品.'
 | 
			
		||||
  
 | 
			
		||||
info:
 | 
			
		||||
  title: '当前加载的 {0} 个区块中 共有 {1} 个商店 覆盖 {2} 个世界.'
 | 
			
		||||
  selling: '出售商店有 {0} 个.'
 | 
			
		||||
  buying: '收购商店有 {0} 个.'
 | 
			
		||||
  double: '大箱子商店 {0} 个.'
 | 
			
		||||
  canclean: '可以用 /qs clean 清理的商店有 {0} 个.'
 | 
			
		||||
  
 | 
			
		||||
bypassing-lock: '&c无视快捷商店锁!'
 | 
			
		||||
that-is-locked: '&c此快捷商店已上锁.'
 | 
			
		||||
how-many-buy: '&a请输入 &b购买商品数量&a 在聊天栏.'
 | 
			
		||||
how-many-sell: '&a请输入 &d出售商品数量&a 在聊天栏. 你目前有 &e{0}&a 件物品'
 | 
			
		||||
not-allowed-to-create: '&c你不能在这里创建商店.'
 | 
			
		||||
blacklisted-item: '&c此物品在快捷商店黑名单内. 你不能出售它'
 | 
			
		||||
how-much-to-trade-for: '&a请输入物品 &e{0}&a 的价格在聊天栏开始&c出售商品.'
 | 
			
		||||
 | 
			
		||||
command:
 | 
			
		||||
   success-created-unlimited: "&a无限商店创建成功!"
 | 
			
		||||
   toggle-unlimited: "&a商店现在 {0}"
 | 
			
		||||
   no-owner-given: "&c此商店没有所有者. 请使用 &a/qs setowner <玩家>&c 设置!"
 | 
			
		||||
   new-owner: "&a新的所有者: &e{0}"
 | 
			
		||||
   now-buying: "&a当前商店已改为 &d收购模式 &e{0}"
 | 
			
		||||
   now-selling: "&a当前商店已改为 &b出售模式 &e{0}"
 | 
			
		||||
   cleaning: "&a正在清理0库存的商店..."
 | 
			
		||||
   reloading: "&a配置文件重新载入中..."
 | 
			
		||||
   cleaned: "&a清理 &e{0}&a 商店"
 | 
			
		||||
   no-type-given: "&c请使用: /qs find <物品> 查找商品"
 | 
			
		||||
   description:
 | 
			
		||||
       title: "&a快捷商店帮助"
 | 
			
		||||
       unlimited: "&e创建一个无限商店"
 | 
			
		||||
       setowner: "&e改变商店的所有者"
 | 
			
		||||
       buy: "&e改变商店模式为 &d购买"
 | 
			
		||||
       sell: "&e改变商店模式为 &b出售"
 | 
			
		||||
       clean: "&e清除所有0库存的商店"
 | 
			
		||||
       price: "&e更改商店 &b出售/收购 &e的价格"
 | 
			
		||||
       find: "&e查找附近的商店."
 | 
			
		||||
       reload: "&e从config.yml文件中重载快捷商店配置"
 | 
			
		||||
       refill: "&e给一个商店加入指定数量的物品"
 | 
			
		||||
       empty: "&e清空一个商店的所有货物"
 | 
			
		||||
       
 | 
			
		||||
  success-created-unlimited: '&a无限商店创建成功!'
 | 
			
		||||
  toggle-unlimited: '&a商店现在 {0}'
 | 
			
		||||
  no-owner-given: '&c此商店没有所有者. 请使用 &a/qs setowner <玩家>&c 设置!'
 | 
			
		||||
  new-owner: '&a新的所有者: &e{0}'
 | 
			
		||||
  now-buying: '&a当前商店已改为 &d收购模式 &e{0}'
 | 
			
		||||
  now-selling: '&a当前商店已改为 &b出售模式 &e{0}'
 | 
			
		||||
  cleaning: '&a正在清理0库存的商店...'
 | 
			
		||||
  reloading: '&a配置文件重新载入中...'
 | 
			
		||||
  cleaned: '&a清理 &e{0}&a 商店'
 | 
			
		||||
  no-type-given: '&c请使用: /qs find <物品> 查找商品'
 | 
			
		||||
  description:
 | 
			
		||||
    title: '&a快捷商店帮助'
 | 
			
		||||
    unlimited: '&e创建一个无限商店'
 | 
			
		||||
    setowner: '&e改变商店的所有者'
 | 
			
		||||
    buy: '&e改变商店模式为 &d购买'
 | 
			
		||||
    sell: '&e改变商店模式为 &b出售'
 | 
			
		||||
    clean: '&e清除所有0库存的商店'
 | 
			
		||||
    price: '&e更改商店 &b出售/收购 &e的价格'
 | 
			
		||||
    find: '&e查找附近的商店.'
 | 
			
		||||
    reload: '&e从config.yml文件中重载快捷商店配置'
 | 
			
		||||
    refill: '&e给一个商店加入指定数量的物品'
 | 
			
		||||
    empty: '&e清空一个商店的所有货物.'
 | 
			
		||||
    export: '&e导出 数据库 到 SQLite 或者 MySQL'
 | 
			
		||||
    info: '&e查看当前服务器商店信息.'
 | 
			
		||||
    
 | 
			
		||||
signs:
 | 
			
		||||
    #Line 1 is used as an identifier at the moment, so I kind of need it to work, thats why I won't let you change it
 | 
			
		||||
    #Line 3 is the item name... There really isnt anything to change.
 | 
			
		||||
    selling: "出售数量: {0}"
 | 
			
		||||
    buying: "收购数量: {0}"
 | 
			
		||||
    price: "每件价格: ${0}"
 | 
			
		||||
  selling: '出售数量: {0}'
 | 
			
		||||
  buying: '收购数量: {0}'
 | 
			
		||||
  price: '每件价格: ${0}'
 | 
			
		||||
		Reference in New Issue
	
	Block a user