1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2025-10-02 12:37:27 +00:00

6 Commits
1.4 ... 1.4.2

Author SHA1 Message Date
3f781c473c Hook WowSuchListener...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-17 17:54:53 +08:00
5bab17a117 show unlimited numner to chinese...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-17 10:58:06 +08:00
b9a9fe292c modify enable magic library method...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-17 10:47:23 +08:00
efb4e18617 use default jenkins... 2015-10-16 16:08:57 +08:00
f807c054d4 add config usemagiclib...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-16 16:02:48 +08:00
037f5138bb set Default Inventory Title...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-16 13:11:23 +08:00
8 changed files with 148 additions and 97 deletions

10
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>1.4</version>
<version>1.4.3</version>
<build>
<finalName>${project.name}</finalName>
<resources>
@ -63,7 +63,7 @@
</repository>
<repository>
<id>sumcraft-repo</id>
<url>http://ci.sumcraft.net:8080/plugin/repository/everything/</url>
<url>${jenkins.url}/plugin/repository/everything/</url>
</repository>
<repository>
<id>Plugin Metrics</id>
@ -97,6 +97,11 @@
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.github.Cnly.WowSuchCleaner</groupId>
<artifactId>WowSuchCleaner</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
@ -106,5 +111,6 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
</properties>
</project>

View File

