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

41 Commits
1.1 ... 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
738fe9e06b update to 1.4...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-16 10:58:15 +08:00
40e4922acd add new show item Handler...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-15 19:04:15 +08:00
38ebc66431 Modify Check Display Item Mothed...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-13 21:00:23 +08:00
775a4207cf update...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-13 12:31:57 +08:00
d057967aec update item config...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-11 21:31:48 +08:00
a6fcfbcc85 add Despawn Event and update item config...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-11 18:04:29 +08:00
149e5564db update project...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-10 17:51:24 +08:00
342a66988a update items file... 2015-10-09 16:00:34 +08:00
f32a5114fc fix Interact check error...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 15:55:30 +08:00
6ac9a8d762 fix some bug...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 15:15:11 +08:00
2f22d07915 fix some bug...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 13:29:28 +08:00
3f09e80b0b fix command can exter...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 13:13:16 +08:00
10341806f6 add command class...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 13:02:12 +08:00
1babb8e362 conver command and complete info command ...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 12:44:39 +08:00
d5581a7a2e fix SuperItem Create Shop error...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-09 08:36:01 +08:00
379f6593c9 fix SuperItem Left Click...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-08 23:35:38 +08:00
1bf689c39d fix Aciton... 2015-10-08 23:18:04 +08:00
8b4e2c5ece change Aciton Mode...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-08 23:13:04 +08:00
a0768cdf7a add new SuperItem Action...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-08 22:20:14 +08:00
8ac297cd4d add new Action to toggle unlimited...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-08 21:10:34 +08:00
3d5aa384b1 change tool tip...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-08 20:07:14 +08:00
e728777aee add web site...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-07 19:36:20 +08:00
ad932ecdef change load tip...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-07 15:58:26 +08:00
6532d6f546 fix load shop while Chunk unload error...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-07 14:58:16 +08:00
3bcee64220 fix some bug and Release Version 1.3...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-07 13:29:54 +08:00
ba8848eff4 fix remove shop and add invcheck...
Signed-off-by: j502647092 <jtb1@163.com>
2015-10-06 22:25:24 +08:00
32 changed files with 1530 additions and 1062 deletions

29
pom.xml
View File

