mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2025-10-02 12:37:27 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
5b6abc1c07 | |||
7d908ff59a | |||
c83ace24c9 | |||
b409fcc32f | |||
714ce2fa32 | |||
7f1c37ec4e | |||
3f781c473c | |||
5bab17a117 | |||
b9a9fe292c | |||
efb4e18617 | |||
f807c054d4 | |||
037f5138bb |
10
pom.xml
10
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<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.4.4</version>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
@ -63,7 +63,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>
|
||||||
<repository>
|
<repository>
|
||||||
<id>Plugin Metrics</id>
|
<id>Plugin Metrics</id>
|
||||||
@ -97,6 +97,11 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.Cnly.WowSuchCleaner</groupId>
|
||||||
|
<artifactId>WowSuchCleaner</artifactId>
|
||||||
|
<version>1.6.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mcstats.bukkit</groupId>
|
<groupId>org.mcstats.bukkit</groupId>
|
||||||
<artifactId>metrics</artifactId>
|
<artifactId>metrics</artifactId>
|
||||||
@ -106,5 +111,6 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 NoClassDefFoundError | NoSuchMethodError | 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;
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
|
@ -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();
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -14,13 +14,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 +42,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;
|
||||||
@ -54,7 +55,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 */
|
||||||
@ -63,26 +63,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 +134,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 +212,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 +305,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);
|
||||||
|
@ -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());
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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
|
||||||
|
@ -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个.'
|
||||||
|
|
||||||
|
@ -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
|
Reference in New Issue
Block a user