1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-12-28 07:58:49 +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.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.QuickShop.QuickShop;
import cn.citycraft.PluginHelper.config.FileConfig;
import mkremins.fanciful.FancyMessage;
public class ConfigManager {
private boolean enableMagicLib;
/** Whether debug info should be shown in the console */
protected boolean debug = false;
/** Whether we should use display items or not */
@ -17,9 +20,9 @@ public class ConfigManager {
protected double feeForPriceChange = 0.0;
protected int findDistance = 30;
protected String guiTitle = "§6[§b快捷商店§6]";
/** 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;
@ -77,6 +80,22 @@ public class ConfigManager {
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
this.preventhopper = config.getBoolean("preventhopper");
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() {
@ -123,6 +142,10 @@ public class ConfigManager {
return display;
}
public boolean isEnableMagicLib() {
return enableMagicLib;
}
public boolean isLimit() {
return limit;
}

View File

@ -14,7 +14,6 @@ import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
@ -54,7 +53,6 @@ import org.mcstats.Metrics;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker;
import mkremins.fanciful.FancyMessage;
public class QuickShop extends JavaPlugin {
/** The active instance of QuickShop */
@ -74,7 +72,6 @@ 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;
@ -144,10 +141,6 @@ 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.
@ -226,23 +219,6 @@ public class QuickShop extends JavaPlugin {
final LockListener ll = new LockListener(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 {
final ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
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 + "+---------------------------------------------------+");
if (!plugin.isEnableMagicLib()) {
if (!plugin.getConfigManager().isEnableMagicLib()) {
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
in.setItem(4, items);
p.openInventory(in);

View File

@ -6,6 +6,8 @@ superitem: GOLD_AXE
preventhopper: false
#商店GUI的标题
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: 0.00

View File

@ -2,53 +2,58 @@ name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}
authors: [Netherfoam,Timtower, KaiNoMood,喵♂呜]
softdepend: [Vault]
authors:
- Netherfoam
- Timtower
- KaiNoMood
- 喵♂呜
softdepend:
- Vault
website: http://ci.sumcraft.net:8080/job/${project.artifactId}/
commands:
qs:
description: QuickShop command
usage: '§c未知的子命令 请输入 §b/qs help §c查看帮助!'
aliases: [quickshop,shop]
qs:
description: QuickShop command
usage: §c未知的子命令 请输入 §b/qs help §c查看帮助!
aliases:
- quickshop
- shop
permissions:
quickshop.create.sell:
description: Allows a player to sell from a shop
default: op
quickshop.create.buy:
description: Allows a player to buy from a shop
default: op
quickshop.create.double:
description: Allows a player to create a double shop
default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true
quickshop.unlimited:
description: Allows a Staff Member to use /qs unlimited and make a shop infinite
quickshop.bypass.<itemID>:
description: Allows a player to sell <itemID>, even if its blacklisted
quickshop.other.destroy:
description: Allows a Staff Member to destroy other players shops if they are locked in the config
quickshop.other.open:
description: Allows a Staff Member to open someone elses shop if they are locked in the config
quickshop.other.price:
description: Allows a Staff Member to change the price of someone elses shop
quickshop.setowner:
description: Allows a Staff Member to change the owner of any shop
quickshop.find:
description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius.
default: true
quickshop.refill:
description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
default: op
quickshop.empty:
description: Allows a Staff Member to empty the shop theyre looking at of all items.
default: op
quickshop.debug:
description: Enables debug info to console
default: op
quickshop.export:
description: Allows exporting database to mysql or sqlite
default: op
quickshop.create.sell:
description: Allows a player to sell from a shop
default: op
quickshop.create.buy:
description: Allows a player to buy from a shop
default: op
quickshop.create.double:
description: Allows a player to create a double shop
default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true
quickshop.unlimited:
description: Allows a Staff Member to use /qs unlimited and make a shop infinite
quickshop.bypass.<itemID>:
description: Allows a player to sell <itemID>, even if its blacklisted
quickshop.other.destroy:
description: Allows a Staff Member to destroy other players shops if they are locked in the config
quickshop.other.open:
description: Allows a Staff Member to open someone elses shop if they are locked in the config
quickshop.other.price:
description: Allows a Staff Member to change the price of someone elses shop
quickshop.setowner:
description: Allows a Staff Member to change the owner of any shop
quickshop.find:
description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius.
default: true
quickshop.refill:
description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
default: op
quickshop.empty:
description: Allows a Staff Member to empty the shop theyre looking at of all items.
default: op
quickshop.debug:
description: Enables debug info to console
default: op
quickshop.export:
description: Allows exporting database to mysql or sqlite
default: op