mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2025-10-02 12:37:27 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
56e0fd8430 | |||
fa9eead0a9 | |||
6ed44b3def | |||
5b6abc1c07 | |||
7d908ff59a | |||
c83ace24c9 | |||
b409fcc32f | |||
714ce2fa32 | |||
7f1c37ec4e |
27
pom.xml
27
pom.xml
@ -3,7 +3,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>1.4.3</version>
|
||||
<version>1.5</version>
|
||||
<description>快捷商店重置版本...</description>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
@ -31,14 +32,9 @@
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>cn.citycraft:PluginHelper</include>
|
||||
<include>org.mcstats.*:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
@ -56,6 +52,11 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</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>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@ -65,10 +66,6 @@
|
||||
<id>sumcraft-repo</id>
|
||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -102,15 +99,5 @@
|
||||
<artifactId>WowSuchCleaner</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
</properties>
|
||||
</project>
|
@ -19,8 +19,8 @@ public class CommandBuy extends BaseCommand {
|
||||
public CommandBuy(final QuickShop plugin) {
|
||||
super("buy");
|
||||
this.plugin = plugin;
|
||||
setPermission("quickshop.create.buy");
|
||||
setOnlyPlayerExecutable();
|
||||
setPermission("quickshop.create.buy");
|
||||
setDescription(MsgUtil.p("command.description.buy"));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class CommandEmpty extends BaseCommand {
|
||||
public CommandEmpty(final QuickShop plugin) {
|
||||
super("empty");
|
||||
this.plugin = plugin;
|
||||
setPermission("quickshop.refill");
|
||||
setPermission("quickshop.empty");
|
||||
setDescription(MsgUtil.p("command.description.empty"));
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ public class CommandInfo extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
int buying, selling, doubles, chunks, worlds;
|
||||
buying = selling = doubles = chunks = worlds = 0;
|
||||
int buying, selling, doubles, chunks, worlds, unlimited;
|
||||
buying = selling = doubles = chunks = worlds = unlimited = 0;
|
||||
int nostock = 0;
|
||||
sender.sendMessage(ChatColor.RED + "开始检索商店信息中...");
|
||||
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()) {
|
||||
chunks++;
|
||||
for (final Shop shop : inChunk.values()) {
|
||||
if (shop.isUnlimited()) {
|
||||
unlimited++;
|
||||
}
|
||||
if (shop.isBuying()) {
|
||||
buying++;
|
||||
} 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.selling", selling));
|
||||
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.canclean", nostock));
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class CommandUnlimited extends BaseCommand {
|
||||
super("unlimited");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
setPermission("quickshop.unlimited");
|
||||
setDescription(MsgUtil.p("command.description.unlimited"));
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import cn.citycraft.PluginHelper.tellraw.FancyMessage;
|
||||
|
||||
public class ConfigManager {
|
||||
private boolean enableMagicLib = false;
|
||||
@ -83,14 +83,14 @@ public class ConfigManager {
|
||||
if (config.getBoolean("usemagiclib", true)) {
|
||||
try {
|
||||
plugin.getLogger().info("启用魔改库 尝试启动中...");
|
||||
final FancyMessage fm = new FancyMessage("test");
|
||||
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) {
|
||||
} catch (final Error | Exception e) {
|
||||
plugin.getLogger().warning("+=========================================");
|
||||
plugin.getLogger().warning("| 警告: 启动魔改库失败 将使用GUI商店界面...");
|
||||
plugin.getLogger().warning("+=========================================");
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
@ -62,6 +63,11 @@ public class PlayerListener implements Listener {
|
||||
shop.onClick();
|
||||
// Text menu
|
||||
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()) {
|
||||
p.sendMessage(MsgUtil.p("how-many-buy"));
|
||||
} else {
|
||||
|
@ -2,11 +2,12 @@ package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
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.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Util.MarkUtil;
|
||||
|
||||
public class ProtectListener implements Listener {
|
||||
@ -26,18 +29,41 @@ public class ProtectListener implements Listener {
|
||||
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
|
||||
public void onInvMove(final InventoryMoveItemEvent e) {
|
||||
final ItemStack ci = e.getItem();
|
||||
if (MarkUtil.hasMark(ci)) {
|
||||
e.setCancelled(true);
|
||||
final ItemStack[] items = e.getSource().getContents();
|
||||
for (final ItemStack itemStack : items) {
|
||||
if (MarkUtil.hasMark(itemStack)) {
|
||||
itemStack.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
e.getSource().setContents(items);
|
||||
|
||||
final Inventory src = e.getSource();
|
||||
final Inventory me = e.getInitiator();
|
||||
final Inventory des = e.getDestination();
|
||||
final Shop srcshop = getShop(src);
|
||||
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
|
||||
public void onPlayerHandlerItem(final PlayerItemHeldEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.maxgamer.QuickShop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -51,7 +50,6 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
import org.maxgamer.QuickShop.Watcher.ItemWatcher;
|
||||
import org.maxgamer.QuickShop.Watcher.LogWatcher;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
@ -182,9 +180,13 @@ public class QuickShop extends JavaPlugin {
|
||||
logWatcher.close(); // Closes the file
|
||||
}
|
||||
/* Remove all display items, and any dupes we can find */
|
||||
if (shopManager != null) {
|
||||
shopManager.clear();
|
||||
}
|
||||
/* Empty the buffer */
|
||||
if (database != null) {
|
||||
database.close();
|
||||
}
|
||||
try {
|
||||
this.database.getConnection().close();
|
||||
} catch (final SQLException e) {
|
||||
@ -336,11 +338,6 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
this.getLogger().info("载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜");
|
||||
new VersionChecker(this);
|
||||
try {
|
||||
final Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (final IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,13 +9,12 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import cn.citycraft.PluginHelper.tellraw.FancyMessage;
|
||||
|
||||
public class MsgUtil {
|
||||
private static FileConfig messages;
|
||||
@ -90,7 +89,7 @@ public class MsgUtil {
|
||||
public static String p(final String loc, final Object... args) {
|
||||
String raw = messages.getString(loc);
|
||||
if (raw == null || raw.isEmpty()) {
|
||||
return "语言文件词条丢失: " + loc;
|
||||
return ChatColor.RED + "语言文件词条丢失: " + loc;
|
||||
}
|
||||
if (args == null) {
|
||||
return raw;
|
||||
@ -128,7 +127,7 @@ public class MsgUtil {
|
||||
|
||||
public static void sendItemMessage(final Player p, final ItemStack is, final String msg) {
|
||||
try {
|
||||
final FancyMessage fm = new FancyMessage();
|
||||
final FancyMessage fm = FancyMessage.newFM();
|
||||
fm.text(msg).itemTooltip(is).send(p);
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError e) {
|
||||
p.sendMessage(msg);
|
||||
@ -193,10 +192,5 @@ public class MsgUtil {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
if (!plugin.getConfigManager().isEnableMagicLib()) {
|
||||
final Inventory in = Bukkit.createInventory(null, 9, plugin.getConfigManager().getGuiTitle());
|
||||
in.setItem(4, items);
|
||||
p.openInventory(in);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
Version: 1.2
|
||||
Version: 1.4
|
||||
|
||||
not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个商店.'
|
||||
no-permission: '&4你没有此命令的权限.'
|
||||
@ -58,6 +58,7 @@ info:
|
||||
title: '&a当前加载的 &e{0} &a个区块中 共有 &e{1} &a个商店 覆盖 &e{2} &a个世界.'
|
||||
selling: '&b出售商店&a有 &e{0} &a个.'
|
||||
buying: '&d收购商店&a有 &e{0} &a个.'
|
||||
unlimited: '&c无限商店&a有 &e{0} &a个.'
|
||||
double: '&3大箱子商店 &e{0} &a个.'
|
||||
canclean: '&a可以用 &b/qs clean &a清理的商店有 &e{0} &a个.'
|
||||
|
||||
|
Reference in New Issue
Block a user