diff --git a/bin/.gitignore b/bin/.gitignore
deleted file mode 100644
index fa527594b..000000000
--- a/bin/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-*.class
-lib/
-src/test/
-.settings/
-target/
-.idea/
-*.iml
-.classpath
-.project
-/bin/
diff --git a/bin/README.md b/bin/README.md
deleted file mode 100644
index 875be32e4..000000000
--- a/bin/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# QuickShop
-QuickShop is a shop plugin, that allows players to sell items from a chest with no commands. It allows players to purchase any number of items easily. In fact, this plugin doesn't even have any commands that a player would ever need!
-
-## Support
-Open a new issue here: https://github.com/KaiKikuchi/QuickShop/issues
-
-## Features
-- Easy to use
-- Togglable Display Item on top of chest
-- NBT Data, Enchants, Tool Damage, Potion and Mob Egg support
-- Unlimited chest support
-- Blacklist support & bypass permissions
-- Shops that buy items and sell items at the same time are possible (Using double chests)
-- Herochat support
-- Checks a player can open a chest before letting them create a shop!
-- UUID support
-
-## Releases
-Github projects have a "releases" link on their home page. If you still don't see it, [click here](https://github.com/KaiKikuchi/QuickShop/releases) for QuickShop releases.
-
-## Links
-- [SpigotMC](https://www.spigotmc.org/resources/quickshop.18676/)
-- [dev.bukkit.org](http://dev.bukkit.org/bukkit-plugins/quickshop-notlikeme/) (no longer maintained)
-
-## Contribute
-If you're a developer, you can contribute to the QuickShop code! Just make a fork, then make a pull request when you're done! Please try to follow [Google Java Style](https://google.github.io/styleguide/javaguide.html). Also do not increase the plugin version number. Thank you very much!
diff --git a/bin/pom.xml b/bin/pom.xml
deleted file mode 100644
index e857f088d..000000000
--- a/bin/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
- 4.0.0
- org.maxgamer
- QuickShop
- Reremake 1.0.5
-
-
-
- GPL v3 License
- http://www.gnu.org/licenses/
- repo
-
-
-
-
- https://github.com/${developer}/${name}/issues
- GitHub Issues
-
-
-
- https://github.com/${developer}/${version}
- scm:git:git://github.com/${developer}/${version}.git
- scm:git:git@github.com:${developer}/${version}.git
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- 1.8
- 1.8
-
-
-
-
-
- src/main/resources
- true
-
-
-
-
-
- bukkit-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- sk89q-repo
- http://maven.sk89q.com/repo/
-
-
- vault-repo
- http://nexus.hc.to/content/repositories/pub_releases
-
-
-
-
- com.sk89q
- worldguard
- system
- 7.0.0
- ${basedir}/lib/worldguard-legacy-7.0.0-SNAPSHOT-dist.jar
-
-
- net.milkbowl.vault
- VaultAPI
- 1.5
- system
- ${basedir}/lib/Vault-1.6.6.jar
-
-
- org.bukkit.craftbukkit.v1_13_R1
- spigot
- v1_13_R1
- system
- ${basedir}/lib/spigot-1.13-SNAPSHOT.jar
-
-
-
- org.maxgamer.quickshop
- KaiNoMood
-
-
\ No newline at end of file
diff --git a/bin/src/main/resources/config.yml b/bin/src/main/resources/config.yml
deleted file mode 100644
index 761f4d619..000000000
--- a/bin/src/main/resources/config.yml
+++ /dev/null
@@ -1,129 +0,0 @@
-#Default config: https://github.com/KaiKikuchi/QuickShop/blob/master/src/main/resources/config.yml
-
-#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
-
-#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
-show-tax: false
-
-#Should we log transactions/creations to Bukkit\Plugins\QuickShop\qs.log?
-log-actions: true
-
-#For item-item based economies that don't use virtual coins.
-whole-number-prices-only: false
-
-#Force bukkit chat handler (https://github.com/KaiKikuchi/QuickShop/issues/10)
-force-bukkit-chat-handler: false
-
-database:
- mysql: false
- host: localhost
- port: 3306
- database: quickshop
- user: root
- password: passwd
-
-#Limits the number of shops a person can create and own at a single time.
-limits:
- #Disable these if you're not using them! If this is false, the rest of this section is ignored
- use: false
-
- #The default number of shops players can make
- default: 10
-
- #Players with these permissions can create these amounts of shops.
- ranks:
- #Anyone with 'quickshop.vip' permissions, can create 20 shops instead of 10.
- quickshop.vip: 20 #Players with quickshop.vip can make 20 shops.
-
-#A list of block (materials) which can be used to create shops.
-#By default, chests are added to this list.
-#This will only work for blocks which implement InventoryHolder
-#in other words, no enderchest shops, no shops on dirt blocks, etc.
-#May cause unexpected behaviour with some blocks... Eg don't make a
-#shop on a hopper (It sucks the display item in) and furnace shops
-#allow players to put whatever item they want in all 3 slots and
-#dispenser shops aren't protected from redstone... Etc.
-shop-blocks:
- - CHEST
- - TRAPPED_CHEST
-
-shop:
- #Cost to make a stall
- cost: 10
- #Should we refund when their shops are deleted/removed/broken?
- 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
-
- #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?
- 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
- pay-unlimited-shop-owners: false
-
- #Should we place display items on the chests? This may cause duped items, especially for modded servers.
- display-items: false
-
- #The plugin will check if the display item is in a valid position every the specified amount of ticks. 0 to disable.
- display-items-check-ticks: 0
-
- #When someone uses /qs find , how far should we search in blocks?
- #This command lets users shop quickly without wasting time searching
- #Settings > 100 WILL cause lag. Don't do it, or don't cry when your server lags.
- find-distance: 45
-
-#List of items to disallow selling of. Anyone with quickshop.bypass. can bypass it
-blacklist:
-- 7 #Bedrock
-
-
-#List of items with restricted prices. Format: ;;
-price-restriction:
-- Bedrock;100;200
-
-#Custom name for items. Format: ;;
-# Vanilla Material list (ItemIDs): https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
-custom-items-name:
-- NETHER_STALK;Nether Wart;Nether Wart
-
-custom-potions-name:
- sign:
- format: "%variety%type"
- variety:
- normal: ""
- splash: "Splash"
- lingering: "Ling"
- shopinfo:
- format: "%variety %type"
- variety:
- normal: ""
- splash: "Splash"
- lingering: "Lingering"
-
- #Custom names for potions types. Format: ;;
- # PotionType: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionType.html
- types:
- - INVISIBILITY;Invis;Invisibility
-
- #Custom names for potion effect type. Format: ;
- # PotionEffect: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html
- effects:
- - FIRE_RESISTANCE;Fire resistance
- - INVISIBILITY;Invisibility
-
-
\ No newline at end of file
diff --git a/bin/src/main/resources/messages.yml b/bin/src/main/resources/messages.yml
deleted file mode 100644
index 1134e4e24..000000000
--- a/bin/src/main/resources/messages.yml
+++ /dev/null
@@ -1,108 +0,0 @@
-# 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
-
-not-looking-at-shop: "&cNo QuickShop found. You must be looking at one."
-no-permission: "&cYou do not have permission to do that."
-no-creative-break: "&cYou cannot break other players shops in creative mode. Use survival instead."
-no-double-chests: "&cYou don't have permission to create a double-chest shop."
-shop-already-owned: "&cThat is already a shop."
-chest-was-removed: "&cThat chest was removed."
-price-too-cheap: "&cPrice must be greater than &e$0.01"
-no-price-change: "&cThat wouldn't result in a price change!"
-you-cant-afford-a-new-shop: "&cIt costs {0} to create a new shop."
-player-bought-from-your-store-tax: "&c{0} purchased {1} {2} from your store, and you paid {3} in taxes."
-you-cant-afford-to-change-price: "&cIt costs {0} to change the price in your shop."
-success-created-shop: "&aCreated shop."
-success-removed-shop: "&aShop removed."
-shops-arent-locked: "&cRemember, shops are NOT protected from theft! If you want to stop thieves, lock it with LWC, Lockette, etc!"
-shop-creation-cancelled: "&cCancelled Shop Creation."
-shop-purchase-cancelled: "&cCancelled Shop Purchase."
-shop-stock-too-low: "&cThe shop only has {0} {1} left"
-you-cant-afford-to-buy: "&cThat costs {0}, but you only have {1}"
-negative-amount: "&cDerp, can't trade negative amounts"
-player-bought-from-your-store: "&c{0} purchased {1} {2} from your store."
-shop-out-of-stock: "&5Your shop at {0}, {1}, {2}, has run out of {3}"
-shop-has-no-space: "&cThe shop only has room for {0} more {1}."
-you-dont-have-that-many-items: "&cYou only have {0} {1}."
-the-owner-cant-afford-to-buy-from-you: "&cThat costs {0} but the owner only has {1}"
-player-sold-to-your-store: "&a{0} sold {1} {2} to your store."
-shop-out-of-space: "&5Your shop at {0}, {1}, {2}, is now full."
-fee-charged-for-price-change: "&aYou pay &c{0}&a to change the price."
-price-is-now: "&aThe shops new price is &e{0}"
-thats-not-a-number: "&cInvalid number"
-no-price-given: "&cPlease give a valid price."
-average-price-nearby: "&aAverage Price Nearby: &e{0}"
-shop-has-changed: "&cThe shop you tried to use has changed since you clicked it!"
-nearby-shop-this-way: "&aShop is {0} blocks away from you."
-no-nearby-shop: "&cNo shops matching {0} nearby."
-buying-more-than-selling: "&cWARNING: You are buying items for more than you are selling them!"
-not-enough-space: "&cYou only have room for {0} more of that!"
-refill-success: "&aRefill success"
-empty-success: "&aEmpty success"
-admin-shop: "AdminShop"
-unknown-owner: "Unknown"
-
-menu:
- successful-purchase: "&aSuccessfully Purchased:"
- successfully-sold: "&aSuccessfully Sold:"
- item-name-and-price: "&e{0} {1} &afor &e{2}"
- sell-tax: "&aYou paid &e{0} &ain taxes."
- sell-tax-self: "&aYou own this shop so you don't pay taxes."
- enchants: "&5Enchants"
- stored-enchants: "&5Stored Enchants"
-
- shop-information: "&aShop Information:"
- owner: "&aOwner: {0}"
- item: "&aItem: &e{0}"
- space: "&aSpace: &e{0}"
- stock: "&aStock &e{0}"
- price-per: "&aPrice per &e{0} &a- &e{1}"
- total-value-of-chest: "&aTotal value of Chest: &e{0}"
- damage-percent-remaining: "&e{0}% &aRemaining."
- this-shop-is-buying: "&aThis shop is &dBUYING&a items."
- this-shop-is-selling: "&aThis shop is &bSELLING&a items."
- effects: "&aEffects: &e{0}"
-
-
-bypassing-lock: "&cBypassing a QuickShop lock!"
-that-is-locked: "&cThat shop is locked."
-
-how-many-buy: "&aEnter how many you wish to &bBUY&a in chat."
-how-many-sell: "&aEnter how many you wish to &dSELL&a in chat. You have &e{0}&a available"
-
-not-allowed-to-create: "&cYou may not create a shop here."
-blacklisted-item: "&cThat item is blacklisted. You may not sell it"
-how-much-to-trade-for: "&aEnter how much you wish to trade one &e{0}&a for in chat."
-
-command:
- #success-created-unlimited: "&aUnlimited QuickShop created."
- toggle-unlimited: "&aShop is now {0}"
- no-owner-given: "&cNo owner given. Use &a/qs setowner &c"
- new-owner: "&aNew owner: &e{0}"
- now-buying: "&aNow &dBUYING&a &e{0}"
- now-selling: "&aNow &bSELLING &e{0}"
- cleaning: "&aCleaning up shops with 0 stock..."
- reloading: "&aReloading..."
- cleaned: "&aCleaned &e{0}&a shops"
- no-type-given: "&cUsage: /qs find "
- description:
- title: "&aQuickShop Help"
- unlimited: "&eMakes a shop unlimited"
- setowner: "&eChanges who owns a shop"
- buy: "&eChanges a shop to &dBUY&e mode"
- sell: "&eChanges a shop to &bSELL&e mode"
- clean: "&eRemoves all (loaded) shops with 0 stock"
- price: "&eChanges the buy/selling price of one of your shops"
- find: "&eLocates the nearest shop of a specific type."
- reload: "&eReloads QuickShop from config.yml"
- refill: "&eAdds a given number of items to a shop"
- empty: "&eRemoves all stock from a shop"
- create: "&eCreates a new shop at the target chest"
-
-signs:
- header: "&c{0}"
- selling: "Selling {0}"
- buying: "Buying {0}"
- item: "{0}"
- price: "{0} each"
\ No newline at end of file
diff --git a/bin/src/main/resources/plugin.yml b/bin/src/main/resources/plugin.yml
deleted file mode 100644
index 7b630cb15..000000000
--- a/bin/src/main/resources/plugin.yml
+++ /dev/null
@@ -1,63 +0,0 @@
-name: ${name}
-main: ${package}.${name}
-version: ${version}
-authors: [Netherfoam, Timtower, KaiNoMood, Ghost_chu]
-
-description: Economy Shops plugin
-#softdepend: [Herochat, Vault, Essentials, OpenInv] OLD Remove Herochat support.
-softdepend: [Vault, WorldGuard, Essentials, OpenInv]
-
-api-version: 1.13
-
-commands:
- qs:
- description: QuickShop command
- usage: /qs
- aliases: [shop]
-
-permissions:
- quickshop.create.sell:
- description: Allows a player to sell from a shop
- default: op
- quickshop.create.buy:
- description: Allows a player to buy from a shop
- default: op
- quickshop.create.double:
- description: Allows a player to create a double shop
- default: op
- quickshop.use:
- description: Allows a player to buy/sell using other players shops
- default: true
- quickshop.unlimited:
- description: Allows a Staff Member to use /qs unlimited and make a shop infinite
- quickshop.bypass.:
- description: Allows a player to sell , even if its blacklisted
- quickshop.other.destroy:
- description: Allows a Staff Member to destroy other players shops if they are locked in the config
- quickshop.other.open:
- description: Allows a Staff Member to open someone elses shop if they are locked in the config
- quickshop.other.price:
- description: Allows a Staff Member to change the price of someone elses shop
- quickshop.setowner:
- description: Allows a Staff Member to change the owner of any shop
- quickshop.find:
- description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius.
- default: true
- quickshop.refill:
- description: Allows a Staff Member to refill the shop theyre looking at with the given number of items.
- default: op
- quickshop.empty:
- description: Allows a Staff Member to empty the shop theyre looking at of all items.
- default: op
- quickshop.debug:
- description: Enables debug info to console
- default: op
- quickshop.export:
- description: Allows exporting database to mysql or sqlite
- default: op
- quickshop.taxexemption:
- description: Tax exemption
- default: false
- quickshop.alerts:
- description: Alert the player when someone tries to cheat with the display item
- default: op
\ No newline at end of file
diff --git a/src/main/java/org/maxgamer/quickshop/Util/ItemNMS.java b/src/main/java/org/maxgamer/quickshop/Util/ItemNMS.java
index 7a3a63e58..0204166c3 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/ItemNMS.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/ItemNMS.java
@@ -1,43 +1,42 @@
package org.maxgamer.quickshop.Util;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import org.maxgamer.quickshop.QuickShop;
-public class ItemNMS {
- public String getItemJSON(ItemStack iStack) {
- ItemStack itemStack = iStack.clone();
- String name = Bukkit.getServer().getClass().getPackage().getName();
- String version = name.substring(name.lastIndexOf('.') + 1);
- Class> nmsClass;
- try {
- nmsClass = Class.forName("org.maxgamer.quickshop.Nms." + version);
- } catch (ClassNotFoundException e2) {
- return null;
- }
- Object obj;
- try {
- obj = nmsClass.newInstance();
- } catch (InstantiationException e1) { //NMS Class not found, Use old preview
- return null;
- } catch (IllegalAccessException e1) {
- return null;
- }
- try {
- Method method = nmsClass.getMethod("getNBTJson", ItemStack.class);
- String itemJSON = (String) method.invoke(obj, new Object[] { itemStack });
- return itemJSON;
- } catch (NoSuchMethodException | IllegalArgumentException | InvocationTargetException
- | IllegalAccessException e) {
- // do somethings
- QuickShop.instance.getLogger().info("A error happend:");
- e.printStackTrace();
- return null;
- }
- }
+public abstract class ItemNMS {
+ private static final String nmsVersion;
+
+ private static Method craftItemStack_asNMSCopyMethod;
+ private static Class> nbtTagCompoundClass;
+ private static Method itemStack_saveMethod;
+
+ static {
+ String name = Bukkit.getServer().getClass().getPackage().getName();
+ nmsVersion = name.substring(name.lastIndexOf('.') + 1);
+
+ try {
+ craftItemStack_asNMSCopyMethod = Class.forName("org.bukkit.craftbukkit." + nmsVersion + ".inventory.CraftItemStack")
+ .getDeclaredMethod("asNMSCopy", ItemStack.class);
+
+ nbtTagCompoundClass = Class.forName("net.minecraft.server." + nmsVersion + ".NBTTagCompound");
+
+ itemStack_saveMethod = Class.forName("net.minecraft.server." + nmsVersion + ".ItemStack")
+ .getDeclaredMethod("save", nbtTagCompoundClass);
+
+ } catch (Throwable t) {
+ QuickShop.instance.getLogger().info("A error happend:");
+ t.printStackTrace();
+ }
+ }
-
+ public static String saveJsonfromNMS(ItemStack bStack) throws Throwable {
+ Object mcStack = craftItemStack_asNMSCopyMethod.invoke(null, bStack);
+ Object nbtTagCompound = nbtTagCompoundClass.newInstance();
+
+ itemStack_saveMethod.invoke(mcStack, nbtTagCompound);
+ return nbtTagCompound.toString();
+ }
}
diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java
index 688587dc2..789c0f51c 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/Util.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java
@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -560,21 +559,16 @@ public class Util {
}
//Use NMS
public static void sendItemholochat(ItemStack itemStack, Player player, String normalText) {
- ItemNMS nms = new ItemNMS();
- String json = nms.getItemJSON(itemStack);
- if(json == null) {
- sendItemholochatAsNormaly(itemStack, player, normalText);
- return;
- }
- try {
- TextComponent normalmessage = new TextComponent(normalText+" "+MsgUtil.getMessage("menu.preview"));
- ComponentBuilder cBuilder = new ComponentBuilder(json);
- HoverEvent he = new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create());
- normalmessage.setHoverEvent(he);
- player.spigot().sendMessage(normalmessage);
- }catch (Exception e) {
- sendItemholochatAsNormaly(itemStack, player, normalText);
- }
+ try {
+ String json = ItemNMS.saveJsonfromNMS(itemStack);
+ TextComponent normalmessage = new TextComponent(normalText+" "+MsgUtil.getMessage("menu.preview"));
+ ComponentBuilder cBuilder = new ComponentBuilder(json);
+ HoverEvent he = new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create());
+ normalmessage.setHoverEvent(he);
+ player.spigot().sendMessage(normalmessage);
+ } catch (Throwable t) {
+ sendItemholochatAsNormaly(itemStack, player, normalText);
+ }
}
// Without NMS