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

15 Commits
1.4 ... 1.5

Author SHA1 Message Date
56e0fd8430 catch all error and exception while load magic lib...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-21 14:20:06 +08:00
fa9eead0a9 update pom and add update description...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-21 09:52:15 +08:00
6ed44b3def remove Plugin Metrics...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-21 00:31:36 +08:00
5b6abc1c07 add protect holder and update version to 1.4.4...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-20 18:36:53 +08:00
7d908ff59a update new magic lib...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-18 23:07:34 +08:00
c83ace24c9 fix Owner can't remove shop while gui mode...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-18 14:43:37 +08:00
b409fcc32f fix command permission error...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-18 12:01:28 +08:00
714ce2fa32 add new info unlimited...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-18 11:39:15 +08:00
7f1c37ec4e update priject...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-17 22:33:18 +08:00
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
15 changed files with 211 additions and 152 deletions

29
pom.xml
View File

@ -3,7 +3,8 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId> <groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId> <artifactId>QuickShop</artifactId>
<version>1.4</version> <version>1.5</version>
<description>快捷商店重置版本...</description>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
<resources> <resources>
@ -31,14 +32,9 @@
<artifactSet> <artifactSet>
<includes> <includes>
<include>cn.citycraft:PluginHelper</include> <include>cn.citycraft:PluginHelper</include>
<include>org.mcstats.*:*</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>cn.citycraft.PluginHelper</pattern> <pattern>cn.citycraft.PluginHelper</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern> <shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
@ -56,6 +52,11 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
<update.description>更新7老板的底层Gson库...</update.description>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -63,11 +64,7 @@
</repository> </repository>
<repository> <repository>
<id>sumcraft-repo</id> <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>
<url>http://repo.mcstats.org/content/repositories/public</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -98,13 +95,9 @@
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mcstats.bukkit</groupId> <groupId>io.github.Cnly.WowSuchCleaner</groupId>
<artifactId>metrics</artifactId> <artifactId>WowSuchCleaner</artifactId>
<version>R8-SNAPSHOT</version> <version>1.6.1</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project> </project>

View File