@ -5,21 +5,24 @@ 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 = false;
/** Whether debug info should be shown in the console */
protected boolean debug = false;
/** Whether we should use display items or not */
protected boolean display = true;
protected double feeForPriceChange = 0.0;
protected int findDistance = 30;
protected String guiTitle;
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,23 @@ public class ConfigManager {
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
this.preventhopper = config.getBoolean("preventhopper");
this.guiTitle = config.getMessage("guititle");
if (config.getBoolean("usemagiclib", true)) {
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;
}
}
}
public double getFeeForPriceChange() {
@ -123,6 +143,10 @@ public class ConfigManager {
return display;
}
public boolean isEnableMagicLib() {
return enableMagicLib;
}
public boolean isLimit() {
return limit;
}

View File

@ -0,0 +1,32 @@
package org.maxgamer.QuickShop.Listeners;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.QuickShop.Util.MarkUtil;
import io.github.Cnly.WowSuchCleaner.WowSuchCleaner.ItemPreCleanEvent;
public class WowSuchCleanerListener implements Listener {
@EventHandler
public void onWSCClear(final ItemPreCleanEvent e) {
final List<Item> clearList = new ArrayList<Item>();
final List<ItemStack> aucList = new ArrayList<ItemStack>();
for (final Item item : e.getItemsToClean()) {
if (MarkUtil.hasMark(item.getItemStack())) {
clearList.add(item);
}
}
for (final ItemStack itemStack : e.getItemsToAuction()) {
if (MarkUtil.hasMark(itemStack)) {
aucList.add(itemStack);
}
}
e.getItemsToClean().removeAll(clearList);
e.getItemsToAuction().removeAll(aucList);
}
}

View File

@ -14,13 +14,13 @@ 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;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
@ -42,6 +42,7 @@ import org.maxgamer.QuickShop.Listeners.LockListener;
import org.maxgamer.QuickShop.Listeners.PlayerListener;
import org.maxgamer.QuickShop.Listeners.ProtectListener;
import org.maxgamer.QuickShop.Listeners.WorldListener;
import org.maxgamer.QuickShop.Listeners.WowSuchCleanerListener;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopManager;
@ -54,7 +55,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 */
@ -63,26 +63,16 @@ public class QuickShop extends JavaPlugin {
public FileConfig config;
// private HeroChatListener heroChatListener;
// Listeners (These don't)
private final BlockListener blockListener = new BlockListener(this);
// Listeners - We decide which one to use at runtime
private ChatListener chatListener;
private final ChunkListener chunkListener = new ChunkListener(this);
/** The Config Manager used to read config */
private ConfigManager configManager;
/** The database for storing all our data for persistence */
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);
/** The Shop Manager used to store shops */
private ShopManager shopManager;
private final WorldListener worldListener = new WorldListener(this);
/**
* Prints debug information if QuickShop is configured to do so.
@ -144,10 +134,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 +212,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;
@ -336,19 +305,29 @@ public class QuickShop extends JavaPlugin {
MsgUtil.clean();
// Register events
final PluginManager pm = this.getServer().getPluginManager();
pm.registerEvents(blockListener, this);
pm.registerEvents(playerListener, this);
pm.registerEvents(worldListener, this);
pm.registerEvents(protectListener, this);
final Plugin wsc = pm.getPlugin("WowSuchCleaner");
if (wsc != null && wsc.isEnabled()) {
getLogger().info("发现 WowSuchCleaner 插件 开启相关功能...");
try {
Class.forName("io.github.Cnly.WowSuchCleaner.WowSuchCleaner.ItemPreCleanEvent");
pm.registerEvents(new WowSuchCleanerListener(), this);
} catch (final ClassNotFoundException e) {
getLogger().info("WowSuchCleaner 版本过低 可能造成悬浮物上架...");
}
}
pm.registerEvents(new BlockListener(this), this);
pm.registerEvents(new PlayerListener(this), this);
pm.registerEvents(new WorldListener(this), this);
pm.registerEvents(new ProtectListener(this), this);
pm.registerEvents(new ChatListener(this), this);
if (configManager.isDisplay()) {
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this);
Bukkit.getServer().getPluginManager().registerEvents(new ChunkListener(this), this);
// Display item handler thread
getLogger().info("开启商店检查以及悬浮物刷新线程...");
final ItemWatcher itemWatcher = new ItemWatcher(this);
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 1800);
}
this.chatListener = new ChatListener(this);
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
// Command handlers
final QuickShopCommands commandExecutor = new QuickShopCommands(this);
getCommand("qs").setExecutor(commandExecutor);

View File

@ -601,10 +601,12 @@ public class ContainerShop implements Shop {
final String[] lines = new String[4];
lines[0] = ChatColor.RED + "[QuickShop]";
if (this.isBuying()) {
lines[1] = MsgUtil.p("signs.buying", "" + this.getRemainingSpace());
final int remsp = this.getRemainingSpace();
lines[1] = MsgUtil.p("signs.buying", "" + (remsp == 10000 ? "无限" : remsp));
}
if (this.isSelling()) {
lines[1] = MsgUtil.p("signs.selling", "" + this.getRemainingStock());
final int remst = this.getRemainingStock();
lines[1] = MsgUtil.p("signs.selling", "" + (remst == 10000 ? "无限" : remst));
}
lines[2] = Util.getNameForSign(this.item);
lines[3] = MsgUtil.p("signs.price", "" + this.getPrice());

View File

@ -181,10 +181,10 @@ public class MsgUtil {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items)));
}
if (shop.isSelling()) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + stock));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + (stock == 10000 ? "无限" : stock)));
} else {
final int space = shop.getRemainingSpace();
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + space));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + (space == 10000 ? "无限" : space)));
}
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
if (shop.isBuying()) {
@ -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,16 +2,22 @@ name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}
authors: [Netherfoam,Timtower, KaiNoMood,喵♂呜]
softdepend: [Vault]
website: http://ci.sumcraft.net:8080/job/${project.artifactId}/
authors:
- Netherfoam
- Timtower
- KaiNoMood
- 喵♂呜
softdepend:
- Vault
- WowSuchCleaner
website: ${jenkins.url}/job/${project.artifactId}/
commands:
qs:
description: QuickShop command
usage: '§c未知的子命令 请输入 §b/qs help §c查看帮助!'
aliases: [quickshop,shop]
usage: §c未知的子命令 请输入 §b/qs help §c查看帮助!
aliases:
- quickshop
- shop
permissions:
quickshop.create.sell:
description: Allows a player to sell from a shop