mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-12-29 08:08:49 +00:00
Release Version 1.0...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
d870528b7f
commit
ebf4d99e72
@ -2,12 +2,12 @@ package org.maxgamer.QuickShop.Economy;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
public class Economy_Vault implements EconomyCore {
|
||||
private Economy vault;
|
||||
|
||||
@ -15,12 +15,37 @@ public class Economy_Vault implements EconomyCore {
|
||||
setupEconomy();
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
this.vault = ((Economy) economyProvider.getProvider());
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean deposit(final String name, final double amount) {
|
||||
return this.vault.depositPlayer(name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deposit(final UUID name, final double amount) {
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.depositPlayer(p, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(final double balance) {
|
||||
try {
|
||||
return this.vault.format(balance);
|
||||
} catch (final NumberFormatException e) {
|
||||
}
|
||||
return this.vault != null;
|
||||
return "" + balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public double getBalance(final String name) {
|
||||
return this.vault.getBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(final UUID name) {
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.getBalance(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,19 +55,7 @@ public class Economy_Vault implements EconomyCore {
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean deposit(String name, double amount) {
|
||||
return this.vault.depositPlayer(name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean withdraw(String name, double amount) {
|
||||
return this.vault.withdrawPlayer(name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean transfer(String from, String to, double amount) {
|
||||
public boolean transfer(final String from, final String to, final double amount) {
|
||||
if (this.vault.getBalance(from) >= amount) {
|
||||
if (this.vault.withdrawPlayer(from, amount).transactionSuccess()) {
|
||||
if (!this.vault.depositPlayer(to, amount).transactionSuccess()) {
|
||||
@ -57,36 +70,9 @@ public class Economy_Vault implements EconomyCore {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public double getBalance(String name) {
|
||||
return this.vault.getBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double balance) {
|
||||
try {
|
||||
return this.vault.format(balance);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return "$" + balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deposit(UUID name, double amount) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.depositPlayer(p, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdraw(UUID name, double amount) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.withdrawPlayer(p, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transfer(UUID from, UUID to, double amount) {
|
||||
OfflinePlayer pFrom = Bukkit.getOfflinePlayer(from);
|
||||
OfflinePlayer pTo = Bukkit.getOfflinePlayer(to);
|
||||
public boolean transfer(final UUID from, final UUID to, final double amount) {
|
||||
final OfflinePlayer pFrom = Bukkit.getOfflinePlayer(from);
|
||||
final OfflinePlayer pTo = Bukkit.getOfflinePlayer(to);
|
||||
if (this.vault.getBalance(pFrom) >= amount) {
|
||||
if (this.vault.withdrawPlayer(pFrom, amount).transactionSuccess()) {
|
||||
if (!this.vault.depositPlayer(pTo, amount).transactionSuccess()) {
|
||||
@ -101,8 +87,22 @@ public class Economy_Vault implements EconomyCore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(UUID name) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.getBalance(p);
|
||||
@Deprecated
|
||||
public boolean withdraw(final String name, final double amount) {
|
||||
return this.vault.withdrawPlayer(name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdraw(final UUID name, final double amount) {
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||
return this.vault.withdrawPlayer(p, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
final RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
this.vault = (economyProvider.getProvider());
|
||||
}
|
||||
return this.vault != null;
|
||||
}
|
||||
}
|
@ -7,20 +7,20 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Netherfoam
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ChatListener implements Listener {
|
||||
QuickShop plugin;
|
||||
|
||||
public ChatListener(QuickShop plugin) {
|
||||
public ChatListener(final QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(final AsyncPlayerChatEvent e) {
|
||||
if (!plugin.getShopManager().getActions().containsKey(e.getPlayer().getUniqueId())) {
|
||||
if (!plugin.getShopManager().getActions().containsKey(e.getPlayer().getName())) {
|
||||
return;
|
||||
}
|
||||
plugin.getShopManager().handleChat(e.getPlayer(), e.getMessage());
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -14,12 +13,14 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
@ -37,17 +38,6 @@ public class PlayerListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Could be useful one day private LinkedList<String> getParents(Class<?>
|
||||
* clazz){ LinkedList<String> classes = new LinkedList<String>();
|
||||
*
|
||||
* while(clazz != null){ classes.add("Extends " + ChatColor.GREEN +
|
||||
* clazz.getCanonicalName()); for(Class<?> iface : clazz.getInterfaces()){
|
||||
* classes.add("Implements " + ChatColor.RED + iface.getCanonicalName());
|
||||
* classes.addAll(getParents(iface)); }
|
||||
*
|
||||
* clazz = clazz.getSuperclass(); } return classes; }
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
/**
|
||||
* Handles players left clicking a chest. Left click a NORMAL chest with
|
||||
@ -90,9 +80,9 @@ public class PlayerListener implements Listener {
|
||||
p.sendMessage(MsgUtil.p("how-many-sell", "" + items));
|
||||
}
|
||||
// Add the new action
|
||||
final HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
|
||||
final HashMap<String, Info> actions = plugin.getShopManager().getActions();
|
||||
final Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
|
||||
actions.put(p.getUniqueId(), info);
|
||||
actions.put(p.getName(), info);
|
||||
return;
|
||||
}
|
||||
// Handles creating shops
|
||||
@ -127,17 +117,31 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
// Send creation menu.
|
||||
final Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
|
||||
plugin.getShopManager().getActions().put(p.getName(), info);
|
||||
p.sendMessage(MsgUtil.p("how-much-to-trade-for", Util.getName(info.getItem())));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemClick(final InventoryClickEvent e) {
|
||||
final Player p = (Player) e.getWhoClicked();
|
||||
final ItemStack ci = e.getCurrentItem();
|
||||
final Inventory inv = e.getInventory();
|
||||
final int solt = e.getSlot();
|
||||
try {
|
||||
if (MarkUtil.hasMark(ci)) {
|
||||
inv.setItem(solt, new ItemStack(Material.AIR));
|
||||
p.chat("§c非法获取快捷商店悬浮物品 已清理...");
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemMove(final InventoryMoveItemEvent e) {
|
||||
final ItemStack ci = e.getItem();
|
||||
if (MarkUtil.hasMark(ci)) {
|
||||
ci.setType(Material.AIR);
|
||||
e.setCancelled(true);
|
||||
e.setItem(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +164,7 @@ public class PlayerListener implements Listener {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final Info info = plugin.getShopManager().getActions().get(e.getPlayer().getUniqueId());
|
||||
final Info info = plugin.getShopManager().getActions().get(e.getPlayer().getName());
|
||||
if (info != null) {
|
||||
final Player p = e.getPlayer();
|
||||
final Location loc1 = info.getLocation();
|
||||
@ -171,7 +175,7 @@ public class PlayerListener implements Listener {
|
||||
} else if (info.getAction() == ShopAction.BUY) {
|
||||
p.sendMessage(MsgUtil.p("shop-purchase-cancelled"));
|
||||
}
|
||||
plugin.getShopManager().getActions().remove(p.getUniqueId());
|
||||
plugin.getShopManager().getActions().remove(p.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -180,13 +184,15 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerPickup(final PlayerPickupItemEvent e) {
|
||||
final ItemStack ci = e.getItem().getItemStack();
|
||||
e.setCancelled(!MarkUtil.hasMark(ci));
|
||||
if (MarkUtil.hasMark(ci)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent e) {
|
||||
// Remove them from the menu
|
||||
plugin.getShopManager().getActions().remove(e.getPlayer().getUniqueId());
|
||||
plugin.getShopManager().getActions().remove(e.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -159,8 +159,8 @@ public class QuickShop extends JavaPlugin {
|
||||
final EconomyCore core = new Economy_Vault();
|
||||
if (!core.isValid()) {
|
||||
// getLogger().severe("Economy is not valid!");
|
||||
getLogger().severe("QuickShop could not hook an economy!");
|
||||
getLogger().severe("QuickShop CANNOT start!");
|
||||
getLogger().warning("无法找到经济管理类插件...");
|
||||
getLogger().warning("卸载插件!!!");
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
// if(econ.equals("Vault"))
|
||||
// getLogger().severe("(Does Vault have an Economy to hook into?!)");
|
||||
@ -283,7 +283,7 @@ public class QuickShop extends JavaPlugin {
|
||||
int count = 0; // Shops count
|
||||
Connection con;
|
||||
try {
|
||||
getLogger().info("从数据看载入商店数据...");
|
||||
getLogger().info("从数据库载入商店数据...");
|
||||
con = database.getConnection();
|
||||
final PreparedStatement ps = con.prepareStatement("SELECT * FROM shops");
|
||||
final ResultSet rs = ps.executeQuery();
|
||||
|
@ -638,13 +638,13 @@ public class ContainerShop implements Shop {
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder(
|
||||
"Shop " + (loc.getWorld() == null ? "unloaded world" : loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")");
|
||||
sb.append(" Owner: " + getOwner().toString());
|
||||
"商店 " + (loc.getWorld() == null ? "世界尚未载入" : "坐标: " + loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")");
|
||||
sb.append(" 所有者: " + getOwner());
|
||||
if (isUnlimited()) {
|
||||
sb.append(" Unlimited: true");
|
||||
sb.append("无限模式: true");
|
||||
}
|
||||
sb.append(" Price: " + getPrice());
|
||||
sb.append("Item: " + getItem().toString());
|
||||
sb.append("价格: " + getPrice());
|
||||
sb.append("物品: " + getItem().toString());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ public class ContainerShop implements Shop {
|
||||
final int unlimited = this.isUnlimited() ? 1 : 0;
|
||||
final String q = "UPDATE shops SET owner = ?, itemConfig = ?, unlimited = ?, type = ?, price = ? WHERE x = ? AND y = ? and z = ? and world = ?";
|
||||
try {
|
||||
plugin.getDB().execute(q, this.getOwner().toString(), Util.serialize(this.getItem()), unlimited, shopType.toID(), this.getPrice(), x, y, z, world);
|
||||
plugin.getDB().execute(q, this.getOwner(), Util.serialize(this.getItem()), unlimited, shopType.toID(), this.getPrice(), x, y, z, world);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Could not update shop in database! Changes will revert after a reboot!");
|
||||
|
@ -3,7 +3,6 @@ package org.maxgamer.QuickShop.Shop;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -90,7 +89,7 @@ public class ShopManager {
|
||||
}
|
||||
|
||||
private final QuickShop plugin;
|
||||
private final HashMap<UUID, Info> actions = new HashMap<UUID, Info>();
|
||||
private final HashMap<String, Info> actions = new HashMap<String, Info>();
|
||||
|
||||
private final HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = new HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>>();
|
||||
|
||||
@ -113,13 +112,13 @@ public class ShopManager {
|
||||
int owned = 0;
|
||||
final Iterator<Shop> it = getShopIterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().getOwner().equals(p.getUniqueId())) {
|
||||
if (it.next().getOwner().equals(p.getName())) {
|
||||
owned++;
|
||||
}
|
||||
}
|
||||
final int max = plugin.getShopLimit(p);
|
||||
if (owned + 1 > max) {
|
||||
p.sendMessage(ChatColor.RED + "You have already created a maximum of " + owned + "/" + max + " shops!");
|
||||
p.sendMessage(ChatColor.RED + "您已经创建了 " + owned + "/" + max + " 个商店!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -171,8 +170,9 @@ public class ShopManager {
|
||||
// Add it to the world
|
||||
addShop(loc.getWorld().getName(), shop);
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().warning("无法保存商店到数据库! 下次重启商店将会消失!");
|
||||
plugin.getLogger().warning("错误信息: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
System.out.println("Could not create shop! Changes will revert after a reboot!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class ShopManager {
|
||||
* @return Returns the HashMap<Player name, shopInfo>. Info contains what
|
||||
* their last question etc was.
|
||||
*/
|
||||
public HashMap<UUID, Info> getActions() {
|
||||
public HashMap<String, Info> getActions() {
|
||||
return this.actions;
|
||||
}
|
||||
|
||||
@ -273,9 +273,9 @@ public class ShopManager {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
final HashMap<UUID, Info> actions = getActions();
|
||||
final HashMap<String, Info> actions = getActions();
|
||||
// They wanted to do something.
|
||||
final Info info = actions.remove(p.getUniqueId());
|
||||
final Info info = actions.remove(p.getName());
|
||||
if (info == null) {
|
||||
return; // multithreaded means this can happen
|
||||
}
|
||||
@ -323,26 +323,25 @@ public class ShopManager {
|
||||
}
|
||||
// Create the sample shop.
|
||||
final Shop shop = new ContainerShop(info.getLocation(), price, info.getItem(), p.getName());
|
||||
shop.onLoad();
|
||||
final ShopCreateEvent e = new ShopCreateEvent(shop, p);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
shop.onUnload();
|
||||
return;
|
||||
}
|
||||
// This must be called after the event has been called.
|
||||
// Else, if the event is cancelled, they won't get their
|
||||
// money back.
|
||||
if (tax != 0) {
|
||||
if (!plugin.getEcon().withdraw(p.getName(), tax)) {
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-a-new-shop", format(tax)));
|
||||
shop.onUnload();
|
||||
return;
|
||||
}
|
||||
plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), tax);
|
||||
}
|
||||
final ShopCreateEvent e = new ShopCreateEvent(shop, p);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
shop.onLoad();
|
||||
/* The shop has hereforth been successfully created */
|
||||
createShop(shop);
|
||||
p.sendMessage(MsgUtil.p("success-created-shop"));
|
||||
final Location loc = shop.getLocation();
|
||||
plugin.log(p.getName() + " created a " + shop.getDataName() + " shop at (" + loc.getWorld().getName() + " - " + loc.getX() + "," + loc.getY() + "," + loc.getZ() + ")");
|
||||
if (!plugin.getConfig().getBoolean("shop.lock")) {
|
||||
@ -363,34 +362,6 @@ public class ShopManager {
|
||||
sign.setFacingDirection(bf);
|
||||
bs.update(true);
|
||||
shop.setSignText();
|
||||
/*
|
||||
* Block b = shop.getLocation().getBlock();
|
||||
* ItemFrame iFrame = (ItemFrame)
|
||||
* b.getWorld().spawnEntity(b.getLocation(),
|
||||
* EntityType.ITEM_FRAME);
|
||||
*
|
||||
* BlockFace[] faces = new
|
||||
* BlockFace[]{BlockFace.NORTH, BlockFace.EAST,
|
||||
* BlockFace.SOUTH, BlockFace.WEST}; for(BlockFace
|
||||
* face : faces){ if(face == bf) continue; //This is
|
||||
* the sign's location iFrame.setFacingDirection(bf,
|
||||
* true); //iFrame.setItem(shop.getItem());
|
||||
* ItemStack iStack = shop.getItem().clone();
|
||||
* iStack.setAmount(0); iFrame.setItem(iStack); /*
|
||||
* Field handleField =
|
||||
* iFrame.getClass().getField("entity");
|
||||
* handleField.setAccessible(true); Object handle =
|
||||
* handleField.get(iFrame);
|
||||
*
|
||||
* ItemStack bukkitStack = shop.getItem();
|
||||
*
|
||||
* Field itemStackHandle =
|
||||
*
|
||||
* Method setItemStack =
|
||||
* handle.getClass().getMethod("a", Object.class);
|
||||
* setItemStack.
|
||||
*/
|
||||
// }
|
||||
}
|
||||
if (shop instanceof ContainerShop) {
|
||||
final ContainerShop cs = (ContainerShop) shop;
|
||||
@ -456,7 +427,7 @@ public class ShopManager {
|
||||
return; // Cancelled
|
||||
}
|
||||
// Money handling
|
||||
if (!p.getUniqueId().equals(shop.getOwner())) {
|
||||
if (!p.getName().equals(shop.getOwner())) {
|
||||
// Check their balance. Works with *most* economy
|
||||
// plugins*
|
||||
if (plugin.getEcon().getBalance(p.getName()) < amount * shop.getPrice()) {
|
||||
@ -468,7 +439,7 @@ public class ShopManager {
|
||||
// Do charge an amount of tax though.
|
||||
final double tax = plugin.getConfig().getDouble("tax");
|
||||
final double total = amount * shop.getPrice();
|
||||
if (!plugin.getEcon().withdraw(p.getUniqueId(), total)) {
|
||||
if (!plugin.getEcon().withdraw(p.getName(), total)) {
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
|
||||
return;
|
||||
}
|
||||
@ -521,7 +492,7 @@ public class ShopManager {
|
||||
return;
|
||||
}
|
||||
// Money handling
|
||||
if (!p.getUniqueId().equals(shop.getOwner())) {
|
||||
if (!p.getName().equals(shop.getOwner())) {
|
||||
// Don't tax them if they're purchasing from
|
||||
// themselves.
|
||||
// Do charge an amount of tax though.
|
||||
|
@ -4,17 +4,13 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
|
||||
@ -35,7 +31,7 @@ public class MsgUtil {
|
||||
* on space.
|
||||
*/
|
||||
public static void clean() {
|
||||
System.out.println("Cleaning purchase messages from database that are over a week old...");
|
||||
System.out.println("清理超过 一周 的 商店交易记录...");
|
||||
// 604800,000 msec = 1 week.
|
||||
final long weekAgo = System.currentTimeMillis() - 604800000;
|
||||
plugin.getDB().execute("DELETE FROM messages WHERE time < ?", weekAgo);
|
||||
@ -139,38 +135,8 @@ public class MsgUtil {
|
||||
public static void sendPurchaseSuccess(final Player p, final Shop shop, final int amount) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.successful-purchase"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice()))));
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("menu.enchants") + "-----------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.p("menu.stored-enchants") + "--------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
|
||||
if (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.p("menu.stored-enchants") + "--------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final ClassNotFoundException e) {
|
||||
// They don't have an up to date enough build of CB to do this.
|
||||
// TODO: Remove this when it becomes redundant
|
||||
}
|
||||
final FancyMessage fm = new FancyMessage();
|
||||
fm.text(ChatColor.DARK_PURPLE + "| ").then(MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice())))).itemTooltip(shop.getItem()).send(p);
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
@ -189,30 +155,6 @@ public class MsgUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("menu.enchants") + "-----------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
|
||||
if (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("menu.stored-enchants") + "-----------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final ClassNotFoundException e) {
|
||||
// They don't have an up to date enough build of CB to do this.
|
||||
// TODO: Remove this when it becomes redundant
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class Util {
|
||||
try {
|
||||
return plugin.getEcon().format(n);
|
||||
} catch (final NumberFormatException e) {
|
||||
return "$" + n;
|
||||
return "" + n;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: 1.2
|
||||
Version: 1.0
|
||||
|
||||
AIR_-1: 爪子
|
||||
AIR: 爪子
|
||||
STONE: 石头
|
||||
|
@ -1,6 +1,7 @@
|
||||
# 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.0
|
||||
|
||||
not-looking-at-shop: "&c没找到快捷商店. 你必须看着那个箱子."
|
||||
no-permission: "&4你没有此命令的权限."
|
||||
@ -43,14 +44,14 @@ empty-success: "&a库存清理成功"
|
||||
menu:
|
||||
successful-purchase: "&a商品购买成功:"
|
||||
successfully-sold: "&a商品出售成功:"
|
||||
item-name-and-price: "&a花费:&e{2} &a获得 &e{0} &a件 &e{1} &a商品"
|
||||
item-name-and-price: "&a花费:&e{2} &a获得 &e{0} &a件 &e{1}&b(查看详情) &a商品"
|
||||
|
||||
shop-information: "&a商店信息:"
|
||||
owner: "&a所有者: {0}"
|
||||
item: "&a物品: &e{0}"
|
||||
item: "&a物品: &e{0} &b(查看详情)"
|
||||
space: "&aSpace: &e{0}"
|
||||
stock: "&a库存: &e{0}"
|
||||
price-per: "&a每件 &e{0} 的价格 &a为 &e{1}"
|
||||
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 物品."
|
||||
|
Loading…
Reference in New Issue
Block a user