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

6 Commits
1.4.2 ... 1.4.4

Author SHA1 Message Date
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
10 changed files with 58 additions and 34 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<build>
<finalName>${project.name}</finalName>
<resources>

View File

@ -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"));
}

View File

@ -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"));
}

View File

@ -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));
}

View File

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

View File

@ -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,7 +83,7 @@ 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");

View File

@ -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 {

View File

@ -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();

View File

@ -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);
}
}
}

View File

@ -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个.'