@ -3,7 +3,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>1.1</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>
@ -63,11 +64,7 @@
</repository>
<repository>
<id>sumcraft-repo</id>
<url>http://ci.sumcraft.net:8080/plugin/repository/everything/</url>
</repository>
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
<url>${jenkins.url}/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
@ -98,13 +95,9 @@
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>R8-SNAPSHOT</version>
<scope>compile</scope>
<groupId>io.github.Cnly.WowSuchCleaner</groupId>
<artifactId>WowSuchCleaner</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,45 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopType;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandBuy extends BaseCommand {
QuickShop plugin;
public CommandBuy(final QuickShop plugin) {
super("buy");
this.plugin = plugin;
setOnlyPlayerExecutable();
setPermission("quickshop.create.buy");
setDescription(MsgUtil.p("command.description.buy"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && shop.getOwner().equals(((Player) sender).getName())) {
shop.setShopType(ShopType.BUYING);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,49 @@
package org.maxgamer.QuickShop.Command;
import java.util.Iterator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandClean extends BaseCommand {
QuickShop plugin;
public CommandClean(final QuickShop plugin) {
super("clean");
this.plugin = plugin;
setPermission("quickshop.clean");
setDescription(MsgUtil.p("command.description.clean"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
sender.sendMessage(MsgUtil.p("command.cleaning"));
final Iterator<Shop> shIt = plugin.getShopManager().getShopIterator();
int i = 0;
while (shIt.hasNext()) {
final Shop shop = shIt.next();
try {
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
if (cs.isDoubleShop()) {
continue;
}
shIt.remove(); // Is selling, but has no stock, and is a chest shop, but is not a double shop. Can be deleted safely.
i++;
}
} catch (final IllegalStateException e) {
// shIt.remove(); // The shop is not there anymore, remove it
}
}
MsgUtil.clean();
sender.sendMessage(MsgUtil.p("command.cleaned", "" + i));
return;
}
}

View File

@ -0,0 +1,47 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandEmpty extends BaseCommand {
QuickShop plugin;
public CommandEmpty(final QuickShop plugin) {
super("empty");
this.plugin = plugin;
setPermission("quickshop.empty");
setDescription(MsgUtil.p("command.description.empty"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if (shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
cs.getInventory().clear();
sender.sendMessage(MsgUtil.p("empty-success"));
return;
} else {
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,79 @@
package org.maxgamer.QuickShop.Command;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Database.Database;
import org.maxgamer.QuickShop.Database.MySQLCore;
import org.maxgamer.QuickShop.Database.SQLiteCore;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandExport extends BaseCommand {
QuickShop plugin;
public CommandExport(final QuickShop plugin) {
super("export");
this.plugin = plugin;
setPermission("quickshop.export");
setMinimumArguments(1);
setPossibleArguments("[mysql|sqlite]");
setDescription(MsgUtil.p("command.description.export"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final String type = args[0].toLowerCase();
if (type.startsWith("mysql")) {
if (plugin.getDB().getCore() instanceof MySQLCore) {
sender.sendMessage(ChatColor.RED + "数据已保存在 MySQL 无需转换!");
return;
}
final ConfigurationSection cfg = plugin.getConfig().getConfigurationSection("database");
final String host = cfg.getString("host");
final String port = cfg.getString("port");
final String user = cfg.getString("user");
final String pass = cfg.getString("password");
final String name = cfg.getString("database");
final MySQLCore core = new MySQLCore(host, user, pass, name, port);
Database target;
try {
target = new Database(core);
QuickShop.instance.getDB().copyTo(target);
sender.sendMessage(ChatColor.GREEN + "导出成功 - 数据已保存至 MySQL " + user + "@" + host + "." + name);
} catch (final Exception e) {
e.printStackTrace();
sender.sendMessage(ChatColor.RED + "导出数据到 MySQL 失败 " + user + "@" + host + "." + name + ChatColor.DARK_RED + " 由于: " + e.getMessage());
}
return;
}
if (type.startsWith("sql") || type.contains("file")) {
if (plugin.getDB().getCore() instanceof SQLiteCore) {
sender.sendMessage(ChatColor.RED + "数据已保存在 SQLite 无需转换!");
return;
}
final File file = new File(plugin.getDataFolder(), "shops.db");
if (file.exists()) {
if (file.delete() == false) {
sender.sendMessage(ChatColor.RED + "警告: 删除旧的数据文件 shops.db 失败. 可能会导致部分信息错误.");
}
}
final SQLiteCore core = new SQLiteCore(file);
try {
final Database target = new Database(core);
QuickShop.instance.getDB().copyTo(target);
sender.sendMessage(ChatColor.GREEN + "导出成功 - 数据已保存至 SQLite: " + file.toString());
} catch (final Exception e) {
e.printStackTrace();
sender.sendMessage(ChatColor.RED + "导出数据到 SQLite: " + file.toString() + " 失败 由于: " + e.getMessage());
}
return;
}
}
}

View File

@ -0,0 +1,108 @@
package org.maxgamer.QuickShop.Command;
import java.util.HashMap;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.PluginHelper.utils.StringUtil;
public class CommandFind extends BaseCommand {
QuickShop plugin;
public CommandFind(final QuickShop plugin) {
super("find");
this.plugin = plugin;
setMinimumArguments(2);
setOnlyPlayerExecutable();
setPermission("quickshop.find");
setDescription(MsgUtil.p("command.description.find"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
String lookFor = StringUtil.consolidateStrings(args, 0);
lookFor = lookFor.toLowerCase();
final Player p = (Player) sender;
final Location loc = p.getEyeLocation().clone();
final double minDistance = plugin.getConfig().getInt("shop.find-distance");
double minDistanceSquared = minDistance * minDistance;
final int chunkRadius = (int) minDistance / 16 + 1;
Shop closest = null;
final Chunk c = loc.getChunk();
for (int x = -chunkRadius + c.getX(); x < chunkRadius + c.getX(); x++) {
for (int z = -chunkRadius + c.getZ(); z < chunkRadius + c.getZ(); z++) {
final Chunk d = c.getWorld().getChunkAt(x, z);
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(d);
if (inChunk == null) {
continue;
}
for (final Shop shop : inChunk.values()) {
if (shop.getDataName().toLowerCase().contains(lookFor) && shop.getLocation().distanceSquared(loc) < minDistanceSquared) {
closest = shop;
minDistanceSquared = shop.getLocation().distanceSquared(loc);
}
}
}
}
if (closest == null) {
sender.sendMessage(MsgUtil.p("no-nearby-shop", args[0]));
return;
}
final Location lookat = closest.getLocation().clone().add(0.5, 0.5, 0.5);
// Hack fix to make /qs find not used by /back
p.teleport(this.lookAt(loc, lookat).add(0, -1.62, 0), TeleportCause.PLUGIN);
p.sendMessage(MsgUtil.p("nearby-shop-this-way", "" + (int) Math.floor(Math.sqrt(minDistanceSquared))));
return;
}
/**
* Returns loc with modified pitch/yaw angles so it faces lookat
*
* @param loc
* The location a players head is
* @param lookat
* The location they should be looking
* @return The location the player should be facing to have their crosshairs
* on the location lookAt Kudos to bergerkiller for most of this
* function
*/
public Location lookAt(Location loc, final Location lookat) {
// Clone the loc to prevent applied changes to the input loc
loc = loc.clone();
// Values of change in distance (make it relative)
final double dx = lookat.getX() - loc.getX();
final double dy = lookat.getY() - loc.getY();
final double dz = lookat.getZ() - loc.getZ();
// Set yaw
if (dx != 0) {
// Set yaw start value based on dx
if (dx < 0) {
loc.setYaw((float) (1.5 * Math.PI));
} else {
loc.setYaw((float) (0.5 * Math.PI));
}
loc.setYaw(loc.getYaw() - (float) Math.atan(dz / dx));
} else if (dz < 0) {
loc.setYaw((float) Math.PI);
}
// Get the distance from dx/dz
final double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
final float pitch = (float) -Math.atan(dy / dxz);
// Set values, convert to degrees
// Minecraft yaw (vertical) angles are inverted (negative)
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI + 360);
// But pitch angles are normal
loc.setPitch(pitch * 180f / (float) Math.PI);
return loc;
}
}

View File

@ -0,0 +1,62 @@
package org.maxgamer.QuickShop.Command;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopChunk;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandInfo extends BaseCommand {
QuickShop plugin;
public CommandInfo(final QuickShop plugin) {
super("info");
this.plugin = plugin;
setPermission("quickshop.info");
setDescription(MsgUtil.p("command.description.info"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
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()) {
worlds++;
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()) {
selling++;
}
if (shop instanceof ContainerShop && ((ContainerShop) shop).isDoubleShop()) {
doubles++;
} else if (shop.isSelling() && shop.getRemainingStock() == 0) {
nostock++;
}
}
}
}
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

@ -0,0 +1,99 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandPrice extends BaseCommand {
QuickShop plugin;
public CommandPrice(final QuickShop plugin) {
super("price");
this.plugin = plugin;
setMinimumArguments(1);
setOnlyPlayerExecutable();
setPossibleArguments("<价格>");
setPermission("quickshop.create.changeprice");
setDescription(MsgUtil.p("command.description.price"));
}
@SuppressWarnings("deprecation")
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final Player p = (Player) sender;
double price;
try {
price = Double.parseDouble(args[0]);
} catch (final NumberFormatException e) {
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
return;
}
if (price < 0.01) {
sender.sendMessage(MsgUtil.p("price-too-cheap"));
return;
}
double fee = 0;
if (plugin.getConfigManager().isPriceChangeRequiresFee()) {
fee = plugin.getConfigManager().getFeeForPriceChange();
if (fee > 0 && plugin.getEcon().getBalance(p.getName()) < fee) {
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
return;
}
}
final BlockIterator bIt = new BlockIterator(p, 10);
// Loop through every block they're looking at upto 10 blocks away
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && (shop.getOwner().equals(p.getName()) || sender.hasPermission("quickshop.other.price"))) {
if (shop.getPrice() == price) {
// Stop here if there isn't a price change
sender.sendMessage(MsgUtil.p("no-price-change"));
return;
}
if (fee > 0) {
if (!plugin.getEcon().withdraw(p.getName(), fee)) {
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
return;
}
sender.sendMessage(MsgUtil.p("fee-charged-for-price-change", plugin.getEcon().format(fee)));
plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), fee);
}
// Update the shop
shop.setPrice(price);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("price-is-now", plugin.getEcon().format(shop.getPrice())));
// Chest shops can be double shops.
if (shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
if (cs.isDoubleShop()) {
final Shop nextTo = cs.getAttachedShop();
if (cs.isSelling()) {
if (cs.getPrice() < nextTo.getPrice()) {
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
}
} else {
// Buying
if (cs.getPrice() > nextTo.getPrice()) {
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
}
}
}
}
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,49 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandRefill extends BaseCommand {
QuickShop plugin;
public CommandRefill(final QuickShop plugin) {
super("refill");
this.plugin = plugin;
setMinimumArguments(1);
setPossibleArguments("<数量>");
setPermission("quickshop.refill");
setDescription(MsgUtil.p("command.description.refill"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
int add;
try {
add = Integer.parseInt(args[0]);
} catch (final NumberFormatException e) {
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
return;
}
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
shop.add(shop.getItem(), add);
sender.sendMessage(MsgUtil.p("refill-success"));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,30 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandReload extends BaseCommand {
QuickShop plugin;
public CommandReload(final QuickShop plugin) {
super("reload");
this.plugin = plugin;
setPermission("quickshop.reload");
setDescription(MsgUtil.p("command.description.reload"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
sender.sendMessage(MsgUtil.p("command.reloading"));
Bukkit.getPluginManager().disablePlugin(plugin);
Bukkit.getPluginManager().enablePlugin(plugin);
plugin.reloadConfig();
return;
}
}

View File

@ -0,0 +1,46 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandRemove extends BaseCommand {
QuickShop plugin;
public CommandRemove(final QuickShop plugin) {
super("remove", "delete");
this.plugin = plugin;
setOnlyPlayerExecutable();
setPermission("quickshop.delete");
setDescription(MsgUtil.p("command.description.remove"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final Player p = (Player) sender;
final BlockIterator bIt = new BlockIterator(p, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if (shop.getOwner().equals(p.getName())) {
shop.delete();
sender.sendMessage(ChatColor.GREEN + "商店已成功移除");
} else {
p.sendMessage(ChatColor.RED + "这个不是你的商店!");
}
return;
}
}
p.sendMessage(ChatColor.RED + "未找到商店!");
}
}

View File

@ -0,0 +1,44 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopType;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandSell extends BaseCommand {
QuickShop plugin;
public CommandSell(final QuickShop plugin) {
super("sell");
this.plugin = plugin;
setPermission("quickshop.create.sell");
setOnlyPlayerExecutable();
setDescription(MsgUtil.p("command.description.sell"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && shop.getOwner().equals(((Player) sender).getUniqueId())) {
shop.setShopType(ShopType.SELLING);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,50 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandSetOwner extends BaseCommand {
QuickShop plugin;
public CommandSetOwner(final QuickShop plugin) {
super("setowner");
this.plugin = plugin;
setPermission("quickshop.setowner");
setOnlyPlayerExecutable();
setDescription(MsgUtil.p("command.description.setowner"));
}
@SuppressWarnings("deprecation")
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
if (args.length < 2) {
sender.sendMessage(MsgUtil.p("command.no-owner-given"));
return;
}
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
final OfflinePlayer p = this.plugin.getServer().getOfflinePlayer(args[1]);
shop.setOwner(p.getName());
shop.update();
sender.sendMessage(MsgUtil.p("command.new-owner", this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -0,0 +1,43 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandUnlimited extends BaseCommand {
QuickShop plugin;
public CommandUnlimited(final QuickShop plugin) {
super("unlimited");
this.plugin = plugin;
setOnlyPlayerExecutable();
setPermission("quickshop.unlimited");
setDescription(MsgUtil.p("command.description.unlimited"));
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
shop.setUnlimited(!shop.isUnlimited());
shop.update();
sender.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "无限模式" : "有限模式")));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}

View File

@ -1,588 +0,0 @@
package org.maxgamer.QuickShop.Command;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.util.BlockIterator;
import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Database.Database;
import org.maxgamer.QuickShop.Database.MySQLCore;
import org.maxgamer.QuickShop.Database.SQLiteCore;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopChunk;
import org.maxgamer.QuickShop.Shop.ShopType;
import org.maxgamer.QuickShop.Util.MsgUtil;
public class QS implements CommandExecutor {
QuickShop plugin;
public QS(final QuickShop plugin) {
this.plugin = plugin;
}
/**
* Returns loc with modified pitch/yaw angles so it faces lookat
*
* @param loc
* The location a players head is
* @param lookat
* The location they should be looking
* @return The location the player should be facing to have their crosshairs
* on the location lookAt Kudos to bergerkiller for most of this
* function
*/
public Location lookAt(Location loc, final Location lookat) {
// Clone the loc to prevent applied changes to the input loc
loc = loc.clone();
// Values of change in distance (make it relative)
final double dx = lookat.getX() - loc.getX();
final double dy = lookat.getY() - loc.getY();
final double dz = lookat.getZ() - loc.getZ();
// Set yaw
if (dx != 0) {
// Set yaw start value based on dx
if (dx < 0) {
loc.setYaw((float) (1.5 * Math.PI));
} else {
loc.setYaw((float) (0.5 * Math.PI));
}
loc.setYaw(loc.getYaw() - (float) Math.atan(dz / dx));
} else if (dz < 0) {
loc.setYaw((float) Math.PI);
}
// Get the distance from dx/dz
final double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
final float pitch = (float) -Math.atan(dy / dxz);
// Set values, convert to degrees
// Minecraft yaw (vertical) angles are inverted (negative)
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI + 360);
// But pitch angles are normal
loc.setPitch(pitch * 180f / (float) Math.PI);
return loc;
}
@Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
if (args.length > 0) {
final String subArg = args[0].toLowerCase();
if (subArg.equals("unlimited")) {
setUnlimited(sender);
return true;
} else if (subArg.equals("setowner")) {
setOwner(sender, args);
return true;
} else if (subArg.equals("find")) {
find(sender, args);
return true;
} else if (subArg.startsWith("buy")) {
setBuy(sender);
return true;
} else if (subArg.startsWith("sell")) {
setSell(sender);
return true;
} else if (subArg.startsWith("price")) {
setPrice(sender, args);
return true;
} else if (subArg.equals("remove")) {
remove(sender, args);
} else if (subArg.equals("refill")) {
refill(sender, args);
return true;
} else if (subArg.equals("empty")) {
empty(sender, args);
return true;
} else if (subArg.equals("clean")) {
clean(sender);
return true;
} else if (subArg.equals("reload")) {
reload(sender);
return true;
} else if (subArg.equals("export")) {
export(sender, args);
return true;
} else if (subArg.equals("info")) {
if (sender.hasPermission("quickshop.info")) {
int buying, selling, doubles, chunks, worlds;
buying = selling = doubles = chunks = worlds = 0;
int nostock = 0;
for (final HashMap<ShopChunk, HashMap<Location, Shop>> inWorld : plugin.getShopManager().getShops().values()) {
worlds++;
for (final HashMap<Location, Shop> inChunk : inWorld.values()) {
chunks++;
for (final Shop shop : inChunk.values()) {
if (shop.isBuying()) {
buying++;
} else if (shop.isSelling()) {
selling++;
}
if (shop instanceof ContainerShop && ((ContainerShop) shop).isDoubleShop()) {
doubles++;
} else if (shop.isSelling() && shop.getRemainingStock() == 0) {
nostock++;
}
}
}
}
sender.sendMessage(ChatColor.RED + "QuickShop Statistics...");
sender.sendMessage(ChatColor.GREEN + "" + (buying + selling) + " shops in " + chunks + " chunks spread over " + worlds + " worlds.");
sender.sendMessage(ChatColor.GREEN + "" + doubles + " double shops. ");
sender.sendMessage(ChatColor.GREEN + "" + nostock + " selling shops (excluding doubles) which will be removed by /qs clean.");
return true;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return true;
}
} else {
// Invalid arg given
sendHelp(sender);
return true;
}
// No args given
sendHelp(sender);
return true;
}
public void sendHelp(final CommandSender s) {
s.sendMessage(MsgUtil.p("command.description.title"));
if (s.hasPermission("quickshop.unlimited")) {
s.sendMessage(ChatColor.GREEN + "/qs unlimited" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.unlimited"));
}
if (s.hasPermission("quickshop.setowner")) {
s.sendMessage(ChatColor.GREEN + "/qs setowner <player>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.setowner"));
}
if (s.hasPermission("quickshop.create.buy")) {
s.sendMessage(ChatColor.GREEN + "/qs buy" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.buy"));
}
if (s.hasPermission("quickshop.create.sell")) {
s.sendMessage(ChatColor.GREEN + "/qs sell" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.sell"));
}
if (s.hasPermission("quickshop.create.changeprice")) {
s.sendMessage(ChatColor.GREEN + "/qs price" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.price"));
}
if (s.hasPermission("quickshop.clean")) {
s.sendMessage(ChatColor.GREEN + "/qs clean" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.clean"));
}
if (s.hasPermission("quickshop.find")) {
s.sendMessage(ChatColor.GREEN + "/qs find <item>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.find"));
}
if (s.hasPermission("quickshop.refill")) {
s.sendMessage(ChatColor.GREEN + "/qs refill <amount>" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.refill"));
}
if (s.hasPermission("quickshop.empty")) {
s.sendMessage(ChatColor.GREEN + "/qs empty" + ChatColor.YELLOW + " - " + MsgUtil.p("command.description.empty"));
}
if (s.hasPermission("quickshop.export")) {
s.sendMessage(ChatColor.GREEN + "/qs export mysql|sqlite" + ChatColor.YELLOW + " - Exports the database to SQLite or MySQL");
}
}
private void clean(final CommandSender sender) {
if (sender.hasPermission("quickshop.clean")) {
sender.sendMessage(MsgUtil.p("command.cleaning"));
final Iterator<Shop> shIt = plugin.getShopManager().getShopIterator();
int i = 0;
while (shIt.hasNext()) {
final Shop shop = shIt.next();
try {
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
if (cs.isDoubleShop()) {
continue;
}
shIt.remove(); // Is selling, but has no stock, and is a chest shop, but is not a double shop. Can be deleted safely.
i++;
}
} catch (final IllegalStateException e) {
shIt.remove(); // The shop is not there anymore, remove it
}
}
MsgUtil.clean();
sender.sendMessage(MsgUtil.p("command.cleaned", "" + i));
return;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
private void empty(final CommandSender sender, final String[] args) {
if (sender instanceof Player && sender.hasPermission("quickshop.refill")) {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if (shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
cs.getInventory().clear();
sender.sendMessage(MsgUtil.p("empty-success"));
return;
} else {
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
} else {
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
private void export(final CommandSender sender, final String[] args) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: /qs export mysql|sqlite");
return;
}
final String type = args[1].toLowerCase();
if (type.startsWith("mysql")) {
if (plugin.getDB().getCore() instanceof MySQLCore) {
sender.sendMessage(ChatColor.RED + "Database is already MySQL");
return;
}
final ConfigurationSection cfg = plugin.getConfig().getConfigurationSection("database");
final String host = cfg.getString("host");
final String port = cfg.getString("port");
final String user = cfg.getString("user");
final String pass = cfg.getString("password");
final String name = cfg.getString("database");
final MySQLCore core = new MySQLCore(host, user, pass, name, port);
Database target;
try {
target = new Database(core);
QuickShop.instance.getDB().copyTo(target);
sender.sendMessage(ChatColor.GREEN + "Success - Exported to MySQL " + user + "@" + host + "." + name);
} catch (final Exception e) {
e.printStackTrace();
sender.sendMessage(ChatColor.RED + "Failed to export to MySQL " + user + "@" + host + "." + name + ChatColor.DARK_RED + " Reason: " + e.getMessage());
}
return;
}
if (type.startsWith("sql") || type.contains("file")) {
if (plugin.getDB().getCore() instanceof SQLiteCore) {
sender.sendMessage(ChatColor.RED + "Database is already SQLite");
return;
}
final File file = new File(plugin.getDataFolder(), "shops.db");
if (file.exists()) {
if (file.delete() == false) {
sender.sendMessage(ChatColor.RED + "Warning: Failed to delete old shops.db file. This may cause errors.");
}
}
final SQLiteCore core = new SQLiteCore(file);
try {
final Database target = new Database(core);
QuickShop.instance.getDB().copyTo(target);
sender.sendMessage(ChatColor.GREEN + "Success - Exported to SQLite: " + file.toString());
} catch (final Exception e) {
e.printStackTrace();
sender.sendMessage(ChatColor.RED + "Failed to export to SQLite: " + file.toString() + " Reason: " + e.getMessage());
}
return;
}
sender.sendMessage(ChatColor.RED + "No target given. Usage: /qs export mysql|sqlite");
}
private void find(final CommandSender sender, final String[] args) {
if (sender instanceof Player && sender.hasPermission("quickshop.find")) {
if (args.length < 2) {
sender.sendMessage(MsgUtil.p("command.no-type-given"));
return;
}
final StringBuilder sb = new StringBuilder(args[1]);
for (int i = 2; i < args.length; i++) {
sb.append(" " + args[i]);
}
String lookFor = sb.toString();
lookFor = lookFor.toLowerCase();
final Player p = (Player) sender;
final Location loc = p.getEyeLocation().clone();
final double minDistance = plugin.getConfig().getInt("shop.find-distance");
double minDistanceSquared = minDistance * minDistance;
final int chunkRadius = (int) minDistance / 16 + 1;
Shop closest = null;
final Chunk c = loc.getChunk();
for (int x = -chunkRadius + c.getX(); x < chunkRadius + c.getX(); x++) {
for (int z = -chunkRadius + c.getZ(); z < chunkRadius + c.getZ(); z++) {
final Chunk d = c.getWorld().getChunkAt(x, z);
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(d);
if (inChunk == null) {
continue;
}
for (final Shop shop : inChunk.values()) {
if (shop.getDataName().toLowerCase().contains(lookFor) && shop.getLocation().distanceSquared(loc) < minDistanceSquared) {
closest = shop;
minDistanceSquared = shop.getLocation().distanceSquared(loc);
}
}
}
}
if (closest == null) {
sender.sendMessage(MsgUtil.p("no-nearby-shop", args[1]));
return;
}
final Location lookat = closest.getLocation().clone().add(0.5, 0.5, 0.5);
// Hack fix to make /qs find not used by /back
p.teleport(this.lookAt(loc, lookat).add(0, -1.62, 0), TeleportCause.UNKNOWN);
p.sendMessage(MsgUtil.p("nearby-shop-this-way", "" + (int) Math.floor(Math.sqrt(minDistanceSquared))));
return;
} else {
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
private void refill(final CommandSender sender, final String[] args) {
if (sender instanceof Player && sender.hasPermission("quickshop.refill")) {
if (args.length < 2) {
sender.sendMessage(MsgUtil.p("command.no-amount-given"));
return;
}
int add;
try {
add = Integer.parseInt(args[1]);
} catch (final NumberFormatException e) {
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
return;
}
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
shop.add(shop.getItem(), add);
sender.sendMessage(MsgUtil.p("refill-success"));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
} else {
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
private void reload(final CommandSender sender) {
if (sender.hasPermission("quickshop.reload")) {
sender.sendMessage(MsgUtil.p("command.reloading"));
Bukkit.getPluginManager().disablePlugin(plugin);
Bukkit.getPluginManager().enablePlugin(plugin);
plugin.reloadConfig();
return;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
private void remove(final CommandSender sender, final String[] args) {
if (sender instanceof Player == false) {
sender.sendMessage(ChatColor.RED + "Only players may use that command.");
return;
}
if (!sender.hasPermission("quickshop.delete")) {
sender.sendMessage(ChatColor.RED + "You do not have permission to use that command. Try break the shop instead?");
return;
}
final Player p = (Player) sender;
final BlockIterator bIt = new BlockIterator(p, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
if (shop.getOwner().equals(p.getName())) {
shop.delete();
sender.sendMessage(ChatColor.GREEN + "Success. Deleted shop.");
} else {
p.sendMessage(ChatColor.RED + "That's not your shop!");
}
return;
}
}
p.sendMessage(ChatColor.RED + "No shop found!");
}
private void setBuy(final CommandSender sender) {
if (sender instanceof Player && sender.hasPermission("quickshop.create.buy")) {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && shop.getOwner().equals(((Player) sender).getName())) {
shop.setShopType(ShopType.BUYING);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
@SuppressWarnings("deprecation")
private void setOwner(final CommandSender sender, final String[] args) {
if (sender instanceof Player && sender.hasPermission("quickshop.setowner")) {
if (args.length < 2) {
sender.sendMessage(MsgUtil.p("command.no-owner-given"));
return;
}
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
final OfflinePlayer p = this.plugin.getServer().getOfflinePlayer(args[1]);
shop.setOwner(p.getName());
shop.update();
sender.sendMessage(MsgUtil.p("command.new-owner", this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
} else {
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
@SuppressWarnings("deprecation")
private void setPrice(final CommandSender sender, final String[] args) {
if (sender instanceof Player && sender.hasPermission("quickshop.create.changeprice")) {
final Player p = (Player) sender;
if (args.length < 2) {
sender.sendMessage(MsgUtil.p("no-price-given"));
return;
}
double price;
try {
price = Double.parseDouble(args[1]);
} catch (final NumberFormatException e) {
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
return;
}
if (price < 0.01) {
sender.sendMessage(MsgUtil.p("price-too-cheap"));
return;
}
double fee = 0;
if (plugin.getConfigManager().isPriceChangeRequiresFee()) {
fee = plugin.getConfigManager().getFeeForPriceChange();
if (fee > 0 && plugin.getEcon().getBalance(p.getName()) < fee) {
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
return;
}
}
final BlockIterator bIt = new BlockIterator(p, 10);
// Loop through every block they're looking at upto 10 blocks away
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && (shop.getOwner().equals(((Player) sender).getUniqueId()) || sender.hasPermission("quickshop.other.price"))) {
if (shop.getPrice() == price) {
// Stop here if there isn't a price change
sender.sendMessage(MsgUtil.p("no-price-change"));
return;
}
if (fee > 0) {
if (!plugin.getEcon().withdraw(p.getName(), fee)) {
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
return;
}
sender.sendMessage(MsgUtil.p("fee-charged-for-price-change", plugin.getEcon().format(fee)));
plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), fee);
}
// Update the shop
shop.setPrice(price);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("price-is-now", plugin.getEcon().format(shop.getPrice())));
// Chest shops can be double shops.
if (shop instanceof ContainerShop) {
final ContainerShop cs = (ContainerShop) shop;
if (cs.isDoubleShop()) {
final Shop nextTo = cs.getAttachedShop();
if (cs.isSelling()) {
if (cs.getPrice() < nextTo.getPrice()) {
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
}
} else {
// Buying
if (cs.getPrice() > nextTo.getPrice()) {
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
}
}
}
}
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
private void setSell(final CommandSender sender) {
if (sender instanceof Player && sender.hasPermission("quickshop.create.sell")) {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null && shop.getOwner().equals(((Player) sender).getUniqueId())) {
shop.setShopType(ShopType.SELLING);
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName()));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
}
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
private void setUnlimited(final CommandSender sender) {
if (sender instanceof Player && sender.hasPermission("quickshop.unlimited")) {
final BlockIterator bIt = new BlockIterator((Player) sender, 10);
while (bIt.hasNext()) {
final Block b = bIt.next();
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
shop.setUnlimited(!shop.isUnlimited());
shop.update();
sender.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "unlimited" : "limited")));
return;
}
}
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
return;
} else {
sender.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
}

View File

@ -0,0 +1,45 @@
package org.maxgamer.QuickShop.Command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.maxgamer.QuickShop.QuickShop;
import cn.citycraft.PluginHelper.commands.DefaultCommand;
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
public class QuickShopCommands implements CommandExecutor, DefaultCommand {
HandlerSubCommand hsc;
QuickShop plugin;
public QuickShopCommands(final QuickShop plugin) {
this.plugin = plugin;
hsc = new HandlerSubCommand(plugin);
hsc.setDefaultCommand(this);
hsc.registerCommand(new CommandClean(plugin));
hsc.registerCommand(new CommandEmpty(plugin));
hsc.registerCommand(new CommandExport(plugin));
hsc.registerCommand(new CommandFind(plugin));
hsc.registerCommand(new CommandInfo(plugin));
hsc.registerCommand(new CommandPrice(plugin));
hsc.registerCommand(new CommandRefill(plugin));
hsc.registerCommand(new CommandReload(plugin));
hsc.registerCommand(new CommandRemove(plugin));
hsc.registerCommand(new CommandBuy(plugin));
hsc.registerCommand(new CommandSetOwner(plugin));
hsc.registerCommand(new CommandSell(plugin));
hsc.registerCommand(new CommandUnlimited(plugin));
}
@Override
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
hsc.sendHelp(sender, label);
}
@Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
return hsc.onCommand(sender, cmd, label, args);
}
}

View File

@ -5,66 +5,98 @@ import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.QuickShop.QuickShop;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.tellraw.FancyMessage;
public class ConfigManager {
private boolean enableMagicLib = false;
/** Whether debug info should be shown in the console */
protected boolean debug = false;
/** Whether we should use display items or not */
protected boolean display = true;
protected double feeForPriceChange = 0.0;
protected int findDistance = 30;
protected String guiTitle = "§6[§b快捷商店§6]";
/** Whether or not to limit players shop amounts */
protected boolean limit = false;
protected int limitdefault = 0;
protected final HashMap<String, Integer> limits = new HashMap<String, Integer>();
protected boolean logAction = true;
protected boolean preventhopper = false;
/**
* A set of players who have been warned
* ("Your shop isn't automatically locked")
* Whether we players are charged a fee to change the price on their shop
* (To help deter endless undercutting
*/
protected HashSet<String> warnings = new HashSet<String>();
protected boolean priceChangeRequiresFee = false;
protected boolean shopLock = true;
protected boolean showTax;
/** Whether players are required to sneak to create/buy from a shop */
protected boolean sneak;
/** Whether players are required to sneak to create a shop */
protected boolean sneakCreate;
/** Whether players are required to sneak to trade with a shop */
protected boolean sneakTrade;
/** Whether we should use display items or not */
protected boolean display = true;
/**
* Whether we players are charged a fee to change the price on their shop
* (To help deter endless undercutting
*/
protected boolean priceChangeRequiresFee = false;
/** Whether or not to limit players shop amounts */
protected boolean limit = false;
protected int limitdefault = 0;
protected final HashMap<String, Integer> limits = new HashMap<String, Integer>();
protected boolean logAction = true;
protected boolean shopLock = true;
protected int findDistance = 30;
protected Material superItem = Material.GOLD_AXE;
protected double feeForPriceChange = 0.0;
protected double tax = 0;
protected String taxAccount;
/** Use SpoutPlugin to get item / block names */
protected boolean useSpout = false;
/**
* A set of players who have been warned
* ("Your shop isn't automatically locked")
*/
protected HashSet<String> warnings = new HashSet<String>();
public ConfigManager(final QuickShop plugin) {
ConfigurationSection limitCfg = plugin.getConfig().getConfigurationSection("limits");
final FileConfig config = (FileConfig) plugin.getConfig();
ConfigurationSection limitCfg = config.getConfigurationSection("limits");
if (limitCfg != null) {
this.limit = limitCfg.getBoolean("use", false);
this.limitdefault = plugin.getConfig().getInt("limits.default");
this.limitdefault = config.getInt("limits.default");
limitCfg = limitCfg.getConfigurationSection("ranks");
for (final String key : limitCfg.getKeys(true)) {
limits.put(key, limitCfg.getInt(key));
}
}
try {
this.superItem = Enum.valueOf(Material.class, plugin.getConfig().getString("superitem"));
this.superItem = Enum.valueOf(Material.class, config.getString("superitem"));
} catch (final Exception e) {
}
this.logAction = plugin.getConfig().getBoolean("log-actions");
this.shopLock = plugin.getConfig().getBoolean("shop.lock");
this.display = plugin.getConfig().getBoolean("shop.display-items");
this.sneak = plugin.getConfig().getBoolean("shop.sneak-only");
this.sneakCreate = plugin.getConfig().getBoolean("shop.sneak-to-create");
this.sneakTrade = plugin.getConfig().getBoolean("shop.sneak-to-trade");
this.priceChangeRequiresFee = plugin.getConfig().getBoolean("shop.price-change-requires-fee");
this.findDistance = plugin.getConfig().getInt("shop.find-distance");
this.feeForPriceChange = plugin.getConfig().getDouble("shop.fee-for-price-change");
this.tax = config.getDouble("tax");
this.showTax = config.getBoolean("show-tax");
this.taxAccount = config.getString("tax-account");
this.logAction = config.getBoolean("log-actions");
this.shopLock = config.getBoolean("shop.lock");
this.display = config.getBoolean("shop.display-items");
this.sneak = config.getBoolean("shop.sneak-only");
this.sneakCreate = config.getBoolean("shop.sneak-to-create");
this.sneakTrade = config.getBoolean("shop.sneak-to-trade");
this.priceChangeRequiresFee = config.getBoolean("shop.price-change-requires-fee");
this.findDistance = config.getInt("shop.find-distance");
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
this.preventhopper = config.getBoolean("preventhopper");
this.guiTitle = config.getMessage("guititle");
if (config.getBoolean("usemagiclib", true)) {
try {
plugin.getLogger().info("启用魔改库 尝试启动中...");
final FancyMessage fm = 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() {
@ -75,6 +107,10 @@ public class ConfigManager {
return findDistance;
}
public String getGuiTitle() {
return guiTitle;
}
public int getLimitdefault() {
return limitdefault;
}
@ -87,6 +123,14 @@ public class ConfigManager {
return superItem;
}
public double getTax() {
return tax;
}
public String getTaxAccount() {
return taxAccount;
}
public HashSet<String> getWarnings() {
return warnings;
}
@ -99,6 +143,10 @@ public class ConfigManager {
return display;
}
public boolean isEnableMagicLib() {
return enableMagicLib;
}
public boolean isLimit() {
return limit;
}
@ -107,6 +155,10 @@ public class ConfigManager {
return logAction;
}
public boolean isPreventHopper() {
return preventhopper;
}
public boolean isPriceChangeRequiresFee() {
return priceChangeRequiresFee;
}
@ -115,6 +167,10 @@ public class ConfigManager {
return shopLock;
}
public boolean isShowTax() {
return showTax;
}
public boolean isSneak() {
return sneak;
}

View File

@ -44,7 +44,7 @@ public class BlockListener implements Listener {
}
// If they're either survival or the owner, they can break it
final ItemStack pinh = p.getItemInHand();
if (p.getName().equals(shop.getOwner()) || (pinh != null && pinh.getType() == plugin.getConfigManager().getSuperItem()) || (p.getGameMode() == GameMode.SURVIVAL)) {
if (p.getName().equals(shop.getOwner()) || p.getGameMode() == GameMode.SURVIVAL || pinh == null || pinh.getType() == plugin.getConfigManager().getSuperItem()) {
// Cancel their current menu... Doesnt cancel other's menu's.
final Info action = plugin.getShopManager().getActions().get(p.getName());
if (action != null) {

View File

@ -37,7 +37,7 @@ public class LockListener implements Listener {
return; // Wasn't a shop
}
// If they owned it or have bypass perms, they can destroy it
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
if (!shop.getOwner().equals(p.getName()) && !p.hasPermission("quickshop.other.destroy")) {
e.setCancelled(true);
p.sendMessage(MsgUtil.p("no-permission"));
return;
@ -50,13 +50,8 @@ public class LockListener implements Listener {
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null) {
return;
}
// If they're the shop owner or have bypass perms, they can destroy
// it.
if (!shop.getOwner().equals(p.getUniqueId()) && !p.hasPermission("quickshop.other.destroy")) {
} else {
e.setCancelled(true);
p.sendMessage(MsgUtil.p("no-permission"));
return;
}
}
}
@ -83,7 +78,7 @@ public class LockListener implements Listener {
return;
}
}
if (!shop.getOwner().equals(p.getUniqueId())) {
if (!shop.getOwner().equals(p.getName())) {
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.p("bypassing-lock"));
return;
@ -143,7 +138,7 @@ public class LockListener implements Listener {
return;
}
}
if (p.getUniqueId().equals(shop.getOwner()) == false) {
if (p.getName().equals(shop.getOwner()) == false) {
if (p.hasPermission("quickshop.other.open")) {
p.sendMessage(MsgUtil.p("bypassing-lock"));
return;

View File

@ -12,11 +12,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
@ -26,7 +24,7 @@ import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Shop.Info;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopAction;
import org.maxgamer.QuickShop.Util.MarkUtil;
import org.maxgamer.QuickShop.Shop.ShopType;
import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util;
@ -44,16 +42,9 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onClick(final PlayerInteractEvent e) {
if (e.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
final Block b = e.getClickedBlock();
if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN) {
return;
}
final Player p = e.getPlayer();
if (plugin.getConfigManager().isSneak() != p.isSneaking()) {
// Sneak only
if (e.getAction() != Action.LEFT_CLICK_BLOCK || (e.getMaterial() == plugin.getConfigManager().getSuperItem() && b.getType() == Material.WALL_SIGN)) {
return;
}
final Location loc = b.getLocation();
@ -72,11 +63,16 @@ 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 {
final int items = Util.countItems(p.getInventory(), shop.getItem());
p.sendMessage(MsgUtil.p("how-many-sell", "" + items));
p.sendMessage(MsgUtil.p("how-many-sell", items));
}
// Add the new action
final HashMap<String, Info> actions = plugin.getShopManager().getActions();
@ -121,21 +117,6 @@ public class PlayerListener implements Listener {
}
}
@EventHandler
public void onItemClick(final InventoryClickEvent e) {
final Player p = (Player) e.getWhoClicked();
final ItemStack ci = e.getCurrentItem();
final Inventory inv = e.getInventory();
final int solt = e.getSlot();
try {
if (MarkUtil.hasMark(ci)) {
inv.setItem(solt, new ItemStack(Material.AIR));
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法获取快捷商店悬浮物品 已清理...");
}
} catch (final Exception ex) {
}
}
@EventHandler
public void onJoin(final PlayerJoinEvent e) {
// Notify the player any messages they were sent
@ -147,14 +128,11 @@ public class PlayerListener implements Listener {
}, 60);
}
@EventHandler(priority = EventPriority.HIGH)
/**
* Waits for a player to move too far from a shop, then cancels the menu.
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onMove(final PlayerMoveEvent e) {
if (e.isCancelled()) {
return;
}
final Info info = plugin.getShopManager().getActions().get(e.getPlayer().getName());
if (info != null) {
final Player p = e.getPlayer();
@ -172,21 +150,48 @@ public class PlayerListener implements Listener {
}
}
@EventHandler
public void onPlayerPickup(final PlayerPickupItemEvent e) {
final ItemStack ci = e.getItem().getItemStack();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
}
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent e) {
// Remove them from the menu
plugin.getShopManager().getActions().remove(e.getPlayer().getName());
}
@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
public void onSuperItemClick(final PlayerInteractEvent e) {
final Player p = e.getPlayer();
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) {
return;
}
final Block b = e.getClickedBlock();
// If that wasn't a shop, search nearby shops
if (b.getType() == Material.WALL_SIGN) {
final Block attached = Util.getAttached(b);
final Shop shop = attached == null ? null : plugin.getShopManager().getShop(attached.getLocation());
if (shop != null) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (p.hasPermission("quickshop.unlimited")) {
shop.setUnlimited(!shop.isUnlimited());
p.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "§e无限模式" : "§c有限模式")));
return;
}
} else {
if (shop.getShopType() == ShopType.BUYING && p.hasPermission("quickshop.create.sell")) {
shop.setShopType(ShopType.SELLING);
p.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName()));
return;
} else if (shop.getShopType() == ShopType.SELLING && p.hasPermission("quickshop.create.buy")) {
shop.setShopType(ShopType.BUYING);
p.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName()));
return;
}
}
shop.setSignText();
shop.update();
}
}
}
@EventHandler(ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent e) {
final PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
onMove(me);

View File

@ -0,0 +1,124 @@
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.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
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 {
private final QuickShop plugin;
public ProtectListener(final QuickShop 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
public void onInvMove(final InventoryMoveItemEvent e) {
final ItemStack ci = e.getItem();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
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);
}
}
@EventHandler
public void onInvPickup(final InventoryPickupItemEvent e) {
if (!plugin.getConfigManager().isPreventHopper()) {
return;
}
final ItemStack ci = e.getItem().getItemStack();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
}
@EventHandler
public void onItemClick(final InventoryClickEvent e) {
final Player p = (Player) e.getWhoClicked();
final ItemStack ci = e.getCurrentItem();
final Inventory inv = e.getInventory();
final int solt = e.getSlot();
if (inv.getType() != InventoryType.PLAYER && inv.getType() != InventoryType.HOPPER) {
if (inv.getTitle().equalsIgnoreCase(plugin.getConfigManager().getGuiTitle())) {
e.setCancelled(true);
p.closeInventory();
}
return;
}
try {
if (MarkUtil.hasMark(ci)) {
inv.setItem(solt, new ItemStack(Material.AIR));
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §d§l获取 " + ci.getItemMeta().getDisplayName() + " §a已清理...");
p.closeInventory();
}
} catch (final Exception ex) {
}
}
@EventHandler
public void onPlayerHandlerItem(final PlayerItemHeldEvent e) {
final Player p = e.getPlayer();
final ItemStack[] cis = p.getInventory().getArmorContents();
for (final ItemStack itemStack : cis) {
if (MarkUtil.hasMark(itemStack)) {
Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §e§l穿戴 " + itemStack.getItemMeta().getDisplayName() + " §a已清理...");
itemStack.setType(Material.AIR);
}
}
p.getInventory().setArmorContents(cis);
}
@EventHandler
public void onPlayerPickup(final PlayerPickupItemEvent e) {
final ItemStack ci = e.getItem().getItemStack();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
}
}

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;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -20,9 +19,11 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.maxgamer.QuickShop.Command.QS;
import org.maxgamer.QuickShop.Command.QuickShopCommands;
import org.maxgamer.QuickShop.Config.ConfigManager;
import org.maxgamer.QuickShop.Config.ItemConfig;
import org.maxgamer.QuickShop.Database.Database;
@ -38,7 +39,9 @@ import org.maxgamer.QuickShop.Listeners.ChatListener;
import org.maxgamer.QuickShop.Listeners.ChunkListener;
import org.maxgamer.QuickShop.Listeners.LockListener;
import org.maxgamer.QuickShop.Listeners.PlayerListener;
import org.maxgamer.QuickShop.Listeners.ProtectListener;
import org.maxgamer.QuickShop.Listeners.WorldListener;
import org.maxgamer.QuickShop.Listeners.WowSuchCleanerListener;
import org.maxgamer.QuickShop.Shop.ContainerShop;
import org.maxgamer.QuickShop.Shop.Shop;
import org.maxgamer.QuickShop.Shop.ShopManager;
@ -47,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;
@ -57,25 +59,18 @@ public class QuickShop extends JavaPlugin {
public static QuickShop instance;
/** The plugin default config */
public FileConfig config;
/** The economy we hook into for transactions */
private Economy economy;
/** The Shop Manager used to store shops */
private ShopManager shopManager;
// private HeroChatListener heroChatListener;
// Listeners (These don't)
/** The Config Manager used to read config */
private ConfigManager configManager;
/** The database for storing all our data for persistence */
private Database database;
// Listeners - We decide which one to use at runtime
private ChatListener chatListener;
// private HeroChatListener heroChatListener;
// Listeners (These don't)
private final BlockListener blockListener = new BlockListener(this);
private final PlayerListener playerListener = new PlayerListener(this);
private final ChunkListener chunkListener = new ChunkListener(this);
private final WorldListener worldListener = new WorldListener(this);
/** The economy we hook into for transactions */
private Economy economy;
private BukkitTask itemWatcherTask;
private LogWatcher logWatcher;
/** The Shop Manager used to store shops */
private ShopManager shopManager;
/**
* Prints debug information if QuickShop is configured to do so.
@ -185,13 +180,16 @@ 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) {
e.printStackTrace();
}
configManager.getWarnings().clear();
}
@ -216,7 +214,6 @@ public class QuickShop extends JavaPlugin {
final LockListener ll = new LockListener(this);
getServer().getPluginManager().registerEvents(ll, this);
}
try {
final ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
DatabaseCore dbCore;
@ -246,6 +243,7 @@ public class QuickShop extends JavaPlugin {
}
/* Load shops from database to memory */
int count = 0; // Shops count
int unload = 0;
Connection con;
try {
getLogger().info("从数据库载入商店数据...");
@ -269,14 +267,9 @@ public class QuickShop extends JavaPlugin {
final double price = rs.getDouble("price");
final Location loc = new Location(world, x, y, z);
/* Skip invalid shops, if we know of any */
if (world != null && (loc.getBlock().getState() instanceof InventoryHolder) == false) {
getLogger().info("商店不是一个可存储的方块 坐标 " + rs.getString("world") + " at: " + x + ", " + y + ", " + z + ". 删除...");
final PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
delps.setInt(1, x);
delps.setInt(2, y);
delps.setInt(3, z);
delps.setString(4, worldName);
delps.execute();
if (world != null && loc.getChunk().isLoaded() && (loc.getBlock().getState() instanceof InventoryHolder) == false) {
getLogger().info("商店不是一个可存储的方块 坐标 " + rs.getString("world") + ", " + x + ", " + y + ", " + z + ". 删除...");
database.execute("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?", x, y, z, worldName);
continue;
}
final int type = rs.getInt("type");
@ -288,21 +281,19 @@ public class QuickShop extends JavaPlugin {
shop.onLoad();
}
count++;
} catch (final IllegalStateException e) {
unload++;
} catch (final Exception e) {
errors++;
e.printStackTrace();
getLogger().warning("载入商店数据时发生错误! 商店位置: " + worldName + " (" + x + ", " + y + ", " + z + ")...");
if (errors < 3) {
getLogger().warning("删除错误的商店数据...");
final PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
delps.setInt(1, x);
delps.setInt(2, y);
delps.setInt(3, z);
delps.setString(4, worldName);
delps.execute();
database.execute("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?", x, y, z, worldName);
} else {
getLogger().warning("过多的错误数据 可能您的数据库文件已损坏! 请检查数据库文件!");
e.printStackTrace();
break;
}
}
}
@ -311,35 +302,42 @@ public class QuickShop extends JavaPlugin {
getLogger().warning("错误信息: " + e.getMessage());
e.printStackTrace();
}
getLogger().info("已载入 " + count + " 个商店...");
getLogger().info("已载入 " + count + " 个商店 剩余 " + unload + " 个商店将在区块载入后加载...");
MsgUtil.loadTransactionMessages();
MsgUtil.clean();
// Register events
Bukkit.getServer().getPluginManager().registerEvents(blockListener, this);
Bukkit.getServer().getPluginManager().registerEvents(playerListener, this);
Bukkit.getServer().getPluginManager().registerEvents(worldListener, this);
if (configManager.isDisplay()) {
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this);
// Display item handler thread
getLogger().info("开启悬浮物品刷新线程...");
final ItemWatcher itemWatcher = new ItemWatcher(this);
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 600);
final PluginManager pm = this.getServer().getPluginManager();
final Plugin wsc = pm.getPlugin("WowSuchCleaner");
if (wsc != null && wsc.isEnabled()) {
getLogger().info("发现 WowSuchCleaner 插件 开启相关功能...");
try {
Class.forName("io.github.Cnly.WowSuchCleaner.WowSuchCleaner.ItemPreCleanEvent");
pm.registerEvents(new WowSuchCleanerListener(), this);
} catch (final ClassNotFoundException e) {
getLogger().info("WowSuchCleaner 版本过低 可能造成悬浮物上架...");
}
this.chatListener = new ChatListener(this);
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
}
pm.registerEvents(new BlockListener(this), this);
pm.registerEvents(new PlayerListener(this), this);
pm.registerEvents(new WorldListener(this), this);
pm.registerEvents(new ProtectListener(this), this);
pm.registerEvents(new ChatListener(this), this);
if (configManager.isDisplay()) {
Bukkit.getServer().getPluginManager().registerEvents(new ChunkListener(this), this);
// Display item handler thread
getLogger().info("开启商店检查以及悬浮物刷新线程...");
final ItemWatcher itemWatcher = new ItemWatcher(this);
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 20, 1800);
}
// Command handlers
final QS commandExecutor = new QS(this);
final QuickShopCommands commandExecutor = new QuickShopCommands(this);
getCommand("qs").setExecutor(commandExecutor);
if (configManager.getFindDistance() > 100) {
getLogger().warning("商店查找半径过大 可能导致服务器Lag! 推荐使用低于 100 的配置!");
}
this.getLogger().info("载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜");
new VersionChecker(this);
try {
final Metrics metrics = new Metrics(this);
metrics.start();
} catch (final IOException e) {
}
}
@Override

View File

@ -23,14 +23,14 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util;
public class ContainerShop implements Shop {
private final Location loc;
private double price;
private String owner;
private final ItemStack item;
private DisplayItem displayItem;
private boolean unlimited;
private ShopType shopType;
private final ItemStack item;
private final Location loc;
private String owner;
private final QuickShop plugin;
private double price;
private ShopType shopType;
private boolean unlimited;
/**
* Adds a new shop.
@ -601,10 +601,12 @@ public class ContainerShop implements Shop {
final String[] lines = new String[4];
lines[0] = ChatColor.RED + "[QuickShop]";
if (this.isBuying()) {
lines[1] = MsgUtil.p("signs.buying", "" + this.getRemainingSpace());
final int remsp = this.getRemainingSpace();
lines[1] = MsgUtil.p("signs.buying", "" + (remsp == 10000 ? "无限" : remsp));
}
if (this.isSelling()) {
lines[1] = MsgUtil.p("signs.selling", "" + this.getRemainingStock());
final int remst = this.getRemainingStock();
lines[1] = MsgUtil.p("signs.selling", "" + (remst == 10000 ? "无限" : remst));
}
lines[2] = Util.getNameForSign(this.item);
lines[3] = MsgUtil.p("signs.price", "" + this.getPrice());
@ -637,8 +639,8 @@ public class ContainerShop implements Shop {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(
"商店 " + (loc.getWorld() == null ? "世界尚未载入" : "坐标: " + loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")");
final StringBuilder sb = new StringBuilder("商店 " + (loc.getWorld() == null ? "世界尚未载入" : "坐标: " + loc.getWorld().getName()) + "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", "
+ loc.getBlockZ() + ")");
sb.append(" 所有者: " + getOwner());
if (isUnlimited()) {
sb.append("无限模式: true");
@ -679,6 +681,7 @@ public class ContainerShop implements Shop {
if (trans && this.getDisplayItem() == null) {
this.displayItem = new DisplayItem(this, this.getItem());
this.getDisplayItem().spawn();
return;
}
if (this.getDisplayItem() != null) {
if (!trans) { // We have a display item in a block... delete it

View File

@ -13,9 +13,9 @@ import org.maxgamer.QuickShop.Util.NMS;
* cannot be interacted with.
*/
public class DisplayItem {
private final Shop shop;
private final ItemStack iStack;
private Item item;
private final Shop shop;
// private Location displayLoc;
/**
@ -65,8 +65,6 @@ public class DisplayItem {
if (shop.getLocation().getWorld() == null) {
return false;
}
// QuickShop qs = (QuickShop)
// Bukkit.getPluginManager().getPlugin("QuickShop");
final Location displayLoc = shop.getLocation().getBlock().getRelative(0, 1, 0).getLocation();
boolean removed = false;
final Chunk c = displayLoc.getChunk();

View File

@ -25,73 +25,9 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util;
public class ShopManager {
public class ShopIterator implements Iterator<Shop> {
private Iterator<Shop> shops;
private Iterator<HashMap<Location, Shop>> chunks;
private final Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> worlds;
private Shop current;
public ShopIterator() {
worlds = getShops().values().iterator();
}
/**
* Returns true if there is still more shops to iterate over.
*/
@Override
public boolean hasNext() {
if (shops == null || !shops.hasNext()) {
if (chunks == null || !chunks.hasNext()) {
if (!worlds.hasNext()) {
return false;
} else {
chunks = worlds.next().values().iterator();
return hasNext();
}
} else {
shops = chunks.next().values().iterator();
return hasNext();
}
}
return true;
}
/**
* Fetches the next shop. Throws NoSuchElementException if there are no
* more shops.
*/
@Override
public Shop next() {
if (shops == null || !shops.hasNext()) {
if (chunks == null || !chunks.hasNext()) {
if (!worlds.hasNext()) {
throw new NoSuchElementException("No more shops to iterate over!");
}
chunks = worlds.next().values().iterator();
}
shops = chunks.next().values().iterator();
}
if (!shops.hasNext()) {
return this.next(); // Skip to the next one (Empty iterator?)
}
current = shops.next();
return current;
}
/**
* Removes the current shop. This method will delete the shop from
* memory and the database.
*/
@Override
public void remove() {
current.delete(false);
shops.remove();
}
}
private final QuickShop plugin;
private final HashMap<String, Info> actions = new HashMap<String, Info>();
private final QuickShop plugin;
private final HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = new HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>>();
public ShopManager(final QuickShop plugin) {
@ -119,14 +55,13 @@ public class ShopManager {
}
final int max = plugin.getShopLimit(p);
if (owned + 1 > max) {
p.sendMessage(ChatColor.RED + "您已经创建了 " + owned + "/" + max + " 个商店!");
p.sendMessage(MsgUtil.p("you-cant-create-more-shop", owned));
return false;
}
}
final PlayerInteractEvent pie = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, new ItemStack(Material.AIR), b, bf); // PIE = PlayerInteractEvent - What else?
Bukkit.getPluginManager().callEvent(pie);
pie.getPlayer().closeInventory(); // If the player has chat open, this
// will close their chat.
pie.getPlayer().closeInventory(); // If the player has chat open, this will close their chat.
if (pie.isCancelled()) {
return false;
}
@ -439,7 +374,7 @@ public class ShopManager {
// Don't tax them if they're purchasing from
// themselves.
// Do charge an amount of tax though.
final double tax = plugin.getConfig().getDouble("tax");
final double tax = plugin.getConfigManager().getTax();
final double total = amount * shop.getPrice();
if (!plugin.getEcon().withdraw(p.getName(), total)) {
p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
@ -448,11 +383,11 @@ public class ShopManager {
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
plugin.getEcon().deposit(shop.getOwner(), total * (1 - tax));
if (tax != 0) {
plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), total * tax);
plugin.getEcon().deposit(plugin.getConfigManager().getTaxAccount(), total * tax);
}
}
// Notify the shop owner
if (plugin.getConfig().getBoolean("show-tax")) {
if (plugin.getConfigManager().isShowTax()) {
String msg = MsgUtil.p("player-bought-from-your-store-tax", p.getName(), "" + amount, shop.getDataName(), Util.format((tax * total)));
if (stock == amount) {
msg += "\n" + MsgUtil.p("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(),
@ -471,7 +406,7 @@ public class ShopManager {
// Transfers the item from A to B
shop.sell(p, amount);
MsgUtil.sendPurchaseSuccess(p, shop, amount);
plugin.log(p.getName() + " bought " + amount + " for " + (shop.getPrice() * amount) + " from " + shop.toString());
plugin.log(String.format("%s 从 %s 购买了 %s 件商品 花费 %s", p.getName(), shop.toString(), amount, shop.getPrice() * amount));
} else if (shop.isBuying()) {
final int space = shop.getRemainingSpace();
if (space < amount) {
@ -498,7 +433,7 @@ public class ShopManager {
// Don't tax them if they're purchasing from
// themselves.
// Do charge an amount of tax though.
final double tax = plugin.getConfig().getDouble("tax");
final double tax = plugin.getConfigManager().getTax();
final double total = amount * shop.getPrice();
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
// Tries to check their balance nicely to see if
@ -513,7 +448,7 @@ public class ShopManager {
return;
}
if (tax != 0) {
plugin.getEcon().deposit(plugin.getConfig().getString("tax-account"), total * tax);
plugin.getEcon().deposit(plugin.getConfigManager().getTaxAccount(), total * tax);
}
}
// Give them the money after we know we succeeded
@ -527,7 +462,7 @@ public class ShopManager {
}
shop.buy(p, amount);
MsgUtil.sendSellSuccess(p, shop, amount);
plugin.log(p.getName() + " sold " + amount + " for " + (shop.getPrice() * amount) + " to " + shop.toString());
plugin.log(String.format("%s 出售了 %s 件商品 到 %s 获得 %s", p.getName(), amount, shop.toString(), shop.getPrice() * amount));
}
shop.setSignText(); // Update the signs count
}
@ -603,4 +538,68 @@ public class ShopManager {
// Put the shop in its location in the chunk list.
inChunk.put(shop.getLocation(), shop);
}
public class ShopIterator implements Iterator<Shop> {
private Iterator<HashMap<Location, Shop>> chunks;
private Shop current;
private Iterator<Shop> shops;
private final Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> worlds;
public ShopIterator() {
worlds = getShops().values().iterator();
}
/**
* Returns true if there is still more shops to iterate over.
*/
@Override
public boolean hasNext() {
if (shops == null || !shops.hasNext()) {
if (chunks == null || !chunks.hasNext()) {
if (!worlds.hasNext()) {
return false;
} else {
chunks = worlds.next().values().iterator();
return hasNext();
}
} else {
shops = chunks.next().values().iterator();
return hasNext();
}
}
return true;
}
/**
* Fetches the next shop. Throws NoSuchElementException if there are no
* more shops.
*/
@Override
public Shop next() {
if (shops == null || !shops.hasNext()) {
if (chunks == null || !chunks.hasNext()) {
if (!worlds.hasNext()) {
throw new NoSuchElementException("No more shops to iterate over!");
}
chunks = worlds.next().values().iterator();
}
shops = chunks.next().values().iterator();
}
if (!shops.hasNext()) {
return this.next(); // Skip to the next one (Empty iterator?)
}
current = shops.next();
return current;
}
/**
* Removes the current shop. This method will delete the shop from
* memory and the database.
*/
@Override
public void remove() {
current.delete(false);
shops.remove();
}
}
}

View File

@ -14,12 +14,12 @@ 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 QuickShop plugin;
private static FileConfig messages;
private static HashMap<String, LinkedList<String>> player_messages = new HashMap<String, LinkedList<String>>();
private static QuickShop plugin;
/**
* Deletes any messages that are older than a week in the database, to save
@ -39,7 +39,7 @@ public class MsgUtil {
* The player to message
* @return true if success, false if the player is offline or null
*/
public static boolean flush(final OfflinePlayer p) { // TODO Changed to UUID
public static boolean flush(final OfflinePlayer p) {
if (p != null && p.isOnline()) {
final String pName = p.getName();
final LinkedList<String> msgs = player_messages.get(pName);
@ -47,7 +47,7 @@ public class MsgUtil {
for (final String msg : msgs) {
p.getPlayer().sendMessage(msg);
}
plugin.getDB().execute("DELETE FROM messages WHERE owner = ?", pName.toString());
plugin.getDB().execute("DELETE FROM messages WHERE owner = ?", pName);
msgs.clear();
}
return true;
@ -66,7 +66,7 @@ public class MsgUtil {
/**
* loads all player purchase messages from the database.
*/
public static void loadTransactionMessages() { // TODO Converted to UUID
public static void loadTransactionMessages() {
player_messages.clear(); // Delete old messages
try {
final ResultSet rs = plugin.getDB().getConnection().prepareStatement("SELECT * FROM messages").executeQuery();
@ -82,20 +82,20 @@ public class MsgUtil {
}
} catch (final SQLException e) {
e.printStackTrace();
System.out.println("Could not load transaction messages from database. Skipping.");
System.out.println("无法从数据库获得玩家的交易记录 跳过...");
}
}
public static String p(final String loc, final String... args) {
public static String p(final String loc, final Object... args) {
String raw = messages.getString(loc);
if (raw == null || raw.isEmpty()) {
return "Invalid message: " + loc;
return ChatColor.RED + "语言文件词条丢失: " + loc;
}
if (args == null) {
return raw;
}
for (int i = 0; i < args.length; i++) {
raw = raw.replace("{" + i + "}", args[i] == null ? "null" : args[i]);
raw = raw.replace("{" + i + "}", args[i] == null ? "null" : args[i].toString());
}
return raw;
}
@ -108,7 +108,7 @@ public class MsgUtil {
* they're online. Else, if they're not online, queues it for
* them in the database.
*/
public static void send(final String player, final String message) { // TODO Converted to UUID
public static void send(final String player, final String message) {
@SuppressWarnings("deprecation")
final OfflinePlayer p = Bukkit.getOfflinePlayer(player);
if (p == null || !p.isOnline()) {
@ -125,11 +125,20 @@ public class MsgUtil {
}
}
public static void sendItemMessage(final Player p, final ItemStack is, final String msg) {
try {
final FancyMessage fm = FancyMessage.newFM();
fm.text(msg).itemTooltip(is).send(p);
} catch (Exception | NoClassDefFoundError | NoSuchMethodError e) {
p.sendMessage(msg);
}
}
public static void sendPurchaseSuccess(final Player p, final Shop shop, final int amount) {
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.successful-purchase"));
final FancyMessage fm = new FancyMessage();
fm.text(ChatColor.DARK_PURPLE + "| ").then(MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice())))).itemTooltip(shop.getItem()).send(p);
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice())));
sendItemMessage(p, shop.getItem(), msg);
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
}
@ -141,7 +150,7 @@ public class MsgUtil {
final double tax = plugin.getConfig().getDouble("tax");
final double total = amount * shop.getPrice();
if (tax != 0) {
if (!p.getUniqueId().equals(shop.getOwner())) {
if (!p.getName().equals(shop.getOwner())) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.sell-tax", "" + Util.format((tax * total))));
} else {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.sell-tax-self"));
@ -165,16 +174,16 @@ public class MsgUtil {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
p.sendMessage(ChatColor.DARK_PURPLE + "| "
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
final FancyMessage fm = new FancyMessage();
fm.text(ChatColor.DARK_PURPLE + "| ").then(MsgUtil.p("menu.item", shop.getDataName())).itemTooltip(items).send(p);
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName());
sendItemMessage(p, shop.getItem(), msg);
if (Util.isTool(items.getType())) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.damage-percent-remaining", Util.getToolPercentage(items)));
}
if (shop.isSelling()) {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + stock));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.stock", "" + (stock == 10000 ? "无限" : stock)));
} else {
final int space = shop.getRemainingSpace();
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + space));
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + (space == 10000 ? "无限" : space)));
}
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
if (shop.isBuying()) {
@ -182,30 +191,6 @@ public class MsgUtil {
} else {
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-selling"));
}
// Map<Enchantment, Integer> enchs = items.getItemMeta().getEnchants();
// if (enchs != null && !enchs.isEmpty()) {
// p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.getMessage("menu.enchants") + "-----------------------+");
// for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
// p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
// }
// }
// try {
// Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
// if (items.getItemMeta() instanceof EnchantmentStorageMeta) {
// final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) items.getItemMeta();
// stor.getStoredEnchants();
// enchs = stor.getStoredEnchants();
// if (enchs != null && !enchs.isEmpty()) {
// p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.getMessage("menu.stored-enchants") + "--------------------+");
// for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
// p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
// }
// }
// }
// } catch (final ClassNotFoundException e) {
// // They don't have an up to date enough build of CB to do this.
// // TODO: Remove this when it becomes redundant
// }
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
}
}

View File

@ -1,6 +1,5 @@
package org.maxgamer.QuickShop.Util;
import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -26,18 +25,18 @@ import org.maxgamer.QuickShop.Config.ItemConfig;
@SuppressWarnings("deprecation")
public class Util {
private static HashSet<Material> tools = new HashSet<Material>();
private static HashSet<Material> blacklist = new HashSet<Material>();
private static HashSet<Material> shoppables = new HashSet<Material>();
private static HashSet<Material> transparent = new HashSet<Material>();
private static QuickShop plugin;
private static HashSet<Material> shoppables = new HashSet<Material>();
private static HashSet<Material> tools = new HashSet<Material>();
private static HashSet<Material> transparent = new HashSet<Material>();
public static void addTransparentBlock(final Material m) {
if (transparent.add(m) == false) {
System.out.println("Already added as transparent: " + m.toString());
System.out.println("已添加透明方块: " + m.toString());
}
if (!m.isBlock()) {
System.out.println(m + " is not a block!");
System.out.println(m + " 不是一个方块!");
}
}
@ -49,11 +48,15 @@ public class Util {
* @return True if it can be made into a shop, otherwise false.
*/
public static boolean canBeShop(final Block b) {
try {
final BlockState bs = b.getState();
if (bs instanceof InventoryHolder == false) {
return false;
}
return shoppables.contains(bs.getType());
} catch (final Exception e) {
return false;
}
}
/**
@ -142,10 +145,7 @@ public class Util {
final Sign sign = (Sign) b.getState().getData(); // Throws a NPE
// sometimes??
final BlockFace attached = sign.getAttachedFace();
if (attached == null) {
return null;
}
return b.getRelative(attached);
return attached == null ? null : b.getRelative(attached);
} catch (final NullPointerException e) {
return null; // /Not sure what causes this.
}
@ -174,23 +174,6 @@ public class Util {
name = name.substring(0, 16);
}
return name;
// final String[] nameParts = name.split("_");
// if (nameParts.length == 1) {
// return firstUppercase(nameParts[0]);
// }
//
// for (int i = 0; i < nameParts.length - 1; i++) {
// final int length = StringUtils.join(nameParts).length();
// if (length > 16) {
// nameParts[i] = nameParts[i].substring(0, 1) + ".";
// } else {
// nameParts[i] = firstUppercase(nameParts[i]);
// }
// }
//
// nameParts[nameParts.length - 1] = firstUppercase(nameParts[nameParts.length - 1]);
//
// return StringUtils.join(nameParts);
}
/**
@ -228,8 +211,7 @@ public class Util {
public static String getToolPercentage(final ItemStack item) {
final double dura = item.getDurability();
final double max = item.getType().getMaxDurability();
final DecimalFormat formatter = new DecimalFormat("0");
return dura + "/" + max + "(" + formatter.format((1 - dura / max) * 100.0) + ")";
return String.format("%.2f%%(剩余耐久%s/总耐久%s)", (1 - dura / max) * 100.0, max - dura, max);
}
public static void initialize() {

View File

@ -1,10 +1,16 @@
Version: 1.0
Version: 1.1
#超级工具(OP可以用该工具在创造模式打破所有商店)
superitem: GOLD_AXE
#阻止漏斗吸取商店物品(非特殊情况不要开启)
preventhopper: false
#商店GUI的标题
guititle: '&6[&b快捷商店&6]&r'
#启用魔改库支持
usemagiclib: true
#Tax amount (decimal) - Eg, P1 buys $50 worth of stuff from P2. Therefore, P1 loses $50, P2 gains $(1-0.05)*50, and tax-account gains $(0.05)*50.
tax: 0.05
tax: 0.00
#The fake player who money from taxing people goes to
tax-account: tax
#Whether or not to show taxes paid when selling to a shop
@ -51,23 +57,23 @@ shop-blocks:
- TRAPPED_CHEST
shop:
#Cost to make a stall
cost: 10
#Should we refund when their shops are deleted/removed/broken?
#创建商店需花费
cost: 0
#是否需要再次扣费 当玩家 删除/移除/破坏 商店的时候?
refund: false
#Is there a fee for changing prices on a shop (Help deter endless undercutting)
price-change-requires-fee: true
#If price changes require a fee, how much is the fee
fee-for-price-change: 50
#是否需要在玩家修改商店价格的时候扣费
price-change-requires-fee: false
#玩家修改商店价格时的扣费金额
fee-for-price-change: 0
#Should we try and lock their shops from other players, so people can't steal from them?
#是否需要锁定箱子防止其他玩家破坏
lock: true
#Should we require players be sneaking to create and use shops?
#是否需要玩家按住Shift才可以创建或交易?
sneak-to-create: false
sneak-to-trade: false
#Should we automatically create the sign for the chest?
#是否需要自动创建木牌在箱子上?
auto-sign: true
#If a player owns an unlimited shop, should they receive the cash from it or not?
#If you buy from YOUR unlimited shop, you will NEVER be charged $$, regardless of this setting

View File

@ -1,4 +1,4 @@
Version: 1.1
Version: 1.0
AIR_-1: 爪子
AIR: 爪子
@ -103,6 +103,21 @@ DIODE_BLOCK_OFF: DIODE_BLOCK_OFF
DIODE_BLOCK_ON: DIODE_BLOCK_ON
LOCKED_CHEST: 上锁的箱子
STAINED_GLASS: 白色染色玻璃
STAINED_GLASS_1: 橙色染色玻璃
STAINED_GLASS_2: 品红色染色玻璃
STAINED_GLASS_3: 淡蓝色染色玻璃
STAINED_GLASS_4: 黄色染色玻璃
STAINED_GLASS_5: 黄绿色染色玻璃
STAINED_GLASS_6: 粉红色染色玻璃
STAINED_GLASS_7: 灰色染色玻璃
STAINED_GLASS_8: 淡灰色染色玻璃
STAINED_GLASS_9: 青色染色玻璃
STAINED_GLASS_10: 紫色染色玻璃
STAINED_GLASS_11: 蓝色染色玻璃
STAINED_GLASS_12: 棕色染色玻璃
STAINED_GLASS_13: 绿色染色玻璃
STAINED_GLASS_14: 红色染色玻璃
STAINED_GLASS_15: 黑色染色玻璃
TRAP_DOOR: 活板门
MONSTER_EGGS: 石头刷怪蛋
SMOOTH_BRICK: 石砖
@ -167,13 +182,58 @@ QUARTZ_STAIRS: 石英楼梯
ACTIVATOR_RAIL: 激活铁轨
DROPPER: 掉落物
STAINED_CLAY: 白色染色粘土
STAINED_CLAY_1: 橙色染色粘土
STAINED_CLAY_2: 品红色染色粘土
STAINED_CLAY_3: 淡蓝色染色粘土
STAINED_CLAY_4: 黄色染色粘土
STAINED_CLAY_5: 黄绿色染色粘土
STAINED_CLAY_6: 粉红色染色粘土
STAINED_CLAY_7: 灰色染色粘土
STAINED_CLAY_8: 淡灰色染色粘土
STAINED_CLAY_9: 青色染色粘土
STAINED_CLAY_10: 紫色染色粘土
STAINED_CLAY_11: 蓝色染色粘土
STAINED_CLAY_12: 棕色染色粘土
STAINED_CLAY_13: 绿色染色粘土
STAINED_CLAY_14: 红色染色粘土
STAINED_CLAY_15: 黑色染色粘土
STAINED_GLASS_PANE: 白色染色玻璃板
STAINED_GLASS_PANE_1: 橙色染色玻璃板
STAINED_GLASS_PANE_2: 品红色染色玻璃板
STAINED_GLASS_PANE_3: 淡蓝色染色玻璃板
STAINED_GLASS_PANE_4: 黄色染色玻璃板
STAINED_GLASS_PANE_5: 黄绿色染色玻璃板
STAINED_GLASS_PANE_6: 粉红色染色玻璃板
STAINED_GLASS_PANE_7: 灰色染色玻璃板
STAINED_GLASS_PANE_8: 淡灰色染色玻璃板
STAINED_GLASS_PANE_9: 青色染色玻璃板
STAINED_GLASS_PANE_10: 紫色染色玻璃板
STAINED_GLASS_PANE_11: 蓝色染色玻璃板
STAINED_GLASS_PANE_12: 棕色染色玻璃板
STAINED_GLASS_PANE_13: 绿色染色玻璃板
STAINED_GLASS_PANE_14: 红色染色玻璃板
STAINED_GLASS_PANE_15: 黑色染色玻璃板
LEAVES_2: 合金欢树叶
LOG_2: 合金欢木
ACACIA_STAIRS: 合金欢楼梯
DARK_OAK_STAIRS: 深色橡木楼梯
HAY_BLOCK: 干草快
CARPET: 白色地毯
CARPET_1: 橙色地毯
CARPET_2: 品红色地毯
CARPET_3: 淡蓝色地毯
CARPET_4: 黄色地毯
CARPET_5: 黄绿色地毯
CARPET_6: 粉红色地毯
CARPET_7: 灰色地毯
CARPET_8: 淡灰色地毯
CARPET_9: 青色地毯
CARPET_10: 紫色地毯
CARPET_11: 蓝色地毯
CARPET_12: 棕色地毯
CARPET_13: 绿色地毯
CARPET_14: 红色地毯
CARPET_15: 黑色地毯
HARD_CLAY: 硬化粘土
COAL_BLOCK: 煤炭快
PACKED_ICE: 浮冰
@ -208,7 +268,8 @@ MUSHROOM_SOUP: 蘑菇煲
GOLD_SWORD: 金剑
GOLD_SPADE: 金楸
GOLD_PICKAXE: 金稿
GOLD_AXE:
GOLD_AXE:
GOLD_HOE: 金锄
STRING: 线
FEATHER: 羽毛
SULPHUR: 火药
@ -216,7 +277,6 @@ WOOD_HOE: 木锄
STONE_HOE: 石锄
IRON_HOE: 铁锄
DIAMOND_HOE: 钻石锄
GOLD_HOE: 金锄
SEEDS: 种子
WHEAT: 小麦
BREAD: 面包
@ -274,6 +334,21 @@ GLOWSTONE_DUST: 萤石粉
RAW_FISH: 生鱼
COOKED_FISH: 熟鱼
INK_SACK: 墨囊
INK_SACK_1: 玫瑰红
INK_SACK_2: 仙人掌绿
INK_SACK_3: 可可豆
INK_SACK_4: 青金石
INK_SACK_5: 紫色染料
INK_SACK_6: 青色染料
INK_SACK_7: 淡灰色染料
INK_SACK_8: 灰色染料
INK_SACK_9: 粉色染料
INK_SACK_10: 黄绿色染料
INK_SACK_11: 蒲公英黄染料
INK_SACK_12: 淡蓝色染料
INK_SACK_13: 品红色染料
INK_SACK_14: 橙色染料
INK_SACK_15: 骨粉
BONE: 骨粉
SUGAR:
CAKE: 蛋糕
@ -290,11 +365,11 @@ COOKED_BEEF: 熟牛肉
RAW_CHICKEN: 生鸡肉
COOKED_CHICKEN: 熟鸡肉
ROTTEN_FLESH: 腐肉
ENDER_PEARL: 地传送门
ENDER_PEARL: 影之眼
BLAZE_ROD: 烈焰棒
GHAST_TEAR: 恶魂之泪
GOLD_NUGGET: 金粒
NETHER_STALK: NETHER_STALK
NETHER_STALK: 地狱疣
POTION: 药水
GLASS_BOTTLE: 玻璃瓶
SPIDER_EYE: 蜘蛛眼
@ -303,8 +378,6 @@ BLAZE_POWDER: 烈焰粉
MAGMA_CREAM: 岩浆膏
BREWING_STAND_ITEM: 酿造台
CAULDRON_ITEM: 炼药锅
BREWING_STAND: 酿造台
CAULDRON: 炼药锅
EYE_OF_ENDER: 末影之眼
SPECKLED_MELON: 闪烁的西瓜
MONSTER_EGG: 刷怪蛋

View File

@ -1,99 +1,103 @@
# Colors:
# &0-9, &a-f
# {0}, {1}, {2}, etc are variables. You can swap them around, but adding a new variable won't work. Removing them will work
Version: 1.0
Version: 1.4
not-looking-at-shop: "&c没找到快捷商店. 你必须看着那个箱子."
no-permission: "&4你没有此命令的权限."
no-creative-break: "&c你不能在创造模式中打破其他玩家的商店,请使用生存模式."
no-double-chests: "&c你没有权限创建一个大箱子商店请使用个箱子."
shop-already-owned: "&c这已经是一个箱子了."
chest-was-removed: "&c商店已被移除."
price-too-cheap: "&c商品价格不能低于 &e¥0.01"
no-price-change: "&c商店价格未改变!"
you-cant-afford-a-new-shop: "&c创建一个新的商店需要花费 {0} 你没有足够的钱!."
you-cant-afford-to-change-price: "&c改变商店的价格需要花费 {0} 你没有足够的钱!."
success-created-shop: "&a成功创建商店."
success-removed-shop: "&a成功移除商店."
shops-arent-locked: "&c注意商店还没有被保护! 请用木牌锁锁上箱子保护你的商店!"
shop-creation-cancelled: "&c取消创建商店."
shop-purchase-cancelled: "&c取消购买."
shop-stock-too-low: "&c商店库存仅剩 {0} {1} "
you-cant-afford-to-buy: "&c此商品需要 {0}, 但是你只有 {1}"
negative-amount: "&c警告, 不能交易负数物品."
player-bought-from-your-store: "&c{0} 购买了 {1} {2} 从你的商店."
shop-out-of-stock: "&5你在 {0}, {1}, {2} 的商店, {3} 库存不足了"
shop-has-no-space: "&c商店只能收购 {0} more {1}."
you-dont-have-that-many-items: "&c你只有 {0} {1}."
the-owner-cant-afford-to-buy-from-you: "&c此商品出售价格为 {0} 但是所有者只有 {1}"
player-sold-to-your-store: "&a{0} 出售 {1} 个 {2} 到你的商店."
shop-out-of-space: "&5你在 {0}, {1}, {2}, 的商店库存满了."
fee-charged-for-price-change: "&a你只付了 &c{0}&a 改变了商品价格."
price-is-now: "&a此商店目前的价格为 &e{0}"
thats-not-a-number: "&4错误参数:请输入一个数字!"
no-price-given: "&c请设置一个价格."
average-price-nearby: "&a附近平均价格: &e{0}"
shop-has-changed: "&c你点击的商店已经改变!"
nearby-shop-this-way: "&a商店距离你 {0} 个方块."
no-nearby-shop: "&c附近未找到 {0} 商店."
buying-more-than-selling: "&4警告: 你购买的物品将比收购的物品多!"
not-enough-space: "&c你没有足够的空间装{0}!"
refill-success: "&a库存补充成功"
empty-success: "&a库存清理成功"
not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个商店.'
no-permission: '&4你没有此命令的权限.'
no-creative-break: '&c你不能在创造模式中打破其他玩家的商店,请使用生存模式.'
no-double-chests: '&c你没有权限创建一个大箱子商店请使用个箱子.'
shop-already-owned: '&c当前箱子已经是商店了.'
chest-was-removed: '&c商店已被移除.'
price-too-cheap: '&c商品价格不能低于 &e{0}'
no-price-change: '&c商店价格未改变!'
you-cant-create-more-shop: '&c您已经创建了 {0} 个商店 无法建造更多商店!'
you-cant-afford-a-new-shop: '&c创建一个新的商店需要花费 {0} 你没有足够的钱!.'
you-cant-afford-to-change-price: '&c改变商店的价格需要花费 {0} 你没有足够的钱!.'
success-created-shop: '&a成功创建商店.'
success-removed-shop: '&c成功移除商店.'
shops-arent-locked: '&c注意商店还没有被保护! 请用木牌锁锁上箱子保护你的商店!'
shop-creation-cancelled: '&c取消创建商店.'
shop-purchase-cancelled: '&c取消购买.'
shop-stock-too-low: '&c商店库存仅剩 {0} {1} '
you-cant-afford-to-buy: '&c此商品需要 {0}, 但是你只有 {1}'
negative-amount: '&c警告, 错误的物品数量.'
player-bought-from-your-store: '&d{0} 购买了 {1} {2} 从你的商店.'
shop-out-of-stock: '&5你在 {0}, {1}, {2} 的商店, {3} 库存不足了'
shop-has-no-space: '&c商店只能收购 {0} {1} 商品.'
you-dont-have-that-many-items: '&c你只有 {0} {1}.'
the-owner-cant-afford-to-buy-from-you: '&c此商品出售价格为 {0} 但是所有者只有 {1}'
player-sold-to-your-store: '&a{0} 出售 {1} {2} 到你的商店.'
shop-out-of-space: '&5你在 {0}, {1}, {2}, 的商店库存满了.'
fee-charged-for-price-change: '&a你只付了 &c{0}&a 改变了商品价格.'
price-is-now: '&a此商店目前的价格为 &e{0}'
thats-not-a-number: '&4错误参数:请输入一个数字!'
no-price-given: '&c请设置一个价格.'
average-price-nearby: '&a附近平均价格: &e{0}.'
shop-has-changed: '&c你点击的商店已经改变!'
nearby-shop-this-way: '&a商店距离你 {0} 个方块.'
no-nearby-shop: '&c附近未找到 {0} 商店.'
buying-more-than-selling: '&4警告: 你购买的物品超出了商店的库存!'
not-enough-space: '&c你没有足够的空间装 {0} !'
refill-success: '&a库存补充成功!'
empty-success: '&a商店清理成功!'
menu:
successful-purchase: "&a商品购买成功:"
successfully-sold: "&a商品出售成功:"
item-name-and-price: "&a花费&e{2} &a获得 &e{0} &a件 &e{1}&b(查看详情) &a商品"
successful-purchase: '&a商品购买成功:'
successfully-sold: '&a商品出售成功:'
item-name-and-price: '&d交易成功 &e{0} &a件 &e{1}&b(查看详情) &a商品 &b金额 &e{2}'
shop-information: '&a商店信息:'
owner: '&a所有者: {0}'
item: '&a物品: &e{0} &b(查看详情)'
space: '&a剩余容量: &e{0}'
stock: '&a剩余库存: &e{0}'
price-per: '&a单价: &e{1}元'
total-value-of-chest: '&a所有存货总价格: &c{0}元'
damage-percent-remaining: '&a耐久剩余: &e{0}.'
this-shop-is-buying: '&a此商店只 &d收购&a 物品.'
this-shop-is-selling: '&a此商店只 &b出售&a 商品.'
shop-information: "&a商店信息:"
owner: "&a所有者: {0}"
item: "&a物品: &e{0} &b(查看详情)"
space: "&aSpace: &e{0}"
stock: "&a库存: &e{0}"
price-per: "&a单价: &e{1}元"
total-value-of-chest: "&a所有存货总价格: &c{0}元"
damage-percent-remaining: "&a耐久剩余: &e{0}% ."
this-shop-is-buying: "&a此商店只 &d购买&a 物品."
this-shop-is-selling: "&a此商店只 &b出售&a 商品."
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个.'
bypassing-lock: "&c无视快捷商店锁!"
that-is-locked: "&c此商店已上锁."
how-many-buy: "&a请输入 &b购买商品数量&a 在聊天栏."
how-many-sell: "&a请输入 &d出售商品数量&a 在聊天栏. 你目前有 &e{0}&a 件物品"
not-allowed-to-create: "&c你不能在这里创建商店."
blacklisted-item: "&c此物品在快捷商店黑名单内. 你不能出售它"
how-much-to-trade-for: "&a请输入物品 &e{0}&a 的价格在聊天栏开始&c出售商品."
bypassing-lock: '&c无视快捷商店锁!'
that-is-locked: '&c此快捷商店已上锁.'
how-many-buy: '&a请输入 &b购买商品数量&a 在聊天栏.'
how-many-sell: '&a请输入 &d出售商品数量&a 在聊天栏. 你目前有 &e{0}&a 件物品'
not-allowed-to-create: '&c你不能在这里创建商店.'
blacklisted-item: '&c此物品在快捷商店黑名单内. 你不能出售它'
how-much-to-trade-for: '&a请输入物品 &e{0}&a 的价格在聊天栏开始&c出售商品.'
command:
success-created-unlimited: "&a无限商店创建成功!"
toggle-unlimited: "&a商店现在 {0}"
no-owner-given: "&c此商店没有所有者. 请使用 &a/qs setowner <玩家>&c 设置!"
new-owner: "&a新的所有者: &e{0}"
now-buying: "&a当前商店已改为 &d收购模式 &e{0}"
now-selling: "&a当前商店已改为 &b出售模式 &e{0}"
cleaning: "&a正在清理0库存的商店..."
reloading: "&a配置文件重新载入中..."
cleaned: "&a清理 &e{0}&a 商店"
no-type-given: "&c请使用: /qs find <物品> 查找商品"
success-created-unlimited: '&a无限商店创建成功!'
toggle-unlimited: '&a商店模式切换为 {0}'
no-owner-given: '&c此商店没有所有者. 请使用 &a/qs setowner <玩家>&c 设置!'
new-owner: '&a新的所有者: &e{0}'
now-buying: '&a商店模式切换为 &d收购模式 &e{0}'
now-selling: '&a商店模式切换为 &b出售模式 &e{0}'
cleaning: '&a正在清理0库存的商店...'
reloading: '&a配置文件重新载入中...'
cleaned: '&a清理 &e{0}&a 商店'
no-type-given: '&c请使用: /qs find <物品> 查找商品'
description:
title: "&a快捷商店帮助"
unlimited: "&e创建一个无限商店"
setowner: "&e改变商店的所有者"
buy: "&e改变商店模式为 &d购买"
sell: "&e改变商店模式为 &b出售"
clean: "&e清除所有0库存的商店"
price: "&e更改商店 &b出售/收购 &e的价格"
find: "&e查找附近的商店."
reload: "&e从config.yml文件中重载快捷商店配置"
refill: "&e给一个商店加入指定数量的物品"
empty: "&e清空一个商店的所有货物"
title: '&a快捷商店帮助'
unlimited: '&e创建一个无限商店'
setowner: '&e改变商店的所有者'
buy: '&e改变商店模式为 &d购买'
sell: '&e改变商店模式为 &b出售'
clean: '&e清除所有0库存的商店'
price: '&e更改商店 &b出售/收购 &e的价格'
find: '&e查找附近的商店.'
reload: '&e重载快捷商店配置'
refill: '&e给一个商店加入指定数量的物品'
empty: '&e清空一个商店的所有货物.'
export: '&e导出 数据库 到 SQLite 或者 MySQL'
info: '&e查看当前服务器商店信息.'
remove: '&e移除眼前的商店.'
signs:
#Line 1 is used as an identifier at the moment, so I kind of need it to work, thats why I won't let you change it
#Line 3 is the item name... There really isnt anything to change.
selling: "出售数量: {0}"
buying: "收购数量: {0}"
price: "每件价格: ${0}"
selling: '出售数量: {0}'
buying: '收购数量: {0}'
price: '每件价格: {0}'

View File

@ -2,15 +2,22 @@ name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}
authors: [Netherfoam,Timtower, KaiNoMood,喵♂呜]
softdepend: [Vault]
authors:
- Netherfoam
- Timtower
- KaiNoMood
- 喵♂呜
softdepend:
- Vault
- WowSuchCleaner
website: ${jenkins.url}/job/${project.artifactId}/
commands:
qs:
description: QuickShop command
usage: /qs
aliases: [shop]
usage: §c未知的子命令 请输入 §b/qs help §c查看帮助!
aliases:
- quickshop
- shop
permissions:
quickshop.create.sell:
description: Allows a player to sell from a shop