@ -19,8 +19,8 @@ public class CommandBuy extends BaseCommand {
public CommandBuy(final QuickShop plugin) { public CommandBuy(final QuickShop plugin) {
super("buy"); super("buy");
this.plugin = plugin; this.plugin = plugin;
setPermission("quickshop.create.buy");
setOnlyPlayerExecutable(); setOnlyPlayerExecutable();
setPermission("quickshop.create.buy");
setDescription(MsgUtil.p("command.description.buy")); setDescription(MsgUtil.p("command.description.buy"));
} }

View File

@ -19,7 +19,7 @@ public class CommandEmpty extends BaseCommand {
public CommandEmpty(final QuickShop plugin) { public CommandEmpty(final QuickShop plugin) {
super("empty"); super("empty");
this.plugin = plugin; this.plugin = plugin;
setPermission("quickshop.refill"); setPermission("quickshop.empty");
setDescription(MsgUtil.p("command.description.empty")); setDescription(MsgUtil.p("command.description.empty"));
} }

View File

@ -27,8 +27,8 @@ public class CommandInfo extends BaseCommand {
@Override @Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException { public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
int buying, selling, doubles, chunks, worlds; int buying, selling, doubles, chunks, worlds, unlimited;
buying = selling = doubles = chunks = worlds = 0; buying = selling = doubles = chunks = worlds = unlimited = 0;
int nostock = 0; int nostock = 0;
sender.sendMessage(ChatColor.RED + "开始检索商店信息中..."); sender.sendMessage(ChatColor.RED + "开始检索商店信息中...");
for (final HashMap<ShopChunk, HashMap<Location, Shop>> inWorld : plugin.getShopManager().getShops().values()) { for (final HashMap<ShopChunk, HashMap<Location, Shop>> inWorld : plugin.getShopManager().getShops().values()) {
@ -36,6 +36,9 @@ public class CommandInfo extends BaseCommand {
for (final HashMap<Location, Shop> inChunk : inWorld.values()) { for (final HashMap<Location, Shop> inChunk : inWorld.values()) {
chunks++; chunks++;
for (final Shop shop : inChunk.values()) { for (final Shop shop : inChunk.values()) {
if (shop.isUnlimited()) {
unlimited++;
}
if (shop.isBuying()) { if (shop.isBuying()) {
buying++; buying++;
} else if (shop.isSelling()) { } else if (shop.isSelling()) {
@ -52,6 +55,7 @@ public class CommandInfo extends BaseCommand {
sender.sendMessage(MsgUtil.p("info.title", chunks, buying + selling, worlds)); sender.sendMessage(MsgUtil.p("info.title", chunks, buying + selling, worlds));
sender.sendMessage(MsgUtil.p("info.selling", selling)); sender.sendMessage(MsgUtil.p("info.selling", selling));
sender.sendMessage(MsgUtil.p("info.buying", buying)); sender.sendMessage(MsgUtil.p("info.buying", buying));
sender.sendMessage(MsgUtil.p("info.unlimited", unlimited));
sender.sendMessage(MsgUtil.p("info.double", doubles)); sender.sendMessage(MsgUtil.p("info.double", doubles));
sender.sendMessage(MsgUtil.p("info.canclean", nostock)); sender.sendMessage(MsgUtil.p("info.canclean", nostock));
} }

View File

@ -19,6 +19,7 @@ public class CommandUnlimited extends BaseCommand {
super("unlimited"); super("unlimited");
this.plugin = plugin; this.plugin = plugin;
setOnlyPlayerExecutable(); setOnlyPlayerExecutable();
setPermission("quickshop.unlimited");
setDescription(MsgUtil.p("command.description.unlimited")); setDescription(MsgUtil.p("command.description.unlimited"));
} }

View File

@ -5,21 +5,24 @@ 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 cn.citycraft.PluginHelper.tellraw.FancyMessage;
public class ConfigManager { public class ConfigManager {
private boolean enableMagicLib = false;
/** 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 */
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; 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,23 @@ 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");
if (config.getBoolean("usemagiclib", true)) {
try {
plugin.getLogger().info("启用魔改库 尝试启动中...");
final FancyMessage fm = FancyMessage.newFM("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 Error | Exception e) {
plugin.getLogger().warning("+=========================================");
plugin.getLogger().warning("| 警告: 启动魔改库失败 将使用GUI商店界面...");
plugin.getLogger().warning("+=========================================");
this.enableMagicLib = false;
}
}
} }
public double getFeeForPriceChange() { public double getFeeForPriceChange() {
@ -123,6 +143,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

@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BlockIterator; import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop; import org.maxgamer.QuickShop.QuickShop;
@ -62,6 +63,11 @@ public class PlayerListener implements Listener {
shop.onClick(); shop.onClick();
// Text menu // Text menu
MsgUtil.sendShopInfo(p, shop); MsgUtil.sendShopInfo(p, shop);
if (!plugin.getConfigManager().isEnableMagicLib() && !shop.getOwner().equalsIgnoreCase(p.getName()) && b.getType() == Material.WALL_SIGN) {
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
in.setItem(4, shop.getItem());
p.openInventory(in);
}
if (shop.isSelling()) { if (shop.isSelling()) {
p.sendMessage(MsgUtil.p("how-many-buy")); p.sendMessage(MsgUtil.p("how-many-buy"));
} else { } else {

View File

@ -2,11 +2,12 @@ package org.maxgamer.QuickShop.Listeners;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.DoubleChest;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent;
@ -14,8 +15,10 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
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.Util.MarkUtil; import org.maxgamer.QuickShop.Util.MarkUtil;
public class ProtectListener implements Listener { public class ProtectListener implements Listener {
@ -26,18 +29,41 @@ public class ProtectListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
public Shop getShop(final Inventory inv) {
if (inv == null) {
return null;
}
InventoryHolder holder = inv.getHolder();
if (holder instanceof DoubleChest) {
holder = ((DoubleChest) holder).getLeftSide();
}
if (holder instanceof BlockState) {
final Block block = ((BlockState) holder).getBlock();
final Shop sp = plugin.getShopManager().getShop(block.getLocation());
if (sp != null) {
return sp;
}
}
return null;
}
@EventHandler @EventHandler
public void onInvMove(final InventoryMoveItemEvent e) { public void onInvMove(final InventoryMoveItemEvent e) {
final ItemStack ci = e.getItem(); final ItemStack ci = e.getItem();
if (MarkUtil.hasMark(ci)) { if (MarkUtil.hasMark(ci)) {
e.setCancelled(true); e.setCancelled(true);
final ItemStack[] items = e.getSource().getContents(); }
for (final ItemStack itemStack : items) {
if (MarkUtil.hasMark(itemStack)) { final Inventory src = e.getSource();
itemStack.setType(Material.AIR); final Inventory me = e.getInitiator();
} final Inventory des = e.getDestination();
} final Shop srcshop = getShop(src);
e.getSource().setContents(items); final Shop meshop = getShop(me);
final Shop desshop = getShop(des);
if ((srcshop != null && meshop == null) || (meshop != null && desshop == null) || (srcshop != null && desshop != null && srcshop.getOwner().equalsIgnoreCase(desshop.getOwner()))) {
e.setCancelled(true);
} }
} }
@ -75,14 +101,6 @@ public class ProtectListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemDespawn(final ItemDespawnEvent e) {
final ItemStack ci = e.getEntity().getItemStack();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
}
@EventHandler @EventHandler
public void onPlayerHandlerItem(final PlayerItemHeldEvent e) { public void onPlayerHandlerItem(final PlayerItemHeldEvent e) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();

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

@ -1,7 +1,6 @@
package org.maxgamer.QuickShop; package org.maxgamer.QuickShop;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -14,13 +13,13 @@ 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;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -42,6 +41,7 @@ import org.maxgamer.QuickShop.Listeners.LockListener;
import org.maxgamer.QuickShop.Listeners.PlayerListener; import org.maxgamer.QuickShop.Listeners.PlayerListener;
import org.maxgamer.QuickShop.Listeners.ProtectListener; import org.maxgamer.QuickShop.Listeners.ProtectListener;
import org.maxgamer.QuickShop.Listeners.WorldListener; import org.maxgamer.QuickShop.Listeners.WorldListener;
import org.maxgamer.QuickShop.Listeners.WowSuchCleanerListener;
import org.maxgamer.QuickShop.Shop.ContainerShop; import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop; import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopManager; import org.maxgamer.QuickShop.Shop.ShopManager;
@ -50,11 +50,9 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util; import org.maxgamer.QuickShop.Util.Util;
import org.maxgamer.QuickShop.Watcher.ItemWatcher; import org.maxgamer.QuickShop.Watcher.ItemWatcher;
import org.maxgamer.QuickShop.Watcher.LogWatcher; import org.maxgamer.QuickShop.Watcher.LogWatcher;
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 */
@ -63,26 +61,16 @@ public class QuickShop extends JavaPlugin {
public FileConfig config; public FileConfig config;
// private HeroChatListener heroChatListener; // private HeroChatListener heroChatListener;
// Listeners (These don't) // 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 */ /** The Config Manager used to read config */
private ConfigManager configManager; private ConfigManager configManager;
/** The database for storing all our data for persistence */ /** The database for storing all our data for persistence */
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 ProtectListener protectListener = new ProtectListener(this);
/** The Shop Manager used to store shops */ /** The Shop Manager used to store shops */
private ShopManager shopManager; private ShopManager shopManager;
private final WorldListener worldListener = new WorldListener(this);
/** /**
* Prints debug information if QuickShop is configured to do so. * Prints debug information if QuickShop is configured to do so.
@ -144,10 +132,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.
@ -196,9 +180,13 @@ public class QuickShop extends JavaPlugin {
logWatcher.close(); // Closes the file logWatcher.close(); // Closes the file
} }
/* Remove all display items, and any dupes we can find */ /* Remove all display items, and any dupes we can find */
shopManager.clear(); if (shopManager != null) {
shopManager.clear();
}
/* Empty the buffer */ /* Empty the buffer */
database.close(); if (database != null) {
database.close();
}
try { try {
this.database.getConnection().close(); this.database.getConnection().close();
} catch (final SQLException e) { } catch (final SQLException e) {
@ -226,23 +214,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;
@ -336,19 +307,29 @@ public class QuickShop extends JavaPlugin {
MsgUtil.clean(); MsgUtil.clean();
// Register events // Register events
final PluginManager pm = this.getServer().getPluginManager(); final PluginManager pm = this.getServer().getPluginManager();
pm.registerEvents(blockListener, this); final Plugin wsc = pm.getPlugin("WowSuchCleaner");
pm.registerEvents(playerListener, this); if (wsc != null && wsc.isEnabled()) {
pm.registerEvents(worldListener, this); getLogger().info("发现 WowSuchCleaner 插件 开启相关功能...");
pm.registerEvents(protectListener, this); 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()) { if (configManager.isDisplay()) {
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this); Bukkit.getServer().getPluginManager().registerEvents(new ChunkListener(this), this);
// Display item handler thread // Display item handler thread
getLogger().info("开启商店检查以及悬浮物刷新线程..."); getLogger().info("开启商店检查以及悬浮物刷新线程...");
final ItemWatcher itemWatcher = new ItemWatcher(this); final ItemWatcher itemWatcher = new ItemWatcher(this);
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 1800); itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 1800);
} }
this.chatListener = new ChatListener(this);
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
// Command handlers // Command handlers
final QuickShopCommands commandExecutor = new QuickShopCommands(this); final QuickShopCommands commandExecutor = new QuickShopCommands(this);
getCommand("qs").setExecutor(commandExecutor); getCommand("qs").setExecutor(commandExecutor);
@ -357,11 +338,6 @@ public class QuickShop extends JavaPlugin {
} }
this.getLogger().info("载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜"); this.getLogger().info("载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜");
new VersionChecker(this); new VersionChecker(this);
try {
final Metrics metrics = new Metrics(this);
metrics.start();
} catch (final IOException e) {
}
} }
@Override @Override

View File

@ -601,10 +601,12 @@ public class ContainerShop implements Shop {
final String[] lines = new String[4]; final String[] lines = new String[4];
lines[0] = ChatColor.RED + "[QuickShop]"; lines[0] = ChatColor.RED + "[QuickShop]";
if (this.isBuying()) { 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()) { 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[2] = Util.getNameForSign(this.item);
lines[3] = MsgUtil.p("signs.price", "" + this.getPrice()); lines[3] = MsgUtil.p("signs.price", "" + this.getPrice());

View File

@ -9,13 +9,12 @@ 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;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import mkremins.fanciful.FancyMessage; import cn.citycraft.PluginHelper.tellraw.FancyMessage;
public class MsgUtil { public class MsgUtil {
private static FileConfig messages; private static FileConfig messages;
@ -90,7 +89,7 @@ public class MsgUtil {
public static String p(final String loc, final Object... args) { public static String p(final String loc, final Object... args) {
String raw = messages.getString(loc); String raw = messages.getString(loc);
if (raw == null || raw.isEmpty()) { if (raw == null || raw.isEmpty()) {
return "语言文件词条丢失: " + loc; return ChatColor.RED + "语言文件词条丢失: " + loc;
} }
if (args == null) { if (args == null) {
return raw; return raw;
@ -128,7 +127,7 @@ public class MsgUtil {
public static void sendItemMessage(final Player p, final ItemStack is, final String msg) { public static void sendItemMessage(final Player p, final ItemStack is, final String msg) {
try { try {
final FancyMessage fm = new FancyMessage(); final FancyMessage fm = FancyMessage.newFM();
fm.text(msg).itemTooltip(is).send(p); fm.text(msg).itemTooltip(is).send(p);
} catch (Exception | NoClassDefFoundError | NoSuchMethodError e) { } catch (Exception | NoClassDefFoundError | NoSuchMethodError e) {
p.sendMessage(msg); p.sendMessage(msg);
@ -181,10 +180,10 @@ public class MsgUtil {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items))); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items)));
} }
if (shop.isSelling()) { 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 { } else {
final int space = shop.getRemainingSpace(); 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()))); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
if (shop.isBuying()) { if (shop.isBuying()) {
@ -193,10 +192,5 @@ 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);
}
} }
} }

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

@ -1,4 +1,4 @@
Version: 1.2 Version: 1.4
not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个商店.' not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个商店.'
no-permission: '&4你没有此命令的权限.' no-permission: '&4你没有此命令的权限.'
@ -58,6 +58,7 @@ info:
title: '&a当前加载的 &e{0} &a个区块中 共有 &e{1} &a个商店 覆盖 &e{2} &a个世界.' title: '&a当前加载的 &e{0} &a个区块中 共有 &e{1} &a个商店 覆盖 &e{2} &a个世界.'
selling: '&b出售商店&a有 &e{0} &a个.' selling: '&b出售商店&a有 &e{0} &a个.'
buying: '&d收购商店&a有 &e{0} &a个.' buying: '&d收购商店&a有 &e{0} &a个.'
unlimited: '&c无限商店&a有 &e{0} &a个.'
double: '&3大箱子商店 &e{0} &a个.' double: '&3大箱子商店 &e{0} &a个.'
canclean: '&a可以用 &b/qs clean &a清理的商店有 &e{0} &a个.' canclean: '&a可以用 &b/qs clean &a清理的商店有 &e{0} &a个.'

View File

@ -2,53 +2,59 @@ 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
website: http://ci.sumcraft.net:8080/job/${project.artifactId}/ - Timtower
- KaiNoMood
- 喵♂呜
softdepend:
- Vault
- WowSuchCleaner
website: ${jenkins.url}/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
default: op default: op
quickshop.create.buy: quickshop.create.buy:
description: Allows a player to buy from a shop description: Allows a player to buy from a shop
default: op default: op
quickshop.create.double: quickshop.create.double:
description: Allows a player to create a double shop description: Allows a player to create a double shop
default: op default: op
quickshop.use: quickshop.use:
description: Allows a player to buy/sell using other players shops description: Allows a player to buy/sell using other players shops
default: true default: true
quickshop.unlimited: quickshop.unlimited:
description: Allows a Staff Member to use /qs unlimited and make a shop infinite description: Allows a Staff Member to use /qs unlimited and make a shop infinite
quickshop.bypass.<itemID>: quickshop.bypass.<itemID>:
description: Allows a player to sell <itemID>, even if its blacklisted description: Allows a player to sell <itemID>, even if its blacklisted
quickshop.other.destroy: quickshop.other.destroy:
description: Allows a Staff Member to destroy other players shops if they are locked in the config description: Allows a Staff Member to destroy other players shops if they are locked in the config
quickshop.other.open: quickshop.other.open:
description: Allows a Staff Member to open someone elses shop if they are locked in the config description: Allows a Staff Member to open someone elses shop if they are locked in the config
quickshop.other.price: quickshop.other.price:
description: Allows a Staff Member to change the price of someone elses shop description: Allows a Staff Member to change the price of someone elses shop
quickshop.setowner: quickshop.setowner:
description: Allows a Staff Member to change the owner of any shop description: Allows a Staff Member to change the owner of any shop
quickshop.find: quickshop.find:
description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius. description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius.
default: true default: true
quickshop.refill: quickshop.refill:
description: Allows a Staff Member to refill the shop theyre looking at with the given number of items. description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
default: op default: op
quickshop.empty: quickshop.empty:
description: Allows a Staff Member to empty the shop theyre looking at of all items. description: Allows a Staff Member to empty the shop theyre looking at of all items.
default: op default: op
quickshop.debug: quickshop.debug:
description: Enables debug info to console description: Enables debug info to console
default: op default: op
quickshop.export: quickshop.export:
description: Allows exporting database to mysql or sqlite description: Allows exporting database to mysql or sqlite
default: op default: op