mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-22 01:58:54 +00:00
add ItemTip...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
c486efe8a0
commit
4a8d08e575
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
/repo
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/Soulbound
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
BIN
lib/Vault.jar
Normal file
BIN
lib/Vault.jar
Normal file
Binary file not shown.
BIN
lib/WorldEdit.jar
Normal file
BIN
lib/WorldEdit.jar
Normal file
Binary file not shown.
164
pom.xml
164
pom.xml
@ -1,56 +1,110 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>${name}</artifactId>
|
||||
<version>${version}</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<!-- <url>http://repo.bukkit.org/content/groups/public/</url> -->
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<!-- <version>1.6.4-R2.0</version> -->
|
||||
<!-- <version>1.7.9-R0.2</version> -->
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<version>0.9.8</version>
|
||||
<package>org.maxgamer.quickshop</package>
|
||||
<name>QuickShop</name>
|
||||
</properties>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>1.0</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<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>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</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>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Vault.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>5.4.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/WorldEdit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>PluginHelper</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Command;
|
||||
package org.maxgamer.QuickShop.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@ -18,15 +18,15 @@ import org.bukkit.entity.LivingEntity;
|
||||
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.ShopType;
|
||||
import org.maxgamer.quickshop.Shop.ShopChunk;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
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;
|
||||
@ -44,14 +44,14 @@ public class QS implements CommandExecutor {
|
||||
if (shop != null) {
|
||||
shop.setUnlimited(!shop.isUnlimited());
|
||||
shop.update();
|
||||
sender.sendMessage(MsgUtil.getMessage("command.toggle-unlimited", (shop.isUnlimited() ? "unlimited" : "limited")));
|
||||
sender.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "unlimited" : "limited")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ public class QS implements CommandExecutor {
|
||||
private void setOwner(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player && sender.hasPermission("quickshop.setowner")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MsgUtil.getMessage("command.no-owner-given"));
|
||||
sender.sendMessage(MsgUtil.p("command.no-owner-given"));
|
||||
return;
|
||||
}
|
||||
BlockIterator bIt = new BlockIterator((Player) sender, 10);
|
||||
@ -152,14 +152,14 @@ public class QS implements CommandExecutor {
|
||||
OfflinePlayer p = this.plugin.getServer().getOfflinePlayer(args[1]);
|
||||
shop.setOwner(p.getUniqueId());
|
||||
shop.update();
|
||||
sender.sendMessage(MsgUtil.getMessage("command.new-owner", this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
|
||||
sender.sendMessage(MsgUtil.p("command.new-owner", this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -167,14 +167,14 @@ public class QS implements CommandExecutor {
|
||||
private void refill(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player && sender.hasPermission("quickshop.refill")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MsgUtil.getMessage("command.no-amount-given"));
|
||||
sender.sendMessage(MsgUtil.p("command.no-amount-given"));
|
||||
return;
|
||||
}
|
||||
int add;
|
||||
try {
|
||||
add = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(MsgUtil.getMessage("thats-not-a-number"));
|
||||
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
|
||||
return;
|
||||
}
|
||||
BlockIterator bIt = new BlockIterator((LivingEntity) (Player) sender, 10);
|
||||
@ -183,14 +183,14 @@ public class QS implements CommandExecutor {
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop != null) {
|
||||
shop.add(shop.getItem(), add);
|
||||
sender.sendMessage(MsgUtil.getMessage("refill-success"));
|
||||
sender.sendMessage(MsgUtil.p("refill-success"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -205,18 +205,18 @@ public class QS implements CommandExecutor {
|
||||
if (shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
cs.getInventory().clear();
|
||||
sender.sendMessage(MsgUtil.getMessage("empty-success"));
|
||||
sender.sendMessage(MsgUtil.p("empty-success"));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class QS implements CommandExecutor {
|
||||
private void find(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player && sender.hasPermission("quickshop.find")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MsgUtil.getMessage("command.no-type-given"));
|
||||
sender.sendMessage(MsgUtil.p("command.no-type-given"));
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(args[1]);
|
||||
@ -255,16 +255,16 @@ public class QS implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
if (closest == null) {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-nearby-shop", args[1]));
|
||||
sender.sendMessage(MsgUtil.p("no-nearby-shop", args[1]));
|
||||
return;
|
||||
}
|
||||
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.getMessage("nearby-shop-this-way", "" + (int) Math.floor(Math.sqrt(minDistanceSquared))));
|
||||
p.sendMessage(MsgUtil.p("nearby-shop-this-way", "" + (int) Math.floor(Math.sqrt(minDistanceSquared))));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -279,14 +279,14 @@ public class QS implements CommandExecutor {
|
||||
shop.setShopType(ShopType.BUYING);
|
||||
shop.setSignText();
|
||||
shop.update();
|
||||
sender.sendMessage(MsgUtil.getMessage("command.now-buying", shop.getDataName()));
|
||||
sender.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -300,14 +300,14 @@ public class QS implements CommandExecutor {
|
||||
shop.setShopType(ShopType.SELLING);
|
||||
shop.setSignText();
|
||||
shop.update();
|
||||
sender.sendMessage(MsgUtil.getMessage("command.now-selling", shop.getDataName()));
|
||||
sender.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -316,25 +316,25 @@ public class QS implements CommandExecutor {
|
||||
if (sender instanceof Player && sender.hasPermission("quickshop.create.changeprice")) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MsgUtil.getMessage("no-price-given"));
|
||||
sender.sendMessage(MsgUtil.p("no-price-given"));
|
||||
return;
|
||||
}
|
||||
double price;
|
||||
try {
|
||||
price = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(MsgUtil.getMessage("thats-not-a-number"));
|
||||
sender.sendMessage(MsgUtil.p("thats-not-a-number"));
|
||||
return;
|
||||
}
|
||||
if (price < 0.01) {
|
||||
sender.sendMessage(MsgUtil.getMessage("price-too-cheap"));
|
||||
sender.sendMessage(MsgUtil.p("price-too-cheap"));
|
||||
return;
|
||||
}
|
||||
double fee = 0;
|
||||
if (plugin.priceChangeRequiresFee) {
|
||||
fee = plugin.getConfig().getDouble("shop.fee-for-price-change");
|
||||
if (fee > 0 && plugin.getEcon().getBalance(p.getUniqueId()) < fee) {
|
||||
sender.sendMessage(MsgUtil.getMessage("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
|
||||
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -346,22 +346,22 @@ public class QS implements CommandExecutor {
|
||||
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.getMessage("no-price-change"));
|
||||
sender.sendMessage(MsgUtil.p("no-price-change"));
|
||||
return;
|
||||
}
|
||||
if (fee > 0) {
|
||||
if (!plugin.getEcon().withdraw(p.getUniqueId(), fee)) {
|
||||
sender.sendMessage(MsgUtil.getMessage("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
|
||||
sender.sendMessage(MsgUtil.p("you-cant-afford-to-change-price", plugin.getEcon().format(fee)));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("fee-charged-for-price-change", plugin.getEcon().format(fee)));
|
||||
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.getMessage("price-is-now", plugin.getEcon().format(shop.getPrice())));
|
||||
sender.sendMessage(MsgUtil.p("price-is-now", plugin.getEcon().format(shop.getPrice())));
|
||||
// Chest shops can be double shops.
|
||||
if (shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
@ -369,12 +369,12 @@ public class QS implements CommandExecutor {
|
||||
Shop nextTo = cs.getAttachedShop();
|
||||
if (cs.isSelling()) {
|
||||
if (cs.getPrice() < nextTo.getPrice()) {
|
||||
sender.sendMessage(MsgUtil.getMessage("buying-more-than-selling"));
|
||||
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
||||
}
|
||||
} else {
|
||||
// Buying
|
||||
if (cs.getPrice() > nextTo.getPrice()) {
|
||||
sender.sendMessage(MsgUtil.getMessage("buying-more-than-selling"));
|
||||
sender.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,16 +382,16 @@ public class QS implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
sender.sendMessage(MsgUtil.p("not-looking-at-shop"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
|
||||
private void clean(CommandSender sender) {
|
||||
if (sender.hasPermission("quickshop.clean")) {
|
||||
sender.sendMessage(MsgUtil.getMessage("command.cleaning"));
|
||||
sender.sendMessage(MsgUtil.p("command.cleaning"));
|
||||
Iterator<Shop> shIt = plugin.getShopManager().getShopIterator();
|
||||
int i = 0;
|
||||
while (shIt.hasNext()) {
|
||||
@ -410,21 +410,21 @@ public class QS implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
MsgUtil.clean();
|
||||
sender.sendMessage(MsgUtil.getMessage("command.cleaned", "" + i));
|
||||
sender.sendMessage(MsgUtil.p("command.cleaned", "" + i));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
|
||||
private void reload(CommandSender sender) {
|
||||
if (sender.hasPermission("quickshop.reload")) {
|
||||
sender.sendMessage(MsgUtil.getMessage("command.reloading"));
|
||||
sender.sendMessage(MsgUtil.p("command.reloading"));
|
||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ public class QS implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.GREEN + "" + nostock + " selling shops (excluding doubles) which will be removed by /qs clean.");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
sender.sendMessage(MsgUtil.p("no-permission"));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ -551,25 +551,25 @@ public class QS implements CommandExecutor {
|
||||
}
|
||||
|
||||
public void sendHelp(CommandSender s) {
|
||||
s.sendMessage(MsgUtil.getMessage("command.description.title"));
|
||||
s.sendMessage(MsgUtil.p("command.description.title"));
|
||||
if (s.hasPermission("quickshop.unlimited"))
|
||||
s.sendMessage(ChatColor.GREEN + "/qs unlimited" + ChatColor.YELLOW + " - " + MsgUtil.getMessage("command.description.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.getMessage("command.description.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.getMessage("command.description.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.getMessage("command.description.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.getMessage("command.description.price"));
|
||||
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.getMessage("command.description.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.getMessage("command.description.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.getMessage("command.description.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.getMessage("command.description.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");
|
||||
}
|
40
src/main/java/org/maxgamer/QuickShop/Config/ItemConfig.java
Normal file
40
src/main/java/org/maxgamer/QuickShop/Config/ItemConfig.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.maxgamer.QuickShop.Config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
|
||||
public class ItemConfig {
|
||||
public static FileConfig config;
|
||||
public static File file;
|
||||
private static String CONFIG_NAME = "item.yml";
|
||||
|
||||
public static String getItemName(final ItemStack i) {
|
||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
||||
return i.getItemMeta().getDisplayName();
|
||||
}
|
||||
final String name = i.getType().name();
|
||||
final int dur = i.getDurability();
|
||||
final String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : "";
|
||||
final String iname = name + dura;
|
||||
return getItemName(iname);
|
||||
}
|
||||
|
||||
public static String getItemName(final String iname) {
|
||||
String aname = config.getString(iname);
|
||||
if (aname == null) {
|
||||
aname = iname;
|
||||
config.set(iname, iname);
|
||||
config.save();
|
||||
}
|
||||
return aname;
|
||||
}
|
||||
|
||||
public static void load(final Plugin p) {
|
||||
config = new FileConfig(p, CONFIG_NAME);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Database;
|
||||
package org.maxgamer.QuickShop.Database;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Economy;
|
||||
package org.maxgamer.QuickShop.Economy;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Economy;
|
||||
package org.maxgamer.QuickShop.Economy;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Economy;
|
||||
package org.maxgamer.QuickShop.Economy;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -14,80 +14,53 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
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.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
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.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
public BlockListener(QuickShop plugin) {
|
||||
public BlockListener(final QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for chest placement, so a doublechest shop can't be created.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
if (e.isCancelled())
|
||||
return;
|
||||
BlockState bs = e.getBlock().getState();
|
||||
if (bs instanceof DoubleChest == false)
|
||||
return;
|
||||
Block b = e.getBlock();
|
||||
Player p = e.getPlayer();
|
||||
Block chest = Util.getSecondHalf(b);
|
||||
if (chest != null && plugin.getShopManager().getShop(chest.getLocation()) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes chests when they're destroyed.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBreak(BlockBreakEvent e) {
|
||||
Block b = e.getBlock();
|
||||
Player p = e.getPlayer();
|
||||
public void onBreak(final BlockBreakEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Player p = e.getPlayer();
|
||||
// If the shop was a chest
|
||||
if (b.getState() instanceof InventoryHolder) {
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null)
|
||||
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null) {
|
||||
return;
|
||||
}
|
||||
// If they're either survival or the owner, they can break it
|
||||
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.getMessage("no-creative-break"));
|
||||
p.sendMessage(MsgUtil.p("no-creative-break"));
|
||||
return;
|
||||
}
|
||||
// Cancel their current menu... Doesnt cancel other's menu's.
|
||||
Info action = plugin.getShopManager().getActions().get(p.getName());
|
||||
final Info action = plugin.getShopManager().getActions().get(p.getName());
|
||||
if (action != null) {
|
||||
action.setAction(ShopAction.CANCELLED);
|
||||
}
|
||||
shop.delete();
|
||||
p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
|
||||
p.sendMessage(MsgUtil.p("success-removed-shop"));
|
||||
} else if (b.getType() == Material.WALL_SIGN) {
|
||||
Shop shop = getShopNextTo(b.getLocation());
|
||||
if (shop == null)
|
||||
final Shop shop = getShopNextTo(b.getLocation());
|
||||
if (shop == null) {
|
||||
return;
|
||||
// If they're in creative and not the owner, don't let them
|
||||
// (accidents happen)
|
||||
if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) {
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.getMessage("no-creative-break"));
|
||||
return;
|
||||
}
|
||||
if (e.isCancelled())
|
||||
return;
|
||||
e.setCancelled(true); // Cancel the event so that the sign does not
|
||||
// drop.. TODO: Find a better way.
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,18 +68,40 @@ public class BlockListener implements Listener {
|
||||
* Handles shops breaking through explosions
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (e.isCancelled())
|
||||
public void onExplode(final EntityExplodeEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < e.blockList().size(); i++) {
|
||||
Block b = e.blockList().get(i);
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
final Block b = e.blockList().get(i);
|
||||
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop != null) {
|
||||
shop.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for chest placement, so a doublechest shop can't be created.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlace(final BlockPlaceEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final BlockState bs = e.getBlock().getState();
|
||||
if (bs instanceof DoubleChest == false) {
|
||||
return;
|
||||
}
|
||||
final Block b = e.getBlock();
|
||||
final Player p = e.getPlayer();
|
||||
final Block chest = Util.getSecondHalf(b);
|
||||
if (chest != null && plugin.getShopManager().getShop(chest.getLocation()) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.p("no-double-chests"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shop a sign is attached to
|
||||
*
|
||||
@ -114,11 +109,12 @@ public class BlockListener implements Listener {
|
||||
* The location of the sign
|
||||
* @return The shop
|
||||
*/
|
||||
private Shop getShopNextTo(Location loc) {
|
||||
Block b = Util.getAttached(loc.getBlock());
|
||||
private Shop getShopNextTo(final Location loc) {
|
||||
final Block b = Util.getAttached(loc.getBlock());
|
||||
// Util.getAttached(b)
|
||||
if (b == null)
|
||||
if (b == null) {
|
||||
return null;
|
||||
}
|
||||
return plugin.getShopManager().getShop(b.getLocation());
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -9,8 +9,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
|
||||
public class ChunkListener implements Listener {
|
||||
private QuickShop plugin;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -11,129 +11,100 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
public class LockListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
public LockListener(QuickShop plugin) {
|
||||
public LockListener(final QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
Block b = e.getClickedBlock();
|
||||
Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return; // Didn't right click it, we dont care.
|
||||
if (!Util.canBeShop(b))
|
||||
return; // Interacted with air
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
// Make sure they're not using the non-shop half of a double chest.
|
||||
if (shop == null) {
|
||||
b = Util.getSecondHalf(b);
|
||||
if (b == null)
|
||||
return;
|
||||
shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null)
|
||||
return;
|
||||
}
|
||||
if (!shop.getOwner().equals(p.getUniqueId())) {
|
||||
if (p.hasPermission("quickshop.other.open")) {
|
||||
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hopper placement
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
Block b = e.getBlock();
|
||||
try {
|
||||
if (b.getType() != Material.HOPPER)
|
||||
return;
|
||||
} catch (NoSuchFieldError er) {
|
||||
return; // Your server doesn't have hoppers
|
||||
}
|
||||
Block c = e.getBlockAgainst();
|
||||
if (Util.canBeShop(c) == false)
|
||||
return;
|
||||
Player p = e.getPlayer();
|
||||
Shop shop = plugin.getShopManager().getShop(c.getLocation());
|
||||
if (shop == null) {
|
||||
c = Util.getSecondHalf(c);
|
||||
if (c == null)
|
||||
return; // You didn't place a hopper on a shop. Meh.
|
||||
else
|
||||
shop = plugin.getShopManager().getShop(c.getLocation());
|
||||
if (shop == null)
|
||||
return;
|
||||
}
|
||||
if (p.getUniqueId().equals(shop.getOwner()) == false) {
|
||||
if (p.hasPermission("quickshop.other.open")) {
|
||||
p.sendMessage(MsgUtil.getMessage("bypassing-lock"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(MsgUtil.getMessage("that-is-locked"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes chests when they're destroyed.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBreak(BlockBreakEvent e) {
|
||||
public void onBreak(final BlockBreakEvent e) {
|
||||
Block b = e.getBlock();
|
||||
Player p = e.getPlayer();
|
||||
final Player p = e.getPlayer();
|
||||
// If the chest was a chest
|
||||
if (Util.canBeShop(b)) {
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null)
|
||||
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null) {
|
||||
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")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
p.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
} else if (b.getType() == Material.WALL_SIGN) {
|
||||
b = Util.getAttached(b);
|
||||
if (b == null)
|
||||
if (b == null) {
|
||||
return;
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null)
|
||||
}
|
||||
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")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(MsgUtil.getMessage("no-permission"));
|
||||
p.sendMessage(MsgUtil.p("no-permission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onClick(final PlayerInteractEvent e) {
|
||||
Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return; // Didn't right click it, we dont care.
|
||||
}
|
||||
if (!Util.canBeShop(b)) {
|
||||
return; // Interacted with air
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
// Make sure they're not using the non-shop half of a double chest.
|
||||
if (shop == null) {
|
||||
b = Util.getSecondHalf(b);
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!shop.getOwner().equals(p.getUniqueId())) {
|
||||
if (p.hasPermission("quickshop.other.open")) {
|
||||
p.sendMessage(MsgUtil.p("bypassing-lock"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(MsgUtil.p("that-is-locked"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles shops breaking through explosions
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (e.isCancelled())
|
||||
public void onExplode(final EntityExplodeEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < e.blockList().size(); i++) {
|
||||
Block b = e.blockList().get(i);
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
final Block b = e.blockList().get(i);
|
||||
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
if (shop != null) {
|
||||
// ToDo: Shouldn't I be decrementing 1 here? Concurrency and
|
||||
// all..
|
||||
@ -141,4 +112,45 @@ public class LockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hopper placement
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlace(final BlockPlaceEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
try {
|
||||
if (b.getType() != Material.HOPPER) {
|
||||
return;
|
||||
}
|
||||
} catch (final NoSuchFieldError er) {
|
||||
return; // Your server doesn't have hoppers
|
||||
}
|
||||
Block c = e.getBlockAgainst();
|
||||
if (Util.canBeShop(c) == false) {
|
||||
return;
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
Shop shop = plugin.getShopManager().getShop(c.getLocation());
|
||||
if (shop == null) {
|
||||
c = Util.getSecondHalf(c);
|
||||
if (c == null) {
|
||||
return; // You didn't place a hopper on a shop. Meh.
|
||||
} else {
|
||||
shop = plugin.getShopManager().getShop(c.getLocation());
|
||||
}
|
||||
if (shop == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (p.getUniqueId().equals(shop.getOwner()) == false) {
|
||||
if (p.hasPermission("quickshop.other.open")) {
|
||||
p.sendMessage(MsgUtil.p("bypassing-lock"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(MsgUtil.p("that-is-locked"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@ -22,17 +22,17 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
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.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
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.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
private final QuickShop plugin;
|
||||
|
||||
public PlayerListener(QuickShop plugin) {
|
||||
public PlayerListener(final QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -53,24 +53,26 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
public void onClick(final PlayerInteractEvent e) {
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||
return;
|
||||
Block b = e.getClickedBlock();
|
||||
if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN)
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN) {
|
||||
return;
|
||||
Player p = e.getPlayer();
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
if (plugin.sneak && !p.isSneaking()) {
|
||||
// Sneak only
|
||||
return;
|
||||
}
|
||||
Location loc = b.getLocation();
|
||||
ItemStack item = e.getItem();
|
||||
final Location loc = b.getLocation();
|
||||
final ItemStack item = e.getItem();
|
||||
// Get the shop
|
||||
Shop shop = plugin.getShopManager().getShop(loc);
|
||||
// If that wasn't a shop, search nearby shops
|
||||
if (shop == null && b.getType() == Material.WALL_SIGN) {
|
||||
Block attached = Util.getAttached(b);
|
||||
final Block attached = Util.getAttached(b);
|
||||
if (attached != null) {
|
||||
shop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
}
|
||||
@ -81,19 +83,20 @@ public class PlayerListener implements Listener {
|
||||
// Text menu
|
||||
MsgUtil.sendShopInfo(p, shop);
|
||||
if (shop.isSelling()) {
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-buy"));
|
||||
p.sendMessage(MsgUtil.p("how-many-buy"));
|
||||
} else {
|
||||
int items = Util.countItems(p.getInventory(), shop.getItem());
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-sell", "" + items));
|
||||
final int items = Util.countItems(p.getInventory(), shop.getItem());
|
||||
p.sendMessage(MsgUtil.p("how-many-sell", "" + items));
|
||||
}
|
||||
// Add the new action
|
||||
HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
|
||||
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
|
||||
final HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
|
||||
final Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
|
||||
actions.put(p.getUniqueId(), info);
|
||||
return;
|
||||
}
|
||||
// Handles creating shops
|
||||
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR && p.hasPermission("quickshop.create.sell") && Util.canBeShop(b) && p.getGameMode() != GameMode.CREATIVE && (plugin.sneakCreate == false || p.isSneaking())) {
|
||||
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR && p.hasPermission("quickshop.create.sell") && Util.canBeShop(b)
|
||||
&& p.getGameMode() != GameMode.CREATIVE && (plugin.sneakCreate == false || p.isSneaking())) {
|
||||
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
|
||||
// As of the new checking system, most plugins will tell the
|
||||
// player why they can't create a shop there.
|
||||
@ -101,62 +104,33 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
|
||||
p.sendMessage(MsgUtil.p("no-double-chests"));
|
||||
return;
|
||||
}
|
||||
if (Util.isBlacklisted(item.getType()) && !p.hasPermission("quickshop.bypass." + item.getTypeId())) {
|
||||
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
|
||||
p.sendMessage(MsgUtil.p("blacklisted-item"));
|
||||
return;
|
||||
}
|
||||
// Finds out where the sign should be placed for the shop
|
||||
Block last = null;
|
||||
Location from = p.getLocation().clone();
|
||||
final Location from = p.getLocation().clone();
|
||||
from.setY(b.getY());
|
||||
from.setPitch(0);
|
||||
BlockIterator bIt = new BlockIterator(from, 0, 7);
|
||||
final BlockIterator bIt = new BlockIterator(from, 0, 7);
|
||||
while (bIt.hasNext()) {
|
||||
Block n = bIt.next();
|
||||
if (n.equals(b))
|
||||
final Block n = bIt.next();
|
||||
if (n.equals(b)) {
|
||||
break;
|
||||
}
|
||||
last = n;
|
||||
}
|
||||
// Send creation menu.
|
||||
Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
final Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
|
||||
p.sendMessage(MsgUtil.getMessage("how-much-to-trade-for", Util.getName(info.getItem())));
|
||||
p.sendMessage(MsgUtil.p("how-much-to-trade-for", Util.getName(info.getItem())));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
/**
|
||||
* Waits for a player to move too far from a shop, then cancels the menu.
|
||||
*/
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
if (e.isCancelled())
|
||||
return;
|
||||
Info info = plugin.getShopManager().getActions().get(e.getPlayer().getUniqueId());
|
||||
if (info != null) {
|
||||
Player p = e.getPlayer();
|
||||
Location loc1 = info.getLocation();
|
||||
Location loc2 = p.getLocation();
|
||||
if (loc1.getWorld() != loc2.getWorld() || loc1.distanceSquared(loc2) > 25) {
|
||||
if (info.getAction() == ShopAction.CREATE) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
|
||||
} else if (info.getAction() == ShopAction.BUY) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled"));
|
||||
}
|
||||
plugin.getShopManager().getActions().remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeleport(PlayerTeleportEvent e) {
|
||||
PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
|
||||
onMove(me);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
// Notify the player any messages they were sent
|
||||
@ -168,22 +142,53 @@ public class PlayerListener implements Listener {
|
||||
}, 60);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
// Remove them from the menu
|
||||
plugin.getShopManager().getActions().remove(e.getPlayer().getUniqueId());
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
/**
|
||||
* Waits for a player to move too far from a shop, then cancels the menu.
|
||||
*/
|
||||
public void onMove(final PlayerMoveEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final Info info = plugin.getShopManager().getActions().get(e.getPlayer().getUniqueId());
|
||||
if (info != null) {
|
||||
final Player p = e.getPlayer();
|
||||
final Location loc1 = info.getLocation();
|
||||
final Location loc2 = p.getLocation();
|
||||
if (loc1.getWorld() != loc2.getWorld() || loc1.distanceSquared(loc2) > 25) {
|
||||
if (info.getAction() == ShopAction.CREATE) {
|
||||
p.sendMessage(MsgUtil.p("shop-creation-cancelled"));
|
||||
} else if (info.getAction() == ShopAction.BUY) {
|
||||
p.sendMessage(MsgUtil.p("shop-purchase-cancelled"));
|
||||
}
|
||||
plugin.getShopManager().getActions().remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickup(PlayerPickupItemEvent e) {
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
public void onPlayerPickup(final PlayerPickupItemEvent e) {
|
||||
final ItemStack stack = e.getItem().getItemStack();
|
||||
try {
|
||||
if (stack.getItemMeta().getDisplayName().startsWith(ChatColor.RED + "QuickShop ")) {
|
||||
e.setCancelled(true);
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} catch (final NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that
|
||||
// case.
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent e) {
|
||||
// Remove them from the menu
|
||||
plugin.getShopManager().getActions().remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeleport(final PlayerTeleportEvent e) {
|
||||
final PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo());
|
||||
onMove(me);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Shop.ShopChunk;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
QuickShop plugin;
|
||||
|
||||
public WorldListener(final QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(final WorldLoadEvent e) {
|
||||
/*
|
||||
* *************************************
|
||||
* This listener fixes any broken world references. Such as hashmap
|
||||
* lookups will fail, because the World reference is different, but the
|
||||
* world value is the same.
|
||||
* *************************************
|
||||
*/
|
||||
final World world = e.getWorld();
|
||||
// New world data
|
||||
final HashMap<ShopChunk, HashMap<Location, Shop>> inWorld = new HashMap<ShopChunk, HashMap<Location, Shop>>(1);
|
||||
// Old world data
|
||||
final HashMap<ShopChunk, HashMap<Location, Shop>> oldInWorld = plugin.getShopManager().getShops(world.getName());
|
||||
// Nothing in the old world, therefore we don't care. No locations to
|
||||
// update.
|
||||
if (oldInWorld == null) {
|
||||
return;
|
||||
}
|
||||
for (final Entry<ShopChunk, HashMap<Location, Shop>> oldInChunk : oldInWorld.entrySet()) {
|
||||
final HashMap<Location, Shop> inChunk = new HashMap<Location, Shop>(1);
|
||||
// Put the new chunk were the old chunk was
|
||||
inWorld.put(oldInChunk.getKey(), inChunk);
|
||||
for (final Entry<Location, Shop> entry : oldInChunk.getValue().entrySet()) {
|
||||
final Shop shop = entry.getValue();
|
||||
shop.getLocation().setWorld(world);
|
||||
inChunk.put(shop.getLocation(), shop);
|
||||
}
|
||||
}
|
||||
// Done - Now we can store the new world dataz!
|
||||
plugin.getShopManager().getShops().put(world.getName(), inWorld);
|
||||
// This is a workaround, because I don't get parsed chunk events when a
|
||||
// world first loads....
|
||||
// So manually tell all of these shops they're loaded.
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk);
|
||||
if (inChunk == null) {
|
||||
continue;
|
||||
}
|
||||
for (final Shop shop : inChunk.values()) {
|
||||
shop.onLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(final WorldUnloadEvent e) {
|
||||
// This is a workaround, because I don't get parsed chunk events when a
|
||||
// world unloads, I think...
|
||||
// So manually tell all of these shops they're unloaded.
|
||||
for (final Chunk chunk : e.getWorld().getLoadedChunks()) {
|
||||
final HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk);
|
||||
if (inChunk == null) {
|
||||
continue;
|
||||
}
|
||||
for (final Shop shop : inChunk.values()) {
|
||||
shop.onUnload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package org.maxgamer.quickshop;
|
||||
package org.maxgamer.QuickShop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -23,37 +24,41 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.maxgamer.quickshop.Command.QS;
|
||||
import org.maxgamer.quickshop.Database.Database;
|
||||
import org.maxgamer.quickshop.Database.Database.ConnectionException;
|
||||
import org.maxgamer.quickshop.Database.DatabaseCore;
|
||||
import org.maxgamer.quickshop.Database.DatabaseHelper;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.Database.SQLiteCore;
|
||||
import org.maxgamer.quickshop.Economy.Economy;
|
||||
import org.maxgamer.quickshop.Economy.EconomyCore;
|
||||
import org.maxgamer.quickshop.Economy.Economy_Vault;
|
||||
import org.maxgamer.quickshop.Listeners.BlockListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChatListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChunkListener;
|
||||
import org.maxgamer.quickshop.Listeners.HeroChatListener;
|
||||
import org.maxgamer.quickshop.Listeners.LockListener;
|
||||
import org.maxgamer.quickshop.Listeners.PlayerListener;
|
||||
import org.maxgamer.quickshop.Listeners.WorldListener;
|
||||
import org.maxgamer.quickshop.Shop.ContainerShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopManager;
|
||||
import org.maxgamer.quickshop.Shop.ShopType;
|
||||
import org.maxgamer.quickshop.Util.Converter;
|
||||
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.maxgamer.QuickShop.Command.QS;
|
||||
import org.maxgamer.QuickShop.Database.Database;
|
||||
import org.maxgamer.QuickShop.Database.Database.ConnectionException;
|
||||
import org.maxgamer.QuickShop.Database.DatabaseCore;
|
||||
import org.maxgamer.QuickShop.Database.DatabaseHelper;
|
||||
import org.maxgamer.QuickShop.Database.MySQLCore;
|
||||
import org.maxgamer.QuickShop.Database.SQLiteCore;
|
||||
import org.maxgamer.QuickShop.Economy.Economy;
|
||||
import org.maxgamer.QuickShop.Economy.EconomyCore;
|
||||
import org.maxgamer.QuickShop.Economy.Economy_Vault;
|
||||
import org.maxgamer.QuickShop.Listeners.BlockListener;
|
||||
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.WorldListener;
|
||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Shop.ShopManager;
|
||||
import org.maxgamer.QuickShop.Shop.ShopType;
|
||||
import org.maxgamer.QuickShop.Util.Converter;
|
||||
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.utils.VersionChecker;
|
||||
|
||||
public class QuickShop extends JavaPlugin {
|
||||
/** The active instance of QuickShop */
|
||||
public static QuickShop instance;
|
||||
// private Metrics metrics;
|
||||
/** Whether debug info should be shown in the console */
|
||||
public static boolean debug = true;
|
||||
/** The economy we hook into for transactions */
|
||||
private Economy economy;
|
||||
/** The Shop Manager used to store shops */
|
||||
@ -67,12 +72,12 @@ public class QuickShop extends JavaPlugin {
|
||||
private Database database;
|
||||
// Listeners - We decide which one to use at runtime
|
||||
private ChatListener chatListener;
|
||||
private HeroChatListener heroChatListener;
|
||||
// private HeroChatListener heroChatListener;
|
||||
// Listeners (These don't)
|
||||
private BlockListener blockListener = new BlockListener(this);
|
||||
private PlayerListener playerListener = new PlayerListener(this);
|
||||
private ChunkListener chunkListener = new ChunkListener(this);
|
||||
private WorldListener worldListener = new WorldListener(this);
|
||||
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);
|
||||
private BukkitTask itemWatcherTask;
|
||||
private LogWatcher logWatcher;
|
||||
/** Whether players are required to sneak to create/buy from a shop */
|
||||
@ -90,24 +95,122 @@ public class QuickShop extends JavaPlugin {
|
||||
public boolean priceChangeRequiresFee = false;
|
||||
/** Whether or not to limit players shop amounts */
|
||||
public boolean limit = false;
|
||||
private HashMap<String, Integer> limits = new HashMap<String, Integer>();
|
||||
private final HashMap<String, Integer> limits = new HashMap<String, Integer>();
|
||||
/** Use SpoutPlugin to get item / block names */
|
||||
public boolean useSpout = false;
|
||||
// private Metrics metrics;
|
||||
/** Whether debug info should be shown in the console */
|
||||
public static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Prints debug information if QuickShop is configured to do so.
|
||||
*
|
||||
* @param s
|
||||
* The string to print.
|
||||
*/
|
||||
public void debug(final String s) {
|
||||
if (!debug) {
|
||||
return;
|
||||
}
|
||||
this.getLogger().info(ChatColor.YELLOW + "[Debug] " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the database handler for queries etc.
|
||||
*/
|
||||
public Database getDB() {
|
||||
return this.database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the economy for moving currency around
|
||||
*
|
||||
* @return The economy for moving currency around
|
||||
*/
|
||||
public EconomyCore getEcon() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
/** The plugin metrics from Hidendra */
|
||||
// public Metrics getMetrics(){ return metrics; }
|
||||
public int getShopLimit(Player p) {
|
||||
public int getShopLimit(final Player p) {
|
||||
int max = getConfig().getInt("limits.default");
|
||||
for (Entry<String, Integer> entry : limits.entrySet()) {
|
||||
if (entry.getValue() > max && p.hasPermission(entry.getKey()))
|
||||
for (final Entry<String, Integer> entry : limits.entrySet()) {
|
||||
if (entry.getValue() > max && p.hasPermission(entry.getKey())) {
|
||||
max = entry.getValue();
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ShopManager. This is used for fetching, adding and removing
|
||||
* shops.
|
||||
*
|
||||
* @return The ShopManager.
|
||||
*/
|
||||
public ShopManager getShopManager() {
|
||||
return this.shopManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the economy and its core. If this fails, it will try to use
|
||||
* vault. If that fails, it will return false.
|
||||
*
|
||||
* @return true if successful, false if the core is invalid or is not found,
|
||||
* and vault cannot be used.
|
||||
*/
|
||||
public boolean loadEcon() {
|
||||
final EconomyCore core = new Economy_Vault();
|
||||
if (!core.isValid()) {
|
||||
// getLogger().severe("Economy is not valid!");
|
||||
getLogger().severe("QuickShop could not hook an economy!");
|
||||
getLogger().severe("QuickShop CANNOT start!");
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
// if(econ.equals("Vault"))
|
||||
// getLogger().severe("(Does Vault have an Economy to hook into?!)");
|
||||
return false;
|
||||
} else {
|
||||
this.economy = new Economy(core);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the given string to qs.log, if QuickShop is configured to do so.
|
||||
*
|
||||
* @param s
|
||||
* The string to log. It will be prefixed with the date and time.
|
||||
*/
|
||||
public void log(final String s) {
|
||||
if (this.logWatcher == null) {
|
||||
return;
|
||||
}
|
||||
final Date date = Calendar.getInstance().getTime();
|
||||
final Timestamp time = new Timestamp(date.getTime());
|
||||
this.logWatcher.add("[" + time.toString() + "] " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (itemWatcherTask != null) {
|
||||
itemWatcherTask.cancel();
|
||||
}
|
||||
if (logWatcher != null) {
|
||||
logWatcher.task.cancel();
|
||||
logWatcher.close(); // Closes the file
|
||||
}
|
||||
/* Remove all display items, and any dupes we can find */
|
||||
shopManager.clear();
|
||||
/* Empty the buffer */
|
||||
database.close();
|
||||
try {
|
||||
this.database.getConnection().close();
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.warnings.clear();
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
saveDefaultConfig(); // Creates the config folder and copies config.yml
|
||||
@ -115,10 +218,12 @@ public class QuickShop extends JavaPlugin {
|
||||
reloadConfig(); // Reloads messages.yml too, aswell as config.yml and
|
||||
// others.
|
||||
getConfig().options().copyDefaults(true); // Load defaults.
|
||||
if (getConfig().contains("debug"))
|
||||
if (getConfig().contains("debug")) {
|
||||
debug = true;
|
||||
if (loadEcon() == false)
|
||||
}
|
||||
if (loadEcon() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Util
|
||||
Util.initialize();
|
||||
@ -128,7 +233,7 @@ public class QuickShop extends JavaPlugin {
|
||||
if (this.display) {
|
||||
// Display item handler thread
|
||||
getLogger().info("Starting item scheduler");
|
||||
ItemWatcher itemWatcher = new ItemWatcher(this);
|
||||
final ItemWatcher itemWatcher = new ItemWatcher(this);
|
||||
itemWatcherTask = Bukkit.getScheduler().runTaskTimer(this, itemWatcher, 600, 600);
|
||||
}
|
||||
if (this.getConfig().getBoolean("log-actions")) {
|
||||
@ -137,7 +242,7 @@ public class QuickShop extends JavaPlugin {
|
||||
logWatcher.task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, this.logWatcher, 150, 150);
|
||||
}
|
||||
if (getConfig().getBoolean("shop.lock")) {
|
||||
LockListener ll = new LockListener(this);
|
||||
final LockListener ll = new LockListener(this);
|
||||
getServer().getPluginManager().registerEvents(ll, this);
|
||||
}
|
||||
ConfigurationSection limitCfg = this.getConfig().getConfigurationSection("limits");
|
||||
@ -146,21 +251,21 @@ public class QuickShop extends JavaPlugin {
|
||||
this.limit = limitCfg.getBoolean("use", false);
|
||||
getLogger().info("Limits.use: " + limit);
|
||||
limitCfg = limitCfg.getConfigurationSection("ranks");
|
||||
for (String key : limitCfg.getKeys(true)) {
|
||||
for (final String key : limitCfg.getKeys(true)) {
|
||||
limits.put(key, limitCfg.getInt(key));
|
||||
}
|
||||
getLogger().info(limits.toString());
|
||||
}
|
||||
try {
|
||||
ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
|
||||
final ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
|
||||
DatabaseCore dbCore;
|
||||
if (dbCfg.getBoolean("mysql")) {
|
||||
// MySQL database - Required database be created first.
|
||||
String user = dbCfg.getString("user");
|
||||
String pass = dbCfg.getString("password");
|
||||
String host = dbCfg.getString("host");
|
||||
String port = dbCfg.getString("port");
|
||||
String database = dbCfg.getString("database");
|
||||
final String user = dbCfg.getString("user");
|
||||
final String pass = dbCfg.getString("password");
|
||||
final String host = dbCfg.getString("host");
|
||||
final String port = dbCfg.getString("port");
|
||||
final String database = dbCfg.getString("database");
|
||||
dbCore = new MySQLCore(host, user, pass, database, port);
|
||||
} else {
|
||||
// SQLite database - Doing this handles file creation
|
||||
@ -169,12 +274,12 @@ public class QuickShop extends JavaPlugin {
|
||||
this.database = new Database(dbCore);
|
||||
// Make the database up to date
|
||||
DatabaseHelper.setup(getDB());
|
||||
} catch (ConnectionException e) {
|
||||
} catch (final ConnectionException e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Error connecting to database. Aborting plugin load.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} catch (SQLException e) {
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Error setting up database. Aborting plugin load.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
@ -185,7 +290,7 @@ public class QuickShop extends JavaPlugin {
|
||||
Connection con;
|
||||
try {
|
||||
getLogger().info("Loading shops from database...");
|
||||
int res = Converter.convert();
|
||||
final int res = Converter.convert();
|
||||
if (res < 0) {
|
||||
System.out.println("Could not convert shops. Exitting.");
|
||||
return;
|
||||
@ -194,8 +299,8 @@ public class QuickShop extends JavaPlugin {
|
||||
System.out.println("Conversion success. Continuing...");
|
||||
}
|
||||
con = database.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM shops");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
final PreparedStatement ps = con.prepareStatement("SELECT * FROM shops");
|
||||
final ResultSet rs = ps.executeQuery();
|
||||
int errors = 0;
|
||||
while (rs.next()) {
|
||||
int x = 0;
|
||||
@ -207,15 +312,15 @@ public class QuickShop extends JavaPlugin {
|
||||
y = rs.getInt("y");
|
||||
z = rs.getInt("z");
|
||||
worldName = rs.getString("world");
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
ItemStack item = Util.deserialize(rs.getString("itemConfig"));
|
||||
String owner = rs.getString("owner");
|
||||
double price = rs.getDouble("price");
|
||||
Location loc = new Location(world, x, y, z);
|
||||
final World world = Bukkit.getWorld(worldName);
|
||||
final ItemStack item = Util.deserialize(rs.getString("itemConfig"));
|
||||
final String owner = rs.getString("owner");
|
||||
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("Shop is not an InventoryHolder in " + rs.getString("world") + " at: " + x + ", " + y + ", " + z + ". Deleting.");
|
||||
PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
|
||||
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);
|
||||
@ -223,8 +328,8 @@ public class QuickShop extends JavaPlugin {
|
||||
delps.execute();
|
||||
continue;
|
||||
}
|
||||
int type = rs.getInt("type");
|
||||
Shop shop = new ContainerShop(loc, price, item, UUID.fromString(owner));
|
||||
final int type = rs.getInt("type");
|
||||
final Shop shop = new ContainerShop(loc, price, item, UUID.fromString(owner));
|
||||
shop.setUnlimited(rs.getBoolean("unlimited"));
|
||||
shop.setShopType(ShopType.fromID(type));
|
||||
shopManager.loadShop(rs.getString("world"), shop);
|
||||
@ -232,13 +337,13 @@ public class QuickShop extends JavaPlugin {
|
||||
shop.onLoad();
|
||||
}
|
||||
count++;
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
errors++;
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Error loading a shop! Coords: " + worldName + " (" + x + ", " + y + ", " + z + ")...");
|
||||
if (errors < 3) {
|
||||
getLogger().info("Deleting the shop...");
|
||||
PreparedStatement delps = getDB().getConnection().prepareStatement("DELETE FROM shops WHERE x = ? AND y = ? and z = ? and world = ?");
|
||||
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);
|
||||
@ -250,7 +355,7 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Could not load shops.");
|
||||
}
|
||||
@ -268,30 +373,24 @@ public class QuickShop extends JavaPlugin {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(worldListener, this);
|
||||
if (this.getConfig().getBoolean("force-bukkit-chat-handler", false) && Bukkit.getPluginManager().getPlugin("Herochat") != null) {
|
||||
this.getLogger().info("Found Herochat... Hooking!");
|
||||
this.heroChatListener = new HeroChatListener(this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(heroChatListener, this);
|
||||
// this.heroChatListener = new HeroChatListener(this);
|
||||
// Bukkit.getServer().getPluginManager().registerEvents(heroChatListener, this);
|
||||
} else {
|
||||
this.chatListener = new ChatListener(this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
|
||||
}
|
||||
// Command handlers
|
||||
QS commandExecutor = new QS(this);
|
||||
final QS commandExecutor = new QS(this);
|
||||
getCommand("qs").setExecutor(commandExecutor);
|
||||
if (getConfig().getInt("shop.find-distance") > 100) {
|
||||
getLogger().severe("Shop.find-distance is too high! Pick a number under 100!");
|
||||
}
|
||||
/**
|
||||
* If the server has Spout we can get the names of custom items. Latest
|
||||
* SpoutPlugin http://get.spout.org/1412/SpoutPlugin.jar
|
||||
* http://build.spout.org/view/Legacy/job/SpoutPlugin/1412/
|
||||
*/
|
||||
// if (Bukkit.getPluginManager().getPlugin("Spout") != null) {
|
||||
// this.getLogger().info("Found Spout...");
|
||||
// this.useSpout = true;
|
||||
// } else {
|
||||
// this.useSpout = false;
|
||||
// }
|
||||
getLogger().info("QuickShop loaded!");
|
||||
new VersionChecker(this);
|
||||
try {
|
||||
final Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (final IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads QuickShops config */
|
||||
@ -306,100 +405,4 @@ public class QuickShop extends JavaPlugin {
|
||||
this.priceChangeRequiresFee = this.getConfig().getBoolean("shop.price-change-requires-fee");
|
||||
MsgUtil.loadCfgMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the economy and its core. If this fails, it will try to use
|
||||
* vault. If that fails, it will return false.
|
||||
*
|
||||
* @return true if successful, false if the core is invalid or is not found,
|
||||
* and vault cannot be used.
|
||||
*/
|
||||
public boolean loadEcon() {
|
||||
EconomyCore core = new Economy_Vault();
|
||||
if (core == null || !core.isValid()) {
|
||||
// getLogger().severe("Economy is not valid!");
|
||||
getLogger().severe("QuickShop could not hook an economy!");
|
||||
getLogger().severe("QuickShop CANNOT start!");
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
// if(econ.equals("Vault"))
|
||||
// getLogger().severe("(Does Vault have an Economy to hook into?!)");
|
||||
return false;
|
||||
} else {
|
||||
this.economy = new Economy(core);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
if (itemWatcherTask != null) {
|
||||
itemWatcherTask.cancel();
|
||||
}
|
||||
if (logWatcher != null) {
|
||||
logWatcher.task.cancel();
|
||||
logWatcher.close(); // Closes the file
|
||||
}
|
||||
/* Remove all display items, and any dupes we can find */
|
||||
shopManager.clear();
|
||||
/* Empty the buffer */
|
||||
database.close();
|
||||
try {
|
||||
this.database.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.warnings.clear();
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the economy for moving currency around
|
||||
*
|
||||
* @return The economy for moving currency around
|
||||
*/
|
||||
public EconomyCore getEcon() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the given string to qs.log, if QuickShop is configured to do so.
|
||||
*
|
||||
* @param s
|
||||
* The string to log. It will be prefixed with the date and time.
|
||||
*/
|
||||
public void log(String s) {
|
||||
if (this.logWatcher == null)
|
||||
return;
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
Timestamp time = new Timestamp(date.getTime());
|
||||
this.logWatcher.add("[" + time.toString() + "] " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the database handler for queries etc.
|
||||
*/
|
||||
public Database getDB() {
|
||||
return this.database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints debug information if QuickShop is configured to do so.
|
||||
*
|
||||
* @param s
|
||||
* The string to print.
|
||||
*/
|
||||
public void debug(String s) {
|
||||
if (!debug)
|
||||
return;
|
||||
this.getLogger().info(ChatColor.YELLOW + "[Debug] " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ShopManager. This is used for fetching, adding and removing
|
||||
* shops.
|
||||
*
|
||||
* @return The ShopManager.
|
||||
*/
|
||||
public ShopManager getShopManager() {
|
||||
return this.shopManager;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -6,8 +6,8 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.NMS;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Util.NMS;
|
||||
|
||||
/**
|
||||
* @author Netherfoam A display item, that spawns a block above the chest and
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
public enum ShopAction {
|
||||
BUY(), CREATE(), CANCELLED();
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
public class ShopChunk {
|
||||
private String world;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -19,10 +19,10 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Database.Database;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Database.Database;
|
||||
import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
public class ShopManager {
|
||||
private QuickShop plugin;
|
||||
@ -263,11 +263,11 @@ public class ShopManager {
|
||||
if (info == null)
|
||||
return; // multithreaded means this can happen
|
||||
if (info.getLocation().getWorld() != p.getLocation().getWorld()) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
|
||||
p.sendMessage(MsgUtil.p("shop-creation-cancelled"));
|
||||
return;
|
||||
}
|
||||
if (info.getLocation().distanceSquared(p.getLocation()) > 25) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
|
||||
p.sendMessage(MsgUtil.p("shop-creation-cancelled"));
|
||||
return;
|
||||
}
|
||||
/* Creation handling */
|
||||
@ -275,15 +275,15 @@ public class ShopManager {
|
||||
try {
|
||||
// Checking the shop can be created
|
||||
if (plugin.getShopManager().getShop(info.getLocation()) != null) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-already-owned"));
|
||||
p.sendMessage(MsgUtil.p("shop-already-owned"));
|
||||
return;
|
||||
}
|
||||
if (Util.getSecondHalf(info.getLocation().getBlock()) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
|
||||
p.sendMessage(MsgUtil.p("no-double-chests"));
|
||||
return;
|
||||
}
|
||||
if (Util.canBeShop(info.getLocation().getBlock()) == false) {
|
||||
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
|
||||
p.sendMessage(MsgUtil.p("chest-was-removed"));
|
||||
return;
|
||||
}
|
||||
// Price per item
|
||||
@ -294,14 +294,14 @@ public class ShopManager {
|
||||
price = Double.parseDouble(message);
|
||||
}
|
||||
if (price < 0.01) {
|
||||
p.sendMessage(MsgUtil.getMessage("price-too-cheap"));
|
||||
p.sendMessage(MsgUtil.p("price-too-cheap"));
|
||||
return;
|
||||
}
|
||||
double tax = plugin.getConfig().getDouble("shop.cost");
|
||||
// Tax refers to the cost to create a shop. Not actual
|
||||
// tax, that would be silly
|
||||
if (tax != 0 && plugin.getEcon().getBalance(p.getName()) < tax) {
|
||||
p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(tax)));
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-a-new-shop", format(tax)));
|
||||
return;
|
||||
}
|
||||
// Create the sample shop.
|
||||
@ -318,7 +318,7 @@ public class ShopManager {
|
||||
// money back.
|
||||
if (tax != 0) {
|
||||
if (!plugin.getEcon().withdraw(p.getName(), tax)) {
|
||||
p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(tax)));
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-a-new-shop", format(tax)));
|
||||
shop.onUnload();
|
||||
return;
|
||||
}
|
||||
@ -332,7 +332,7 @@ public class ShopManager {
|
||||
// Warn them if they haven't been warned since
|
||||
// reboot
|
||||
if (!plugin.warnings.contains(p.getName())) {
|
||||
p.sendMessage(MsgUtil.getMessage("shops-arent-locked"));
|
||||
p.sendMessage(MsgUtil.p("shops-arent-locked"));
|
||||
plugin.warnings.add(p.getName());
|
||||
}
|
||||
}
|
||||
@ -382,14 +382,14 @@ public class ShopManager {
|
||||
if (nextTo.getPrice() > shop.getPrice()) {
|
||||
// The one next to it must always be a
|
||||
// buying shop.
|
||||
p.sendMessage(MsgUtil.getMessage("buying-more-than-selling"));
|
||||
p.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* They didn't enter a number. */
|
||||
catch (NumberFormatException ex) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-creation-cancelled"));
|
||||
p.sendMessage(MsgUtil.p("shop-creation-cancelled"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -399,24 +399,24 @@ public class ShopManager {
|
||||
try {
|
||||
amount = Integer.parseInt(message);
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled"));
|
||||
p.sendMessage(MsgUtil.p("shop-purchase-cancelled"));
|
||||
return;
|
||||
}
|
||||
// Get the shop they interacted with
|
||||
Shop shop = plugin.getShopManager().getShop(info.getLocation());
|
||||
// It's not valid anymore
|
||||
if (shop == null || Util.canBeShop(info.getLocation().getBlock()) == false) {
|
||||
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
|
||||
p.sendMessage(MsgUtil.p("chest-was-removed"));
|
||||
return;
|
||||
}
|
||||
if (info.hasChanged(shop)) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-has-changed"));
|
||||
p.sendMessage(MsgUtil.p("shop-has-changed"));
|
||||
return;
|
||||
}
|
||||
if (shop.isSelling()) {
|
||||
int stock = shop.getRemainingStock();
|
||||
if (stock < amount) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-stock-too-low", "" + shop.getRemainingStock(), shop.getDataName()));
|
||||
p.sendMessage(MsgUtil.p("shop-stock-too-low", "" + shop.getRemainingStock(), shop.getDataName()));
|
||||
return;
|
||||
}
|
||||
if (amount == 0) {
|
||||
@ -425,12 +425,12 @@ public class ShopManager {
|
||||
return;
|
||||
} else if (amount < 0) {
|
||||
// & Dumber
|
||||
p.sendMessage(MsgUtil.getMessage("negative-amount"));
|
||||
p.sendMessage(MsgUtil.p("negative-amount"));
|
||||
return;
|
||||
}
|
||||
int pSpace = Util.countSpace(p.getInventory(), shop.getItem());
|
||||
if (amount > pSpace) {
|
||||
p.sendMessage(MsgUtil.getMessage("not-enough-space", "" + pSpace));
|
||||
p.sendMessage(MsgUtil.p("not-enough-space", "" + pSpace));
|
||||
return;
|
||||
}
|
||||
ShopPurchaseEvent e = new ShopPurchaseEvent(shop, p, amount);
|
||||
@ -442,7 +442,7 @@ public class ShopManager {
|
||||
// Check their balance. Works with *most* economy
|
||||
// plugins*
|
||||
if (plugin.getEcon().getBalance(p.getName()) < amount * shop.getPrice()) {
|
||||
p.sendMessage(MsgUtil.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
|
||||
return;
|
||||
}
|
||||
// Don't tax them if they're purchasing from
|
||||
@ -451,7 +451,7 @@ public class ShopManager {
|
||||
double tax = plugin.getConfig().getDouble("tax");
|
||||
double total = amount * shop.getPrice();
|
||||
if (!plugin.getEcon().withdraw(p.getUniqueId(), total)) {
|
||||
p.sendMessage(MsgUtil.getMessage("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
|
||||
p.sendMessage(MsgUtil.p("you-cant-afford-to-buy", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(p.getName()))));
|
||||
return;
|
||||
}
|
||||
if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) {
|
||||
@ -462,14 +462,14 @@ public class ShopManager {
|
||||
}
|
||||
// Notify the shop owner
|
||||
if (plugin.getConfig().getBoolean("show-tax")) {
|
||||
String msg = MsgUtil.getMessage("player-bought-from-your-store-tax", p.getName(), "" + amount, shop.getDataName(), Util.format((tax * total)));
|
||||
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.getMessage("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), shop.getDataName());
|
||||
msg += "\n" + MsgUtil.p("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), shop.getDataName());
|
||||
MsgUtil.send(shop.getOwner(), msg);
|
||||
} else {
|
||||
String msg = MsgUtil.getMessage("player-bought-from-your-store", p.getName(), "" + amount, shop.getDataName());
|
||||
String msg = MsgUtil.p("player-bought-from-your-store", p.getName(), "" + amount, shop.getDataName());
|
||||
if (stock == amount)
|
||||
msg += "\n" + MsgUtil.getMessage("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), shop.getDataName());
|
||||
msg += "\n" + MsgUtil.p("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), shop.getDataName());
|
||||
MsgUtil.send(shop.getOwner(), msg);
|
||||
}
|
||||
}
|
||||
@ -480,13 +480,13 @@ public class ShopManager {
|
||||
} else if (shop.isBuying()) {
|
||||
int space = shop.getRemainingSpace();
|
||||
if (space < amount) {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-has-no-space", "" + space, shop.getDataName()));
|
||||
p.sendMessage(MsgUtil.p("shop-has-no-space", "" + space, shop.getDataName()));
|
||||
return;
|
||||
}
|
||||
int count = Util.countItems(p.getInventory(), shop.getItem());
|
||||
// Not enough items
|
||||
if (amount > count) {
|
||||
p.sendMessage(MsgUtil.getMessage("you-dont-have-that-many-items", "" + count, shop.getDataName()));
|
||||
p.sendMessage(MsgUtil.p("you-dont-have-that-many-items", "" + count, shop.getDataName()));
|
||||
return;
|
||||
}
|
||||
if (amount == 0) {
|
||||
@ -495,7 +495,7 @@ public class ShopManager {
|
||||
return;
|
||||
} else if (amount < 0) {
|
||||
// & Dumber
|
||||
p.sendMessage(MsgUtil.getMessage("negative-amount"));
|
||||
p.sendMessage(MsgUtil.p("negative-amount"));
|
||||
return;
|
||||
}
|
||||
// Money handling
|
||||
@ -509,12 +509,12 @@ public class ShopManager {
|
||||
// Tries to check their balance nicely to see if
|
||||
// they can afford it.
|
||||
if (plugin.getEcon().getBalance(shop.getOwner()) < amount * shop.getPrice()) {
|
||||
p.sendMessage(MsgUtil.getMessage("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner()))));
|
||||
p.sendMessage(MsgUtil.p("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner()))));
|
||||
return;
|
||||
}
|
||||
// Check for plugins faking econ.has(amount)
|
||||
if (!plugin.getEcon().withdraw(shop.getOwner(), total)) {
|
||||
p.sendMessage(MsgUtil.getMessage("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner()))));
|
||||
p.sendMessage(MsgUtil.p("the-owner-cant-afford-to-buy-from-you", format(amount * shop.getPrice()), format(plugin.getEcon().getBalance(shop.getOwner()))));
|
||||
return;
|
||||
}
|
||||
if (tax != 0) {
|
||||
@ -524,9 +524,9 @@ public class ShopManager {
|
||||
// Give them the money after we know we succeeded
|
||||
plugin.getEcon().deposit(p.getName(), total * (1 - tax));
|
||||
// Notify the owner of the purchase.
|
||||
String msg = MsgUtil.getMessage("player-sold-to-your-store", p.getName(), "" + amount, shop.getDataName());
|
||||
String msg = MsgUtil.p("player-sold-to-your-store", p.getName(), "" + amount, shop.getDataName());
|
||||
if (space == amount)
|
||||
msg += "\n" + MsgUtil.getMessage("shop-out-of-space", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ());
|
||||
msg += "\n" + MsgUtil.p("shop-out-of-space", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ());
|
||||
MsgUtil.send(shop.getOwner(), msg);
|
||||
}
|
||||
shop.buy(p, amount);
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
public enum ShopType {
|
||||
SELLING(0), BUYING(1);
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
package org.maxgamer.QuickShop.Util;
|
||||
|
||||
public class Converter {
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
package org.maxgamer.QuickShop.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -18,87 +18,21 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.ContainerShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MsgUtil {
|
||||
private static QuickShop plugin;
|
||||
private static YamlConfiguration messages;
|
||||
private static HashMap<UUID, LinkedList<String>> player_messages = new HashMap<UUID, LinkedList<String>>();
|
||||
private static HashMap<String, LinkedList<String>> player_messages = new HashMap<String, LinkedList<String>>();
|
||||
|
||||
static {
|
||||
plugin = QuickShop.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all the messages from messages.yml
|
||||
*/
|
||||
public static void loadCfgMessages() {
|
||||
// Load messages.yml
|
||||
File messageFile = new File(plugin.getDataFolder(), "messages.yml");
|
||||
if (!messageFile.exists()) {
|
||||
plugin.getLogger().info("Creating messages.yml");
|
||||
plugin.saveResource("messages.yml", true);
|
||||
}
|
||||
// Store it
|
||||
messages = YamlConfiguration.loadConfiguration(messageFile);
|
||||
messages.options().copyDefaults(true);
|
||||
// Load default messages
|
||||
InputStream defMessageStream = plugin.getResource("messages.yml");
|
||||
YamlConfiguration defMessages = YamlConfiguration.loadConfiguration(defMessageStream);
|
||||
messages.setDefaults(defMessages);
|
||||
// Parse colour codes
|
||||
Util.parseColours(messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* loads all player purchase messages from the database.
|
||||
*/
|
||||
public static void loadTransactionMessages() { //TODO Converted to UUID
|
||||
player_messages.clear(); // Delete old messages
|
||||
try {
|
||||
ResultSet rs = plugin.getDB().getConnection().prepareStatement("SELECT * FROM messages").executeQuery();
|
||||
while (rs.next()) {
|
||||
UUID owner = UUID.fromString(rs.getString("owner"));
|
||||
String message = rs.getString("message");
|
||||
LinkedList<String> msgs = player_messages.get(owner);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(owner, msgs);
|
||||
}
|
||||
msgs.add(message);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Could not load transaction messages from database. Skipping.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* The name of the player to message
|
||||
* @param message
|
||||
* The message to send them Sends the given player a message if
|
||||
* they're online. Else, if they're not online, queues it for
|
||||
* them in the database.
|
||||
*/
|
||||
public static void send(UUID player, String message) { //TODO Converted to UUID
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null || !p.isOnline()) {
|
||||
LinkedList<String> msgs = player_messages.get(player);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(player, msgs);
|
||||
}
|
||||
msgs.add(message);
|
||||
String q = "INSERT INTO messages (owner, message, time) VALUES (?, ?, ?)";
|
||||
plugin.getDB().execute(q, player.toString(), message, System.currentTimeMillis());
|
||||
} else {
|
||||
p.getPlayer().sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes any messages that are older than a week in the database, to save
|
||||
* on space.
|
||||
@ -106,7 +40,7 @@ public class MsgUtil {
|
||||
public static void clean() {
|
||||
System.out.println("Cleaning purchase messages from database that are over a week old...");
|
||||
// 604800,000 msec = 1 week.
|
||||
long weekAgo = System.currentTimeMillis() - 604800000;
|
||||
final long weekAgo = System.currentTimeMillis() - 604800000;
|
||||
plugin.getDB().execute("DELETE FROM messages WHERE time < ?", weekAgo);
|
||||
}
|
||||
|
||||
@ -117,12 +51,12 @@ public class MsgUtil {
|
||||
* The player to message
|
||||
* @return true if success, false if the player is offline or null
|
||||
*/
|
||||
public static boolean flush(OfflinePlayer p) { //TODO Changed to UUID
|
||||
public static boolean flush(final OfflinePlayer p) { // TODO Changed to UUID
|
||||
if (p != null && p.isOnline()) {
|
||||
UUID pName = p.getUniqueId();
|
||||
LinkedList<String> msgs = player_messages.get(pName);
|
||||
final UUID pName = p.getUniqueId();
|
||||
final LinkedList<String> msgs = player_messages.get(pName);
|
||||
if (msgs != null) {
|
||||
for (String msg : msgs) {
|
||||
for (final String msg : msgs) {
|
||||
p.getPlayer().sendMessage(msg);
|
||||
}
|
||||
plugin.getDB().execute("DELETE FROM messages WHERE owner = ?", pName.toString());
|
||||
@ -133,142 +67,51 @@ public class MsgUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void sendShopInfo(Player p, Shop shop) {
|
||||
sendShopInfo(p, shop, shop.getRemainingStock());
|
||||
/**
|
||||
* Loads all the messages from messages.yml
|
||||
*/
|
||||
public static void loadCfgMessages() {
|
||||
// Load messages.yml
|
||||
final File messageFile = new File(plugin.getDataFolder(), "messages.yml");
|
||||
if (!messageFile.exists()) {
|
||||
plugin.getLogger().info("Creating messages.yml");
|
||||
plugin.saveResource("messages.yml", true);
|
||||
}
|
||||
// Store it
|
||||
messages = YamlConfiguration.loadConfiguration(messageFile);
|
||||
messages.options().copyDefaults(true);
|
||||
// Load default messages
|
||||
final InputStream defMessageStream = plugin.getResource("messages.yml");
|
||||
final YamlConfiguration defMessages = YamlConfiguration.loadConfiguration(defMessageStream);
|
||||
messages.setDefaults(defMessages);
|
||||
// Parse colour codes
|
||||
Util.parseColours(messages);
|
||||
}
|
||||
|
||||
public static void sendShopInfo(Player p, Shop shop, int stock) {
|
||||
// Potentially faster with an array?
|
||||
ItemStack items = shop.getItem();
|
||||
p.sendMessage("");
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.shop-information"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName()==null ? (shop.isUnlimited() ? "AdminShop" : "Unknown") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.item", shop.getDataName()));
|
||||
if (Util.isTool(items.getType())) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.damage-percent-remaining", Util.getToolPercentage(items)));
|
||||
}
|
||||
if (shop.isSelling()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.stock", "" + stock));
|
||||
} else {
|
||||
int space = shop.getRemainingSpace();
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.space", "" + space));
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
|
||||
if (shop.isBuying()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.this-shop-is-buying"));
|
||||
} else {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("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 (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* loads all player purchase messages from the database.
|
||||
*/
|
||||
public static void loadTransactionMessages() { // TODO Converted to UUID
|
||||
player_messages.clear(); // Delete old messages
|
||||
try {
|
||||
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
|
||||
if (items.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
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 (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
final ResultSet rs = plugin.getDB().getConnection().prepareStatement("SELECT * FROM messages").executeQuery();
|
||||
while (rs.next()) {
|
||||
final UUID owner = UUID.fromString(rs.getString("owner"));
|
||||
final String message = rs.getString("message");
|
||||
LinkedList<String> msgs = player_messages.get(owner);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(owner, msgs);
|
||||
}
|
||||
msgs.add(message);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// They don't have an up to date enough build of CB to do this.
|
||||
// TODO: Remove this when it becomes redundant
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Could not load transaction messages from database. Skipping.");
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
public static void sendPurchaseSuccess(Player p, Shop shop, int amount) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.successful-purchase"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice()))));
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.getMessage("menu.enchants") + "-----------------------+");
|
||||
for (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.getMessage("menu.stored-enchants") + "--------------------+");
|
||||
for (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 (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.getMessage("menu.stored-enchants") + "--------------------+");
|
||||
for (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (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 + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
public static void sendSellSuccess(Player p, Shop shop, int amount) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.successfully-sold"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice()))));
|
||||
if (plugin.getConfig().getBoolean("show-tax")) {
|
||||
double tax = plugin.getConfig().getDouble("tax");
|
||||
double total = amount * shop.getPrice();
|
||||
if (tax != 0) {
|
||||
if (!p.getUniqueId().equals(shop.getOwner())) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.sell-tax", "" + Util.format((tax * total))));
|
||||
} else {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.sell-tax-self"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.getMessage("menu.enchants") + "-----------------------+");
|
||||
for (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 (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.getMessage("menu.stored-enchants") + "-----------------------+");
|
||||
for (Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (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 + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
public static String getMessage(String loc, String... args) {
|
||||
public static String p(final String loc, final String... args) {
|
||||
String raw = messages.getString(loc);
|
||||
if (raw == null || raw.isEmpty()) {
|
||||
return "Invalid message: " + loc;
|
||||
@ -277,8 +120,169 @@ public class MsgUtil {
|
||||
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]);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* The name of the player to message
|
||||
* @param message
|
||||
* The message to send them Sends the given player a message if
|
||||
* 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
|
||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null || !p.isOnline()) {
|
||||
LinkedList<String> msgs = player_messages.get(player);
|
||||
if (msgs == null) {
|
||||
msgs = new LinkedList<String>();
|
||||
player_messages.put(player, msgs);
|
||||
}
|
||||
msgs.add(message);
|
||||
final String q = "INSERT INTO messages (owner, message, time) VALUES (?, ?, ?)";
|
||||
plugin.getDB().execute(q, player.toString(), message, System.currentTimeMillis());
|
||||
} else {
|
||||
p.getPlayer().sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice()))));
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("menu.enchants") + "-----------------------+");
|
||||
for (final Entry<Enchantment, Integer> entries : enchs.entrySet()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + ChatColor.YELLOW + entries.getKey().getName() + " " + entries.getValue());
|
||||
}
|
||||
}
|
||||
enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.p("menu.stored-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 (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+-----------------" + MsgUtil.p("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 + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
public static void sendSellSuccess(final Player p, final Shop shop, final int amount) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.successfully-sold"));
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item-name-and-price", "" + amount, shop.getDataName(), Util.format((amount * shop.getPrice()))));
|
||||
if (plugin.getConfig().getBoolean("show-tax")) {
|
||||
final double tax = plugin.getConfig().getDouble("tax");
|
||||
final double total = amount * shop.getPrice();
|
||||
if (tax != 0) {
|
||||
if (!p.getUniqueId().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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Enchantment, Integer> enchs = shop.getItem().getItemMeta().getEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("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 (shop.getItem().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
final EnchantmentStorageMeta stor = (EnchantmentStorageMeta) shop.getItem().getItemMeta();
|
||||
stor.getStoredEnchants();
|
||||
enchs = stor.getStoredEnchants();
|
||||
if (enchs != null && !enchs.isEmpty()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+--------------------" + MsgUtil.p("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 + "+---------------------------------------------------+");
|
||||
}
|
||||
|
||||
public static void sendShopInfo(final Player p, final Shop shop) {
|
||||
sendShopInfo(p, shop, shop.getRemainingStock());
|
||||
}
|
||||
|
||||
public static void sendShopInfo(final Player p, final Shop shop, final int stock) {
|
||||
// Potentially faster with an array?
|
||||
final ItemStack items = shop.getItem();
|
||||
p.sendMessage("");
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
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);
|
||||
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));
|
||||
} else {
|
||||
final int space = shop.getRemainingSpace();
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.space", "" + space));
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.price-per", shop.getDataName(), Util.format(shop.getPrice())));
|
||||
if (shop.isBuying()) {
|
||||
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.this-shop-is-buying"));
|
||||
} 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 + "+---------------------------------------------------+");
|
||||
}
|
||||
}
|
254
src/main/java/org/maxgamer/QuickShop/Util/NMS.java
Normal file
254
src/main/java/org/maxgamer/QuickShop/Util/NMS.java
Normal file
@ -0,0 +1,254 @@
|
||||
package org.maxgamer.QuickShop.Util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
public class NMS {
|
||||
// private static ArrayList<NMSDependent> dependents = new ArrayList<NMSDependent>();
|
||||
private static int nextId = 0;
|
||||
// private static NMSDependent nms;
|
||||
|
||||
// static {
|
||||
// NMSDependent dep;
|
||||
// dep = new NMSDependent("v1_6_R3") {
|
||||
// @Override
|
||||
// public void safeGuard(Item item) {
|
||||
// org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
// net.minecraft.server.v1_6_R3.ItemStack nmsI = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// nmsI.count = 0;
|
||||
// iStack = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
// item.setItemStack(iStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
// net.minecraft.server.v1_6_R3.ItemStack is = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// net.minecraft.server.v1_6_R3.NBTTagCompound itemCompound = new net.minecraft.server.v1_6_R3.NBTTagCompound();
|
||||
// itemCompound = is.save(itemCompound);
|
||||
// return net.minecraft.server.v1_6_R3.NBTCompressedStreamTools.a(itemCompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
// net.minecraft.server.v1_6_R3.NBTTagCompound c = net.minecraft.server.v1_6_R3.NBTCompressedStreamTools.a(bytes);
|
||||
// net.minecraft.server.v1_6_R3.ItemStack is = net.minecraft.server.v1_6_R3.ItemStack.createStack(c);
|
||||
// return org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
// }
|
||||
// };
|
||||
// dependents.add(dep);
|
||||
// dep = new NMSDependent("v1_7_R1") {
|
||||
// @Override
|
||||
// public void safeGuard(Item item) {
|
||||
// if(QuickShop.debug)System.out.println("safeGuard");
|
||||
// org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
// net.minecraft.server.v1_7_R1.ItemStack nmsI = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// nmsI.count = 0;
|
||||
// iStack = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
// item.setItemStack(iStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
// if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
// net.minecraft.server.v1_7_R1.ItemStack is = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// net.minecraft.server.v1_7_R1.NBTTagCompound itemCompound = new net.minecraft.server.v1_7_R1.NBTTagCompound();
|
||||
// itemCompound = is.save(itemCompound);
|
||||
// return net.minecraft.server.v1_7_R1.NBTCompressedStreamTools.a(itemCompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
// if(QuickShop.debug)System.out.println("getItemStack");
|
||||
// net.minecraft.server.v1_7_R1.NBTTagCompound c = net.minecraft.server.v1_7_R1.NBTCompressedStreamTools.a(bytes);
|
||||
// net.minecraft.server.v1_7_R1.ItemStack is = net.minecraft.server.v1_7_R1.ItemStack.createStack(c);
|
||||
// return org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
// }
|
||||
// };
|
||||
// dependents.add(dep);
|
||||
// dep = new NMSDependent("v1_7_R3") {
|
||||
// @Override
|
||||
// public void safeGuard(Item item) {
|
||||
// if(QuickShop.debug)System.out.println("safeGuard");
|
||||
// org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
// net.minecraft.server.v1_7_R3.ItemStack nmsI = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// nmsI.count = 0;
|
||||
// iStack = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
// item.setItemStack(iStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
// if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
// net.minecraft.server.v1_7_R3.ItemStack is = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// net.minecraft.server.v1_7_R3.NBTTagCompound itemCompound = new net.minecraft.server.v1_7_R3.NBTTagCompound();
|
||||
// itemCompound = is.save(itemCompound);
|
||||
// return net.minecraft.server.v1_7_R3.NBTCompressedStreamTools.a(itemCompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
// if(QuickShop.debug)System.out.println("getItemStack");
|
||||
// net.minecraft.server.v1_7_R3.NBTTagCompound c = net.minecraft.server.v1_7_R3.NBTCompressedStreamTools.a(bytes, null);
|
||||
// net.minecraft.server.v1_7_R3.ItemStack is = net.minecraft.server.v1_7_R3.ItemStack.createStack(c);
|
||||
// return org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
// }
|
||||
// };
|
||||
// dependents.add(dep);
|
||||
// dep = new NMSDependent("v1_8") {
|
||||
// @Override
|
||||
// public void safeGuard(Item item) {
|
||||
// if(QuickShop.debug)System.out.println("safeGuard");
|
||||
// org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
// net.minecraft.server.v1_8_R1.ItemStack nmsI = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// nmsI.count = 0;
|
||||
// iStack = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
// item.setItemStack(iStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
// try{
|
||||
// if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
// net.minecraft.server.v1_8_R1.ItemStack is = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
// net.minecraft.server.v1_8_R1.NBTTagCompound itemCompound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
|
||||
// itemCompound = is.save(itemCompound);
|
||||
// ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
// DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(bytearrayoutputstream));
|
||||
// try {
|
||||
// net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(itemCompound, (DataOutput) dataoutputstream);
|
||||
// } finally {
|
||||
// dataoutputstream.close();
|
||||
// }
|
||||
// return bytearrayoutputstream.toByteArray();
|
||||
// }catch(Exception e){
|
||||
// return new byte[0];
|
||||
// }
|
||||
// //return net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(itemCompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
// try{
|
||||
// if(QuickShop.debug)System.out.println("getItemStack");
|
||||
// DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes))));
|
||||
// net.minecraft.server.v1_8_R1.NBTTagCompound nbttagcompound;
|
||||
// try {
|
||||
// nbttagcompound = net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a((DataInput) datainputstream, null);
|
||||
// } finally {
|
||||
// datainputstream.close();
|
||||
// }
|
||||
// //net.minecraft.server.v1_8_R1.NBTTagCompound c = net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(bytes, null);
|
||||
// net.minecraft.server.v1_8_R1.ItemStack is = net.minecraft.server.v1_8_R1.ItemStack.createStack(nbttagcompound);
|
||||
// return org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
// }catch(Exception e){
|
||||
// return new ItemStack(Material.AIR);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// dependents.add(dep);
|
||||
// }
|
||||
|
||||
public static void safeGuard(final Item item) throws ClassNotFoundException {
|
||||
if (QuickShop.debug) {
|
||||
System.out.println("Renaming");
|
||||
}
|
||||
rename(item.getItemStack());
|
||||
if (QuickShop.debug) {
|
||||
System.out.println("Protecting");
|
||||
}
|
||||
protect(item);
|
||||
if (QuickShop.debug) {
|
||||
System.out.println("Seting pickup delay");
|
||||
}
|
||||
item.setPickupDelay(2147483647);
|
||||
}
|
||||
|
||||
private static void protect(final Item item) {
|
||||
try {
|
||||
final Field itemField = item.getClass().getDeclaredField("item");
|
||||
itemField.setAccessible(true);
|
||||
final Object nmsEntityItem = itemField.get(item);
|
||||
Method getItemStack;
|
||||
try {
|
||||
getItemStack = nmsEntityItem.getClass().getMethod("getItemStack", new Class[0]);
|
||||
} catch (final NoSuchMethodException e) {
|
||||
try {
|
||||
getItemStack = nmsEntityItem.getClass().getMethod("d", new Class[0]);
|
||||
} catch (final NoSuchMethodException e2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Object itemStack = getItemStack.invoke(nmsEntityItem, new Object[0]);
|
||||
Field countField;
|
||||
try {
|
||||
countField = itemStack.getClass().getDeclaredField("count");
|
||||
} catch (final NoSuchFieldException e) {
|
||||
countField = itemStack.getClass().getDeclaredField("a");
|
||||
}
|
||||
countField.setAccessible(true);
|
||||
countField.set(itemStack, Integer.valueOf(1));
|
||||
} catch (final NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("[QuickShop] Could not protect item from pickup properly! Dupes are now possible.");
|
||||
} catch (final Exception e) {
|
||||
System.out.println("Other error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// public static byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) throws ClassNotFoundException {
|
||||
// validate();
|
||||
// return nms.getNBTBytes(iStack);
|
||||
// }
|
||||
//
|
||||
// public static ItemStack getItemStack(byte[] bytes) throws ClassNotFoundException {
|
||||
// validate();
|
||||
// return nms.getItemStack(bytes);
|
||||
// }
|
||||
|
||||
private static void rename(final ItemStack iStack) {
|
||||
final ItemMeta meta = iStack.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.RED + "QuickShop " + Util.getName(iStack) + " " + nextId++);
|
||||
iStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
// private static void validate() throws ClassNotFoundException {
|
||||
// if (nms != null) {
|
||||
// return;
|
||||
// }
|
||||
// String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
// packageName = packageName.substring(packageName.lastIndexOf(".") + 1);
|
||||
// // System.out.println("Package: " + packageName);
|
||||
// for (NMSDependent dep : dependents) {
|
||||
// if ((packageName.startsWith(dep.getVersion())) || ((dep.getVersion().isEmpty()) && ((packageName.equals("bukkit")) || (packageName.equals("craftbukkit"))))) {
|
||||
// nms = dep;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// throw new ClassNotFoundException("This version of QuickShop is incompatible.");
|
||||
// }
|
||||
|
||||
// private static abstract class NMSDependent {
|
||||
// private String version;
|
||||
//
|
||||
// public String getVersion() {
|
||||
// return this.version;
|
||||
// }
|
||||
//
|
||||
// public NMSDependent(String version) {
|
||||
// this.version = version;
|
||||
// }
|
||||
//
|
||||
// public abstract void safeGuard(Item paramItem);
|
||||
//
|
||||
// public abstract byte[] getNBTBytes(org.bukkit.inventory.ItemStack paramItemStack);
|
||||
//
|
||||
// public abstract org.bukkit.inventory.ItemStack getItemStack(byte[] paramArrayOfByte);
|
||||
// }
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
package org.maxgamer.QuickShop.Util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashSet;
|
||||
@ -24,7 +24,8 @@ import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Config.ItemConfig;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Util {
|
||||
@ -34,6 +35,206 @@ public class Util {
|
||||
private static HashSet<Material> transparent = new HashSet<Material>();
|
||||
private static QuickShop plugin;
|
||||
|
||||
private static final String[] ROMAN = { "X", "IX", "V", "IV", "I" };
|
||||
|
||||
private static final int[] DECIMAL = { 10, 9, 5, 4, 1 };
|
||||
|
||||
public static void addTransparentBlock(final Material m) {
|
||||
if (transparent.add(m) == false) {
|
||||
System.out.println("Already added as transparent: " + m.toString());
|
||||
}
|
||||
if (!m.isBlock()) {
|
||||
System.out.println(m + " is not a block!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given block could be used to make a shop out of.
|
||||
*
|
||||
* @param b
|
||||
* The block to check. Possibly a chest, dispenser, etc.
|
||||
* @return True if it can be made into a shop, otherwise false.
|
||||
*/
|
||||
public static boolean canBeShop(final Block b) {
|
||||
final BlockState bs = b.getState();
|
||||
if (bs instanceof InventoryHolder == false) {
|
||||
return false;
|
||||
}
|
||||
return shoppables.contains(bs.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of items in the given inventory where
|
||||
* Util.matches(inventory item, item) is true.
|
||||
*
|
||||
* @param inv
|
||||
* The inventory to search
|
||||
* @param item
|
||||
* The ItemStack to search for
|
||||
* @return The number of items that match in this inventory.
|
||||
*/
|
||||
public static int countItems(final Inventory inv, final ItemStack item) {
|
||||
int items = 0;
|
||||
for (final ItemStack iStack : inv.getContents()) {
|
||||
if (iStack == null) {
|
||||
continue;
|
||||
}
|
||||
if (Util.matches(item, iStack)) {
|
||||
items += iStack.getAmount();
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of items that can be given to the inventory safely.
|
||||
*
|
||||
* @param inv
|
||||
* The inventory to count
|
||||
* @param item
|
||||
* The item prototype. Material, durabiltiy and enchants must
|
||||
* match for 'stackability' to occur.
|
||||
* @return The number of items that can be given to the inventory safely.
|
||||
*/
|
||||
public static int countSpace(final Inventory inv, final ItemStack item) {
|
||||
int space = 0;
|
||||
for (final ItemStack iStack : inv.getContents()) {
|
||||
if (iStack == null || iStack.getType() == Material.AIR) {
|
||||
space += item.getMaxStackSize();
|
||||
} else if (matches(item, iStack)) {
|
||||
space += item.getMaxStackSize() - iStack.getAmount();
|
||||
}
|
||||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
public static ItemStack deserialize(final String config) throws InvalidConfigurationException {
|
||||
final YamlConfiguration cfg = new YamlConfiguration();
|
||||
cfg.loadFromString(config);
|
||||
final ItemStack stack = cfg.getItemStack("item");
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static String firstUppercase(final String string) {
|
||||
if (string.length() > 1) {
|
||||
return Character.toUpperCase(string.charAt(0)) + string.substring(1).toLowerCase();
|
||||
} else {
|
||||
return string.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given number according to how vault would like it. E.g. $50
|
||||
* or 5 dollars.
|
||||
*
|
||||
* @return The formatted string.
|
||||
*/
|
||||
public static String format(final double n) {
|
||||
try {
|
||||
return plugin.getEcon().format(n);
|
||||
} catch (final NumberFormatException e) {
|
||||
return "$" + n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the block which the given sign is attached to
|
||||
*
|
||||
* @param sign
|
||||
* The sign which is attached
|
||||
* @return The block the sign is attached to
|
||||
*/
|
||||
public static Block getAttached(final Block b) {
|
||||
try {
|
||||
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);
|
||||
} catch (final NullPointerException e) {
|
||||
return null; // /Not sure what causes this.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an ItemStack's name - For example, converting INK_SAC:11 to
|
||||
* Dandellion Yellow, or WOOL:14 to Red Wool
|
||||
*
|
||||
* @param i
|
||||
* The itemstack to fetch the name of
|
||||
* @return The human readable item name.
|
||||
*/
|
||||
public static String getName(final ItemStack i) {
|
||||
// final String vanillaName = getDataName(i.getType(), i.getDurability());
|
||||
final String vanillaName = ItemConfig.getItemName(i);
|
||||
return prettifyText(vanillaName);
|
||||
}
|
||||
|
||||
// Let's make very long names shorter for our sign
|
||||
public static String getNameForSign(final ItemStack itemStack) {
|
||||
// final String name = getDataName(itemStack.getType(), itemStack.getDurability());
|
||||
final String name = getName(itemStack);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chest attached to the given chest. The given block must be a
|
||||
* chest.
|
||||
*
|
||||
* @param b
|
||||
* The chest to check.
|
||||
* @return the block which is also a chest and connected to b.
|
||||
*/
|
||||
public static Block getSecondHalf(final Block b) {
|
||||
if (b.getType().toString().contains("CHEST") == false) {
|
||||
return null;
|
||||
}
|
||||
final Block[] blocks = new Block[4];
|
||||
blocks[0] = b.getRelative(1, 0, 0);
|
||||
blocks[1] = b.getRelative(-1, 0, 0);
|
||||
blocks[2] = b.getRelative(0, 0, 1);
|
||||
blocks[3] = b.getRelative(0, 0, -1);
|
||||
for (final Block c : blocks) {
|
||||
if (c.getType() == b.getType()) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the percentage (Without trailing %) damage on a tool.
|
||||
*
|
||||
* @param item
|
||||
* The ItemStack of tools to check
|
||||
* @return The percentage 'health' the tool has. (Opposite of total damage)
|
||||
*/
|
||||
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) + ")";
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
tools.clear();
|
||||
blacklist.clear();
|
||||
@ -41,12 +242,12 @@ public class Util {
|
||||
transparent.clear();
|
||||
|
||||
plugin = QuickShop.instance;
|
||||
for (String s : plugin.getConfig().getStringList("shop-blocks")) {
|
||||
for (final String s : plugin.getConfig().getStringList("shop-blocks")) {
|
||||
Material mat = Material.getMaterial(s.toUpperCase());
|
||||
if (mat == null) {
|
||||
try {
|
||||
mat = Material.getMaterial(Integer.parseInt(s));
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (final NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if (mat == null) {
|
||||
@ -104,8 +305,8 @@ public class Util {
|
||||
tools.add(Material.IRON_CHESTPLATE);
|
||||
tools.add(Material.IRON_HELMET);
|
||||
tools.add(Material.IRON_LEGGINGS);
|
||||
List<String> configBlacklist = plugin.getConfig().getStringList("blacklist");
|
||||
for (String s : configBlacklist) {
|
||||
final List<String> configBlacklist = plugin.getConfig().getStringList("blacklist");
|
||||
for (final String s : configBlacklist) {
|
||||
Material mat = Material.getMaterial(s.toUpperCase());
|
||||
if (mat == null) {
|
||||
mat = Material.getMaterial(Integer.parseInt(s));
|
||||
@ -201,81 +402,54 @@ public class Util {
|
||||
addTransparentBlock(Material.WOOD_STEP);
|
||||
}
|
||||
|
||||
public static boolean isTransparent(Material m) {
|
||||
boolean trans = transparent.contains(m);
|
||||
return trans;
|
||||
}
|
||||
|
||||
public static void addTransparentBlock(Material m) {
|
||||
if (transparent.add(m) == false) {
|
||||
System.out.println("Already added as transparent: " + m.toString());
|
||||
}
|
||||
if (!m.isBlock())
|
||||
System.out.println(m + " is not a block!");
|
||||
}
|
||||
|
||||
public static void parseColours(YamlConfiguration config) {
|
||||
Set<String> keys = config.getKeys(true);
|
||||
for (String key : keys) {
|
||||
String filtered = config.getString(key);
|
||||
if (filtered.startsWith("MemorySection")) {
|
||||
continue;
|
||||
}
|
||||
filtered = ChatColor.translateAlternateColorCodes('&', filtered);
|
||||
config.set(key, filtered);
|
||||
}
|
||||
/**
|
||||
* @param m
|
||||
* The material to check if it is blacklisted
|
||||
* @return true if the material is black listed. False if not.
|
||||
*/
|
||||
public static boolean isBlacklisted(final Material m) {
|
||||
return blacklist.contains(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given block could be used to make a shop out of.
|
||||
* Returns true if the given location is loaded or not.
|
||||
*
|
||||
* @param b
|
||||
* The block to check. Possibly a chest, dispenser, etc.
|
||||
* @return True if it can be made into a shop, otherwise false.
|
||||
* @param loc
|
||||
* The location
|
||||
* @return true if the given location is loaded or not.
|
||||
*/
|
||||
public static boolean canBeShop(Block b) {
|
||||
BlockState bs = b.getState();
|
||||
if (bs instanceof InventoryHolder == false)
|
||||
public static boolean isLoaded(final Location loc) {
|
||||
// System.out.println("Checking isLoaded(Location loc)");
|
||||
if (loc.getWorld() == null) {
|
||||
// System.out.println("Is not loaded. (No world)");
|
||||
return false;
|
||||
return shoppables.contains(bs.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the percentage (Without trailing %) damage on a tool.
|
||||
*
|
||||
* @param item
|
||||
* The ItemStack of tools to check
|
||||
* @return The percentage 'health' the tool has. (Opposite of total damage)
|
||||
*/
|
||||
public static String getToolPercentage(ItemStack item) {
|
||||
double dura = item.getDurability();
|
||||
double max = item.getType().getMaxDurability();
|
||||
DecimalFormat formatter = new DecimalFormat("0");
|
||||
return formatter.format((1 - dura / max) * 100.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chest attached to the given chest. The given block must be a
|
||||
* chest.
|
||||
*
|
||||
* @param b
|
||||
* The chest to check.
|
||||
* @return the block which is also a chest and connected to b.
|
||||
*/
|
||||
public static Block getSecondHalf(Block b) {
|
||||
if (b.getType().toString().contains("CHEST") == false)
|
||||
return null;
|
||||
Block[] blocks = new Block[4];
|
||||
blocks[0] = b.getRelative(1, 0, 0);
|
||||
blocks[1] = b.getRelative(-1, 0, 0);
|
||||
blocks[2] = b.getRelative(0, 0, 1);
|
||||
blocks[3] = b.getRelative(0, 0, -1);
|
||||
for (Block c : blocks) {
|
||||
if (c.getType() == b.getType()) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// Calculate the chunks coordinates. These are 1,2,3 for each chunk, NOT
|
||||
// location rounded to the nearest 16.
|
||||
final int x = (int) Math.floor((loc.getBlockX()) / 16.0);
|
||||
final int z = (int) Math.floor((loc.getBlockZ()) / 16.0);
|
||||
if (loc.getWorld().isChunkLoaded(x, z)) {
|
||||
// System.out.println("Chunk is loaded " + x + ", " + z);
|
||||
return true;
|
||||
} else {
|
||||
// System.out.println("Chunk is NOT loaded " + x + ", " + z);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mat
|
||||
* The material to check
|
||||
* @return Returns true if the item is a tool (Has durability) or false if
|
||||
* it doesn't.
|
||||
*/
|
||||
public static boolean isTool(final Material mat) {
|
||||
return tools.contains(mat);
|
||||
}
|
||||
|
||||
public static boolean isTransparent(final Material m) {
|
||||
final boolean trans = transparent.contains(m);
|
||||
return trans;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,21 +460,23 @@ public class Util {
|
||||
* item).
|
||||
* @return A new itemstack, with the properties given in the string
|
||||
*/
|
||||
public static ItemStack makeItem(String itemString) {
|
||||
String[] itemInfo = itemString.split(":");
|
||||
ItemStack item = new ItemStack(Material.getMaterial(itemInfo[0]));
|
||||
MaterialData data = new MaterialData(Integer.parseInt(itemInfo[1]));
|
||||
public static ItemStack makeItem(final String itemString) {
|
||||
final String[] itemInfo = itemString.split(":");
|
||||
final ItemStack item = new ItemStack(Material.getMaterial(itemInfo[0]));
|
||||
final MaterialData data = new MaterialData(Integer.parseInt(itemInfo[1]));
|
||||
item.setData(data);
|
||||
item.setDurability(Short.parseShort(itemInfo[2]));
|
||||
item.setAmount(Integer.parseInt(itemInfo[3]));
|
||||
for (int i = 4; i < itemInfo.length; i = i + 2) {
|
||||
int level = Integer.parseInt(itemInfo[i + 1]);
|
||||
Enchantment ench = Enchantment.getByName(itemInfo[i]);
|
||||
if (ench == null)
|
||||
final Enchantment ench = Enchantment.getByName(itemInfo[i]);
|
||||
if (ench == null) {
|
||||
continue; // Invalid
|
||||
}
|
||||
if (ench.canEnchantItem(item)) {
|
||||
if (level <= 0)
|
||||
if (level <= 0) {
|
||||
continue;
|
||||
}
|
||||
level = Math.min(ench.getMaxLevel(), level);
|
||||
item.addEnchantment(ench, level);
|
||||
}
|
||||
@ -308,30 +484,72 @@ public class Util {
|
||||
return item;
|
||||
}
|
||||
|
||||
public static String serialize(ItemStack iStack) {
|
||||
YamlConfiguration cfg = new YamlConfiguration();
|
||||
cfg.set("item", iStack);
|
||||
return cfg.saveToString();
|
||||
}
|
||||
|
||||
public static ItemStack deserialize(String config) throws InvalidConfigurationException {
|
||||
YamlConfiguration cfg = new YamlConfiguration();
|
||||
cfg.loadFromString(config);
|
||||
ItemStack stack = cfg.getItemStack("item");
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an ItemStack's name - For example, converting INK_SAC:11 to
|
||||
* Dandellion Yellow, or WOOL:14 to Red Wool
|
||||
* Compares two items to each other. Returns true if they match.
|
||||
*
|
||||
* @param i
|
||||
* The itemstack to fetch the name of
|
||||
* @return The human readable item name.
|
||||
* @param stack1
|
||||
* The first item stack
|
||||
* @param stack2
|
||||
* The second item stack
|
||||
* @return true if the itemstacks match. (Material, durability, enchants, name)
|
||||
*/
|
||||
public static String getName(ItemStack i) {
|
||||
String vanillaName = getDataName(i.getType(), i.getDurability());
|
||||
return prettifyText(vanillaName);
|
||||
public static boolean matches(final ItemStack stack1, final ItemStack stack2) {
|
||||
if (stack1 == stack2) {
|
||||
return true; // Referring to the same thing, or both are null.
|
||||
}
|
||||
if (stack1 == null || stack2 == null) {
|
||||
return false; // One of them is null (Can't be both, see above)
|
||||
}
|
||||
if (stack1.getType() != stack2.getType()) {
|
||||
return false; // Not the same material
|
||||
}
|
||||
if (stack1.getDurability() != stack2.getDurability()) {
|
||||
return false; // Not the same durability
|
||||
}
|
||||
if (!stack1.getEnchantments().equals(stack2.getEnchantments())) {
|
||||
return false; // They have the same enchants
|
||||
}
|
||||
if (stack1.getItemMeta().hasDisplayName() || stack2.getItemMeta().hasDisplayName()) {
|
||||
if (stack1.getItemMeta().hasDisplayName() && stack2.getItemMeta().hasDisplayName()) {
|
||||
if (!stack1.getItemMeta().getDisplayName().equals(stack2.getItemMeta().getDisplayName())) {
|
||||
return false; // items have different display name
|
||||
}
|
||||
} else {
|
||||
return false; // one of the item stacks have a display name
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
|
||||
final boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta;
|
||||
final boolean book2 = stack2.getItemMeta() instanceof EnchantmentStorageMeta;
|
||||
if (book1 != book2) {
|
||||
return false;// One has enchantment meta, the other does not.
|
||||
}
|
||||
if (book1 == true) { // They are the same here (both true or both
|
||||
// false). So if one is true, the other is
|
||||
// true.
|
||||
final Map<Enchantment, Integer> ench1 = ((EnchantmentStorageMeta) stack1.getItemMeta()).getStoredEnchants();
|
||||
final Map<Enchantment, Integer> ench2 = ((EnchantmentStorageMeta) stack2.getItemMeta()).getStoredEnchants();
|
||||
if (!ench1.equals(ench2)) {
|
||||
return false; // Enchants aren't the same.
|
||||
}
|
||||
}
|
||||
} catch (final ClassNotFoundException e) {
|
||||
// Nothing. They dont have a build high enough to support this.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void parseColours(final YamlConfiguration config) {
|
||||
final Set<String> keys = config.getKeys(true);
|
||||
for (final String key : keys) {
|
||||
String filtered = config.getString(key);
|
||||
if (filtered.startsWith("MemorySection")) {
|
||||
continue;
|
||||
}
|
||||
filtered = ChatColor.translateAlternateColorCodes('&', filtered);
|
||||
config.set(key, filtered);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,79 +560,24 @@ public class Util {
|
||||
* @return A nicer version, such as Iron Ingot
|
||||
*
|
||||
*/
|
||||
public static String prettifyText(String ugly) {
|
||||
String[] nameParts = ugly.split("_");
|
||||
if (nameParts.length==1) {
|
||||
public static String prettifyText(final String ugly) {
|
||||
final String[] nameParts = ugly.split("_");
|
||||
if (nameParts.length == 1) {
|
||||
return firstUppercase(ugly);
|
||||
}
|
||||
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (String part : nameParts) {
|
||||
sb.append(firstUppercase(part)+" ");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (final String part : nameParts) {
|
||||
sb.append(firstUppercase(part) + " ");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Let's make very long names shorter for our sign
|
||||
public static String getNameForSign(ItemStack itemStack) {
|
||||
String name = getDataName(itemStack.getType(), itemStack.getDurability());
|
||||
|
||||
String[] nameParts = name.split("_");
|
||||
if (nameParts.length==1) {
|
||||
return firstUppercase(nameParts[0]);
|
||||
}
|
||||
|
||||
for (int i=0; i<nameParts.length-1; i++) {
|
||||
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);
|
||||
}
|
||||
|
||||
public static String firstUppercase(String string) {
|
||||
if (string.length()>1) {
|
||||
return Character.toUpperCase(string.charAt(0))+string.substring(1).toLowerCase();
|
||||
} else {
|
||||
return string.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String toRomain(Integer value) {
|
||||
return toRoman(value.intValue());
|
||||
}
|
||||
|
||||
private static final String[] ROMAN = { "X", "IX", "V", "IV", "I" };
|
||||
private static final int[] DECIMAL = { 10, 9, 5, 4, 1 };
|
||||
|
||||
/**
|
||||
* Converts the given number to roman numerals. If the number is >= 40 or <=
|
||||
* 0, it will just return the number as a string.
|
||||
*
|
||||
* @param n
|
||||
* The number to convert
|
||||
* @return The roman numeral representation of this number, or the number in
|
||||
* decimal form as a string if n <= 0 || n >= 40.
|
||||
*/
|
||||
public static String toRoman(int n) {
|
||||
if (n <= 0 || n >= 40)
|
||||
return "" + n;
|
||||
String roman = "";
|
||||
for (int i = 0; i < ROMAN.length; i++) {
|
||||
while (n >= DECIMAL[i]) {
|
||||
n -= DECIMAL[i];
|
||||
roman += ROMAN[i];
|
||||
}
|
||||
}
|
||||
return roman;
|
||||
public static String serialize(final ItemStack iStack) {
|
||||
final YamlConfiguration cfg = new YamlConfiguration();
|
||||
cfg.set("item", iStack);
|
||||
return cfg.saveToString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,11 +591,11 @@ public class Util {
|
||||
* The durability/damage of the item.
|
||||
* @return A string with the name of the item.
|
||||
*/
|
||||
private static String getDataName(Material mat, short damage) {
|
||||
int id = mat.getId();
|
||||
private static String getDataName(final Material mat, short damage) {
|
||||
final int id = mat.getId();
|
||||
switch (id) {
|
||||
case 35:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "WHITE_WOOL";
|
||||
case 1:
|
||||
@ -468,7 +631,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 351:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "INK_SAC";
|
||||
case 1:
|
||||
@ -504,7 +667,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 98:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "STONE_BRICKS";
|
||||
case 1:
|
||||
@ -517,24 +680,28 @@ public class Util {
|
||||
return mat.toString();
|
||||
case 373:
|
||||
// Special case,.. Why?
|
||||
if (damage == 0)
|
||||
if (damage == 0) {
|
||||
return "WATER_BOTTLE";
|
||||
}
|
||||
Potion pot;
|
||||
try {
|
||||
pot = Potion.fromDamage(damage);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
return "CUSTOM_POTION";
|
||||
}
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
if (pot.getLevel() > 0)
|
||||
if (pot.getLevel() > 0) {
|
||||
suffix += "_" + pot.getLevel();
|
||||
if (pot.hasExtendedDuration())
|
||||
}
|
||||
if (pot.hasExtendedDuration()) {
|
||||
prefix += "EXTENDED_";
|
||||
if (pot.isSplash())
|
||||
}
|
||||
if (pot.isSplash()) {
|
||||
prefix += "SPLASH_";
|
||||
}
|
||||
if (pot.getEffects().isEmpty()) {
|
||||
switch ((int) pot.getNameId()) {
|
||||
switch (pot.getNameId()) {
|
||||
case 0:
|
||||
return prefix + "MUNDANE_POTION" + suffix;
|
||||
case 7:
|
||||
@ -552,14 +719,14 @@ public class Util {
|
||||
}
|
||||
} else {
|
||||
String effects = "";
|
||||
for (PotionEffect effect : pot.getEffects()) {
|
||||
for (final PotionEffect effect : pot.getEffects()) {
|
||||
effects += effect.toString().split(":")[0];
|
||||
}
|
||||
return prefix + effects + suffix;
|
||||
}
|
||||
return mat.toString();
|
||||
case 6:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "OAK_SAPLING";
|
||||
case 1:
|
||||
@ -571,7 +738,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 5:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "OAK_PLANKS";
|
||||
case 1:
|
||||
@ -615,7 +782,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 24:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "SANDSTONE";
|
||||
case 1:
|
||||
@ -625,7 +792,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 31:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "DEAD_SHRUB";
|
||||
case 1:
|
||||
@ -635,7 +802,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 44:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "STONE_SLAB";
|
||||
case 1:
|
||||
@ -651,7 +818,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 383:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 50:
|
||||
return "CREEPER_EGG";
|
||||
case 51:
|
||||
@ -713,7 +880,7 @@ public class Util {
|
||||
}
|
||||
return mat.toString();
|
||||
case 397:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "SKELETON_SKULL";
|
||||
case 1:
|
||||
@ -747,7 +914,7 @@ public class Util {
|
||||
case 391:
|
||||
return "CARROT";
|
||||
case 322:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "GOLDEN_APPLE";
|
||||
case 1:
|
||||
@ -757,7 +924,7 @@ public class Util {
|
||||
case 390:
|
||||
return "FLOWER_POT";
|
||||
case 145:
|
||||
switch ((int) damage) {
|
||||
switch (damage) {
|
||||
case 0:
|
||||
return "ANVIL";
|
||||
case 1:
|
||||
@ -773,180 +940,9 @@ public class Util {
|
||||
case 385:
|
||||
return "FIREWORK_CHARGE";
|
||||
}
|
||||
if (damage == 0 || isTool(mat))
|
||||
if (damage == 0 || isTool(mat)) {
|
||||
return mat.toString();
|
||||
}
|
||||
return mat.toString() + ":" + damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mat
|
||||
* The material to check
|
||||
* @return Returns true if the item is a tool (Has durability) or false if
|
||||
* it doesn't.
|
||||
*/
|
||||
public static boolean isTool(Material mat) {
|
||||
return tools.contains(mat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two items to each other. Returns true if they match.
|
||||
*
|
||||
* @param stack1
|
||||
* The first item stack
|
||||
* @param stack2
|
||||
* The second item stack
|
||||
* @return true if the itemstacks match. (Material, durability, enchants, name)
|
||||
*/
|
||||
public static boolean matches(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1 == stack2)
|
||||
return true; // Referring to the same thing, or both are null.
|
||||
if (stack1 == null || stack2 == null)
|
||||
return false; // One of them is null (Can't be both, see above)
|
||||
if (stack1.getType() != stack2.getType())
|
||||
return false; // Not the same material
|
||||
if (stack1.getDurability() != stack2.getDurability())
|
||||
return false; // Not the same durability
|
||||
if (!stack1.getEnchantments().equals(stack2.getEnchantments()))
|
||||
return false; // They have the same enchants
|
||||
if (stack1.getItemMeta().hasDisplayName() || stack2.getItemMeta().hasDisplayName()) {
|
||||
if (stack1.getItemMeta().hasDisplayName() && stack2.getItemMeta().hasDisplayName()) {
|
||||
if (!stack1.getItemMeta().getDisplayName().equals(stack2.getItemMeta().getDisplayName())) {
|
||||
return false; // items have different display name
|
||||
}
|
||||
} else {
|
||||
return false; // one of the item stacks have a display name
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta");
|
||||
boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta;
|
||||
boolean book2 = stack2.getItemMeta() instanceof EnchantmentStorageMeta;
|
||||
if (book1 != book2)
|
||||
return false;// One has enchantment meta, the other does not.
|
||||
if (book1 == true) { // They are the same here (both true or both
|
||||
// false). So if one is true, the other is
|
||||
// true.
|
||||
Map<Enchantment, Integer> ench1 = ((EnchantmentStorageMeta) stack1.getItemMeta()).getStoredEnchants();
|
||||
Map<Enchantment, Integer> ench2 = ((EnchantmentStorageMeta) stack2.getItemMeta()).getStoredEnchants();
|
||||
if (!ench1.equals(ench2))
|
||||
return false; // Enchants aren't the same.
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Nothing. They dont have a build high enough to support this.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given number according to how vault would like it. E.g. $50
|
||||
* or 5 dollars.
|
||||
*
|
||||
* @return The formatted string.
|
||||
*/
|
||||
public static String format(double n) {
|
||||
try {
|
||||
return plugin.getEcon().format(n);
|
||||
} catch (NumberFormatException e) {
|
||||
return "$" + n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param m
|
||||
* The material to check if it is blacklisted
|
||||
* @return true if the material is black listed. False if not.
|
||||
*/
|
||||
public static boolean isBlacklisted(Material m) {
|
||||
return blacklist.contains(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the block which the given sign is attached to
|
||||
*
|
||||
* @param sign
|
||||
* The sign which is attached
|
||||
* @return The block the sign is attached to
|
||||
*/
|
||||
public static Block getAttached(Block b) {
|
||||
try {
|
||||
Sign sign = (Sign) b.getState().getData(); // Throws a NPE
|
||||
// sometimes??
|
||||
BlockFace attached = sign.getAttachedFace();
|
||||
if (attached == null)
|
||||
return null;
|
||||
return b.getRelative(attached);
|
||||
} catch (NullPointerException e) {
|
||||
return null; // /Not sure what causes this.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of items in the given inventory where
|
||||
* Util.matches(inventory item, item) is true.
|
||||
*
|
||||
* @param inv
|
||||
* The inventory to search
|
||||
* @param item
|
||||
* The ItemStack to search for
|
||||
* @return The number of items that match in this inventory.
|
||||
*/
|
||||
public static int countItems(Inventory inv, ItemStack item) {
|
||||
int items = 0;
|
||||
for (ItemStack iStack : inv.getContents()) {
|
||||
if (iStack == null)
|
||||
continue;
|
||||
if (Util.matches(item, iStack)) {
|
||||
items += iStack.getAmount();
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of items that can be given to the inventory safely.
|
||||
*
|
||||
* @param inv
|
||||
* The inventory to count
|
||||
* @param item
|
||||
* The item prototype. Material, durabiltiy and enchants must
|
||||
* match for 'stackability' to occur.
|
||||
* @return The number of items that can be given to the inventory safely.
|
||||
*/
|
||||
public static int countSpace(Inventory inv, ItemStack item) {
|
||||
int space = 0;
|
||||
for (ItemStack iStack : inv.getContents()) {
|
||||
if (iStack == null || iStack.getType() == Material.AIR) {
|
||||
space += item.getMaxStackSize();
|
||||
} else if (matches(item, iStack)) {
|
||||
space += item.getMaxStackSize() - iStack.getAmount();
|
||||
}
|
||||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given location is loaded or not.
|
||||
*
|
||||
* @param loc
|
||||
* The location
|
||||
* @return true if the given location is loaded or not.
|
||||
*/
|
||||
public static boolean isLoaded(Location loc) {
|
||||
// System.out.println("Checking isLoaded(Location loc)");
|
||||
if (loc.getWorld() == null) {
|
||||
// System.out.println("Is not loaded. (No world)");
|
||||
return false;
|
||||
}
|
||||
// Calculate the chunks coordinates. These are 1,2,3 for each chunk, NOT
|
||||
// location rounded to the nearest 16.
|
||||
int x = (int) Math.floor((loc.getBlockX()) / 16.0);
|
||||
int z = (int) Math.floor((loc.getBlockZ()) / 16.0);
|
||||
if (loc.getWorld().isChunkLoaded(x, z)) {
|
||||
// System.out.println("Chunk is loaded " + x + ", " + z);
|
||||
return true;
|
||||
} else {
|
||||
// System.out.println("Chunk is NOT loaded " + x + ", " + z);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
package org.maxgamer.QuickShop.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -8,9 +8,9 @@ import java.util.Map.Entry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopChunk;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Shop.ShopChunk;
|
||||
|
||||
/**
|
||||
* @author Netherfoam Maintains the display items, restoring them when needed.
|
@ -1,4 +1,4 @@
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
package org.maxgamer.QuickShop.Watcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -8,7 +8,7 @@ import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
|
||||
public class LogWatcher implements Runnable {
|
||||
private PrintStream ps;
|
@ -1,30 +0,0 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import com.dthielke.herochat.ChannelChatEvent;
|
||||
import com.dthielke.herochat.Chatter.Result;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Netherfoam
|
||||
*
|
||||
*/
|
||||
public class HeroChatListener implements Listener {
|
||||
QuickShop plugin;
|
||||
|
||||
public HeroChatListener(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onHeroChat(ChannelChatEvent e) {
|
||||
if (!plugin.getShopManager().getActions().containsKey(e.getSender().getPlayer().getUniqueId()))
|
||||
return;
|
||||
plugin.getShopManager().handleChat(e.getSender().getPlayer(), e.getMessage());
|
||||
e.setResult(Result.FAIL);
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopChunk;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
QuickShop plugin;
|
||||
|
||||
public WorldListener(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent e) {
|
||||
/* *************************************
|
||||
* This listener fixes any broken world references. Such as hashmap
|
||||
* lookups will fail, because the World reference is different, but the
|
||||
* world value is the same. ************************************
|
||||
*/
|
||||
World world = e.getWorld();
|
||||
// New world data
|
||||
HashMap<ShopChunk, HashMap<Location, Shop>> inWorld = new HashMap<ShopChunk, HashMap<Location, Shop>>(1);
|
||||
// Old world data
|
||||
HashMap<ShopChunk, HashMap<Location, Shop>> oldInWorld = plugin.getShopManager().getShops(world.getName());
|
||||
// Nothing in the old world, therefore we don't care. No locations to
|
||||
// update.
|
||||
if (oldInWorld == null)
|
||||
return;
|
||||
for (Entry<ShopChunk, HashMap<Location, Shop>> oldInChunk : oldInWorld.entrySet()) {
|
||||
HashMap<Location, Shop> inChunk = new HashMap<Location, Shop>(1);
|
||||
// Put the new chunk were the old chunk was
|
||||
inWorld.put(oldInChunk.getKey(), inChunk);
|
||||
for (Entry<Location, Shop> entry : oldInChunk.getValue().entrySet()) {
|
||||
Shop shop = entry.getValue();
|
||||
shop.getLocation().setWorld(world);
|
||||
inChunk.put(shop.getLocation(), shop);
|
||||
}
|
||||
}
|
||||
// Done - Now we can store the new world dataz!
|
||||
plugin.getShopManager().getShops().put(world.getName(), inWorld);
|
||||
// This is a workaround, because I don't get parsed chunk events when a
|
||||
// world first loads....
|
||||
// So manually tell all of these shops they're loaded.
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk);
|
||||
if (inChunk == null)
|
||||
continue;
|
||||
for (Shop shop : inChunk.values()) {
|
||||
shop.onLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent e) {
|
||||
// This is a workaround, because I don't get parsed chunk events when a
|
||||
// world unloads, I think...
|
||||
// So manually tell all of these shops they're unloaded.
|
||||
for (Chunk chunk : e.getWorld().getLoadedChunks()) {
|
||||
HashMap<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk);
|
||||
if (inChunk == null)
|
||||
continue;
|
||||
for (Shop shop : inChunk.values()) {
|
||||
shop.onUnload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,260 +0,0 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
public class NMS {
|
||||
private static ArrayList<NMSDependent> dependents = new ArrayList<NMSDependent>();
|
||||
private static int nextId = 0;
|
||||
private static NMSDependent nms;
|
||||
|
||||
static {
|
||||
NMSDependent dep;
|
||||
dep = new NMSDependent("v1_6_R3") {
|
||||
@Override
|
||||
public void safeGuard(Item item) {
|
||||
org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
net.minecraft.server.v1_6_R3.ItemStack nmsI = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
nmsI.count = 0;
|
||||
iStack = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
item.setItemStack(iStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
net.minecraft.server.v1_6_R3.ItemStack is = org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
net.minecraft.server.v1_6_R3.NBTTagCompound itemCompound = new net.minecraft.server.v1_6_R3.NBTTagCompound();
|
||||
itemCompound = is.save(itemCompound);
|
||||
return net.minecraft.server.v1_6_R3.NBTCompressedStreamTools.a(itemCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
net.minecraft.server.v1_6_R3.NBTTagCompound c = net.minecraft.server.v1_6_R3.NBTCompressedStreamTools.a(bytes);
|
||||
net.minecraft.server.v1_6_R3.ItemStack is = net.minecraft.server.v1_6_R3.ItemStack.createStack(c);
|
||||
return org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
}
|
||||
};
|
||||
dependents.add(dep);
|
||||
dep = new NMSDependent("v1_7_R1") {
|
||||
@Override
|
||||
public void safeGuard(Item item) {
|
||||
if(QuickShop.debug)System.out.println("safeGuard");
|
||||
org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
net.minecraft.server.v1_7_R1.ItemStack nmsI = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
nmsI.count = 0;
|
||||
iStack = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
item.setItemStack(iStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
net.minecraft.server.v1_7_R1.ItemStack is = org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
net.minecraft.server.v1_7_R1.NBTTagCompound itemCompound = new net.minecraft.server.v1_7_R1.NBTTagCompound();
|
||||
itemCompound = is.save(itemCompound);
|
||||
return net.minecraft.server.v1_7_R1.NBTCompressedStreamTools.a(itemCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
if(QuickShop.debug)System.out.println("getItemStack");
|
||||
net.minecraft.server.v1_7_R1.NBTTagCompound c = net.minecraft.server.v1_7_R1.NBTCompressedStreamTools.a(bytes);
|
||||
net.minecraft.server.v1_7_R1.ItemStack is = net.minecraft.server.v1_7_R1.ItemStack.createStack(c);
|
||||
return org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
}
|
||||
};
|
||||
dependents.add(dep);
|
||||
dep = new NMSDependent("v1_7_R3") {
|
||||
@Override
|
||||
public void safeGuard(Item item) {
|
||||
if(QuickShop.debug)System.out.println("safeGuard");
|
||||
org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
net.minecraft.server.v1_7_R3.ItemStack nmsI = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
nmsI.count = 0;
|
||||
iStack = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
item.setItemStack(iStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
net.minecraft.server.v1_7_R3.ItemStack is = org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
net.minecraft.server.v1_7_R3.NBTTagCompound itemCompound = new net.minecraft.server.v1_7_R3.NBTTagCompound();
|
||||
itemCompound = is.save(itemCompound);
|
||||
return net.minecraft.server.v1_7_R3.NBTCompressedStreamTools.a(itemCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
if(QuickShop.debug)System.out.println("getItemStack");
|
||||
net.minecraft.server.v1_7_R3.NBTTagCompound c = net.minecraft.server.v1_7_R3.NBTCompressedStreamTools.a(bytes, null);
|
||||
net.minecraft.server.v1_7_R3.ItemStack is = net.minecraft.server.v1_7_R3.ItemStack.createStack(c);
|
||||
return org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
}
|
||||
};
|
||||
dependents.add(dep);
|
||||
dep = new NMSDependent("v1_8") {
|
||||
@Override
|
||||
public void safeGuard(Item item) {
|
||||
if(QuickShop.debug)System.out.println("safeGuard");
|
||||
org.bukkit.inventory.ItemStack iStack = item.getItemStack();
|
||||
net.minecraft.server.v1_8_R1.ItemStack nmsI = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
nmsI.count = 0;
|
||||
iStack = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asBukkitCopy(nmsI);
|
||||
item.setItemStack(iStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) {
|
||||
try{
|
||||
if(QuickShop.debug)System.out.println("getNBTBytes");
|
||||
net.minecraft.server.v1_8_R1.ItemStack is = org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asNMSCopy(iStack);
|
||||
net.minecraft.server.v1_8_R1.NBTTagCompound itemCompound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
|
||||
itemCompound = is.save(itemCompound);
|
||||
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(bytearrayoutputstream));
|
||||
try {
|
||||
net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(itemCompound, (DataOutput) dataoutputstream);
|
||||
} finally {
|
||||
dataoutputstream.close();
|
||||
}
|
||||
return bytearrayoutputstream.toByteArray();
|
||||
}catch(Exception e){
|
||||
return new byte[0];
|
||||
}
|
||||
//return net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(itemCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getItemStack(byte[] bytes) {
|
||||
try{
|
||||
if(QuickShop.debug)System.out.println("getItemStack");
|
||||
DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes))));
|
||||
net.minecraft.server.v1_8_R1.NBTTagCompound nbttagcompound;
|
||||
try {
|
||||
nbttagcompound = net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a((DataInput) datainputstream, null);
|
||||
} finally {
|
||||
datainputstream.close();
|
||||
}
|
||||
//net.minecraft.server.v1_8_R1.NBTTagCompound c = net.minecraft.server.v1_8_R1.NBTCompressedStreamTools.a(bytes, null);
|
||||
net.minecraft.server.v1_8_R1.ItemStack is = net.minecraft.server.v1_8_R1.ItemStack.createStack(nbttagcompound);
|
||||
return org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack.asBukkitCopy(is);
|
||||
}catch(Exception e){
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
};
|
||||
dependents.add(dep);
|
||||
}
|
||||
|
||||
public static void safeGuard(Item item) throws ClassNotFoundException {
|
||||
if(QuickShop.debug)System.out.println("Renaming");
|
||||
rename(item.getItemStack());
|
||||
if(QuickShop.debug)System.out.println("Protecting");
|
||||
protect(item);
|
||||
if(QuickShop.debug)System.out.println("Seting pickup delay");
|
||||
item.setPickupDelay(2147483647);
|
||||
}
|
||||
|
||||
private static void rename(ItemStack iStack) {
|
||||
ItemMeta meta = iStack.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.RED + "QuickShop " + Util.getName(iStack) + " " + nextId++);
|
||||
iStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public static byte[] getNBTBytes(org.bukkit.inventory.ItemStack iStack) throws ClassNotFoundException {
|
||||
validate();
|
||||
return nms.getNBTBytes(iStack);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(byte[] bytes) throws ClassNotFoundException {
|
||||
validate();
|
||||
return nms.getItemStack(bytes);
|
||||
}
|
||||
|
||||
private static void protect(Item item) {
|
||||
try {
|
||||
Field itemField = item.getClass().getDeclaredField("item");
|
||||
itemField.setAccessible(true);
|
||||
Object nmsEntityItem = itemField.get(item);
|
||||
Method getItemStack;
|
||||
try {
|
||||
getItemStack = nmsEntityItem.getClass().getMethod("getItemStack", new Class[0]);
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
getItemStack = nmsEntityItem.getClass().getMethod("d", new Class[0]);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Object itemStack = getItemStack.invoke(nmsEntityItem, new Object[0]);
|
||||
Field countField;
|
||||
try {
|
||||
countField = itemStack.getClass().getDeclaredField("count");
|
||||
} catch (NoSuchFieldException e) {
|
||||
countField = itemStack.getClass().getDeclaredField("a");
|
||||
}
|
||||
countField.setAccessible(true);
|
||||
countField.set(itemStack, Integer.valueOf(0));
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("[QuickShop] Could not protect item from pickup properly! Dupes are now possible.");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Other error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void validate() throws ClassNotFoundException {
|
||||
if (nms != null) {
|
||||
return;
|
||||
}
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
packageName = packageName.substring(packageName.lastIndexOf(".") + 1);
|
||||
// System.out.println("Package: " + packageName);
|
||||
for (NMSDependent dep : dependents) {
|
||||
if ((packageName.startsWith(dep.getVersion())) || ((dep.getVersion().isEmpty()) && ((packageName.equals("bukkit")) || (packageName.equals("craftbukkit"))))) {
|
||||
nms = dep;
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ClassNotFoundException("This version of QuickShop is incompatible.");
|
||||
}
|
||||
|
||||
private static abstract class NMSDependent {
|
||||
private String version;
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public NMSDependent(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public abstract void safeGuard(Item paramItem);
|
||||
|
||||
public abstract byte[] getNBTBytes(org.bukkit.inventory.ItemStack paramItemStack);
|
||||
|
||||
public abstract org.bukkit.inventory.ItemStack getItemStack(byte[] paramArrayOfByte);
|
||||
}
|
||||
}
|
347
src/main/resources/item.yml
Normal file
347
src/main/resources/item.yml
Normal file
@ -0,0 +1,347 @@
|
||||
version: 1.2
|
||||
AIR_-1: 爪子
|
||||
AIR: 爪子
|
||||
STONE: 石头
|
||||
GRASS: 草方块
|
||||
DIRT: 泥土
|
||||
COBBLESTONE: 圆石
|
||||
WOOD: 木板
|
||||
SAPLING: 树苗
|
||||
BEDROCK: 基岩
|
||||
WATER: 水
|
||||
STATIONARY_WATER: 静态的水
|
||||
LAVA: 岩浆
|
||||
STATIONARY_LAVA: 静态的岩浆
|
||||
SAND: 沙子
|
||||
GRAVEL: 沙砾
|
||||
GOLD_ORE: 金矿石
|
||||
IRON_ORE: 铁矿石
|
||||
COAL_ORE: 煤矿石
|
||||
LOG: 橡木
|
||||
LEAVES: 橡木树叶
|
||||
SPONGE: 海绵
|
||||
GLASS: 玻璃
|
||||
LAPIS_ORE: 青金石矿石
|
||||
LAPIS_BLOCK: 青金石块
|
||||
DISPENSER: 发射器
|
||||
SANDSTONE: 沙石
|
||||
NOTE_BLOCK: 音符盒
|
||||
BED_BLOCK: BED_BLOCK
|
||||
POWERED_RAIL: 动力铁轨
|
||||
DETECTOR_RAIL: 探测铁轨
|
||||
PISTON_STICKY_BASE: 粘性活塞
|
||||
WEB: 蜘蛛网
|
||||
LONG_GRASS: 灌木
|
||||
DEAD_BUSH: 枯死的灌木
|
||||
PISTON_BASE: 活塞
|
||||
PISTON_EXTENSION: 活塞帽
|
||||
WOOL: 羊毛
|
||||
PISTON_MOVING_PIECE: PISTON_MOVING_PIECE
|
||||
YELLOW_FLOWER: 蒲公英
|
||||
RED_ROSE: 罂粟
|
||||
BROWN_MUSHROOM: 棕色蘑菇
|
||||
RED_MUSHROOM: 红色蘑菇
|
||||
GOLD_BLOCK: 金块
|
||||
IRON_BLOCK: 铁块
|
||||
DOUBLE_STEP: 石台阶(两层)
|
||||
STEP: 石台阶
|
||||
BRICK: 砖块
|
||||
TNT: TNT
|
||||
BOOKSHELF: 书架
|
||||
MOSSY_COBBLESTONE: 苔石
|
||||
OBSIDIAN: 黑曜石
|
||||
TORCH: 火把
|
||||
FIRE: 火
|
||||
MOB_SPAWNER: 刷怪笼
|
||||
WOOD_STAIRS: 橡木楼梯
|
||||
CHEST: 箱子
|
||||
REDSTONE_WIRE: 红石粉
|
||||
DIAMOND_ORE: 钻石原矿
|
||||
DIAMOND_BLOCK: 钻石块
|
||||
WORKBENCH: 工作台
|
||||
CROPS: 农作物
|
||||
SOIL: 耕地
|
||||
FURNACE: 熔炉
|
||||
BURNING_FURNACE: 燃烧的熔炉
|
||||
SIGN_POST: 木牌
|
||||
WOODEN_DOOR: 橡木门
|
||||
LADDER: 梯子
|
||||
RAILS: 铁轨
|
||||
COBBLESTONE_STAIRS: 圆石台阶
|
||||
WALL_SIGN: 墙上的木牌
|
||||
LEVER: 拉杆
|
||||
STONE_PLATE: 石质压力板
|
||||
IRON_DOOR_BLOCK: 铁门
|
||||
WOOD_PLATE: 木质压力板
|
||||
REDSTONE_ORE: 红石原矿
|
||||
GLOWING_REDSTONE_ORE: 采集中的红石原矿
|
||||
REDSTONE_TORCH_OFF: 红石火把(关闭)
|
||||
REDSTONE_TORCH_ON: 红石火把(打开)
|
||||
STONE_BUTTON: 石按钮
|
||||
SNOW: 雪
|
||||
ICE: 冰
|
||||
SNOW_BLOCK: 雪块
|
||||
CACTUS: 仙人掌
|
||||
CLAY: 粘土
|
||||
SUGAR_CANE_BLOCK: SUGAR_CANE_BLOCK
|
||||
JUKEBOX: 唱片机
|
||||
FENCE: 栅栏
|
||||
PUMPKIN: 南瓜
|
||||
NETHERRACK: 地狱岩
|
||||
SOUL_SAND: 灵魂沙
|
||||
GLOWSTONE: 萤石
|
||||
PORTAL: 传送门
|
||||
JACK_O_LANTERN: 南瓜灯
|
||||
CAKE_BLOCK: 蛋糕
|
||||
DIODE_BLOCK_OFF: DIODE_BLOCK_OFF
|
||||
DIODE_BLOCK_ON: DIODE_BLOCK_ON
|
||||
LOCKED_CHEST: 上锁的箱子
|
||||
STAINED_GLASS: 白色染色玻璃
|
||||
TRAP_DOOR: 活板门
|
||||
MONSTER_EGGS: 石头刷怪蛋
|
||||
SMOOTH_BRICK: 石砖
|
||||
HUGE_MUSHROOM_1: 蘑菇
|
||||
HUGE_MUSHROOM_2: 蘑菇
|
||||
IRON_FENCE: 铁栅栏
|
||||
THIN_GLASS: 玻璃板
|
||||
MELON_BLOCK: 西瓜方块
|
||||
PUMPKIN_STEM: 南瓜种子
|
||||
MELON_STEM: 西瓜种子
|
||||
VINE: 藤蔓
|
||||
FENCE_GATE: 栅栏门
|
||||
BRICK_STAIRS: 砖楼梯
|
||||
SMOOTH_STAIRS: 石砖楼梯
|
||||
MYCEL: 菌丝
|
||||
WATER_LILY: 睡莲
|
||||
NETHER_BRICK: 地狱砖块
|
||||
NETHER_FENCE: 地狱栅栏
|
||||
NETHER_BRICK_STAIRS: 地狱砖楼梯
|
||||
NETHER_WARTS: NETHER_WARTS
|
||||
ENCHANTMENT_TABLE: 附魔台
|
||||
BREWING_STAND: BREWING_STAND
|
||||
CAULDRON: CAULDRON
|
||||
ENDER_PORTAL: 末地传送门
|
||||
ENDER_PORTAL_FRAME: 末地传送框架
|
||||
ENDER_STONE: 末地石
|
||||
DRAGON_EGG: 龙蛋
|
||||
REDSTONE_LAMP_OFF: 红石灯(关闭)
|
||||
REDSTONE_LAMP_ON: 红石灯(打开)
|
||||
WOOD_DOUBLE_STEP: 橡木台阶(两层)
|
||||
WOOD_STEP: 橡木台阶
|
||||
COCOA: 可可豆
|
||||
SANDSTONE_STAIRS: 沙石台阶
|
||||
EMERALD_ORE: 绿宝石矿石
|
||||
ENDER_CHEST: 末影箱
|
||||
TRIPWIRE_HOOK: 绊线钩
|
||||
TRIPWIRE: 绊线钩
|
||||
EMERALD_BLOCK: 绿宝石块
|
||||
SPRUCE_WOOD_STAIRS: 云杉木楼梯
|
||||
BIRCH_WOOD_STAIRS: 桦木楼梯
|
||||
JUNGLE_WOOD_STAIRS: 丛林木楼梯
|
||||
COMMAND: 命令方块
|
||||
BEACON: 信标
|
||||
COBBLE_WALL: 圆石墙
|
||||
FLOWER_POT: FLOWER_POT
|
||||
CARROT: 胡萝卜
|
||||
POTATO: 土豆
|
||||
WOOD_BUTTON: 木按钮
|
||||
SKULL: SKULL
|
||||
ANVIL: 铁毡
|
||||
TRAPPED_CHEST: TRAPPED_CHEST
|
||||
GOLD_PLATE: 测重压力板(轻质)
|
||||
IRON_PLATE: 测重压力板(重质)
|
||||
REDSTONE_COMPARATOR_OFF: 红石比较器(关闭)
|
||||
REDSTONE_COMPARATOR_ON: 红石比较器(打开)
|
||||
DAYLIGHT_DETECTOR: 阳光传感器
|
||||
REDSTONE_BLOCK: 红石块
|
||||
QUARTZ_ORE: 下界石英矿石
|
||||
HOPPER: 漏洞
|
||||
QUARTZ_BLOCK: 石英块
|
||||
QUARTZ_STAIRS: 石英楼梯
|
||||
ACTIVATOR_RAIL: 激活铁轨
|
||||
DROPPER: 掉落物
|
||||
STAINED_CLAY: 白色染色粘土
|
||||
STAINED_GLASS_PANE: 白色染色玻璃板
|
||||
LEAVES_2: 合金欢树叶
|
||||
LOG_2: 合金欢木
|
||||
ACACIA_STAIRS: 合金欢楼梯
|
||||
DARK_OAK_STAIRS: 深色橡木楼梯
|
||||
HAY_BLOCK: 干草快
|
||||
CARPET: 白色地毯
|
||||
HARD_CLAY: 硬化粘土
|
||||
COAL_BLOCK: 煤炭快
|
||||
PACKED_ICE: 浮冰
|
||||
DOUBLE_PLANT: 向日葵
|
||||
IRON_SPADE: 铁楸
|
||||
IRON_PICKAXE: 铁镐
|
||||
IRON_AXE: 铁斧
|
||||
FLINT_AND_STEEL: 打火石
|
||||
APPLE: 苹果
|
||||
BOW: 弓
|
||||
ARROW: 箭
|
||||
COAL: 煤炭
|
||||
DIAMOND: 钻石
|
||||
IRON_INGOT: 铁锭
|
||||
GOLD_INGOT: 金锭
|
||||
IRON_SWORD: 铁剑
|
||||
WOOD_SWORD: 木剑
|
||||
WOOD_SPADE: 木楸
|
||||
WOOD_PICKAXE: 木稿
|
||||
WOOD_AXE: 木斧
|
||||
STONE_SWORD: 石剑
|
||||
STONE_SPADE: 石楸
|
||||
STONE_PICKAXE: 石稿
|
||||
STONE_AXE: 石斧
|
||||
DIAMOND_SWORD: 钻石剑
|
||||
DIAMOND_SPADE: 钻石楸
|
||||
DIAMOND_PICKAXE: 钻石稿
|
||||
DIAMOND_AXE: 钻石斧
|
||||
STICK: 木棍
|
||||
BOWL: 碗
|
||||
MUSHROOM_SOUP: 蘑菇煲
|
||||
GOLD_SWORD: 金剑
|
||||
GOLD_SPADE: 金楸
|
||||
GOLD_PICKAXE: 金稿
|
||||
GOLD_AXE: 金锄
|
||||
STRING: 线
|
||||
FEATHER: 羽毛
|
||||
SULPHUR: 火药
|
||||
WOOD_HOE: 木锄
|
||||
STONE_HOE: 石锄
|
||||
IRON_HOE: 铁锄
|
||||
DIAMOND_HOE: 钻石锄
|
||||
GOLD_HOE: 金锄
|
||||
SEEDS: 种子
|
||||
WHEAT: 小麦
|
||||
BREAD: 面包
|
||||
LEATHER_HELMET: 皮革帽子
|
||||
LEATHER_CHESTPLATE: 皮革外套
|
||||
LEATHER_LEGGINGS: 皮革护腿
|
||||
LEATHER_BOOTS: 皮革靴子
|
||||
CHAINMAIL_HELMET: 锁链帽子
|
||||
CHAINMAIL_CHESTPLATE: 锁链外套
|
||||
CHAINMAIL_LEGGINGS: 锁链护腿
|
||||
CHAINMAIL_BOOTS: 锁链靴子
|
||||
IRON_HELMET: 铁帽子
|
||||
IRON_CHESTPLATE: 铁外套
|
||||
IRON_LEGGINGS: 铁护腿
|
||||
IRON_BOOTS: 铁靴子
|
||||
DIAMOND_HELMET: 钻石帽子
|
||||
DIAMOND_CHESTPLATE: 钻石外套
|
||||
DIAMOND_LEGGINGS: 钻石护腿
|
||||
DIAMOND_BOOTS: 钻石靴子
|
||||
GOLD_HELMET: 金帽子
|
||||
GOLD_CHESTPLATE: 金外套
|
||||
GOLD_LEGGINGS: 金护腿
|
||||
GOLD_BOOTS: 金靴子
|
||||
FLINT: 燧石
|
||||
PORK: 猪排
|
||||
GRILLED_PORK: GRILLED_PORK
|
||||
PAINTING: 画
|
||||
GOLDEN_APPLE: 金苹果
|
||||
SIGN: 木牌
|
||||
WOOD_DOOR: 木门
|
||||
BUCKET: 桶
|
||||
WATER_BUCKET: 水桶
|
||||
LAVA_BUCKET: 岩浆桶
|
||||
MINECART: 矿车
|
||||
SADDLE: SADDLE
|
||||
IRON_DOOR: 铁门
|
||||
REDSTONE: 红石
|
||||
SNOW_BALL: 雪球
|
||||
BOAT: 船
|
||||
LEATHER: 皮革
|
||||
MILK_BUCKET: 牛奶桶
|
||||
CLAY_BRICK: CLAY_BRICK
|
||||
CLAY_BALL: 粘土
|
||||
SUGAR_CANE: 甘蔗
|
||||
PAPER: 纸
|
||||
BOOK: 书
|
||||
SLIME_BALL: 史莱姆球
|
||||
STORAGE_MINECART: 运输矿车
|
||||
POWERED_MINECART: 动力矿车
|
||||
EGG: 鸡蛋
|
||||
COMPASS: 指南针
|
||||
FISHING_ROD: 鱼竿
|
||||
WATCH: 钟
|
||||
GLOWSTONE_DUST: 萤石粉
|
||||
RAW_FISH: 生鱼
|
||||
COOKED_FISH: 熟鱼
|
||||
INK_SACK: 墨囊
|
||||
BONE: 骨粉
|
||||
SUGAR: 糖
|
||||
CAKE: 蛋糕
|
||||
BED: 床
|
||||
DIODE: 红石中继器
|
||||
COOKIE: 曲奇
|
||||
MAP: 地图
|
||||
SHEARS: 剪刀
|
||||
MELON: 西瓜
|
||||
PUMPKIN_SEEDS: 南瓜种子
|
||||
MELON_SEEDS: 西瓜种子
|
||||
RAW_BEEF: 生牛肉
|
||||
COOKED_BEEF: 熟牛肉
|
||||
RAW_CHICKEN: 生鸡肉
|
||||
COOKED_CHICKEN: 熟鸡肉
|
||||
ROTTEN_FLESH: 腐肉
|
||||
ENDER_PEARL: 末地传送门
|
||||
BLAZE_ROD: 烈焰棒
|
||||
GHAST_TEAR: 恶魂之泪
|
||||
GOLD_NUGGET: 金粒
|
||||
NETHER_STALK: NETHER_STALK
|
||||
POTION: 药水
|
||||
GLASS_BOTTLE: 玻璃瓶
|
||||
SPIDER_EYE: 蜘蛛眼
|
||||
FERMENTED_SPIDER_EYE: 发酵蛛眼
|
||||
BLAZE_POWDER: BLAZE_POWDER
|
||||
MAGMA_CREAM: MAGMA_CREAM
|
||||
BREWING_STAND_ITEM: 酿造台
|
||||
CAULDRON_ITEM: 炼药锅
|
||||
BREWING_STAND: 酿造台
|
||||
CAULDRON: 炼药锅
|
||||
EYE_OF_ENDER: 末影之眼
|
||||
SPECKLED_MELON: 闪烁的西瓜
|
||||
MONSTER_EGG: 刷怪蛋
|
||||
EXP_BOTTLE: 附魔之瓶
|
||||
FIREBALL: 火焰弹
|
||||
BOOK_AND_QUILL: 书和笔
|
||||
WRITTEN_BOOK: 成书
|
||||
EMERALD: 绿宝石
|
||||
ITEM_FRAME: 物品展示框
|
||||
FLOWER_POT_ITEM: FLOWER_POT_ITEM
|
||||
CARROT_ITEM: 胡萝卜
|
||||
POTATO_ITEM: 马铃薯
|
||||
BAKED_POTATO: 烤马铃薯
|
||||
POISONOUS_POTATO: 毒马铃薯
|
||||
EMPTY_MAP: 空地图
|
||||
GOLDEN_CARROT: 金萝卜
|
||||
SKULL_ITEM: 头颅
|
||||
CARROT_STICK: CARROT_STICK
|
||||
NETHER_STAR: 下界之星
|
||||
PUMPKIN_PIE: 南瓜派
|
||||
FIREWORK: 烟花
|
||||
FIREWORK_CHARGE: FIREWORK_CHARGE
|
||||
ENCHANTED_BOOK: 附魔书
|
||||
REDSTONE_COMPARATOR: 红石比较器
|
||||
NETHER_BRICK_ITEM: 地狱砖块
|
||||
QUARTZ: 石英
|
||||
EXPLOSIVE_MINECART: TNT矿车
|
||||
HOPPER_MINECART: 漏斗矿车
|
||||
IRON_BARDING: 铁马凯
|
||||
GOLD_BARDING: 金马凯
|
||||
DIAMOND_BARDING: 钻石马凯
|
||||
LEASH: 栓绳
|
||||
NAME_TAG: 命名牌
|
||||
COMMAND_MINECART: 命令方块
|
||||
GOLD_RECORD: 音乐唱片
|
||||
GREEN_RECORD: 音乐唱片
|
||||
RECORD_3: 音乐唱片
|
||||
RECORD_4: 音乐唱片
|
||||
RECORD_5: 音乐唱片
|
||||
RECORD_6: 音乐唱片
|
||||
RECORD_7: 音乐唱片
|
||||
RECORD_8: 音乐唱片
|
||||
RECORD_9: 音乐唱片
|
||||
RECORD_10: 音乐唱片
|
||||
RECORD_11: 音乐唱片
|
||||
RECORD_12: 音乐唱片
|
@ -2,103 +2,97 @@
|
||||
# &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"
|
||||
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库存清理成功"
|
||||
|
||||
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"
|
||||
successful-purchase: "&a商品购买成功:"
|
||||
successfully-sold: "&a商品出售成功:"
|
||||
item-name-and-price: "&a花费:&e{2} &a获得 &e{0} &a件 &e{1} &a商品"
|
||||
|
||||
shop-information: "&aShop Information:"
|
||||
owner: "&aOwner: {0}"
|
||||
item: "&aItem: &e{0}"
|
||||
shop-information: "&a商店信息:"
|
||||
owner: "&a所有者: {0}"
|
||||
item: "&a物品: &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."
|
||||
stock: "&a库存: &e{0}"
|
||||
price-per: "&a每件 &e{0} 的价格 &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 商品."
|
||||
|
||||
bypassing-lock: "&c无视快捷商店锁!"
|
||||
that-is-locked: "&c此商店已上锁."
|
||||
|
||||
bypassing-lock: "&cBypassing a QuickShop lock!"
|
||||
that-is-locked: "&cThat shop is locked."
|
||||
how-many-buy: "&a请输入 &b购买商品数量&a 在聊天栏."
|
||||
how-many-sell: "&a请输入 &d出售商品数量&a 在聊天栏. 你目前有 &e{0}&a 件物品"
|
||||
|
||||
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."
|
||||
not-allowed-to-create: "&c你不能在这里创建商店."
|
||||
blacklisted-item: "&c此物品在快捷商店黑名单内. 你不能出售它"
|
||||
how-much-to-trade-for: "&a请输入物品 &e{0}&a 的价格在聊天栏开始&c出售商品."
|
||||
|
||||
command:
|
||||
#success-created-unlimited: "&aUnlimited QuickShop created."
|
||||
toggle-unlimited: "&aShop is now {0}"
|
||||
no-owner-given: "&cNo owner given. Use &a/qs setowner <player>&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 <item>"
|
||||
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: "&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"
|
||||
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清空一个商店的所有货物"
|
||||
|
||||
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: "Selling {0}"
|
||||
buying: "Buying {0}"
|
||||
price: "For {0} each"
|
||||
selling: "出售数量: {0}"
|
||||
buying: "收购数量: {0}"
|
||||
price: "每件价格: ${0}"
|
@ -1,10 +1,9 @@
|
||||
name: ${name}
|
||||
main: ${package}.${name}
|
||||
version: ${version}
|
||||
author: Netherfoam, Timtower, KaiNoMood
|
||||
|
||||
description: Economy Shops plugin
|
||||
softdepend: [Herochat, Vault]
|
||||
name: ${project.artifactId}
|
||||
description: ${project.description}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
version: ${project.version}
|
||||
authors: [Netherfoam,Timtower, KaiNoMood,喵♂呜]
|
||||
softdepend: [Vault]
|
||||
|
||||
commands:
|
||||
qs:
|
||||
|
Loading…
Reference in New Issue
Block a user