mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-22 01:58:54 +00:00
add new show item Handler...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
38ebc66431
commit
40e4922acd
@ -7,6 +7,8 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.maxgamer.QuickShop.QuickShop;
|
import org.maxgamer.QuickShop.QuickShop;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
/** Whether debug info should be shown in the console */
|
/** Whether debug info should be shown in the console */
|
||||||
protected boolean debug = false;
|
protected boolean debug = false;
|
||||||
@ -14,8 +16,10 @@ public class ConfigManager {
|
|||||||
protected boolean display = true;
|
protected boolean display = true;
|
||||||
protected double feeForPriceChange = 0.0;
|
protected double feeForPriceChange = 0.0;
|
||||||
protected int findDistance = 30;
|
protected int findDistance = 30;
|
||||||
|
protected String guiTitle;
|
||||||
/** Whether or not to limit players shop amounts */
|
/** Whether or not to limit players shop amounts */
|
||||||
protected boolean limit = false;
|
protected boolean limit = false;
|
||||||
|
|
||||||
protected int limitdefault = 0;
|
protected int limitdefault = 0;
|
||||||
protected final HashMap<String, Integer> limits = new HashMap<String, Integer>();
|
protected final HashMap<String, Integer> limits = new HashMap<String, Integer>();
|
||||||
protected boolean logAction = true;
|
protected boolean logAction = true;
|
||||||
@ -45,33 +49,34 @@ public class ConfigManager {
|
|||||||
protected HashSet<String> warnings = new HashSet<String>();
|
protected HashSet<String> warnings = new HashSet<String>();
|
||||||
|
|
||||||
public ConfigManager(final QuickShop plugin) {
|
public ConfigManager(final QuickShop plugin) {
|
||||||
|
final FileConfig config = (FileConfig) plugin.getConfig();
|
||||||
ConfigurationSection limitCfg = plugin.getConfig().getConfigurationSection("limits");
|
ConfigurationSection limitCfg = config.getConfigurationSection("limits");
|
||||||
if (limitCfg != null) {
|
if (limitCfg != null) {
|
||||||
this.limit = limitCfg.getBoolean("use", false);
|
this.limit = limitCfg.getBoolean("use", false);
|
||||||
this.limitdefault = plugin.getConfig().getInt("limits.default");
|
this.limitdefault = config.getInt("limits.default");
|
||||||
limitCfg = limitCfg.getConfigurationSection("ranks");
|
limitCfg = limitCfg.getConfigurationSection("ranks");
|
||||||
for (final String key : limitCfg.getKeys(true)) {
|
for (final String key : limitCfg.getKeys(true)) {
|
||||||
limits.put(key, limitCfg.getInt(key));
|
limits.put(key, limitCfg.getInt(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.superItem = Enum.valueOf(Material.class, plugin.getConfig().getString("superitem"));
|
this.superItem = Enum.valueOf(Material.class, config.getString("superitem"));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
}
|
}
|
||||||
this.tax = plugin.getConfig().getDouble("tax");
|
this.tax = config.getDouble("tax");
|
||||||
this.showTax = plugin.getConfig().getBoolean("show-tax");
|
this.showTax = config.getBoolean("show-tax");
|
||||||
this.taxAccount = plugin.getConfig().getString("tax-account");
|
this.taxAccount = config.getString("tax-account");
|
||||||
this.logAction = plugin.getConfig().getBoolean("log-actions");
|
this.logAction = config.getBoolean("log-actions");
|
||||||
this.shopLock = plugin.getConfig().getBoolean("shop.lock");
|
this.shopLock = config.getBoolean("shop.lock");
|
||||||
this.display = plugin.getConfig().getBoolean("shop.display-items");
|
this.display = config.getBoolean("shop.display-items");
|
||||||
this.sneak = plugin.getConfig().getBoolean("shop.sneak-only");
|
this.sneak = config.getBoolean("shop.sneak-only");
|
||||||
this.sneakCreate = plugin.getConfig().getBoolean("shop.sneak-to-create");
|
this.sneakCreate = config.getBoolean("shop.sneak-to-create");
|
||||||
this.sneakTrade = plugin.getConfig().getBoolean("shop.sneak-to-trade");
|
this.sneakTrade = config.getBoolean("shop.sneak-to-trade");
|
||||||
this.priceChangeRequiresFee = plugin.getConfig().getBoolean("shop.price-change-requires-fee");
|
this.priceChangeRequiresFee = config.getBoolean("shop.price-change-requires-fee");
|
||||||
this.findDistance = plugin.getConfig().getInt("shop.find-distance");
|
this.findDistance = config.getInt("shop.find-distance");
|
||||||
this.feeForPriceChange = plugin.getConfig().getDouble("shop.fee-for-price-change");
|
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
|
||||||
this.preventhopper = plugin.getConfig().getBoolean("preventhopper");
|
this.preventhopper = config.getBoolean("preventhopper");
|
||||||
|
this.guiTitle = config.getMessage("guititle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getFeeForPriceChange() {
|
public double getFeeForPriceChange() {
|
||||||
@ -82,6 +87,10 @@ public class ConfigManager {
|
|||||||
return findDistance;
|
return findDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGuiTitle() {
|
||||||
|
return guiTitle;
|
||||||
|
}
|
||||||
|
|
||||||
public int getLimitdefault() {
|
public int getLimitdefault() {
|
||||||
return limitdefault;
|
return limitdefault;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +59,17 @@ public class ProtectListener implements Listener {
|
|||||||
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) {
|
if (inv.getType() != InventoryType.PLAYER && inv.getType() != InventoryType.HOPPER) {
|
||||||
|
if (inv.getTitle().equalsIgnoreCase(plugin.getConfigManager().getGuiTitle())) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
p.closeInventory();
|
||||||
|
}
|
||||||
return;
|
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));
|
||||||
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §d§l获取 " + ci.getItemMeta().getDisplayName() + " §a已清理...");
|
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §d§l获取 " + ci.getItemMeta().getDisplayName() + " §a已清理...");
|
||||||
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,9 @@ public class QuickShop extends JavaPlugin {
|
|||||||
private Database database;
|
private Database database;
|
||||||
/** The economy we hook into for transactions */
|
/** The economy we hook into for transactions */
|
||||||
private Economy economy;
|
private Economy economy;
|
||||||
|
private boolean enableMagicLib;
|
||||||
private BukkitTask itemWatcherTask;
|
private BukkitTask itemWatcherTask;
|
||||||
|
|
||||||
private LogWatcher logWatcher;
|
private LogWatcher logWatcher;
|
||||||
private final PlayerListener playerListener = new PlayerListener(this);
|
private final PlayerListener playerListener = new PlayerListener(this);
|
||||||
private final ProtectListener protectListener = new ProtectListener(this);
|
private final ProtectListener protectListener = new ProtectListener(this);
|
||||||
@ -142,6 +144,10 @@ public class QuickShop extends JavaPlugin {
|
|||||||
return this.shopManager;
|
return this.shopManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnableMagicLib() {
|
||||||
|
return enableMagicLib;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to load the economy and its core. If this fails, it will try to use
|
* Tries to load the economy and its core. If this fails, it will try to use
|
||||||
* vault. If that fails, it will return false.
|
* vault. If that fails, it will return false.
|
||||||
@ -229,10 +235,12 @@ public class QuickShop extends JavaPlugin {
|
|||||||
fm.then("suggest").suggest("qs help");
|
fm.then("suggest").suggest("qs help");
|
||||||
fm.toJSONString();
|
fm.toJSONString();
|
||||||
getLogger().info("魔改库功能测试正常...");
|
getLogger().info("魔改库功能测试正常...");
|
||||||
|
this.enableMagicLib = true;
|
||||||
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
|
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
|
||||||
getLogger().warning("========================================");
|
getLogger().warning("+=========================================");
|
||||||
getLogger().warning("警告: 启动魔改库失败 部分功能将被禁用...");
|
getLogger().warning("| 警告: 启动魔改库失败 部分功能将被禁用...");
|
||||||
getLogger().warning("========================================");
|
getLogger().warning("+=========================================");
|
||||||
|
this.enableMagicLib = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -65,8 +65,6 @@ public class DisplayItem {
|
|||||||
if (shop.getLocation().getWorld() == null) {
|
if (shop.getLocation().getWorld() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// QuickShop qs = (QuickShop)
|
|
||||||
// Bukkit.getPluginManager().getPlugin("QuickShop");
|
|
||||||
final Location displayLoc = shop.getLocation().getBlock().getRelative(0, 1, 0).getLocation();
|
final Location displayLoc = shop.getLocation().getBlock().getRelative(0, 1, 0).getLocation();
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
final Chunk c = displayLoc.getChunk();
|
final Chunk c = displayLoc.getChunk();
|
||||||
@ -95,10 +93,8 @@ 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.
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.maxgamer.QuickShop.QuickShop;
|
import org.maxgamer.QuickShop.QuickShop;
|
||||||
import org.maxgamer.QuickShop.Shop.Shop;
|
import org.maxgamer.QuickShop.Shop.Shop;
|
||||||
@ -192,5 +193,10 @@ public class MsgUtil {
|
|||||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
|
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
|
||||||
}
|
}
|
||||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||||
|
if (!plugin.isEnableMagicLib()) {
|
||||||
|
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
|
||||||
|
in.setItem(4, items);
|
||||||
|
p.openInventory(in);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ Version: 1.1
|
|||||||
superitem: GOLD_AXE
|
superitem: GOLD_AXE
|
||||||
#阻止漏斗吸取商店物品(非特殊情况不要开启)
|
#阻止漏斗吸取商店物品(非特殊情况不要开启)
|
||||||
preventhopper: false
|
preventhopper: false
|
||||||
|
#商店GUI的标题
|
||||||
|
guititle: '&6[&b快捷商店&6]&r'
|
||||||
|
|
||||||
#Tax amount (decimal) - Eg, P1 buys $50 worth of stuff from P2. Therefore, P1 loses $50, P2 gains $(1-0.05)*50, and tax-account gains $(0.05)*50.
|
#Tax amount (decimal) - Eg, P1 buys $50 worth of stuff from P2. Therefore, P1 loses $50, P2 gains $(1-0.05)*50, and tax-account gains $(0.05)*50.
|
||||||
tax: 0.00
|
tax: 0.00
|
||||||
|
Loading…
Reference in New Issue
Block a user