mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-22 01:58:54 +00:00
Modify Check Display Item Mothed...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
775a4207cf
commit
38ebc66431
@ -10,6 +10,7 @@ import org.bukkit.event.entity.ItemDespawnEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -57,6 +58,9 @@ public class ProtectListener implements Listener {
|
|||||||
final ItemStack ci = e.getCurrentItem();
|
final ItemStack ci = e.getCurrentItem();
|
||||||
final Inventory inv = e.getInventory();
|
final Inventory inv = e.getInventory();
|
||||||
final int solt = e.getSlot();
|
final int solt = e.getSlot();
|
||||||
|
if (inv.getType() != InventoryType.PLAYER && inv.getType() != InventoryType.HOPPER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (MarkUtil.hasMark(ci)) {
|
if (MarkUtil.hasMark(ci)) {
|
||||||
inv.setItem(solt, new ItemStack(Material.AIR));
|
inv.setItem(solt, new ItemStack(Material.AIR));
|
||||||
|
@ -225,12 +225,14 @@ public class QuickShop extends JavaPlugin {
|
|||||||
getLogger().info("尝试启动魔改库...");
|
getLogger().info("尝试启动魔改库...");
|
||||||
final FancyMessage fm = new FancyMessage("test");
|
final FancyMessage fm = new FancyMessage("test");
|
||||||
fm.then("item").itemTooltip(new ItemStack(Material.DIAMOND_SWORD));
|
fm.then("item").itemTooltip(new ItemStack(Material.DIAMOND_SWORD));
|
||||||
fm.then("link").link("ci.ccitycraft.cn");
|
fm.then("link").link("ci.citycraft.cn");
|
||||||
fm.then("suggest").suggest("qs help");
|
fm.then("suggest").suggest("qs help");
|
||||||
fm.toJSONString();
|
fm.toJSONString();
|
||||||
getLogger().info("魔改库功能测试正常...");
|
getLogger().info("魔改库功能测试正常...");
|
||||||
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
|
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
|
||||||
getLogger().info("启动魔改库失败 部分功能将被禁用...");
|
getLogger().warning("========================================");
|
||||||
|
getLogger().warning("警告: 启动魔改库失败 部分功能将被禁用...");
|
||||||
|
getLogger().warning("========================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -287,13 +289,8 @@ public class QuickShop extends JavaPlugin {
|
|||||||
final Location loc = new Location(world, x, y, z);
|
final Location loc = new Location(world, x, y, z);
|
||||||
/* Skip invalid shops, if we know of any */
|
/* Skip invalid shops, if we know of any */
|
||||||
if (world != null && loc.getChunk().isLoaded() && (loc.getBlock().getState() instanceof InventoryHolder) == false) {
|
if (world != null && loc.getChunk().isLoaded() && (loc.getBlock().getState() instanceof InventoryHolder) == false) {
|
||||||
getLogger().info("商店不是一个可存储的方块 坐标 " + rs.getString("world") + " at: " + x + ", " + y + ", " + z + ". 删除...");
|
getLogger().info("商店不是一个可存储的方块 坐标 " + rs.getString("world") + ", " + x + ", " + y + ", " + z + ". 删除...");
|
||||||
final PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
|
database.execute("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?", x, y, z, worldName);
|
||||||
delps.setInt(1, x);
|
|
||||||
delps.setInt(2, y);
|
|
||||||
delps.setInt(3, z);
|
|
||||||
delps.setString(4, worldName);
|
|
||||||
delps.execute();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int type = rs.getInt("type");
|
final int type = rs.getInt("type");
|
||||||
@ -313,12 +310,7 @@ public class QuickShop extends JavaPlugin {
|
|||||||
getLogger().warning("载入商店数据时发生错误! 商店位置: " + worldName + " (" + x + ", " + y + ", " + z + ")...");
|
getLogger().warning("载入商店数据时发生错误! 商店位置: " + worldName + " (" + x + ", " + y + ", " + z + ")...");
|
||||||
if (errors < 3) {
|
if (errors < 3) {
|
||||||
getLogger().warning("删除错误的商店数据...");
|
getLogger().warning("删除错误的商店数据...");
|
||||||
final PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
|
database.execute("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?", x, y, z, worldName);
|
||||||
delps.setInt(1, x);
|
|
||||||
delps.setInt(2, y);
|
|
||||||
delps.setInt(3, z);
|
|
||||||
delps.setString(4, worldName);
|
|
||||||
delps.execute();
|
|
||||||
} else {
|
} else {
|
||||||
getLogger().warning("过多的错误数据 可能您的数据库文件已损坏! 请检查数据库文件!");
|
getLogger().warning("过多的错误数据 可能您的数据库文件已损坏! 请检查数据库文件!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -343,9 +335,9 @@ public class QuickShop extends JavaPlugin {
|
|||||||
if (configManager.isDisplay()) {
|
if (configManager.isDisplay()) {
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this);
|
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this);
|
||||||
// Display item handler thread
|
// Display item handler thread
|
||||||
getLogger().info("开启悬浮物品刷新线程...");
|
getLogger().info("开启商店检查以及悬浮物刷新线程...");
|
||||||
final ItemWatcher itemWatcher = new ItemWatcher(this);
|
final ItemWatcher itemWatcher = new ItemWatcher(this);
|
||||||
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 600);
|
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 1800);
|
||||||
}
|
}
|
||||||
this.chatListener = new ChatListener(this);
|
this.chatListener = new ChatListener(this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
|
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
|
||||||
|
@ -23,14 +23,14 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
|
|||||||
import org.maxgamer.QuickShop.Util.Util;
|
import org.maxgamer.QuickShop.Util.Util;
|
||||||
|
|
||||||
public class ContainerShop implements Shop {
|
public class ContainerShop implements Shop {
|
||||||
private final Location loc;
|
|
||||||
private double price;
|
|
||||||
private String owner;
|
|
||||||
private final ItemStack item;
|
|
||||||
private DisplayItem displayItem;
|
private DisplayItem displayItem;
|
||||||
private boolean unlimited;
|
private final ItemStack item;
|
||||||
private ShopType shopType;
|
private final Location loc;
|
||||||
|
private String owner;
|
||||||
private final QuickShop plugin;
|
private final QuickShop plugin;
|
||||||
|
private double price;
|
||||||
|
private ShopType shopType;
|
||||||
|
private boolean unlimited;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new shop.
|
* Adds a new shop.
|
||||||
@ -637,8 +637,8 @@ public class ContainerShop implements Shop {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder sb = new StringBuilder(
|
final StringBuilder sb = new StringBuilder("商店 " + (loc.getWorld() == null ? "世界尚未载入" : "坐标: " + loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", "
|
||||||
"商店 " + (loc.getWorld() == null ? "世界尚未载入" : "坐标: " + loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")");
|
+ loc.getBlockZ() + ")");
|
||||||
sb.append(" 所有者: " + getOwner());
|
sb.append(" 所有者: " + getOwner());
|
||||||
if (isUnlimited()) {
|
if (isUnlimited()) {
|
||||||
sb.append("无限模式: true");
|
sb.append("无限模式: true");
|
||||||
@ -679,6 +679,7 @@ public class ContainerShop implements Shop {
|
|||||||
if (trans && this.getDisplayItem() == null) {
|
if (trans && this.getDisplayItem() == null) {
|
||||||
this.displayItem = new DisplayItem(this, this.getItem());
|
this.displayItem = new DisplayItem(this, this.getItem());
|
||||||
this.getDisplayItem().spawn();
|
this.getDisplayItem().spawn();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (this.getDisplayItem() != null) {
|
if (this.getDisplayItem() != null) {
|
||||||
if (!trans) { // We have a display item in a block... delete it
|
if (!trans) { // We have a display item in a block... delete it
|
||||||
|
@ -13,9 +13,9 @@ import org.maxgamer.QuickShop.Util.NMS;
|
|||||||
* cannot be interacted with.
|
* cannot be interacted with.
|
||||||
*/
|
*/
|
||||||
public class DisplayItem {
|
public class DisplayItem {
|
||||||
private final Shop shop;
|
|
||||||
private final ItemStack iStack;
|
private final ItemStack iStack;
|
||||||
private Item item;
|
private Item item;
|
||||||
|
private final Shop shop;
|
||||||
|
|
||||||
// private Location displayLoc;
|
// private Location displayLoc;
|
||||||
/**
|
/**
|
||||||
@ -95,8 +95,10 @@ public class DisplayItem {
|
|||||||
*/
|
*/
|
||||||
public void respawn() {
|
public void respawn() {
|
||||||
remove();
|
remove();
|
||||||
|
if (item.isValid()) {
|
||||||
spawn();
|
spawn();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawns the dummy item on top of the shop.
|
* Spawns the dummy item on top of the shop.
|
||||||
|
@ -125,11 +125,20 @@ public class MsgUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendItemMessage(final Player p, final ItemStack is, final String msg) {
|
||||||
|
try {
|
||||||
|
final FancyMessage fm = new FancyMessage();
|
||||||
|
fm.text(msg).itemTooltip(is).send(p);
|
||||||
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError e) {
|
||||||
|
p.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendPurchaseSuccess(final Player p, final Shop shop, final int amount) {
|
public static void sendPurchaseSuccess(final Player p, final Shop shop, final int amount) {
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.successful-purchase"));
|
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.successful-purchase"));
|
||||||
final FancyMessage fm = new FancyMessage();
|
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice())));
|
||||||
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);
|
sendItemMessage(p, shop.getItem(), msg);
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +174,8 @@ public class MsgUtil {
|
|||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
|
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| "
|
p.sendMessage(ChatColor.DARK_PURPLE + "| "
|
||||||
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
|
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
|
||||||
final FancyMessage fm = new FancyMessage();
|
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName());
|
||||||
fm.text(ChatColor.DARK_PURPLE + "| ").then(MsgUtil.p("menu.item", shop.getDataName())).itemTooltip(items).send(p);
|
sendItemMessage(p, shop.getItem(), msg);
|
||||||
if (Util.isTool(items.getType())) {
|
if (Util.isTool(items.getType())) {
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items)));
|
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items)));
|
||||||
}
|
}
|
||||||
@ -182,30 +191,6 @@ public class MsgUtil {
|
|||||||
} else {
|
} else {
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
|
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
|
||||||
}
|
}
|
||||||
// Map<Enchantment, Integer> enchs = items.getItemMeta().getEnchants();
|
|
||||||
// if (enchs != null && !enchs.isEmpty()) {
|
|
||||||
// p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.getMessage("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 (items.getItemMeta() instanceof EnchantmentStorageMeta) {
|
|
||||||
// final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) items.getItemMeta();
|
|
||||||
// stor.getStoredEnchants();
|
|
||||||
// enchs = stor.getStoredEnchants();
|
|
||||||
// if (enchs != null && !enchs.isEmpty()) {
|
|
||||||
// p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.getMessage("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 + "+---------------------------------------------------+");
|
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,10 +33,10 @@ public class Util {
|
|||||||
|
|
||||||
public static void addTransparentBlock(final Material m) {
|
public static void addTransparentBlock(final Material m) {
|
||||||
if (transparent.add(m) == false) {
|
if (transparent.add(m) == false) {
|
||||||
System.out.println("Already added as transparent: " + m.toString());
|
System.out.println("已添加透明方块: " + m.toString());
|
||||||
}
|
}
|
||||||
if (!m.isBlock()) {
|
if (!m.isBlock()) {
|
||||||
System.out.println(m + " is not a block!");
|
System.out.println(m + " 不是一个方块!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,11 +48,15 @@ public class Util {
|
|||||||
* @return True if it can be made into a shop, otherwise false.
|
* @return True if it can be made into a shop, otherwise false.
|
||||||
*/
|
*/
|
||||||
public static boolean canBeShop(final Block b) {
|
public static boolean canBeShop(final Block b) {
|
||||||
|
try {
|
||||||
final BlockState bs = b.getState();
|
final BlockState bs = b.getState();
|
||||||
if (bs instanceof InventoryHolder == false) {
|
if (bs instanceof InventoryHolder == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return shoppables.contains(bs.getType());
|
return shoppables.contains(bs.getType());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Version: 1.3
|
Version: 1.0
|
||||||
|
|
||||||
AIR_-1: 爪子
|
AIR_-1: 爪子
|
||||||
AIR: 爪子
|
AIR: 爪子
|
||||||
@ -365,7 +365,7 @@ COOKED_BEEF: 熟牛肉
|
|||||||
RAW_CHICKEN: 生鸡肉
|
RAW_CHICKEN: 生鸡肉
|
||||||
COOKED_CHICKEN: 熟鸡肉
|
COOKED_CHICKEN: 熟鸡肉
|
||||||
ROTTEN_FLESH: 腐肉
|
ROTTEN_FLESH: 腐肉
|
||||||
ENDER_PEARL: 末地传送门
|
ENDER_PEARL: 末影之眼
|
||||||
BLAZE_ROD: 烈焰棒
|
BLAZE_ROD: 烈焰棒
|
||||||
GHAST_TEAR: 恶魂之泪
|
GHAST_TEAR: 恶魂之泪
|
||||||
GOLD_NUGGET: 金粒
|
GOLD_NUGGET: 金粒
|
||||||
|
Loading…
Reference in New Issue
Block a user