1
0
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:
502647092 2015-10-15 19:04:15 +08:00
parent 38ebc66431
commit 40e4922acd
6 changed files with 51 additions and 25 deletions

View File

@ -7,6 +7,8 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.maxgamer.QuickShop.QuickShop;
import cn.citycraft.PluginHelper.config.FileConfig;
public class ConfigManager {
/** Whether debug info should be shown in the console */
protected boolean debug = false;
@ -14,8 +16,10 @@ public class ConfigManager {
protected boolean display = true;
protected double feeForPriceChange = 0.0;
protected int findDistance = 30;
protected String guiTitle;
/** Whether or not to limit players shop amounts */
protected boolean limit = false;
protected int limitdefault = 0;
protected final HashMap<String, Integer> limits = new HashMap<String, Integer>();
protected boolean logAction = true;
@ -45,33 +49,34 @@ public class ConfigManager {
protected HashSet<String> warnings = new HashSet<String>();
public ConfigManager(final QuickShop plugin) {
ConfigurationSection limitCfg = plugin.getConfig().getConfigurationSection("limits");
final FileConfig config = (FileConfig) plugin.getConfig();
ConfigurationSection limitCfg = config.getConfigurationSection("limits");
if (limitCfg != null) {
this.limit = limitCfg.getBoolean("use", false);
this.limitdefault = plugin.getConfig().getInt("limits.default");
this.limitdefault = config.getInt("limits.default");
limitCfg = limitCfg.getConfigurationSection("ranks");
for (final String key : limitCfg.getKeys(true)) {
limits.put(key, limitCfg.getInt(key));
}
}
try {
this.superItem = Enum.valueOf(Material.class, plugin.getConfig().getString("superitem"));
this.superItem = Enum.valueOf(Material.class, config.getString("superitem"));
} catch (final Exception e) {
}
this.tax = plugin.getConfig().getDouble("tax");
this.showTax = plugin.getConfig().getBoolean("show-tax");
this.taxAccount = plugin.getConfig().getString("tax-account");
this.logAction = plugin.getConfig().getBoolean("log-actions");
this.shopLock = plugin.getConfig().getBoolean("shop.lock");
this.display = plugin.getConfig().getBoolean("shop.display-items");
this.sneak = plugin.getConfig().getBoolean("shop.sneak-only");
this.sneakCreate = plugin.getConfig().getBoolean("shop.sneak-to-create");
this.sneakTrade = plugin.getConfig().getBoolean("shop.sneak-to-trade");
this.priceChangeRequiresFee = plugin.getConfig().getBoolean("shop.price-change-requires-fee");
this.findDistance = plugin.getConfig().getInt("shop.find-distance");
this.feeForPriceChange = plugin.getConfig().getDouble("shop.fee-for-price-change");
this.preventhopper = plugin.getConfig().getBoolean("preventhopper");
this.tax = config.getDouble("tax");
this.showTax = config.getBoolean("show-tax");
this.taxAccount = config.getString("tax-account");
this.logAction = config.getBoolean("log-actions");
this.shopLock = config.getBoolean("shop.lock");
this.display = config.getBoolean("shop.display-items");
this.sneak = config.getBoolean("shop.sneak-only");
this.sneakCreate = config.getBoolean("shop.sneak-to-create");
this.sneakTrade = config.getBoolean("shop.sneak-to-trade");
this.priceChangeRequiresFee = config.getBoolean("shop.price-change-requires-fee");
this.findDistance = config.getInt("shop.find-distance");
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
this.preventhopper = config.getBoolean("preventhopper");
this.guiTitle = config.getMessage("guititle");
}
public double getFeeForPriceChange() {
@ -82,6 +87,10 @@ public class ConfigManager {
return findDistance;
}
public String getGuiTitle() {
return guiTitle;
}
public int getLimitdefault() {
return limitdefault;
}

View File

@ -59,12 +59,17 @@ public class ProtectListener implements Listener {
final Inventory inv = e.getInventory();
final int solt = e.getSlot();
if (inv.getType() != InventoryType.PLAYER && inv.getType() != InventoryType.HOPPER) {
if (inv.getTitle().equalsIgnoreCase(plugin.getConfigManager().getGuiTitle())) {
e.setCancelled(true);
p.closeInventory();
}
return;
}
try {
if (MarkUtil.hasMark(ci)) {
inv.setItem(solt, new ItemStack(Material.AIR));
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §d§l获取 " + ci.getItemMeta().getDisplayName() + " §a已清理...");
p.closeInventory();
}
} catch (final Exception ex) {
}

View File

@ -74,7 +74,9 @@ public class QuickShop extends JavaPlugin {
private Database database;
/** The economy we hook into for transactions */
private Economy economy;
private boolean enableMagicLib;
private BukkitTask itemWatcherTask;
private LogWatcher logWatcher;
private final PlayerListener playerListener = new PlayerListener(this);
private final ProtectListener protectListener = new ProtectListener(this);
@ -142,6 +144,10 @@ public class QuickShop extends JavaPlugin {
return this.shopManager;
}
public boolean isEnableMagicLib() {
return enableMagicLib;
}
/**
* Tries to load the economy and its core. If this fails, it will try to use
* vault. If that fails, it will return false.
@ -229,10 +235,12 @@ public class QuickShop extends JavaPlugin {
fm.then("suggest").suggest("qs help");
fm.toJSONString();
getLogger().info("魔改库功能测试正常...");
this.enableMagicLib = true;
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
getLogger().warning("========================================");
getLogger().warning("警告: 启动魔改库失败 部分功能将被禁用...");
getLogger().warning("========================================");
getLogger().warning("+=========================================");
getLogger().warning("| 警告: 启动魔改库失败 部分功能将被禁用...");
getLogger().warning("+=========================================");
this.enableMagicLib = false;
}
try {

View File

@ -65,8 +65,6 @@ public class DisplayItem {
if (shop.getLocation().getWorld() == null) {
return false;
}
// QuickShop qs = (QuickShop)
// Bukkit.getPluginManager().getPlugin("QuickShop");
final Location displayLoc = shop.getLocation().getBlock().getRelative(0, 1, 0).getLocation();
boolean removed = false;
final Chunk c = displayLoc.getChunk();
@ -95,9 +93,7 @@ public class DisplayItem {
*/
public void respawn() {
remove();
if (item.isValid()) {
spawn();
}
spawn();
}
/**

View File

@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.QuickShop.QuickShop;
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 + "+---------------------------------------------------+");
if (!plugin.isEnableMagicLib()) {
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
in.setItem(4, items);
p.openInventory(in);
}
}
}

View File

@ -4,6 +4,8 @@ Version: 1.1
superitem: GOLD_AXE
#阻止漏斗吸取商店物品(非特殊情况不要开启)
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: 0.00