mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-23 18:45:31 +01:00
commit
5a39b6fd62
@ -1,6 +1,8 @@
|
|||||||
ChestShop
|
ChestShop
|
||||||
================================
|
================================
|
||||||
|
|
||||||
|
My fork of ChestShop. Downloads can be found here: [http://ci.dmulloy2.net/job/ChestShop](http://ci.dmulloy2.net/job/ChestShop)
|
||||||
|
|
||||||
ChestShop is an awesome plugin for managing your server's economy.
|
ChestShop is an awesome plugin for managing your server's economy.
|
||||||
By using chests and signs, you can effectively create your own market!
|
By using chests and signs, you can effectively create your own market!
|
||||||
|
|
||||||
@ -28,6 +30,4 @@ To install external dependencies, place your .jar into the main folder and launc
|
|||||||
|
|
||||||
Links
|
Links
|
||||||
--------------------------------
|
--------------------------------
|
||||||
* [Forum Thread](http://forums.bukkit.org/threads/4150/)
|
* [Downloads](http://ci.dmulloy2.net/job/ChestShop)
|
||||||
* [BukkitDev site](http://dev.bukkit.org/server-mods/chestshop/)
|
|
||||||
* [Bug Tracker](http://dev.bukkit.org/server-mods/chestshop/tickets/?status=+)
|
|
||||||
|
41
pom.xml
41
pom.xml
@ -10,9 +10,9 @@
|
|||||||
<description>Chest-and-sign shop plugin for Bukkit</description>
|
<description>Chest-and-sign shop plugin for Bukkit</description>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/Acrobot/ChestShop-3</connection>
|
<connection>scm:git:git://github.com/dmulloy2/ChestShop-3</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/Acrobot/ChestShop-3.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/dmulloy2/ChestShop-3.git</developerConnection>
|
||||||
<url>https://github.com/Acrobot/ChestShop-3</url>
|
<url>https://github.com/dmulloy2/ChestShop-3</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -30,11 +30,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>vault-repo</id>
|
<id>vault-repo</id>
|
||||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>heroes-repo</id>
|
|
||||||
<url>http://nexus.theyeticave.net/content/repositories/pub_snapshots/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>authme-repo</id>
|
<id>authme-repo</id>
|
||||||
@ -69,9 +65,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.11-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -95,7 +91,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>Vault</artifactId>
|
<artifactId>Vault</artifactId>
|
||||||
<version>1.5.2</version>
|
<version>1.6.6</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -130,16 +126,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.herocraftonline.heroes</groupId>
|
<groupId>com.herocraftonline.heroes</groupId>
|
||||||
<artifactId>Heroes</artifactId>
|
<artifactId>Heroes</artifactId>
|
||||||
<version>1.5.5.6-SNAPSHOT</version>
|
<version>1.5.5</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>*</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>*</artifactId>
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -241,11 +233,10 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t00thpick1</groupId>
|
<groupId>com.bekvon.bukkit.residence</groupId>
|
||||||
<artifactId>residence</artifactId>
|
<artifactId>Residence</artifactId>
|
||||||
<version>3.0.0q-SNAPSHOT</version>
|
<version>4.5.3.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -274,8 +265,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package com.Acrobot.Breeze.Configuration;
|
package com.Acrobot.Breeze.Configuration;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.*;
|
import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class which can be used to make configs easier to load
|
* A class which can be used to make configs easier to load
|
||||||
@ -71,18 +76,13 @@ public class Configuration {
|
|||||||
* @return If the file ends with space
|
* @return If the file ends with space
|
||||||
*/
|
*/
|
||||||
public static boolean endsWithSpace(File file) {
|
public static boolean endsWithSpace(File file) {
|
||||||
try {
|
try (Scanner scanner = new Scanner(file)) {
|
||||||
Scanner scanner = new Scanner(file);
|
|
||||||
String lastLine = "";
|
String lastLine = "";
|
||||||
|
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
lastLine = scanner.nextLine();
|
lastLine = scanner.nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanner != null) {
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastLine.isEmpty();
|
return lastLine.isEmpty();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package com.Acrobot.Breeze.Database;
|
package com.Acrobot.Breeze.Database;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database class, which can be used to connect to JDBC
|
* Database class, which can be used to connect to JDBC
|
||||||
*
|
*
|
||||||
@ -49,7 +50,7 @@ public class Database {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String tableName = ((javax.persistence.Table) clazz.getAnnotation(javax.persistence.Table.class)).name();
|
String tableName = clazz.getAnnotation(javax.persistence.Table.class).name();
|
||||||
Table table = getTable(tableName);
|
Table table = getTable(tableName);
|
||||||
|
|
||||||
EntityParser parser = new EntityParser(clazz);
|
EntityParser parser = new EntityParser(clazz);
|
||||||
|
@ -406,7 +406,7 @@ public class Base64 {
|
|||||||
|
|
||||||
byte[] ALPHABET = getAlphabet(options);
|
byte[] ALPHABET = getAlphabet(options);
|
||||||
|
|
||||||
// 1 2 3
|
// 1 2 3
|
||||||
// 01234567890123456789012345678901 Bit position
|
// 01234567890123456789012345678901 Bit position
|
||||||
// --------000000001111111122222222 Array position from threeBytes
|
// --------000000001111111122222222 Array position from threeBytes
|
||||||
// --------| || || || | Six bit groups to index ALPHABET
|
// --------| || || || | Six bit groups to index ALPHABET
|
||||||
@ -1106,8 +1106,8 @@ public class Base64 {
|
|||||||
else {
|
else {
|
||||||
// There's a bad input character in the Base64 stream.
|
// There's a bad input character in the Base64 stream.
|
||||||
throw new java.io.IOException(String.format(
|
throw new java.io.IOException(String.format(
|
||||||
"Bad Base64 input character decimal %d in array position %d", ((int) source[i]) & 0xFF, i));
|
"Bad Base64 input character decimal %d in array position %d", (source[i]) & 0xFF, i));
|
||||||
} // end else:
|
} // end else:
|
||||||
} // each input character
|
} // each input character
|
||||||
|
|
||||||
byte[] out = new byte[outBuffPosn];
|
byte[] out = new byte[outBuffPosn];
|
||||||
@ -1164,7 +1164,7 @@ public class Base64 {
|
|||||||
boolean dontGunzip = (options & DONT_GUNZIP) != 0;
|
boolean dontGunzip = (options & DONT_GUNZIP) != 0;
|
||||||
if ((bytes != null) && (bytes.length >= 4) && (!dontGunzip)) {
|
if ((bytes != null) && (bytes.length >= 4) && (!dontGunzip)) {
|
||||||
|
|
||||||
int head = ((int) bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
|
int head = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
|
||||||
if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
|
if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
|
||||||
java.io.ByteArrayInputStream bais = null;
|
java.io.ByteArrayInputStream bais = null;
|
||||||
java.util.zip.GZIPInputStream gzis = null;
|
java.util.zip.GZIPInputStream gzis = null;
|
||||||
@ -1515,7 +1515,7 @@ public class Base64 {
|
|||||||
out.close();
|
out.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
} // end finally
|
} // end finally
|
||||||
} // end encodeFileToFile
|
} // end encodeFileToFile
|
||||||
|
|
||||||
|
|
||||||
@ -1545,7 +1545,7 @@ public class Base64 {
|
|||||||
out.close();
|
out.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
} // end finally
|
} // end finally
|
||||||
} // end decodeFileToFile
|
} // end decodeFileToFile
|
||||||
|
|
||||||
|
|
||||||
@ -1683,7 +1683,7 @@ public class Base64 {
|
|||||||
else {
|
else {
|
||||||
// Must have broken out from above.
|
// Must have broken out from above.
|
||||||
throw new java.io.IOException("Improperly padded Base64 input.");
|
throw new java.io.IOException("Improperly padded Base64 input.");
|
||||||
} // end
|
} // end
|
||||||
|
|
||||||
} // end else: decode
|
} // end else: decode
|
||||||
} // end else: get data
|
} // end else: get data
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class InventoryUtil {
|
public class InventoryUtil {
|
||||||
|
private static Boolean legacyContents = null;
|
||||||
|
|
||||||
|
private static ItemStack[] getStorageContents(Inventory inventory) {
|
||||||
|
if (legacyContents == null) {
|
||||||
|
try {
|
||||||
|
inventory.getStorageContents();
|
||||||
|
legacyContents = false;
|
||||||
|
} catch (NoSuchMethodError e) {
|
||||||
|
legacyContents = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return legacyContents ? inventory.getContents() : inventory.getStorageContents();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of the item inside the inventory
|
* Returns the amount of the item inside the inventory
|
||||||
*
|
*
|
||||||
@ -49,7 +64,7 @@ public class InventoryUtil {
|
|||||||
* @return Is the inventory empty?
|
* @return Is the inventory empty?
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(Inventory inventory) {
|
public static boolean isEmpty(Inventory inventory) {
|
||||||
for (ItemStack stack : inventory.getContents()) {
|
for (ItemStack stack : getStorageContents(inventory)) {
|
||||||
if (!MaterialUtil.isEmpty(stack)) {
|
if (!MaterialUtil.isEmpty(stack)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -89,7 +104,7 @@ public class InventoryUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack iStack : inventory.getContents()) {
|
for (ItemStack iStack : getStorageContents(inventory)) {
|
||||||
if (left <= 0) {
|
if (left <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,7 +140,7 @@ public class InventoryUtil {
|
|||||||
|
|
||||||
int amountLeft = item.getAmount();
|
int amountLeft = item.getAmount();
|
||||||
|
|
||||||
for (int currentSlot = 0; currentSlot < inventory.getSize() && amountLeft > 0; currentSlot++) {
|
for (int currentSlot = 0; currentSlot < effectiveSize(inventory) && amountLeft > 0; currentSlot++) {
|
||||||
ItemStack currentItem = inventory.getItem(currentSlot);
|
ItemStack currentItem = inventory.getItem(currentSlot);
|
||||||
ItemStack duplicate = item.clone();
|
ItemStack duplicate = item.clone();
|
||||||
|
|
||||||
@ -152,6 +167,12 @@ public class InventoryUtil {
|
|||||||
return amountLeft;
|
return amountLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't use the armor slots or extra slots
|
||||||
|
private static int effectiveSize(Inventory inventory)
|
||||||
|
{
|
||||||
|
return getStorageContents(inventory).length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an item to the inventor
|
* Adds an item to the inventor
|
||||||
*
|
*
|
||||||
|
@ -38,11 +38,21 @@ import com.Acrobot.ChestShop.Signs.RestrictedSign;
|
|||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.Acrobot.ChestShop.Updater.Updater;
|
import com.Acrobot.ChestShop.Updater.Updater;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Marker;
|
||||||
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
|
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||||
|
import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||||
|
import org.apache.logging.log4j.message.Message;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.mcstats.Metrics;
|
import org.mcstats.Metrics;
|
||||||
@ -81,6 +91,7 @@ public class ChestShop extends JavaPlugin {
|
|||||||
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
||||||
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
||||||
|
|
||||||
|
turnOffDatabaseLogging();
|
||||||
handleMigrations();
|
handleMigrations();
|
||||||
|
|
||||||
itemDatabase = new ItemDatabase();
|
itemDatabase = new ItemDatabase();
|
||||||
@ -114,6 +125,46 @@ public class ChestShop extends JavaPlugin {
|
|||||||
startUpdater();
|
startUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void turnOffDatabaseLogging() {
|
||||||
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
|
org.apache.logging.log4j.core.config.Configuration config = ctx.getConfiguration();
|
||||||
|
LoggerConfig loggerConfig = config.getLoggerConfig("");
|
||||||
|
|
||||||
|
loggerConfig.addFilter(new AbstractFilter() {
|
||||||
|
@Override
|
||||||
|
public Result filter(org.apache.logging.log4j.core.Logger logger, Level level, Marker marker, String msg, Object... params) {
|
||||||
|
return filter(logger.getName(), level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result filter(org.apache.logging.log4j.core.Logger logger, Level level, Marker marker, Object msg, Throwable t) {
|
||||||
|
return filter(logger.getName(), level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result filter(org.apache.logging.log4j.core.Logger logger, Level level, Marker marker, Message msg, Throwable t) {
|
||||||
|
return filter(logger.getName(), level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result filter(LogEvent event) {
|
||||||
|
return filter(event.getLoggerName(), event.getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Result filter(String classname, Level level) {
|
||||||
|
if (level.isAtLeastAsSpecificAs(Level.ERROR) && !classname.contains("SqliteDatabaseType")) {
|
||||||
|
return Result.NEUTRAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classname.contains("SqliteDatabaseType") || classname.contains("TableUtils")) {
|
||||||
|
return Result.DENY;
|
||||||
|
} else {
|
||||||
|
return Result.NEUTRAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void handleMigrations() {
|
private void handleMigrations() {
|
||||||
File versionFile = loadFile("version");
|
File versionFile = loadFile("version");
|
||||||
YamlConfiguration previousVersion = YamlConfiguration.loadConfiguration(versionFile);
|
YamlConfiguration previousVersion = YamlConfiguration.loadConfiguration(versionFile);
|
||||||
@ -212,8 +263,9 @@ public class ChestShop extends JavaPlugin {
|
|||||||
|
|
||||||
registerEvent(new ItemInfoListener());
|
registerEvent(new ItemInfoListener());
|
||||||
registerEvent(new GarbageTextListener());
|
registerEvent(new GarbageTextListener());
|
||||||
|
|
||||||
if (this.getServer().getPluginManager().getPlugin("AuthMe") != null && this.getServer().getPluginManager().getPlugin("AuthMe").isEnabled()){
|
Plugin authMe = getServer().getPluginManager().getPlugin("AuthMe");
|
||||||
|
if (authMe != null && authMe.isEnabled()) {
|
||||||
registerEvent(new AuthMeChestShopListener());
|
registerEvent(new AuthMeChestShopListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,4 +137,4 @@ public class Properties {
|
|||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
|
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
|
||||||
public static double HEROES_EXP = 100;
|
public static double HEROES_EXP = 100;
|
||||||
}
|
}
|
@ -1,5 +1,11 @@
|
|||||||
package com.Acrobot.ChestShop.Containers;
|
package com.Acrobot.ChestShop.Containers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
@ -7,45 +13,49 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class AdminInventory implements Inventory {
|
public class AdminInventory implements Inventory {
|
||||||
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMaxStackSize() {
|
public int getMaxStackSize() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMaxStackSize(int i) {
|
public void setMaxStackSize(int i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Admin inventory";
|
return "Admin inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItem(int i) {
|
public ItemStack getItem(int i) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setItem(int i, ItemStack itemStack) {
|
public void setItem(int i, ItemStack itemStack) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
||||||
return new HashMap<Integer, ItemStack>();
|
return new HashMap<Integer, ItemStack>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
||||||
return new HashMap<Integer, ItemStack>();
|
return new HashMap<Integer, ItemStack>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
return new ItemStack[]{
|
return new ItemStack[]{
|
||||||
new ItemStack(Material.CHEST, 1),
|
new ItemStack(Material.CHEST, 1),
|
||||||
@ -53,37 +63,56 @@ public class AdminInventory implements Inventory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setContents(ItemStack[] itemStacks) {
|
public void setContents(ItemStack[] itemStacks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack[] getStorageContents() {
|
||||||
|
return new ItemStack[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStorageContents(ItemStack[] itemStacks) throws IllegalArgumentException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(int i) {
|
public boolean contains(int i) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(Material material) {
|
public boolean contains(Material material) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(ItemStack itemStack) {
|
public boolean contains(ItemStack itemStack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(int i, int i1) {
|
public boolean contains(int i, int i1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(Material material, int i) {
|
public boolean contains(Material material, int i) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(ItemStack itemStack, int i) {
|
public boolean contains(ItemStack itemStack, int i) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean containsAtLeast(ItemStack itemStack, int i) {
|
public boolean containsAtLeast(ItemStack itemStack, int i) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public HashMap<Integer, ? extends ItemStack> all(int i) {
|
public HashMap<Integer, ? extends ItemStack> all(int i) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||||
items.put(1, new ItemStack(i, Integer.MAX_VALUE));
|
items.put(1, new ItemStack(i, Integer.MAX_VALUE));
|
||||||
@ -91,6 +120,7 @@ public class AdminInventory implements Inventory {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
||||||
if (material.getMaxDurability() != 0) {
|
if (material.getMaxDurability() != 0) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||||
@ -105,6 +135,7 @@ public class AdminInventory implements Inventory {
|
|||||||
return all(material.getId());
|
return all(material.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
@ -116,58 +147,78 @@ public class AdminInventory implements Inventory {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int first(int i) {
|
public int first(int i) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int first(Material material) {
|
public int first(Material material) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int first(ItemStack itemStack) {
|
public int first(ItemStack itemStack) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int firstEmpty() {
|
public int firstEmpty() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove(int i) {
|
public void remove(int i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove(Material material) {
|
public void remove(Material material) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove(ItemStack itemStack) {
|
public void remove(ItemStack itemStack) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void clear(int i) {
|
public void clear(int i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<HumanEntity> getViewers() {
|
public List<HumanEntity> getViewers() {
|
||||||
return new ArrayList<HumanEntity>();
|
return new ArrayList<HumanEntity>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return "Admin inventory";
|
return "Admin inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public InventoryType getType() {
|
public InventoryType getType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public InventoryHolder getHolder() {
|
public InventoryHolder getHolder() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ListIterator<ItemStack> iterator() {
|
public ListIterator<ItemStack> iterator() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ListIterator<ItemStack> iterator(int i) {
|
public ListIterator<ItemStack> iterator(int i) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,4 +40,4 @@ public class AuthMeChestShopListener implements Listener {
|
|||||||
|
|
||||||
event.setCancelled(TransactionOutcome.CLIENT_DOES_NOT_HAVE_PERMISSION);
|
event.setCancelled(TransactionOutcome.CLIENT_DOES_NOT_HAVE_PERMISSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,6 +63,9 @@ public class SignBreak implements Listener {
|
|||||||
public static void onSignBreak(BlockBreakEvent event) {
|
public static void onSignBreak(BlockBreakEvent event) {
|
||||||
if (!canBlockBeBroken(event.getBlock(), event.getPlayer())) {
|
if (!canBlockBeBroken(event.getBlock(), event.getPlayer())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
if (isSign(event.getBlock())) {
|
||||||
|
event.getBlock().getState().update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +121,6 @@ public class SignBreak implements Listener {
|
|||||||
boolean canBeBroken = true;
|
boolean canBeBroken = true;
|
||||||
|
|
||||||
for (Sign sign : attachedSigns) {
|
for (Sign sign : attachedSigns) {
|
||||||
sign.update();
|
|
||||||
|
|
||||||
if (!canBeBroken || !ChestShopSign.isValid(sign)) {
|
if (!canBeBroken || !ChestShopSign.isValid(sign)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,18 +1,28 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners.Economy.Plugins;
|
package com.Acrobot.ChestShop.Listeners.Economy.Plugins;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import java.math.BigDecimal;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.*;
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import java.math.BigDecimal;
|
import com.Acrobot.ChestShop.Events.Economy.AccountCheckEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyAmountEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyFormatEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyHoldEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencySubtractEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyTransferEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Vault connector
|
* Represents a Vault connector
|
||||||
@ -20,11 +30,11 @@ import java.math.BigDecimal;
|
|||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class VaultListener implements Listener {
|
public class VaultListener implements Listener {
|
||||||
private final Economy provider;
|
private static Economy provider;
|
||||||
|
|
||||||
private VaultListener(Economy provider) {
|
private VaultListener(Economy provider) { VaultListener.provider = provider; }
|
||||||
this.provider = provider;
|
|
||||||
}
|
public static Economy getProvider() { return provider; }
|
||||||
|
|
||||||
public boolean transactionCanFail() {
|
public boolean transactionCanFail() {
|
||||||
return provider.getName().equals("Gringotts") || provider.getName().equals("GoldIsMoney") || provider.getName().equals("MultiCurrency");
|
return provider.getName().equals("Gringotts") || provider.getName().equals("GoldIsMoney") || provider.getName().equals("MultiCurrency");
|
||||||
@ -61,10 +71,16 @@ public class VaultListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double balance = provider.getBalance(NameManager.getLastSeenName(event.getAccount()), event.getWorld().getName());
|
double balance = 0;
|
||||||
|
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
|
||||||
|
|
||||||
if (balance > Double.MAX_VALUE) {
|
if (lastSeen != null) {
|
||||||
balance = Double.MAX_VALUE;
|
balance = provider.getBalance(lastSeen, event.getWorld().getName());
|
||||||
|
|
||||||
|
if (balance > Double.MAX_VALUE) {
|
||||||
|
balance = Double.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setAmount(balance);
|
event.setAmount(balance);
|
||||||
@ -77,9 +93,15 @@ public class VaultListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
|
||||||
|
|
||||||
if (provider.has(NameManager.getLastSeenName(event.getAccount()), world.getName(), event.getDoubleAmount())) {
|
if (lastSeen != null) {
|
||||||
event.hasEnough(true);
|
if (provider.has(lastSeen, world.getName(), event.getDoubleAmount())) {
|
||||||
|
event.hasEnough(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.hasEnough(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +112,10 @@ public class VaultListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
|
||||||
|
|
||||||
if (!provider.hasAccount(NameManager.getLastSeenName(event.getAccount()), world.getName())) {
|
event.hasAccount(lastSeen != null && provider.hasAccount(lastSeen, world.getName()));
|
||||||
event.hasAccount(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -103,7 +125,6 @@ public class VaultListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String formatted = provider.format(event.getDoubleAmount());
|
String formatted = provider.format(event.getDoubleAmount());
|
||||||
|
|
||||||
event.setFormattedAmount(formatted);
|
event.setFormattedAmount(formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +135,12 @@ public class VaultListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
//String lastSeen = NameManager.getLastSeenName(event.getTarget());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
provider.depositPlayer(NameManager.getLastSeenName(event.getTarget()), world.getName(), event.getDoubleAmount());
|
if (lastSeen != null) {
|
||||||
|
provider.depositPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -125,8 +150,12 @@ public class VaultListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
//String lastSeen = NameManager.getLastSeenName(event.getTarget());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
|
||||||
|
|
||||||
provider.withdrawPlayer(NameManager.getLastSeenName(event.getTarget()), world.getName(), event.getDoubleAmount());
|
if (lastSeen != null) {
|
||||||
|
provider.withdrawPlayer(lastSeen, world.getName(), event.getDoubleAmount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -152,18 +181,27 @@ public class VaultListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!provider.hasAccount(NameManager.getLastSeenName(event.getAccount()), event.getWorld().getName())) {
|
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
|
||||||
|
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
|
||||||
|
String world = event.getWorld().getName();
|
||||||
|
|
||||||
|
if (lastSeen == null) {
|
||||||
event.canHold(false);
|
event.canHold(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EconomyResponse response = provider.depositPlayer(NameManager.getLastSeenName(event.getAccount()), event.getWorld().getName(), event.getDoubleAmount());
|
if (!provider.hasAccount(lastSeen, world)) {
|
||||||
|
event.canHold(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EconomyResponse response = provider.depositPlayer(lastSeen, world, event.getDoubleAmount());
|
||||||
|
|
||||||
if (!response.transactionSuccess()) {
|
if (!response.transactionSuccess()) {
|
||||||
event.canHold(false);
|
event.canHold(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
provider.withdrawPlayer(NameManager.getLastSeenName(event.getAccount()), event.getWorld().getName(), event.getDoubleAmount());
|
provider.withdrawPlayer(lastSeen, world, event.getDoubleAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners.Player;
|
package com.Acrobot.ChestShop.Listeners.Player;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Utils.NameUtil;
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.PlayerDTO;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
|
import com.Acrobot.ChestShop.UUIDs.PlayerDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
@ -24,20 +22,8 @@ public class PlayerConnect implements Listener {
|
|||||||
Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String playerName = NameUtil.stripUsername(playerDTO.getName());
|
// String playerName = NameUtil.stripUsername(playerDTO.getName());
|
||||||
UUID uuid = NameManager.getUUID(playerName);
|
// UUID uuid = NameManager.getUUID(playerName);
|
||||||
|
|
||||||
if (uuid != null && !playerDTO.getUniqueId().equals(uuid)) {
|
|
||||||
Bukkit.getScheduler().runTask(ChestShop.getPlugin(), new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Bukkit.getPlayer(playerDTO.getUniqueId()).kickPlayer("[ChestShop]" +
|
|
||||||
"Unfortunately, this username was already used by " +
|
|
||||||
"another player.");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
NameManager.storeUsername(playerDTO);
|
NameManager.storeUsername(playerDTO);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Properties;
|
|||||||
import com.Acrobot.ChestShop.Containers.AdminInventory;
|
import com.Acrobot.ChestShop.Containers.AdminInventory;
|
||||||
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
||||||
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.Plugins.ChestShop;
|
import com.Acrobot.ChestShop.Plugins.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Security;
|
import com.Acrobot.ChestShop.Security;
|
||||||
@ -45,12 +46,11 @@ import static org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK;
|
|||||||
public class PlayerInteract implements Listener {
|
public class PlayerInteract implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public static void onInteract(PlayerInteractEvent event) {
|
public static void onInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
if (block == null)
|
||||||
if (block == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -68,12 +68,10 @@ public class PlayerInteract implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSign(block) || player.getItemInHand().getType() == Material.SIGN) { // Blocking accidental sign edition
|
if (!isSign(block) || player.getItemInHand().getType() == Material.SIGN) // Blocking accidental sign edition
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
|
|
||||||
if (!ChestShopSign.isValid(sign)) {
|
if (!ChestShopSign.isValid(sign)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -95,17 +93,14 @@ public class PlayerInteract implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bukkit.getLogger().info("ChestShop - DEBUG - "+block.getWorld().getName()+": "+block.getLocation().getBlockX()+", "+block.getLocation().getBlockY()+", "+block.getLocation().getBlockZ());
|
||||||
PreTransactionEvent pEvent = preparePreTransactionEvent(sign, player, action);
|
PreTransactionEvent pEvent = preparePreTransactionEvent(sign, player, action);
|
||||||
|
if (pEvent == null)
|
||||||
if (pEvent == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(pEvent);
|
Bukkit.getPluginManager().callEvent(pEvent);
|
||||||
|
if (pEvent.isCancelled())
|
||||||
if (pEvent.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
TransactionEvent tEvent = new TransactionEvent(pEvent, sign);
|
TransactionEvent tEvent = new TransactionEvent(pEvent, sign);
|
||||||
Bukkit.getPluginManager().callEvent(tEvent);
|
Bukkit.getPluginManager().callEvent(tEvent);
|
||||||
@ -118,14 +113,19 @@ public class PlayerInteract implements Listener {
|
|||||||
String material = sign.getLine(ITEM_LINE);
|
String material = sign.getLine(ITEM_LINE);
|
||||||
|
|
||||||
String ownerName = NameManager.getFullUsername(name);
|
String ownerName = NameManager.getFullUsername(name);
|
||||||
UUID uuid = NameManager.getUUID(ownerName);
|
if (ownerName == null || ownerName.isEmpty())
|
||||||
|
return null;
|
||||||
if (uuid == null) {
|
|
||||||
|
UUID uuid = NameManager.getUUID(ownerName);
|
||||||
|
if (uuid == null)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(uuid);
|
OfflinePlayer owner = Bukkit.getOfflinePlayer(uuid);
|
||||||
|
|
||||||
|
// check if player exists in economy
|
||||||
|
if(!ChestShopSign.isAdminShop(sign) && (owner == null || owner.getName() == null || !VaultListener.getProvider().hasAccount(owner)))
|
||||||
|
return null;
|
||||||
|
|
||||||
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
||||||
double price = (action == buy ? PriceUtil.getBuyPrice(prices) : PriceUtil.getSellPrice(prices));
|
double price = (action == buy ? PriceUtil.getBuyPrice(prices) : PriceUtil.getSellPrice(prices));
|
||||||
|
|
||||||
@ -133,7 +133,6 @@ public class PlayerInteract implements Listener {
|
|||||||
Inventory ownerInventory = (ChestShopSign.isAdminShop(sign) ? new AdminInventory() : chest != null ? chest.getInventory() : null);
|
Inventory ownerInventory = (ChestShopSign.isAdminShop(sign) ? new AdminInventory() : chest != null ? chest.getInventory() : null);
|
||||||
|
|
||||||
ItemStack item = MaterialUtil.getItem(material);
|
ItemStack item = MaterialUtil.getItem(material);
|
||||||
|
|
||||||
if (item == null || !NumberUtil.isInteger(quantity)) {
|
if (item == null || !NumberUtil.isInteger(quantity)) {
|
||||||
player.sendMessage(Messages.prefix(Messages.INVALID_SHOP_DETECTED));
|
player.sendMessage(Messages.prefix(Messages.INVALID_SHOP_DETECTED));
|
||||||
return null;
|
return null;
|
||||||
|
@ -25,7 +25,7 @@ public class EconomicModule implements Listener {
|
|||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
|
||||||
event.getOwner().getUniqueId(),
|
event.getOwner().getUniqueId(),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencyAddEvent);
|
ChestShop.callEvent(currencyAddEvent); // java.lang.StackOverflowError
|
||||||
|
|
||||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
|
||||||
ChestShop.callEvent(currencySubtractEvent);
|
ChestShop.callEvent(currencySubtractEvent);
|
||||||
|
@ -32,6 +32,10 @@ public class ShopRefundListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ownerName = NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
|
String ownerName = NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
|
||||||
|
if (ownerName.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UUID owner = NameManager.getUUID(ownerName);
|
UUID owner = NameManager.getUUID(ownerName);
|
||||||
|
|
||||||
CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld());
|
CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld());
|
||||||
|
@ -76,7 +76,10 @@ public class ItemDatabase {
|
|||||||
* @param code Item code
|
* @param code Item code
|
||||||
* @return ItemStack represented by this code
|
* @return ItemStack represented by this code
|
||||||
*/
|
*/
|
||||||
public ItemStack getFromCode(String code) {
|
public ItemStack getFromCode(String code)
|
||||||
|
{
|
||||||
|
// TODO java.lang.StackOverflowError - http://pastebin.com/eRD8wUFM - Corrupt item DB?
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int id = Base62.decode(code);
|
int id = Base62.decode(code);
|
||||||
Item item = itemDao.queryBuilder().where().eq("id", id).queryForFirst();
|
Item item = itemDao.queryBuilder().where().eq("id", id).queryForFirst();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.Acrobot.ChestShop.Plugins;
|
package com.Acrobot.ChestShop.Plugins;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||||
import net.t00thpick1.residence.Residence;
|
import com.bekvon.bukkit.residence.Residence;
|
||||||
import net.t00thpick1.residence.api.ResidenceAPI;
|
import com.bekvon.bukkit.residence.api.ResidenceApi;
|
||||||
import net.t00thpick1.residence.api.areas.ResidenceArea;
|
import com.bekvon.bukkit.residence.containers.Flags;
|
||||||
import net.t00thpick1.residence.api.flags.FlagManager;
|
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -25,10 +25,10 @@ public class ResidenceChestProtection implements Listener {
|
|||||||
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ResidenceArea area = ResidenceAPI.getResidenceManager().getByLocation(block.getLocation());
|
ClaimedResidence residence = ResidenceApi.getResidenceManager().getByLoc(block.getLocation());
|
||||||
|
|
||||||
if (area != null) {
|
if (residence != null) {
|
||||||
if (!area.allowAction(player.getName(), FlagManager.CONTAINER) && !Residence.getInstance().isAdminMode(player)) {
|
if (!residence.getPermissions().playerHas(player, Flags.container, true) && !Residence.isResAdminOn(player)) {
|
||||||
//Doesn't have permissions to that chest.
|
//Doesn't have permissions to that chest.
|
||||||
event.setResult(Event.Result.DENY);
|
event.setResult(Event.Result.DENY);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,10 @@ public class ChestShopSign {
|
|||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
if (sign == null) return true;
|
if (sign == null) return true;
|
||||||
|
|
||||||
return NameManager.canUseName(player, sign.getLine(NAME_LINE));
|
String name = sign.getLine(NAME_LINE);
|
||||||
|
if (name == null || name.isEmpty()) return true;
|
||||||
|
|
||||||
|
return NameManager.canUseName(player, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidPreparedSign(String[] lines) {
|
public static boolean isValidPreparedSign(String[] lines) {
|
||||||
|
@ -9,20 +9,24 @@ import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
|||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.j256.ormlite.dao.Dao;
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets you save/cache username and UUID relations
|
* Lets you save/cache username and UUID relations
|
||||||
*
|
*
|
||||||
* @author Andrzej Pomirski (Acrobot)
|
* @author Andrzej Pomirski (Acrobot)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedAssignment") //I deliberately set the variables to null while initializing
|
@SuppressWarnings("UnusedAssignment") // I deliberately set the variables to null while initializing
|
||||||
public class NameManager {
|
public class NameManager {
|
||||||
private static Dao<Account, String> accounts;
|
private static Dao<Account, String> accounts;
|
||||||
|
|
||||||
@ -35,9 +39,9 @@ public class NameManager {
|
|||||||
return lastSeenName.get(uuid);
|
return lastSeenName.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getOfflinePlayer(uuid).getName() != null) {
|
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||||
String lastSeen = Bukkit.getOfflinePlayer(uuid).getName();
|
String lastSeen = player.getName();
|
||||||
|
if (lastSeen != null) {
|
||||||
lastSeenName.put(uuid, lastSeen);
|
lastSeenName.put(uuid, lastSeen);
|
||||||
return lastSeen;
|
return lastSeen;
|
||||||
}
|
}
|
||||||
@ -46,25 +50,32 @@ public class NameManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
account = accounts.queryBuilder().selectColumns("lastSeenName", "name").where().eq("uuid", uuid).queryForFirst();
|
account = accounts.queryBuilder().selectColumns("lastSeenName", "name").where().eq("uuid", uuid).queryForFirst();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException ex) {
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().log(Level.WARNING, "[ChestShop] Failed to find last seen name for " + uuid + ":", ex);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.getLastSeenName() != null) {
|
lastSeen = account.getLastSeenName();
|
||||||
lastSeenName.put(uuid, account.getLastSeenName());
|
if (lastSeen != null) {
|
||||||
} else if (account.getName() != null) {
|
lastSeenName.put(uuid, lastSeen);
|
||||||
lastSeenName.put(uuid, account.getName());
|
return lastSeen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return account.getLastSeenName();
|
lastSeen = account.getName();
|
||||||
|
if (lastSeen != null) {
|
||||||
|
lastSeenName.put(uuid, lastSeen);
|
||||||
|
return lastSeen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUID(String username) {
|
public static UUID getUUID(String username) {
|
||||||
|
Validate.notEmpty(username, "user cannot be null or empty!");
|
||||||
|
|
||||||
if (usernameToUUID.containsKey(username)) {
|
if (usernameToUUID.containsKey(username)) {
|
||||||
return usernameToUUID.get(username);
|
return usernameToUUID.get(username);
|
||||||
}
|
}
|
||||||
@ -194,6 +205,7 @@ public class NameManager {
|
|||||||
account = new Account(player.getName(), player.getUniqueId());
|
account = new Account(player.getName(), player.getUniqueId());
|
||||||
|
|
||||||
if (!usernameToUUID.inverse().containsKey(uuid)) {
|
if (!usernameToUUID.inverse().containsKey(uuid)) {
|
||||||
|
usernameToUUID.remove(player.getName()); // https://github.com/dmulloy2/ChestShop-3/issues/11
|
||||||
usernameToUUID.inverse().put(uuid, player.getName());
|
usernameToUUID.inverse().put(uuid, player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,10 +219,17 @@ public class NameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void dropUsername(final Player player) {
|
public static void dropUsername(final Player player) {
|
||||||
final UUID uuid = player.getUniqueId();
|
if (player == null) return;
|
||||||
|
|
||||||
if (usernameToUUID.containsValue(uuid)) {
|
final UUID uuid = player.getUniqueId();
|
||||||
usernameToUUID.inverse().remove(uuid);
|
if (uuid == null) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (usernameToUUID.containsValue(uuid)) {
|
||||||
|
usernameToUUID.inverse().remove(uuid);
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// Sigh...
|
||||||
}
|
}
|
||||||
|
|
||||||
String shortName = NameUtil.stripUsername(player.getName());
|
String shortName = NameUtil.stripUsername(player.getName());
|
||||||
@ -227,7 +246,7 @@ public class NameManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shortenedName.equals(name) || Permission.otherName(player, name) || player.getUniqueId().equals(getUUID(name));
|
return shortenedName.equals(name) || Permission.otherName(player, name) || (!name.isEmpty() && player.getUniqueId().equals(getUUID(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAdminShop(UUID uuid) {
|
public static boolean isAdminShop(UUID uuid) {
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
name: ChestShop
|
name: ChestShop
|
||||||
|
|
||||||
main: com.Acrobot.ChestShop.ChestShop
|
main: com.Acrobot.ChestShop.ChestShop
|
||||||
|
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
|
author: [Acrobot, dmulloy2, L4BORG]
|
||||||
#for CButD
|
description: A chest shop for economy plugins.
|
||||||
dev-url: http://dev.bukkit.org/server-mods/chestshop/
|
|
||||||
|
|
||||||
|
|
||||||
author: Acrobot
|
|
||||||
description: >
|
|
||||||
A chest shop for economy plugins.
|
|
||||||
|
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
softdepend: [LWC, Lockette, Deadbolt, OddItem, WorldGuard, Heroes, SimpleChestLock, Residence]
|
softdepend: [LWC, Lockette, Deadbolt, OddItem, WorldGuard, Heroes, SimpleChestLock, Residence]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user