1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

add config usemagiclib...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-10-16 16:02:48 +08:00
parent 037f5138bb
commit f807c054d4
5 changed files with 79 additions and 73 deletions

View File

@ -5,11 +5,14 @@ import java.util.HashSet;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.QuickShop.QuickShop; import org.maxgamer.QuickShop.QuickShop;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import mkremins.fanciful.FancyMessage;
public class ConfigManager { public class ConfigManager {
private boolean enableMagicLib;
/** 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;
/** Whether we should use display items or not */ /** Whether we should use display items or not */
@ -17,9 +20,9 @@ public class ConfigManager {
protected double feeForPriceChange = 0.0; protected double feeForPriceChange = 0.0;
protected int findDistance = 30; protected int findDistance = 30;
protected String guiTitle = "§6[§b快捷商店§6]"; protected String guiTitle = "§6[§b快捷商店§6]";
/** 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;
@ -77,6 +80,22 @@ public class ConfigManager {
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change"); this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
this.preventhopper = config.getBoolean("preventhopper"); this.preventhopper = config.getBoolean("preventhopper");
this.guiTitle = config.getMessage("guititle"); this.guiTitle = config.getMessage("guititle");
try {
plugin.getLogger().info("尝试启动魔改库...");
final FancyMessage fm = new FancyMessage("test");
fm.then("item").itemTooltip(new ItemStack(Material.DIAMOND_SWORD));
fm.then("link").link("ci.citycraft.cn");
fm.then("suggest").suggest("qs help");
fm.toJSONString();
plugin.getLogger().info("魔改库功能测试正常...");
this.enableMagicLib = true;
} catch (final NoClassDefFoundError | NoSuchMethodError | Exception e) {
plugin.getLogger().warning("+=========================================");
plugin.getLogger().warning("| 警告: 启动魔改库失败 将使用GUI界面...");
plugin.getLogger().warning("+=========================================");
this.enableMagicLib = false;
}
this.enableMagicLib = enableMagicLib && config.getBoolean("usemagiclib", true);
} }
public double getFeeForPriceChange() { public double getFeeForPriceChange() {
@ -123,6 +142,10 @@ public class ConfigManager {
return display; return display;
} }
public boolean isEnableMagicLib() {
return enableMagicLib;
}
public boolean isLimit() { public boolean isLimit() {
return limit; return limit;
} }

View File

@ -14,7 +14,6 @@ import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -54,7 +53,6 @@ import org.mcstats.Metrics;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker; import cn.citycraft.PluginHelper.utils.VersionChecker;
import mkremins.fanciful.FancyMessage;
public class QuickShop extends JavaPlugin { public class QuickShop extends JavaPlugin {
/** The active instance of QuickShop */ /** The active instance of QuickShop */
@ -74,7 +72,6 @@ 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;
@ -144,10 +141,6 @@ 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.
@ -226,23 +219,6 @@ public class QuickShop extends JavaPlugin {
final LockListener ll = new LockListener(this); final LockListener ll = new LockListener(this);
getServer().getPluginManager().registerEvents(ll, this); getServer().getPluginManager().registerEvents(ll, this);
} }
try {
getLogger().info("尝试启动魔改库...");
final FancyMessage fm = new FancyMessage("test");
fm.then("item").itemTooltip(new ItemStack(Material.DIAMOND_SWORD));
fm.then("link").link("ci.citycraft.cn");
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("+=========================================");
this.enableMagicLib = false;
}
try { try {
final ConfigurationSection dbCfg = getConfig().getConfigurationSection("database"); final ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
DatabaseCore dbCore; DatabaseCore dbCore;

View File

@ -193,7 +193,7 @@ 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()) { if (!plugin.getConfigManager().isEnableMagicLib()) {
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle()); final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
in.setItem(4, items); in.setItem(4, items);
p.openInventory(in); p.openInventory(in);

View File

@ -6,6 +6,8 @@ superitem: GOLD_AXE
preventhopper: false preventhopper: false
#商店GUI的标题 #商店GUI的标题
guititle: '&6[&b快捷商店&6]&r' guititle: '&6[&b快捷商店&6]&r'
#启用魔改库支持
usemagiclib: true
#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

View File

@ -2,16 +2,21 @@ name: ${project.artifactId}
description: ${project.description} description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId} main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version} version: ${project.version}
authors: [Netherfoam,Timtower, KaiNoMood,喵♂呜] authors:
softdepend: [Vault] - Netherfoam
- Timtower
- KaiNoMood
- 喵♂呜
softdepend:
- Vault
website: http://ci.sumcraft.net:8080/job/${project.artifactId}/ website: http://ci.sumcraft.net:8080/job/${project.artifactId}/
commands: commands:
qs: qs:
description: QuickShop command description: QuickShop command
usage: '§c未知的子命令 请输入 §b/qs help §c查看帮助!' usage: §c未知的子命令 请输入 §b/qs help §c查看帮助!
aliases: [quickshop,shop] aliases:
- quickshop
- shop
permissions: permissions:
quickshop.create.sell: quickshop.create.sell:
description: Allows a player to sell from a shop description: Allows a player to sell from a shop