mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2025-03-16 13:59:14 +01:00
Add a common module, move hook api, add DebugLogger
This commit is contained in:
parent
57d30b683a
commit
a3a0f0b034
22
common/pom.xml
Normal file
22
common/pom.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>ShopChest-parent</artifactId>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<version>1.14.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>shopchest-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,47 @@
|
||||
package de.epiceric.shopchest.debug;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface DebugLogger {
|
||||
|
||||
static DebugLogger getLogger(File debugLogFile, Logger logger) {
|
||||
try {
|
||||
if (!debugLogFile.exists()) {
|
||||
debugLogFile.createNewFile();
|
||||
}
|
||||
|
||||
new PrintWriter(debugLogFile).close();
|
||||
|
||||
final FileWriter fw = new FileWriter(debugLogFile, true);
|
||||
|
||||
return new FileDebugLogger(fw, logger);
|
||||
} catch (IOException e) {
|
||||
logger.info("Failed to instantiate FileWriter");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new NullDebugLogger(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a message to the <i>/plugins/ShopChest/debug.txt</i> file
|
||||
*
|
||||
* @param message Message to print
|
||||
*/
|
||||
void debug(String message);
|
||||
|
||||
/**
|
||||
* Print a {@link Throwable}'s stacktrace to the <i>/plugins/ShopChest/debug.txt</i> file
|
||||
*
|
||||
* @param throwable {@link Throwable} whose stacktrace will be printed
|
||||
*/
|
||||
void debug(Throwable throwable);
|
||||
|
||||
void close();
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package de.epiceric.shopchest.debug;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class FileDebugLogger extends LogDebugLogger {
|
||||
|
||||
private final FileWriter fw;
|
||||
private final SimpleDateFormat dateFormat;
|
||||
private final long offset;
|
||||
|
||||
public FileDebugLogger(FileWriter fw, Logger logger) {
|
||||
super(logger);
|
||||
this.fw = fw;
|
||||
this.dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
final long offset = System.currentTimeMillis() - Calendar.getInstance().getTimeInMillis(); // Get a long offset
|
||||
this.offset = offset - offset % 100; // Remove the difference made by the Calendar creation time
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
try {
|
||||
final String timestamp = dateFormat.format(new Date(System.currentTimeMillis() - offset));
|
||||
fw.write(String.format("[%s] %s\r\n", timestamp, message));
|
||||
fw.flush();
|
||||
} catch (IOException e) {
|
||||
logger.severe("Failed to print debug message.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Throwable throwable) {
|
||||
final PrintWriter pw = new PrintWriter(fw);
|
||||
throwable.printStackTrace(pw);
|
||||
pw.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
logger.severe("Failed to close FileWriter");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package de.epiceric.shopchest.debug;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class LogDebugLogger implements DebugLogger {
|
||||
|
||||
protected final Logger logger;
|
||||
|
||||
protected LogDebugLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package de.epiceric.shopchest.debug;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class NullDebugLogger extends LogDebugLogger {
|
||||
|
||||
public NullDebugLogger(Logger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.epiceric.shopchest.hook;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class HookManager {
|
||||
|
||||
private final List<UseShopHook> useShopHooks;
|
||||
|
||||
public HookManager() {
|
||||
useShopHooks = new LinkedList<>();
|
||||
}
|
||||
|
||||
public void registerUseShopHook(UseShopHook hook) {
|
||||
useShopHooks.add(hook);
|
||||
}
|
||||
|
||||
public boolean canUseShop(Block block, Player player, boolean admin) {
|
||||
for(UseShopHook useShopHook : useShopHooks) {
|
||||
if(!useShopHook.canUseShop(block, player, admin)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package de.epiceric.shopchest.external;
|
||||
package de.epiceric.shopchest.hook;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface UseShopIntegration {
|
||||
public interface UseShopHook {
|
||||
|
||||
/**
|
||||
* Whether the player can use the player shop represented by this block
|
||||
@ -36,8 +36,8 @@ public interface UseShopIntegration {
|
||||
* It's the method called by the plugin
|
||||
* </p>
|
||||
* <p>
|
||||
* By default, it calls {@link UseShopIntegration#canUsePlayerShop(Block, Player)}} and
|
||||
* {@link UseShopIntegration#canUseAdminShop(Block, Player)}
|
||||
* By default, it calls {@link UseShopHook#canUsePlayerShop(Block, Player)}} and
|
||||
* {@link UseShopHook#canUseAdminShop(Block, Player)}
|
||||
* </p>
|
||||
*
|
||||
* @param block The {@link Block} where the shop is placed
|
@ -23,6 +23,10 @@
|
||||
<artifactId>shopchest-nms-interface</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.inventivetalent</groupId>
|
||||
<artifactId>reflectionhelper</artifactId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.nms.FakeArmorStand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -12,7 +13,7 @@ public class FakeArmorStandImpl extends FakeEntityImpl implements FakeArmorStand
|
||||
|
||||
private final Class<?> packetPlayOutEntityTeleportClass = nmsClassResolver.resolveSilent("network.protocol.game.PacketPlayOutEntityTeleport");
|
||||
|
||||
public FakeArmorStandImpl(ShopChestDebug debug) {
|
||||
public FakeArmorStandImpl(DebugLogger debug) {
|
||||
super(debug);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.nms.FakeEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.inventivetalent.reflection.resolver.minecraft.NMSClassResolver;
|
||||
@ -12,9 +13,9 @@ public abstract class FakeEntityImpl implements FakeEntity {
|
||||
protected final Class<?> dataWatcherClass = nmsClassResolver.resolveSilent("network.syncher.DataWatcher");
|
||||
|
||||
protected final int entityId;
|
||||
protected final ShopChestDebug debug;
|
||||
protected final DebugLogger debug;
|
||||
|
||||
public FakeEntityImpl(ShopChestDebug debug) {
|
||||
public FakeEntityImpl(DebugLogger debug) {
|
||||
this.entityId = ReflectionUtils.getFreeEntityId();
|
||||
this.debug = debug;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.nms.FakeItem;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -16,7 +17,7 @@ public class FakeItemImpl extends FakeEntityImpl implements FakeItem {
|
||||
private final Class<?> vec3dClass = nmsClassResolver.resolveSilent("world.phys.Vec3D");
|
||||
private final Class<?> craftItemStackClass = obcClassResolver.resolveSilent("inventory.CraftItemStack");
|
||||
|
||||
public FakeItemImpl(ShopChestDebug debug) {
|
||||
public FakeItemImpl(DebugLogger debug) {
|
||||
super(debug);
|
||||
|
||||
Class<?> nmsItemStackClass = nmsClassResolver.resolveSilent("world.item.ItemStack");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.inventivetalent.reflection.resolver.FieldResolver;
|
||||
@ -106,7 +107,7 @@ public class JsonBuilder {
|
||||
private static final Pattern HEX_PATTERN = Pattern.compile("(§[a-fA-F0-9]){6}");
|
||||
|
||||
private Part rootPart;
|
||||
private ShopChestDebug debug;
|
||||
private DebugLogger debug;
|
||||
|
||||
private final NMSClassResolver nmsClassResolver = new NMSClassResolver();
|
||||
private Class<?> iChatBaseComponentClass = nmsClassResolver.resolveSilent("network.chat.IChatBaseComponent");
|
||||
@ -114,7 +115,7 @@ public class JsonBuilder {
|
||||
private Class<?> chatSerializerClass = nmsClassResolver.resolveSilent("ChatSerializer", "network.chat.IChatBaseComponent$ChatSerializer");
|
||||
private Class<?> chatMessageTypeClass;
|
||||
|
||||
public JsonBuilder(ShopChestDebug debug) {
|
||||
public JsonBuilder(DebugLogger debug) {
|
||||
this.debug = debug;
|
||||
|
||||
if (ReflectionUtils.getMajorVersion() >= 16) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.nms.FakeArmorStand;
|
||||
import de.epiceric.shopchest.nms.FakeItem;
|
||||
import de.epiceric.shopchest.nms.Platform;
|
||||
@ -7,13 +8,12 @@ import de.epiceric.shopchest.nms.TextComponentHelper;
|
||||
|
||||
public class PlatformImpl implements Platform {
|
||||
|
||||
private final ShopChestDebug debug;
|
||||
private final DebugLogger debug;
|
||||
|
||||
public PlatformImpl(ShopChestDebug debug) {
|
||||
public PlatformImpl(DebugLogger debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FakeArmorStand createFakeArmorStand() {
|
||||
return new FakeArmorStandImpl(debug);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -31,7 +32,7 @@ public class ReflectionUtils {
|
||||
* @param customName Custom Name of the entity or {@code null}
|
||||
* @param nmsItemStack NMS ItemStack or {@code null} if armor stand
|
||||
*/
|
||||
public static Object createDataWatcher(ShopChestDebug debug, String customName, Object nmsItemStack) {
|
||||
public static Object createDataWatcher(DebugLogger debug, String customName, Object nmsItemStack) {
|
||||
String version = getServerVersion();
|
||||
int majorVersion = getMajorVersion();
|
||||
|
||||
@ -130,7 +131,7 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a free entity ID for use in {@link #createPacketSpawnEntity(ShopChestDebug, int, UUID, Location, EntityType)}
|
||||
* Get a free entity ID for use in {@link #createPacketSpawnEntity(DebugLogger, int, UUID, Location, EntityType)}
|
||||
*
|
||||
* @return The id or {@code -1} if a free entity ID could not be retrieved.
|
||||
*/
|
||||
@ -156,7 +157,7 @@ public class ReflectionUtils {
|
||||
* Create a {@code PacketPlayOutSpawnEntity} object.
|
||||
* Only {@link EntityType#ARMOR_STAND} and {@link EntityType#DROPPED_ITEM} are supported!
|
||||
*/
|
||||
public static Object createPacketSpawnEntity(ShopChestDebug debug, int id, UUID uuid, Location loc, EntityType type) {
|
||||
public static Object createPacketSpawnEntity(DebugLogger debug, int id, UUID uuid, Location loc, EntityType type) {
|
||||
try {
|
||||
Class<?> packetPlayOutSpawnEntityClass = nmsClassResolver.resolveSilent("network.protocol.game.PacketPlayOutSpawnEntity");
|
||||
Class<?> entityTypesClass = nmsClassResolver.resolveSilent("world.entity.EntityTypes");
|
||||
@ -226,12 +227,12 @@ public class ReflectionUtils {
|
||||
|
||||
/**
|
||||
* Send a packet to a player
|
||||
* @param debug An instance of the {@link ShopChestDebug} debug instance
|
||||
* @param debug The used {@link DebugLogger} instance
|
||||
* @param packet Packet to send
|
||||
* @param player Player to which the packet should be sent
|
||||
* @return {@code true} if the packet was sent, or {@code false} if an exception was thrown
|
||||
*/
|
||||
public static boolean sendPacket(ShopChestDebug debug, Object packet, Player player) {
|
||||
public static boolean sendPacket(DebugLogger debug, Object packet, Player player) {
|
||||
try {
|
||||
if (packet == null) {
|
||||
debug.debug("Failed to send packet: Packet is null");
|
||||
|
@ -1,30 +0,0 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ShopChestDebug {
|
||||
|
||||
private final Logger logger;
|
||||
private final Consumer<String> debugConsumer;
|
||||
private final Consumer<Throwable> throwableConsumer;
|
||||
|
||||
public ShopChestDebug(Logger logger, Consumer<String> debugConsumer, Consumer<Throwable> throwableConsumer) {
|
||||
this.logger = logger;
|
||||
this.debugConsumer = debugConsumer;
|
||||
this.throwableConsumer = throwableConsumer;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public void debug(String message){
|
||||
debugConsumer.accept(message);
|
||||
}
|
||||
|
||||
public void debug(Throwable e){
|
||||
throwableConsumer.accept(e);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package de.epiceric.shopchest.nms.reflection;
|
||||
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.nms.TextComponentHelper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -18,9 +19,9 @@ public class TextComponentHelperImpl implements TextComponentHelper {
|
||||
private static final Pattern COLOR_CODE_PATTERN = Pattern.compile(".*([§]([a-fA-F0-9]))");
|
||||
private static final Pattern FORMAT_CODE_PATTERN = Pattern.compile(".*([§]([l-oL-OkK]))");
|
||||
|
||||
private final ShopChestDebug debug;
|
||||
private final DebugLogger debug;
|
||||
|
||||
public TextComponentHelperImpl(ShopChestDebug debug) {
|
||||
public TextComponentHelperImpl(DebugLogger debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,10 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-nms-interface</artifactId>
|
||||
@ -66,6 +70,10 @@
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-nms-v1_18_R2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-external</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -6,6 +6,8 @@ package de.epiceric.shopchest;
|
||||
import de.epiceric.shopchest.command.ShopCommand;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.config.hologram.HologramFormat;
|
||||
import de.epiceric.shopchest.debug.DebugLogger;
|
||||
import de.epiceric.shopchest.debug.NullDebugLogger;
|
||||
import de.epiceric.shopchest.event.ShopInitializedEvent;
|
||||
//import de.epiceric.shopchest.external.BentoBoxShopFlag;
|
||||
//import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
|
||||
@ -18,7 +20,6 @@ import de.epiceric.shopchest.language.LanguageUtils;
|
||||
import de.epiceric.shopchest.listeners.*;
|
||||
import de.epiceric.shopchest.nms.Platform;
|
||||
import de.epiceric.shopchest.nms.reflection.PlatformImpl;
|
||||
import de.epiceric.shopchest.nms.reflection.ShopChestDebug;
|
||||
import de.epiceric.shopchest.sql.Database;
|
||||
import de.epiceric.shopchest.sql.MySQL;
|
||||
import de.epiceric.shopchest.sql.SQLite;
|
||||
@ -42,11 +43,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
//import world.bentobox.bentobox.BentoBox;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -69,7 +65,7 @@ public class ShopChest extends JavaPlugin {
|
||||
private String latestVersion = "";
|
||||
private String downloadLink = "";
|
||||
private ShopUtils shopUtils;
|
||||
private FileWriter fw;
|
||||
private DebugLogger debugLogger;
|
||||
/*
|
||||
private Plugin worldGuard;
|
||||
private Towny towny;
|
||||
@ -110,24 +106,11 @@ public class ShopChest extends JavaPlugin {
|
||||
|
||||
config = new Config(this);
|
||||
|
||||
if (Config.enableDebugLog) {
|
||||
File debugLogFile = new File(getDataFolder(), "debug.txt");
|
||||
debugLogger = Config.enableDebugLog ?
|
||||
DebugLogger.getLogger(new File(getDataFolder(), "debug.txt"), getLogger())
|
||||
: new NullDebugLogger(getLogger());
|
||||
|
||||
try {
|
||||
if (!debugLogFile.exists()) {
|
||||
debugLogFile.createNewFile();
|
||||
}
|
||||
|
||||
new PrintWriter(debugLogFile).close();
|
||||
|
||||
fw = new FileWriter(debugLogFile, true);
|
||||
} catch (IOException e) {
|
||||
getLogger().info("Failed to instantiate FileWriter");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
debug("Loading ShopChest version " + getDescription().getVersion());
|
||||
debugLogger.debug("Loading ShopChest version " + getDescription().getVersion());
|
||||
|
||||
// TODO EXTERNAL : Register WorldGuard Flags
|
||||
|
||||
@ -140,17 +123,17 @@ public class ShopChest extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
debug("Enabling ShopChest version " + getDescription().getVersion());
|
||||
debugLogger.debug("Enabling ShopChest version " + getDescription().getVersion());
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
debug("Could not find plugin \"Vault\"");
|
||||
debugLogger.debug("Could not find plugin \"Vault\"");
|
||||
getLogger().severe("Could not find plugin \"Vault\"");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setupEconomy()) {
|
||||
debug("Could not find any Vault economy dependency!");
|
||||
debugLogger.debug("Could not find any Vault economy dependency!");
|
||||
getLogger().severe("Could not find any Vault economy dependency!");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
@ -172,7 +155,7 @@ public class ShopChest extends JavaPlugin {
|
||||
case "v1_16_R1":
|
||||
case "v1_16_R2":
|
||||
case "v1_16_R3":
|
||||
platform = new PlatformImpl(new ShopChestDebug(getLogger(), this::debug, this::debug));
|
||||
platform = new PlatformImpl(debugLogger);
|
||||
break;
|
||||
case "v1_17_R1":
|
||||
// Need to have an implementation for 1.17.1 and 1.17 -> Change in the name of EntityDestroyPacket
|
||||
@ -191,7 +174,7 @@ public class ShopChest extends JavaPlugin {
|
||||
platform = new de.epiceric.shopchest.nms.v1_18_R2.PlatformImpl();
|
||||
break;
|
||||
default:
|
||||
debug("Server version not officially supported: " + Utils.getServerVersion() + "!");
|
||||
debugLogger.debug("Server version not officially supported: " + Utils.getServerVersion() + "!");
|
||||
//debug("Plugin may still work, but more errors are expected!");
|
||||
getLogger().warning("Server version not officially supported: " + Utils.getServerVersion() + "!");
|
||||
//getLogger().warning("Plugin may still work, but more errors are expected!");
|
||||
@ -231,19 +214,12 @@ public class ShopChest extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
debug("Disabling ShopChest...");
|
||||
debugLogger.debug("Disabling ShopChest...");
|
||||
|
||||
if (shopUtils == null) {
|
||||
// Plugin has not been fully enabled (probably due to errors),
|
||||
// so only close file writer.
|
||||
if (fw != null && Config.enableDebugLog) {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Failed to close FileWriter");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
debugLogger.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,7 +230,7 @@ public class ShopChest extends JavaPlugin {
|
||||
ClickType.clear();
|
||||
|
||||
if (updater != null) {
|
||||
debug("Stopping updater");
|
||||
debugLogger.debug("Stopping updater");
|
||||
updater.stop();
|
||||
}
|
||||
|
||||
@ -263,7 +239,7 @@ public class ShopChest extends JavaPlugin {
|
||||
}
|
||||
|
||||
shopUtils.removeShops();
|
||||
debug("Removed shops");
|
||||
debugLogger.debug("Removed shops");
|
||||
|
||||
if (database != null && database.isInitialized()) {
|
||||
if (database instanceof SQLite) {
|
||||
@ -273,14 +249,7 @@ public class ShopChest extends JavaPlugin {
|
||||
database.disconnect();
|
||||
}
|
||||
|
||||
if (fw != null && Config.enableDebugLog) {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Failed to close FileWriter");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
debugLogger.close();
|
||||
}
|
||||
|
||||
private void loadExternalPlugins() {
|
||||
@ -351,11 +320,11 @@ public class ShopChest extends JavaPlugin {
|
||||
|
||||
private void initDatabase() {
|
||||
if (Config.databaseType == Database.DatabaseType.SQLite) {
|
||||
debug("Using database type: SQLite");
|
||||
debugLogger.debug("Using database type: SQLite");
|
||||
getLogger().info("Using SQLite");
|
||||
database = new SQLite(this);
|
||||
} else {
|
||||
debug("Using database type: MySQL");
|
||||
debugLogger.debug("Using database type: MySQL");
|
||||
getLogger().info("Using MySQL");
|
||||
database = new MySQL(this);
|
||||
if (Config.databaseMySqlPingInterval > 0) {
|
||||
@ -413,7 +382,7 @@ public class ShopChest extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
debug("Registering listeners...");
|
||||
debugLogger.debug("Registering listeners...");
|
||||
getServer().getPluginManager().registerEvents(new ShopUpdateListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ShopItemListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ShopInteractListener(this), this);
|
||||
@ -479,7 +448,7 @@ public class ShopChest extends JavaPlugin {
|
||||
@Override
|
||||
public void onResult(Map<UUID, Integer> result) {
|
||||
getLogger().info("Loaded shop amounts");
|
||||
debug("Loaded shop amounts");
|
||||
debugLogger.debug("Loaded shop amounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -494,7 +463,7 @@ public class ShopChest extends JavaPlugin {
|
||||
public void onResult(Integer result) {
|
||||
getServer().getPluginManager().callEvent(new ShopInitializedEvent(result));
|
||||
getLogger().info("Loaded " + result + " shops in already loaded chunks");
|
||||
debug("Loaded " + result + " shops in already loaded chunks");
|
||||
debugLogger.debug("Loaded " + result + " shops in already loaded chunks");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -516,33 +485,10 @@ public class ShopChest extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a message to the <i>/plugins/ShopChest/debug.txt</i> file
|
||||
* @param message Message to print
|
||||
* @return The {@link DebugLogger} instance
|
||||
*/
|
||||
public void debug(String message) {
|
||||
if (Config.enableDebugLog && fw != null) {
|
||||
try {
|
||||
Calendar c = Calendar.getInstance();
|
||||
String timestamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(c.getTime());
|
||||
fw.write(String.format("[%s] %s\r\n", timestamp, message));
|
||||
fw.flush();
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Failed to print debug message.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a {@link Throwable}'s stacktrace to the <i>/plugins/ShopChest/debug.txt</i> file
|
||||
* @param throwable {@link Throwable} whose stacktrace will be printed
|
||||
*/
|
||||
public void debug(Throwable throwable) {
|
||||
if (Config.enableDebugLog && fw != null) {
|
||||
PrintWriter pw = new PrintWriter(fw);
|
||||
throwable.printStackTrace(pw);
|
||||
pw.flush();
|
||||
}
|
||||
public DebugLogger getDebugLogger() {
|
||||
return debugLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class ShopCommand {
|
||||
public ShopCommand(final ShopChest plugin) {
|
||||
if (commandCreated) {
|
||||
IllegalStateException e = new IllegalStateException("Command has already been registered");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ public class ShopCommand {
|
||||
}
|
||||
|
||||
private PluginCommand createPluginCommand() {
|
||||
plugin.debug("Creating plugin command");
|
||||
plugin.getDebugLogger().debug("Creating plugin command");
|
||||
try {
|
||||
Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
|
||||
c.setAccessible(true);
|
||||
@ -197,15 +197,15 @@ public class ShopCommand {
|
||||
return cmd;
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
|
||||
plugin.getLogger().severe("Failed to create command");
|
||||
plugin.debug("Failed to create plugin command");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to create plugin command");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addSubCommand(ShopSubCommand subCommand) {
|
||||
plugin.debug("Adding sub command \"" + subCommand.getName() + "\"");
|
||||
plugin.getDebugLogger().debug("Adding sub command \"" + subCommand.getName() + "\"");
|
||||
this.subCommands.add(subCommand);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ public class ShopCommand {
|
||||
private void register() {
|
||||
if (pluginCommand == null) return;
|
||||
|
||||
plugin.debug("Registering command " + name);
|
||||
plugin.getDebugLogger().debug("Registering command " + name);
|
||||
|
||||
try {
|
||||
Field fCommandMap = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
@ -229,15 +229,15 @@ public class ShopCommand {
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
plugin.getLogger().severe("Failed to register command");
|
||||
plugin.debug("Failed to register plugin command");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to register plugin command");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
if (pluginCommand == null) return;
|
||||
|
||||
plugin.debug("Unregistering command " + name);
|
||||
plugin.getDebugLogger().debug("Unregistering command " + name);
|
||||
|
||||
try {
|
||||
Field fCommandMap = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
@ -262,8 +262,8 @@ public class ShopCommand {
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
plugin.getLogger().severe("Failed to unregister command");
|
||||
plugin.debug("Failed to unregister plugin command");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to unregister plugin command");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ public class ShopCommand {
|
||||
* @param sender {@link CommandSender} who will receive the message
|
||||
*/
|
||||
private void sendBasicHelpMessage(CommandSender sender) {
|
||||
plugin.debug("Sending basic help message to " + sender.getName());
|
||||
plugin.getDebugLogger().debug("Sending basic help message to " + sender.getName());
|
||||
|
||||
sender.sendMessage(" ");
|
||||
String header = LanguageUtils.getMessage(Message.COMMAND_DESC_HEADER,
|
||||
|
@ -133,7 +133,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
} else if (subCommand.getName().equalsIgnoreCase("info")) {
|
||||
info(p);
|
||||
} else if (subCommand.getName().equalsIgnoreCase("limits")) {
|
||||
plugin.debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p));
|
||||
plugin.getDebugLogger().debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p));
|
||||
int limit = shopUtils.getShopLimit(p);
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.OCCUPIED_SHOP_SLOTS,
|
||||
new Replacement(Placeholder.LIMIT, (limit < 0 ? "∞" : String.valueOf(limit))),
|
||||
@ -159,7 +159,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param sender The command executor
|
||||
*/
|
||||
private void checkUpdates(CommandSender sender) {
|
||||
plugin.debug(sender.getName() + " is checking for updates");
|
||||
plugin.getDebugLogger().debug(sender.getName() + " is checking for updates");
|
||||
|
||||
sender.sendMessage(LanguageUtils.getMessage(Message.UPDATE_CHECKING));
|
||||
|
||||
@ -195,12 +195,12 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param sender The command executor
|
||||
*/
|
||||
private void reload(final CommandSender sender) {
|
||||
plugin.debug(sender.getName() + " is reloading the shops");
|
||||
plugin.getDebugLogger().debug(sender.getName() + " is reloading the shops");
|
||||
|
||||
ShopReloadEvent event = new ShopReloadEvent(sender);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()){
|
||||
plugin.debug("Reload event cancelled");
|
||||
plugin.getDebugLogger().debug("Reload event cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
public void onResult(Integer result) {
|
||||
sender.sendMessage(LanguageUtils.getMessage(Message.RELOADED_SHOPS,
|
||||
new Replacement(Placeholder.AMOUNT, String.valueOf(result))));
|
||||
plugin.debug(sender.getName() + " has reloaded " + result + " shops");
|
||||
plugin.getDebugLogger().debug(sender.getName() + " has reloaded " + result + " shops");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -258,7 +258,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param p The command executor
|
||||
*/
|
||||
private void create(String[] args, Shop.ShopType shopType, final Player p) {
|
||||
plugin.debug(p.getName() + " wants to create a shop");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to create a shop");
|
||||
|
||||
int amount;
|
||||
double buyPrice, sellPrice;
|
||||
@ -270,13 +270,13 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
sellPrice = Double.parseDouble(args[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.AMOUNT_PRICE_NOT_NUMBER));
|
||||
plugin.debug(p.getName() + " has entered an invalid amount and/or prices");
|
||||
plugin.getDebugLogger().debug(p.getName() + " has entered an invalid amount and/or prices");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Utils.hasPermissionToCreateShop(p, Utils.getPreferredItemInHand(p), buyPrice > 0, sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE));
|
||||
plugin.debug(p.getName() + " is not permitted to create the shop");
|
||||
plugin.getDebugLogger().debug(p.getName() + " is not permitted to create the shop");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (shopUtils.getShopAmount(p) >= limit) {
|
||||
if (shopType != Shop.ShopType.ADMIN) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_LIMIT_REACHED, new Replacement(Placeholder.LIMIT, String.valueOf(limit))));
|
||||
plugin.debug(p.getName() + " has reached the limit");
|
||||
plugin.getDebugLogger().debug(p.getName() + " has reached the limit");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -294,13 +294,13 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (amount <= 0) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.AMOUNT_IS_ZERO));
|
||||
plugin.debug(p.getName() + " has entered an invalid amount");
|
||||
plugin.getDebugLogger().debug(p.getName() + " has entered an invalid amount");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Config.allowDecimalsInPrice && (buyPrice != (int) buyPrice || sellPrice != (int) sellPrice)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.PRICES_CONTAIN_DECIMALS));
|
||||
plugin.debug(p.getName() + " has entered an invalid price");
|
||||
plugin.getDebugLogger().debug(p.getName() + " has entered an invalid price");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (!buyEnabled && !sellEnabled) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.BUY_SELL_DISABLED));
|
||||
plugin.debug(p.getName() + " has disabled buying and selling");
|
||||
plugin.getDebugLogger().debug(p.getName() + " has disabled buying and selling");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
// Check if item in hand
|
||||
if (inHand == null) {
|
||||
plugin.debug(p.getName() + " does not have an item in his hand");
|
||||
plugin.getDebugLogger().debug(p.getName() + " does not have an item in his hand");
|
||||
|
||||
if (!Config.creativeSelectItem) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_ITEM_IN_HAND));
|
||||
@ -356,13 +356,13 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (is == null) {
|
||||
plugin.getLogger().warning("Invalid item found in blacklist: " + item);
|
||||
plugin.debug("Invalid item in blacklist: " + item);
|
||||
plugin.getDebugLogger().debug("Invalid item in blacklist: " + item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is.getType().equals(itemStack.getType()) && is.getDurability() == itemStack.getDurability()) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CANNOT_SELL_ITEM));
|
||||
plugin.debug(p.getName() + "'s item is on the blacklist");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s item is on the blacklist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -374,7 +374,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (is == null) {
|
||||
plugin.getLogger().warning("Invalid item found in minimum-prices: " + key);
|
||||
plugin.debug("Invalid item in minimum-prices: " + key);
|
||||
plugin.getDebugLogger().debug("Invalid item in minimum-prices: " + key);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (buyEnabled) {
|
||||
if ((buyPrice < amount * minPrice) && (buyPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
|
||||
plugin.debug(p.getName() + "'s buy price is lower than the minimum");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s buy price is lower than the minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -390,7 +390,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (sellEnabled) {
|
||||
if ((sellPrice < amount * minPrice) && (sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SELL_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
|
||||
plugin.debug(p.getName() + "'s sell price is lower than the minimum");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s sell price is lower than the minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -404,7 +404,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (is == null) {
|
||||
plugin.getLogger().warning("Invalid item found in maximum-prices: " + key);
|
||||
plugin.debug("Invalid item in maximum-prices: " + key);
|
||||
plugin.getDebugLogger().debug("Invalid item in maximum-prices: " + key);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (buyEnabled) {
|
||||
if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_HIGH, new Replacement(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
|
||||
plugin.debug(p.getName() + "'s buy price is higher than the maximum");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s buy price is higher than the maximum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -420,7 +420,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (sellEnabled) {
|
||||
if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SELL_PRICE_TOO_HIGH, new Replacement(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
|
||||
plugin.debug(p.getName() + "'s sell price is higher than the maximum");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s sell price is higher than the maximum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -432,7 +432,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (Config.buyGreaterOrEqualSell) {
|
||||
if (buyPrice < sellPrice) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(sellPrice))));
|
||||
plugin.debug(p.getName() + "'s buy price is lower than the sell price");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s buy price is lower than the sell price");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -441,7 +441,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (Enchantment.DURABILITY.canEnchantItem(itemStack)) {
|
||||
if (itemStack.getDurability() > 0 && !Config.allowBrokenItems) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CANNOT_SELL_BROKEN_ITEM));
|
||||
plugin.debug(p.getName() + "'s item is broken");
|
||||
plugin.getDebugLogger().debug(p.getName() + "'s item is broken");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -451,7 +451,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (creationPrice > 0) {
|
||||
if (plugin.getEconomy().getBalance(p, p.getWorld().getName()) < creationPrice) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new Replacement(Placeholder.CREATION_PRICE, String.valueOf(creationPrice))));
|
||||
plugin.debug(p.getName() + " can not pay the creation price");
|
||||
plugin.getDebugLogger().debug(p.getName() + " can not pay the creation price");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -464,10 +464,10 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
ClickType.setPlayerClickType(p, new CreateClickType(product, buyPrice, sellPrice, shopType));
|
||||
plugin.debug(p.getName() + " can now click a chest");
|
||||
plugin.getDebugLogger().debug(p.getName() + " can now click a chest");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_CREATE));
|
||||
} else {
|
||||
plugin.debug("Shop pre create event cancelled");
|
||||
plugin.getDebugLogger().debug("Shop pre create event cancelled");
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -478,16 +478,16 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param p The command executor
|
||||
*/
|
||||
private void remove(final Player p) {
|
||||
plugin.debug(p.getName() + " wants to remove a shop");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to remove a shop");
|
||||
|
||||
ShopPreRemoveEvent event = new ShopPreRemoveEvent(p);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Shop pre remove event cancelled");
|
||||
plugin.getDebugLogger().debug("Shop pre remove event cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + " can now click a chest");
|
||||
plugin.getDebugLogger().debug(p.getName() + " can now click a chest");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_REMOVE));
|
||||
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.REMOVE));
|
||||
}
|
||||
@ -497,16 +497,16 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param p The command executor
|
||||
*/
|
||||
private void info(final Player p) {
|
||||
plugin.debug(p.getName() + " wants to retrieve information");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to retrieve information");
|
||||
|
||||
ShopPreInfoEvent event = new ShopPreInfoEvent(p);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Shop pre info event cancelled");
|
||||
plugin.getDebugLogger().debug("Shop pre info event cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + " can now click a chest");
|
||||
plugin.getDebugLogger().debug(p.getName() + " can now click a chest");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_INFO));
|
||||
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.INFO));
|
||||
}
|
||||
@ -516,16 +516,16 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
* @param p The command executor
|
||||
*/
|
||||
private void open(final Player p) {
|
||||
plugin.debug(p.getName() + " wants to open a shop");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to open a shop");
|
||||
|
||||
ShopPreOpenEvent event = new ShopPreOpenEvent(p);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Shop pre open event cancelled");
|
||||
plugin.getDebugLogger().debug("Shop pre open event cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + " can now click a chest");
|
||||
plugin.getDebugLogger().debug(p.getName() + " can now click a chest");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_OPEN));
|
||||
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.OPEN));
|
||||
}
|
||||
@ -582,7 +582,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean changeConfig(CommandSender sender, String[] args) {
|
||||
plugin.debug(sender.getName() + " is changing the configuration");
|
||||
plugin.getDebugLogger().debug(sender.getName() + " is changing the configuration");
|
||||
|
||||
String property = args[2];
|
||||
String value = args[3];
|
||||
@ -606,7 +606,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
private void removeAll(CommandSender sender, String[] args) {
|
||||
OfflinePlayer vendor = Bukkit.getOfflinePlayer(args[1]);
|
||||
|
||||
plugin.debug(sender.getName() + " is removing all shops of " + vendor.getName());
|
||||
plugin.getDebugLogger().debug(sender.getName() + " is removing all shops of " + vendor.getName());
|
||||
|
||||
plugin.getShopUtils().getShops(vendor, new Callback<Collection<Shop>>(plugin) {
|
||||
@Override
|
||||
@ -616,7 +616,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
ShopRemoveAllEvent event = new ShopRemoveAllEvent(sender, vendor, shops);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()){
|
||||
plugin.debug("Remove all event cancelled");
|
||||
plugin.getDebugLogger().debug("Remove all event cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -527,8 +527,8 @@ public class Config {
|
||||
return (Reader) plugin.getClass().getDeclaredMethod("getTextResource", String.class).invoke(plugin, file);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
if (showMessages) plugin.getLogger().severe("Failed to get file from jar: " + file);
|
||||
plugin.debug("Failed to get file from jar: " + file);
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to get file from jar: " + file);
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -564,7 +564,7 @@ public class Config {
|
||||
|
||||
if (r == null) {
|
||||
if (showMessages) plugin.getLogger().warning("Using default language values");
|
||||
plugin.debug("Using default language values (#1)");
|
||||
plugin.getDebugLogger().debug("Using default language values (#1)");
|
||||
}
|
||||
|
||||
BufferedReader br = new BufferedReader(r);
|
||||
@ -584,8 +584,8 @@ public class Config {
|
||||
plugin.getLogger().warning("Using default language values");
|
||||
}
|
||||
|
||||
plugin.debug("Using default language values (#2)");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Using default language values (#2)");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@ -596,8 +596,8 @@ public class Config {
|
||||
plugin.getLogger().warning("Using default language values");
|
||||
}
|
||||
|
||||
plugin.debug("Using default language values (#3)");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Using default language values (#3)");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -610,8 +610,8 @@ public class Config {
|
||||
plugin.getLogger().warning("Using default language values");
|
||||
}
|
||||
|
||||
plugin.debug("Using default language values (#4)");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Using default language values (#4)");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ public class LanguageConfiguration extends FileConfiguration {
|
||||
if (showMessages)
|
||||
plugin.getLogger().info("Missing translation for \"" + path + "\" has been added as \"" + def + "\" to the selected language file.");
|
||||
} catch (IOException e) {
|
||||
plugin.debug("Failed to add language entry");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to add language entry");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
if (showMessages)
|
||||
plugin.getLogger().severe("Failed to add missing translation for \"" + path + "\" to the selected langauge file.");
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class HologramFormat {
|
||||
// Get lines
|
||||
final ConfigurationSection linesSection = config.getConfigurationSection("lines");
|
||||
if (linesSection == null) {
|
||||
plugin.debug("Can not the hologram format, there is no 'lines' section");
|
||||
plugin.getDebugLogger().debug("Can not the hologram format, there is no 'lines' section");
|
||||
return;
|
||||
}
|
||||
// Get options
|
||||
@ -40,12 +40,12 @@ public class HologramFormat {
|
||||
for (String linesId : linesSection.getKeys(false)) {
|
||||
final ConfigurationSection lineSection = linesSection.getConfigurationSection(linesId);
|
||||
if (lineSection == null) {
|
||||
plugin.debug("'" + linesId + "' is not a line section, skip it in hologram format");
|
||||
plugin.getDebugLogger().debug("'" + linesId + "' is not a line section, skip it in hologram format");
|
||||
continue;
|
||||
}
|
||||
final ConfigurationSection optionSection = lineSection.getConfigurationSection("options");
|
||||
if (optionSection == null) {
|
||||
plugin.debug("The line '" + linesId + "' does not contain 'options' section, skip it in hologram format");
|
||||
plugin.getDebugLogger().debug("The line '" + linesId + "' does not contain 'options' section, skip it in hologram format");
|
||||
continue;
|
||||
}
|
||||
optionSections.put(linesId, optionSection);
|
||||
@ -70,7 +70,7 @@ public class HologramFormat {
|
||||
for (final String optionKey : optionsSection.getKeys(false)) {
|
||||
final ConfigurationSection optionSection = optionsSection.getConfigurationSection(optionKey);
|
||||
if (optionSection == null) {
|
||||
plugin.debug("'" + optionKey + "' is not an option section, skip it in hologram format");
|
||||
plugin.getDebugLogger().debug("'" + optionKey + "' is not an option section, skip it in hologram format");
|
||||
continue;
|
||||
}
|
||||
// Get the requirements
|
||||
@ -89,8 +89,8 @@ public class HologramFormat {
|
||||
data.getRequirementsTypes()
|
||||
);
|
||||
} catch (Exception e) {
|
||||
plugin.debug("Failed to parse the requirement '" + requirement + "'");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to parse the requirement '" + requirement + "'");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -102,13 +102,13 @@ public class HologramFormat {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
plugin.debug("The requirement '" + requirement + "' does not represent a condition");
|
||||
plugin.getDebugLogger().debug("The requirement '" + requirement + "' does not represent a condition");
|
||||
}
|
||||
|
||||
// Get the format
|
||||
final String format = optionSection.getString("format");
|
||||
if (format == null) {
|
||||
plugin.debug("The option '" + optionKey + "' does not contains format. Skip it in hologram format");
|
||||
plugin.getDebugLogger().debug("The option '" + optionKey + "' does not contains format. Skip it in hologram format");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class HologramFormat {
|
||||
}
|
||||
}
|
||||
if (options.isEmpty()) {
|
||||
plugin.debug("The line does not contain any options, skip it in hologram format");
|
||||
plugin.getDebugLogger().debug("The line does not contain any options, skip it in hologram format");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -167,8 +167,8 @@ public class HologramFormat {
|
||||
result = parser.parse(script, data.getPlaceholders(), data.getPlaceholderTypes());
|
||||
} catch (Exception e) {
|
||||
parsedScripts.put(withBrackets, new ParserResult<>(null, null, null, null));
|
||||
plugin.debug("Failed to evaluate the script '" + script + "'");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to evaluate the script '" + script + "'");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
continue;
|
||||
}
|
||||
parsedScripts.put(withBrackets, result);
|
||||
|
13
plugin/src/main/java/de/epiceric/shopchest/external/ExternalManager.java
vendored
Normal file
13
plugin/src/main/java/de/epiceric/shopchest/external/ExternalManager.java
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package de.epiceric.shopchest.external;
|
||||
|
||||
public class ExternalManager {
|
||||
|
||||
public void load() {
|
||||
|
||||
}
|
||||
|
||||
public void enable () {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -68,7 +68,7 @@ public class ChestProtectListener implements Listener {
|
||||
if (creationPrice > 0 && Config.refundShopCreation && p.getUniqueId().equals(shop.getVendor().getUniqueId())) {
|
||||
EconomyResponse r = plugin.getEconomy().depositPlayer(p, shop.getLocation().getWorld().getName(), creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
plugin.debug("Economy transaction failed: " + r.errorMessage);
|
||||
plugin.getDebugLogger().debug("Economy transaction failed: " + r.errorMessage);
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
|
||||
new Replacement(Placeholder.ERROR, r.errorMessage)));
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
|
||||
@ -83,7 +83,7 @@ public class ChestProtectListener implements Listener {
|
||||
});
|
||||
|
||||
shopUtils.removeShop(shop, true);
|
||||
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
plugin.getDebugLogger().debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class ChestProtectListener implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.isSneaking() && Utils.hasAxeInHand(p)) {
|
||||
plugin.debug(String.format("%s tries to break %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
plugin.getDebugLogger().debug(String.format("%s tries to break %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
|
||||
if (shop.getShopType() == Shop.ShopType.ADMIN) {
|
||||
if (p.hasPermission(Permissions.REMOVE_ADMIN)) {
|
||||
@ -219,7 +219,7 @@ public class ChestProtectListener implements Listener {
|
||||
if (shop == null)
|
||||
return;
|
||||
|
||||
plugin.debug(String.format("%s tries to extend %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
plugin.getDebugLogger().debug(String.format("%s tries to extend %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
|
||||
ShopExtendEvent event = new ShopExtendEvent(p, shop, b.getLocation());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@ -248,7 +248,7 @@ public class ChestProtectListener implements Listener {
|
||||
public void onResult(Void result) {
|
||||
newShop.create(true);
|
||||
shopUtils.addShop(newShop, true);
|
||||
plugin.debug(String.format("%s extended %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
plugin.getDebugLogger().debug(String.format("%s extended %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -133,13 +133,13 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
if (e.useInteractedBlock() == Event.Result.DENY && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_PROTECTED));
|
||||
plugin.debug(p.getName() + " is not allowed to create a shop on the selected chest");
|
||||
plugin.getDebugLogger().debug(p.getName() + " is not allowed to create a shop on the selected chest");
|
||||
} else if (shopUtils.isShop(b.getLocation())) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CHEST_ALREADY_SHOP));
|
||||
plugin.debug("Chest is already a shop");
|
||||
plugin.getDebugLogger().debug("Chest is already a shop");
|
||||
} else if (!ItemUtils.isAir(b.getRelative(BlockFace.UP).getType())) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CHEST_BLOCKED));
|
||||
plugin.debug("Chest is blocked");
|
||||
plugin.getDebugLogger().debug("Chest is blocked");
|
||||
} else {
|
||||
CreateClickType clickType = (CreateClickType) ClickType.getPlayerClickType(p);
|
||||
ShopProduct product = clickType.getProduct();
|
||||
@ -183,7 +183,7 @@ public class ShopInteractListener implements Listener {
|
||||
default:
|
||||
if (shop == null) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CHEST_NO_SHOP));
|
||||
plugin.debug("Chest is not a shop");
|
||||
plugin.getDebugLogger().debug("Chest is not a shop");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ public class ShopInteractListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (shop.getShopType() == ShopType.ADMIN || !shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||
plugin.debug(p.getName() + " wants to buy");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to buy");
|
||||
|
||||
if (shop.getBuyPrice() > 0) {
|
||||
if (p.hasPermission(Permissions.BUY)) {
|
||||
@ -278,7 +278,7 @@ public class ShopInteractListener implements Listener {
|
||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||
WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
|
||||
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
||||
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
|
||||
if (!flag.isPresent()) plugin.getDebugLogger().debug("WorldGuard flag '" + flagName + "' is not present!");
|
||||
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
|
||||
externalPluginsAllowed = state == WrappedState.ALLOW;
|
||||
}*/
|
||||
@ -294,14 +294,14 @@ public class ShopInteractListener implements Listener {
|
||||
else needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Needs confirmation");
|
||||
plugin.getDebugLogger().debug("Needs confirmation");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
|
||||
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
|
||||
ids.add(shop.getID());
|
||||
needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug(p.getName() + " doesn't have external plugin's permission");
|
||||
plugin.getDebugLogger().debug(p.getName() + " doesn't have external plugin's permission");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY_HERE));
|
||||
}
|
||||
} else {
|
||||
@ -320,7 +320,7 @@ public class ShopInteractListener implements Listener {
|
||||
else needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Needs confirmation");
|
||||
plugin.getDebugLogger().debug("Needs confirmation");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
|
||||
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
|
||||
ids.add(shop.getID());
|
||||
@ -337,7 +337,7 @@ public class ShopInteractListener implements Listener {
|
||||
else needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Needs confirmation");
|
||||
plugin.getDebugLogger().debug("Needs confirmation");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
|
||||
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
|
||||
ids.add(shop.getID());
|
||||
@ -355,21 +355,21 @@ public class ShopInteractListener implements Listener {
|
||||
new Replacement(Placeholder.ITEM_NAME, shop.getProduct().getLocalizedName()));
|
||||
sendBungeeMessage(shop.getVendor().getName(), message);
|
||||
}
|
||||
plugin.debug("Shop is out of stock");
|
||||
plugin.getDebugLogger().debug("Shop is out of stock");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug(p.getName() + " doesn't have external plugin's permission");
|
||||
plugin.getDebugLogger().debug(p.getName() + " doesn't have external plugin's permission");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY_HERE));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY));
|
||||
plugin.debug(p.getName() + " is not permitted to buy");
|
||||
plugin.getDebugLogger().debug(p.getName() + " is not permitted to buy");
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.BUYING_DISABLED));
|
||||
plugin.debug("Buying is disabled");
|
||||
plugin.getDebugLogger().debug("Buying is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ public class ShopInteractListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
|
||||
if ((shop.getShopType() == ShopType.ADMIN) || (!shop.getVendor().getUniqueId().equals(p.getUniqueId()))) {
|
||||
plugin.debug(p.getName() + " wants to sell");
|
||||
plugin.getDebugLogger().debug(p.getName() + " wants to sell");
|
||||
|
||||
if (shop.getSellPrice() > 0) {
|
||||
if (p.hasPermission(Permissions.SELL)) {
|
||||
@ -405,7 +405,7 @@ public class ShopInteractListener implements Listener {
|
||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||
WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
|
||||
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
||||
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
|
||||
if (!flag.isPresent()) plugin.getDebugLogger().debug("WorldGuard flag '" + flagName + "' is not present!");
|
||||
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
|
||||
externalPluginsAllowed = state == WrappedState.ALLOW;
|
||||
}*/
|
||||
@ -426,7 +426,7 @@ public class ShopInteractListener implements Listener {
|
||||
else needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Needs confirmation");
|
||||
plugin.getDebugLogger().debug("Needs confirmation");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
|
||||
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
|
||||
ids.add(shop.getID());
|
||||
@ -443,7 +443,7 @@ public class ShopInteractListener implements Listener {
|
||||
else needsConfirmation.put(p.getUniqueId(), ids);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Needs confirmation");
|
||||
plugin.getDebugLogger().debug("Needs confirmation");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
|
||||
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
|
||||
ids.add(shop.getID());
|
||||
@ -451,20 +451,20 @@ public class ShopInteractListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_ITEMS));
|
||||
plugin.debug(p.getName() + " doesn't have enough items");
|
||||
plugin.getDebugLogger().debug(p.getName() + " doesn't have enough items");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug(p.getName() + " doesn't have external plugin's permission");
|
||||
plugin.getDebugLogger().debug(p.getName() + " doesn't have external plugin's permission");
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_SELL_HERE));
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_SELL));
|
||||
plugin.debug(p.getName() + " is not permitted to sell");
|
||||
plugin.getDebugLogger().debug(p.getName() + " is not permitted to sell");
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.SELLING_DISABLED));
|
||||
plugin.debug("Selling is disabled");
|
||||
plugin.getDebugLogger().debug("Selling is disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -489,11 +489,11 @@ public class ShopInteractListener implements Listener {
|
||||
* @param shopType Type of the shop
|
||||
*/
|
||||
private void create(final Player executor, final Location location, final ShopProduct product, final double buyPrice, final double sellPrice, final ShopType shopType) {
|
||||
plugin.debug(executor.getName() + " is creating new shop...");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is creating new shop...");
|
||||
|
||||
if (!executor.hasPermission(Permissions.CREATE)) {
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE));
|
||||
plugin.debug(executor.getName() + " is not permitted to create the shop");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is not permitted to create the shop");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -503,7 +503,7 @@ public class ShopInteractListener implements Listener {
|
||||
ShopCreateEvent event = new ShopCreateEvent(executor, shop, creationPrice);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled() && !executor.hasPermission(Permissions.CREATE_PROTECTED)) {
|
||||
plugin.debug("Create event cancelled");
|
||||
plugin.getDebugLogger().debug("Create event cancelled");
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_PROTECTED));
|
||||
return;
|
||||
}
|
||||
@ -513,7 +513,7 @@ public class ShopInteractListener implements Listener {
|
||||
if (creationPrice > 0) {
|
||||
EconomyResponse r = econ.withdrawPlayer(executor, location.getWorld().getName(), creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
plugin.debug("Economy transaction failed: " + r.errorMessage);
|
||||
plugin.getDebugLogger().debug("Economy transaction failed: " + r.errorMessage);
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r.errorMessage)));
|
||||
return;
|
||||
}
|
||||
@ -523,7 +523,7 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
shop.create(true);
|
||||
|
||||
plugin.debug("Shop created");
|
||||
plugin.getDebugLogger().debug("Shop created");
|
||||
shopUtils.addShop(shop, true);
|
||||
|
||||
Message message = shopType == ShopType.ADMIN ? Message.ADMIN_SHOP_CREATED : Message.SHOP_CREATED;
|
||||
@ -549,11 +549,11 @@ public class ShopInteractListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(executor.getName() + " is removing " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is removing " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")");
|
||||
ShopRemoveEvent event = new ShopRemoveEvent(executor, shop);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Remove event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Remove event cancelled (#" + shop.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ public class ShopInteractListener implements Listener {
|
||||
if (creationPrice > 0 && Config.refundShopCreation && executor.getUniqueId().equals(shop.getVendor().getUniqueId())) {
|
||||
EconomyResponse r = econ.depositPlayer(executor, shop.getLocation().getWorld().getName(), creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
plugin.debug("Economy transaction failed: " + r.errorMessage);
|
||||
plugin.getDebugLogger().debug("Economy transaction failed: " + r.errorMessage);
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
|
||||
new Replacement(Placeholder.ERROR, r.errorMessage)));
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED_REFUND,
|
||||
@ -579,7 +579,7 @@ public class ShopInteractListener implements Listener {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
|
||||
shopUtils.removeShop(shop, true);
|
||||
plugin.debug("Removed shop (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Removed shop (#" + shop.getID() + ")");
|
||||
});
|
||||
}, plugin.getShopCreationThreadPool());
|
||||
}
|
||||
@ -596,16 +596,16 @@ public class ShopInteractListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(executor.getName() + " is opening " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is opening " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")");
|
||||
ShopOpenEvent event = new ShopOpenEvent(executor, shop);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Open event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Open event cancelled (#" + shop.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
executor.openInventory(shop.getInventoryHolder().getInventory());
|
||||
plugin.debug("Opened shop (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Opened shop (#" + shop.getID() + ")");
|
||||
if (message) executor.sendMessage(LanguageUtils.getMessage(Message.OPENED_SHOP,
|
||||
new Replacement(Placeholder.VENDOR, shop.getVendor().getName())));
|
||||
}
|
||||
@ -616,12 +616,12 @@ public class ShopInteractListener implements Listener {
|
||||
* @param shop Shop from which the information will be retrieved
|
||||
*/
|
||||
private void info(Player executor, Shop shop) {
|
||||
plugin.debug(executor.getName() + " is retrieving shop info (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is retrieving shop info (#" + shop.getID() + ")");
|
||||
ShopInfoEvent event = new ShopInfoEvent(executor, shop);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug("Info event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Info event cancelled (#" + shop.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -678,7 +678,7 @@ public class ShopInteractListener implements Listener {
|
||||
* @param stack Whether a whole stack should be bought
|
||||
*/
|
||||
private void buy(Player executor, final Shop shop, boolean stack) {
|
||||
plugin.debug(executor.getName() + " is buying (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is buying (#" + shop.getID() + ")");
|
||||
|
||||
ItemStack itemStack = shop.getProduct().getItemStack();
|
||||
int amount = shop.getProduct().getAmount();
|
||||
@ -701,7 +701,7 @@ public class ShopInteractListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(executor.getName() + " has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")");
|
||||
|
||||
double finalPrice = price;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
@ -746,7 +746,7 @@ public class ShopInteractListener implements Listener {
|
||||
double tax = Config.shopTaxes.getOrDefault(itemStack.getType().toString(), Config.shopTaxes.get("default"));
|
||||
|
||||
if (freeSpace >= newAmount) {
|
||||
plugin.debug(executor.getName() + " has enough inventory space for " + freeSpace + " items (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " has enough inventory space for " + freeSpace + " items (#" + shop.getID() + ")");
|
||||
|
||||
EconomyResponse r = econ.withdrawPlayer(executor, worldName, newPrice);
|
||||
|
||||
@ -764,7 +764,7 @@ public class ShopInteractListener implements Listener {
|
||||
if (event.isCancelled()) {
|
||||
econ.depositPlayer(executor, worldName, newPrice);
|
||||
econ.withdrawPlayer(shop.getVendor(), worldName, newPrice * (100d - tax) / 100d);
|
||||
plugin.debug("Buy event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Buy event cancelled (#" + shop.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -788,7 +788,7 @@ public class ShopInteractListener implements Listener {
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.VENDOR, vendorName)));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
|
||||
|
||||
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
|
||||
@ -805,7 +805,7 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
} else {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r2.errorMessage)));
|
||||
econ.withdrawPlayer(shop.getVendor(), worldName, newPrice);
|
||||
econ.depositPlayer(executor, worldName, newPrice * (100d - tax) / 100d);
|
||||
@ -819,7 +819,7 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
if (event.isCancelled()) {
|
||||
econ.depositPlayer(executor, worldName, newPrice * (100d - tax) / 100d);
|
||||
plugin.debug("Buy event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Buy event cancelled (#" + shop.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -840,13 +840,13 @@ public class ShopInteractListener implements Listener {
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.BUY_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(finalNewAmount1)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount1, newProduct.getItemStack().toString(), "ADMIN"));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r.errorMessage)));
|
||||
econ.depositPlayer(executor, worldName, newPrice);
|
||||
}, plugin.getShopCreationThreadPool());
|
||||
@ -868,7 +868,7 @@ public class ShopInteractListener implements Listener {
|
||||
* @param shop Shop, to which the player sells
|
||||
*/
|
||||
private void sell(Player executor, final Shop shop, boolean stack) {
|
||||
plugin.debug(executor.getName() + " is selling (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " is selling (#" + shop.getID() + ")");
|
||||
|
||||
ItemStack itemStack = shop.getProduct().getItemStack();
|
||||
int amount = shop.getProduct().getAmount();
|
||||
@ -890,7 +890,7 @@ public class ShopInteractListener implements Listener {
|
||||
amountForMoney = (int) (finalAmount / finalPrice * econ.getBalance(shop.getVendor(), worldName));
|
||||
}
|
||||
|
||||
plugin.debug("Vendor has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Vendor has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")");
|
||||
|
||||
if (amountForMoney == 0 && Config.autoCalculateItemAmount && shop.getShopType() != ShopType.ADMIN) {
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.VENDOR_NOT_ENOUGH_MONEY));
|
||||
@ -937,7 +937,7 @@ public class ShopInteractListener implements Listener {
|
||||
double tax = plugin.getShopChestConfig().shopTaxes.getOrDefault(itemStack.getType().toString(), plugin.getShopChestConfig().shopTaxes.get("default"));
|
||||
|
||||
if (freeSpace >= newAmount || shop.getShopType() == ShopType.ADMIN) {
|
||||
plugin.debug("Chest has enough inventory space for " + freeSpace + " items (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Chest has enough inventory space for " + freeSpace + " items (#" + shop.getID() + ")");
|
||||
|
||||
int finalNewAmount = newAmount;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
@ -957,7 +957,7 @@ public class ShopInteractListener implements Listener {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
econ.withdrawPlayer(executor, worldName, newPrice * (100d - tax) / 100d);
|
||||
econ.depositPlayer(shop.getVendor(), worldName, newPrice);
|
||||
plugin.debug("Sell event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Sell event cancelled (#" + shop.getID() + ")");
|
||||
}, plugin.getShopCreationThreadPool());
|
||||
return;
|
||||
}
|
||||
@ -982,7 +982,7 @@ public class ShopInteractListener implements Listener {
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.VENDOR, vendorName)));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
plugin.getLogger().info(String.format("%s sold %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
|
||||
|
||||
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
|
||||
@ -999,7 +999,7 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
} else {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r2.errorMessage)));
|
||||
econ.withdrawPlayer(executor, worldName, newPrice * (100d - tax) / 100d);
|
||||
econ.depositPlayer(shop.getVendor(), worldName, newPrice);
|
||||
@ -1013,7 +1013,7 @@ public class ShopInteractListener implements Listener {
|
||||
if (event.isCancelled()) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
econ.withdrawPlayer(executor, worldName, newPrice * (100d - tax) / 100d);
|
||||
plugin.debug("Sell event cancelled (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Sell event cancelled (#" + shop.getID() + ")");
|
||||
}, plugin.getShopCreationThreadPool());
|
||||
return;
|
||||
}
|
||||
@ -1035,13 +1035,13 @@ public class ShopInteractListener implements Listener {
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.SELL_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(finalNewAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), "ADMIN"));
|
||||
}
|
||||
|
||||
} else {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r.errorMessage)));
|
||||
econ.withdrawPlayer(executor, worldName, newPrice);
|
||||
}, plugin.getShopCreationThreadPool());
|
||||
@ -1065,7 +1065,7 @@ public class ShopInteractListener implements Listener {
|
||||
* @return Whether all items were added to the inventory
|
||||
*/
|
||||
private boolean addToInventory(Inventory inventory, ShopProduct product) {
|
||||
plugin.debug("Adding items to inventory...");
|
||||
plugin.getDebugLogger().debug("Adding items to inventory...");
|
||||
|
||||
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
||||
ItemStack itemStack = product.getItemStack();
|
||||
@ -1124,7 +1124,7 @@ public class ShopInteractListener implements Listener {
|
||||
* @return Whether all items were removed from the inventory
|
||||
*/
|
||||
private boolean removeFromInventory(Inventory inventory, ShopProduct product) {
|
||||
plugin.debug("Removing items from inventory...");
|
||||
plugin.getDebugLogger().debug("Removing items from inventory...");
|
||||
|
||||
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
||||
ItemStack itemStack = product.getItemStack();
|
||||
@ -1197,8 +1197,8 @@ public class ShopInteractListener implements Listener {
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.debug("Failed to send bungee message");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to send bungee message");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
plugin.getLogger().warning("Failed to send BungeeCord message");
|
||||
}
|
||||
}
|
||||
|
@ -131,15 +131,15 @@ public class ShopUpdateListener implements Listener {
|
||||
if (result == 0) {
|
||||
return;
|
||||
}
|
||||
plugin.debug("Loaded " + result + " shops in " + chunkCount + " chunks");
|
||||
plugin.getDebugLogger().debug("Loaded " + result + " shops in " + chunkCount + " chunks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
// Database connection probably failed => disable plugin to prevent more errors
|
||||
plugin.getLogger().severe("Failed to load shops in newly loaded chunks");
|
||||
plugin.debug("Failed to load shops in newly loaded chunks");
|
||||
if (throwable != null) plugin.debug(throwable);
|
||||
plugin.getDebugLogger().debug("Failed to load shops in newly loaded chunks");
|
||||
if (throwable != null) plugin.getDebugLogger().debug(throwable);
|
||||
}
|
||||
});
|
||||
newLoadedChunks.clear();
|
||||
|
@ -25,7 +25,7 @@ public class CustomBookMeta {
|
||||
Class<?> craftItemStackClass = obcClassResolver.resolveSilent("inventory.CraftItemStack");
|
||||
|
||||
if (craftItemStackClass == null) {
|
||||
ShopChest.getInstance().debug("Failed to get NBTGeneration: Could not find CraftItemStack class");
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTGeneration: Could not find CraftItemStack class");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -33,13 +33,13 @@ public class CustomBookMeta {
|
||||
|
||||
Object nbtTagCompound = nmsStack.getClass().getMethod("getTag").invoke(nmsStack);
|
||||
if (nbtTagCompound == null) {
|
||||
ShopChest.getInstance().debug("Failed to get NBTGeneration: getTag returned null");
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTGeneration: getTag returned null");
|
||||
return null;
|
||||
}
|
||||
|
||||
Object generationObject = nbtTagCompound.getClass().getMethod("getInt", String.class).invoke(nbtTagCompound, "generation");
|
||||
if (generationObject == null) {
|
||||
ShopChest.getInstance().debug("Failed to get NBTGeneration: getInt returned null");
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTGeneration: getInt returned null");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ public class CustomBookMeta {
|
||||
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
ShopChest.getInstance().getLogger().severe("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().debug("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().debug(e);
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().getDebugLogger().debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -65,7 +65,7 @@ public class CustomBookMeta {
|
||||
Class<?> craftItemStackClass = obcClassResolver.resolveSilent("inventory.CraftItemStack");
|
||||
|
||||
if (craftItemStackClass == null) {
|
||||
ShopChest.getInstance().debug("Failed to get NBTGeneration: Could not find CraftItemStack class");
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTGeneration: Could not find CraftItemStack class");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class CustomBookMeta {
|
||||
|
||||
Object nbtTagCompound = nmsStack.getClass().getMethod("getTag").invoke(nmsStack);
|
||||
if (nbtTagCompound == null) {
|
||||
ShopChest.getInstance().debug("Failed to get NBTGeneration: getTag returned null");
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTGeneration: getTag returned null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ public class CustomBookMeta {
|
||||
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
ShopChest.getInstance().getLogger().severe("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().debug("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().debug(e);
|
||||
ShopChest.getInstance().getDebugLogger().debug("Failed to get NBTEntityID with reflection");
|
||||
ShopChest.getInstance().getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class SpawnEggMeta {
|
||||
Class<?> craftItemStackClass = obcClassResolver.resolveSilent("inventory.CraftItemStack");
|
||||
|
||||
if (craftItemStackClass == null) {
|
||||
plugin.debug("Failed to get NBTEntityID: Could not find CraftItemStack class");
|
||||
plugin.getDebugLogger().debug("Failed to get NBTEntityID: Could not find CraftItemStack class");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -34,8 +34,8 @@ public class SpawnEggMeta {
|
||||
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
plugin.getLogger().severe("Failed to get NBTEntityID with reflection");
|
||||
plugin.debug("Failed to get NBTEntityID with reflection");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to get NBTEntityID with reflection");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -109,7 +109,7 @@ public class Shop {
|
||||
public boolean create(boolean showConsoleMessages) {
|
||||
if (created) return false;
|
||||
|
||||
plugin.debug("Creating shop (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Creating shop (#" + id + ")");
|
||||
|
||||
Block b = location.getBlock();
|
||||
if (!ShopUtils.isShopMaterial(b.getType())) {
|
||||
@ -117,16 +117,16 @@ public class Shop {
|
||||
b.getWorld().getName(), b.getX(), b.getY(), b.getZ()));
|
||||
plugin.getShopUtils().removeShop(this, Config.removeShopOnError);
|
||||
if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage());
|
||||
plugin.debug("Failed to create shop (#" + id + ")");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to create shop (#" + id + ")");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
return false;
|
||||
} else if ((!ItemUtils.isAir(b.getRelative(BlockFace.UP).getType()))) {
|
||||
NotEnoughSpaceException ex = new NotEnoughSpaceException(String.format("No space above chest in world '%s' at location: %d; %d; %d",
|
||||
b.getWorld().getName(), b.getX(), b.getY(), b.getZ()));
|
||||
plugin.getShopUtils().removeShop(this, Config.removeShopOnError);
|
||||
if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage());
|
||||
plugin.debug("Failed to create shop (#" + id + ")");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to create shop (#" + id + ")");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public class Shop {
|
||||
*/
|
||||
public void removeHologram() {
|
||||
if (hologram != null && hologram.exists()) {
|
||||
plugin.debug("Removing hologram (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Removing hologram (#" + id + ")");
|
||||
hologram.remove();
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ public class Shop {
|
||||
*/
|
||||
public void removeItem() {
|
||||
if (item != null) {
|
||||
plugin.debug("Removing shop item (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Removing shop item (#" + id + ")");
|
||||
item.remove();
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class Shop {
|
||||
* <b>Call this after {@link #createHologram(PreCreateResult)}, because it depends on the hologram's location</b>
|
||||
*/
|
||||
private void createItem() {
|
||||
plugin.debug("Creating item (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Creating item (#" + id + ")");
|
||||
|
||||
Location itemLocation;
|
||||
|
||||
@ -191,7 +191,7 @@ public class Shop {
|
||||
* to prepare creating the hologram.
|
||||
*/
|
||||
private PreCreateResult preCreateHologram() {
|
||||
plugin.debug("Creating hologram (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Creating hologram (#" + id + ")");
|
||||
|
||||
InventoryHolder ih = getInventoryHolder();
|
||||
|
||||
|
@ -173,8 +173,8 @@ public abstract class Database {
|
||||
try {
|
||||
time = dateFormat.parse(timestamp).getTime();
|
||||
} catch (ParseException e) {
|
||||
plugin.debug("Failed to parse timestamp '" + timestamp + "': Time is set to 0");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to parse timestamp '" + timestamp + "': Time is set to 0");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
|
||||
String player = rs.getString("executor");
|
||||
@ -263,14 +263,14 @@ public abstract class Database {
|
||||
dataSource = getDataSource();
|
||||
} catch (Exception e) {
|
||||
callback.onError(e);
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataSource == null) {
|
||||
Exception e = new IllegalStateException("Data source is null");
|
||||
callback.onError(e);
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug(e);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ public abstract class Database {
|
||||
int count = rs.getInt(1);
|
||||
initialized = true;
|
||||
|
||||
plugin.debug("Initialized database with " + count + " entries");
|
||||
plugin.getDebugLogger().debug("Initialized database with " + count + " entries");
|
||||
|
||||
if (callback != null) {
|
||||
callback.callSyncResult(count);
|
||||
@ -327,8 +327,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to initialize or connect to database");
|
||||
plugin.debug("Failed to initialize or connect to database");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to initialize or connect to database");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -349,7 +349,7 @@ public abstract class Database {
|
||||
ps.setInt(1, shop.getID());
|
||||
ps.executeUpdate();
|
||||
|
||||
plugin.debug("Removing shop from database (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Removing shop from database (#" + shop.getID() + ")");
|
||||
|
||||
if (callback != null) {
|
||||
callback.callSyncResult(null);
|
||||
@ -360,8 +360,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to remove shop from database");
|
||||
plugin.debug("Failed to remove shop from database (#" + shop.getID() + ")");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to remove shop from database (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -380,7 +380,7 @@ public abstract class Database {
|
||||
Statement s = con.createStatement()) {
|
||||
ResultSet rs = s.executeQuery("SELECT vendor, COUNT(*) AS count FROM " + tableShops + " WHERE shoptype = 'NORMAL' GROUP BY vendor");
|
||||
|
||||
plugin.debug("Getting shop amounts from database");
|
||||
plugin.getDebugLogger().debug("Getting shop amounts from database");
|
||||
|
||||
Map<UUID, Integer> result = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
@ -397,8 +397,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to get shop amounts from database");
|
||||
plugin.debug("Failed to get shop amounts from database");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to get shop amounts from database");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -418,13 +418,13 @@ public abstract class Database {
|
||||
ps.setString(1, playerUuid.toString());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
plugin.debug("Getting a player's shops from database");
|
||||
plugin.getDebugLogger().debug("Getting a player's shops from database");
|
||||
|
||||
Set<Shop> result = new HashSet<>();
|
||||
while (rs.next()) {
|
||||
int id = rs.getInt("id");
|
||||
|
||||
plugin.debug("Getting Shop... (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Getting Shop... (#" + id + ")");
|
||||
|
||||
int x = rs.getInt("x");
|
||||
int y = rs.getInt("y");
|
||||
@ -440,7 +440,7 @@ public abstract class Database {
|
||||
double sellPrice = rs.getDouble("sellprice");
|
||||
ShopType shopType = ShopType.valueOf(rs.getString("shoptype"));
|
||||
|
||||
plugin.debug("Initializing new shop... (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Initializing new shop... (#" + id + ")");
|
||||
|
||||
result.add(new Shop(id, plugin, vendor, product, location, buyPrice, sellPrice, shopType));
|
||||
}
|
||||
@ -454,8 +454,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to get player's shops from database");
|
||||
plugin.debug("Failed to get player's shops from database");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to get player's shops from database");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -527,7 +527,7 @@ public abstract class Database {
|
||||
while (rs.next()) {
|
||||
int id = rs.getInt("id");
|
||||
|
||||
plugin.debug("Getting Shop... (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Getting Shop... (#" + id + ")");
|
||||
|
||||
int x = rs.getInt("x");
|
||||
int y = rs.getInt("y");
|
||||
@ -543,7 +543,7 @@ public abstract class Database {
|
||||
double sellPrice = rs.getDouble("sellprice");
|
||||
ShopType shopType = ShopType.valueOf(rs.getString("shoptype"));
|
||||
|
||||
plugin.debug("Initializing new shop... (#" + id + ")");
|
||||
plugin.getDebugLogger().debug("Initializing new shop... (#" + id + ")");
|
||||
|
||||
shops.add(new Shop(id, plugin, vendor, product, location, buyPrice, sellPrice, shopType));
|
||||
}
|
||||
@ -553,8 +553,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to get shops from database");
|
||||
plugin.debug("Failed to get shops");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to get shops");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -617,15 +617,15 @@ public abstract class Database {
|
||||
callback.callSyncResult(shop.getID());
|
||||
}
|
||||
|
||||
plugin.debug("Adding shop to database (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Adding shop to database (#" + shop.getID() + ")");
|
||||
} catch (SQLException ex) {
|
||||
if (callback != null) {
|
||||
callback.callSyncError(ex);
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to add shop to database");
|
||||
plugin.debug("Failed to add shop to database (#" + shop.getID() + ")");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to add shop to database (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -677,15 +677,15 @@ public abstract class Database {
|
||||
callback.callSyncResult(null);
|
||||
}
|
||||
|
||||
plugin.debug("Logged economy transaction to database");
|
||||
plugin.getDebugLogger().debug("Logged economy transaction to database");
|
||||
} catch (SQLException ex) {
|
||||
if (callback != null) {
|
||||
callback.callSyncError(ex);
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to log economy transaction to database");
|
||||
plugin.debug("Failed to log economy transaction to database");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to log economy transaction to database");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -716,11 +716,11 @@ public abstract class Database {
|
||||
s2.executeUpdate(queryCleanUpPlayers);
|
||||
|
||||
plugin.getLogger().info("Cleaned up economy log");
|
||||
plugin.debug("Cleaned up economy log");
|
||||
plugin.getDebugLogger().debug("Cleaned up economy log");
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().severe("Failed to clean up economy log");
|
||||
plugin.debug("Failed to clean up economy log");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to clean up economy log");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -774,8 +774,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to get revenue from database");
|
||||
plugin.debug("Failed to get revenue from player \"" + player.getUniqueId().toString() + "\"");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to get revenue from player \"" + player.getUniqueId().toString() + "\"");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -801,15 +801,15 @@ public abstract class Database {
|
||||
callback.callSyncResult(null);
|
||||
}
|
||||
|
||||
plugin.debug("Logged logout to database");
|
||||
plugin.getDebugLogger().debug("Logged logout to database");
|
||||
} catch (final SQLException ex) {
|
||||
if (callback != null) {
|
||||
callback.callSyncError(ex);
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to log last logout to database");
|
||||
plugin.debug("Failed to log logout to database");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to log logout to database");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
@ -847,8 +847,8 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
plugin.getLogger().severe("Failed to get last logout from database");
|
||||
plugin.debug("Failed to get last logout from player \"" + player.getName() + "\"");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to get last logout from player \"" + player.getName() + "\"");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
|
@ -41,11 +41,11 @@ public class MySQL extends Database {
|
||||
public void run() {
|
||||
try (Connection con = dataSource.getConnection();
|
||||
Statement s = con.createStatement()) {
|
||||
plugin.debug("Pinging to MySQL server...");
|
||||
plugin.getDebugLogger().debug("Pinging to MySQL server...");
|
||||
s.execute("/* ping */ SELECT 1");
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().severe("Failed to ping to MySQL server. Trying to reconnect...");
|
||||
plugin.debug("Failed to ping to MySQL server. Trying to reconnect...");
|
||||
plugin.getDebugLogger().debug("Failed to ping to MySQL server. Trying to reconnect...");
|
||||
connect(null);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ public class SQLite extends Database {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
} catch (ClassNotFoundException e) {
|
||||
plugin.getLogger().severe("Failed to initialize SQLite driver");
|
||||
plugin.debug("Failed to initialize SQLite driver");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to initialize SQLite driver");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ public class SQLite extends Database {
|
||||
dbFile.createNewFile();
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().severe("Failed to create database file");
|
||||
plugin.debug("Failed to create database file");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to create database file");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -58,11 +58,11 @@ public class SQLite extends Database {
|
||||
Statement s = con.createStatement()) {
|
||||
s.executeUpdate("VACUUM");
|
||||
|
||||
plugin.debug("Vacuumed SQLite database");
|
||||
plugin.getDebugLogger().debug("Vacuumed SQLite database");
|
||||
} catch (final SQLException ex) {
|
||||
plugin.getLogger().warning("Failed to vacuum database");
|
||||
plugin.debug("Failed to vacuum database");
|
||||
plugin.debug(ex);
|
||||
plugin.getDebugLogger().debug("Failed to vacuum database");
|
||||
plugin.getDebugLogger().debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,19 +92,19 @@ public class ShopUtils {
|
||||
*/
|
||||
public void addShop(Shop shop, boolean addToDatabase, Callback<Integer> callback) {
|
||||
InventoryHolder ih = shop.getInventoryHolder();
|
||||
plugin.debug("Adding shop... (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Adding shop... (#" + shop.getID() + ")");
|
||||
|
||||
if (ih instanceof DoubleChest) {
|
||||
DoubleChest dc = (DoubleChest) ih;
|
||||
Chest r = (Chest) dc.getRightSide();
|
||||
Chest l = (Chest) dc.getLeftSide();
|
||||
|
||||
plugin.debug("Added shop as double chest. (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Added shop as double chest. (#" + shop.getID() + ")");
|
||||
|
||||
shopLocation.put(r.getLocation(), shop);
|
||||
shopLocation.put(l.getLocation(), shop);
|
||||
} else {
|
||||
plugin.debug("Added shop as single container. (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Added shop as single container. (#" + shop.getID() + ")");
|
||||
|
||||
shopLocation.put(shop.getLocation(), shop);
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class ShopUtils {
|
||||
shopLocation.forEach((location, shop) -> {
|
||||
if (!shop.isCreated()) return;
|
||||
|
||||
plugin.debug("Removing shop " + shop.getID());
|
||||
plugin.getDebugLogger().debug("Removing shop " + shop.getID());
|
||||
shop.removeItem();
|
||||
shop.removeHologram();
|
||||
});
|
||||
@ -150,7 +150,7 @@ public class ShopUtils {
|
||||
* @see ShopUtils#removeShopById(int, boolean, Callback)
|
||||
*/
|
||||
public void removeShop(Shop shop, boolean removeFromDatabase, Callback<Void> callback) {
|
||||
plugin.debug("Removing shop (#" + shop.getID() + ")");
|
||||
plugin.getDebugLogger().debug("Removing shop (#" + shop.getID() + ")");
|
||||
|
||||
if (shop.isCreated()) {
|
||||
InventoryHolder ih = shop.getInventoryHolder();
|
||||
@ -201,7 +201,7 @@ public class ShopUtils {
|
||||
.filter(e -> e.getValue().getID() == shopId)
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
plugin.debug(String.format("Removing %d shop(s) with ID %d", toRemove.size(), shopId));
|
||||
plugin.getDebugLogger().debug(String.format("Removing %d shop(s) with ID %d", toRemove.size(), shopId));
|
||||
|
||||
if (toRemove.isEmpty()) {
|
||||
if (callback != null) callback.callSyncResult(null);
|
||||
|
@ -28,7 +28,7 @@ public class UpdateChecker {
|
||||
*/
|
||||
public UpdateCheckerResult check() {
|
||||
try {
|
||||
plugin.debug("Checking for updates...");
|
||||
plugin.getDebugLogger().debug("Checking for updates...");
|
||||
|
||||
URL url = new URL("https://api.spiget.org/v2/resources/11431/versions?size=1&page=1&sort=-releaseDate");
|
||||
URLConnection conn = url.openConnection();
|
||||
@ -43,22 +43,22 @@ public class UpdateChecker {
|
||||
version = result.get("name").getAsString();
|
||||
link = "https://www.spigotmc.org/resources/shopchest.11431/download?version=" + id;
|
||||
} else {
|
||||
plugin.debug("Failed to check for updates");
|
||||
plugin.debug("Result: " + element);
|
||||
plugin.getDebugLogger().debug("Failed to check for updates");
|
||||
plugin.getDebugLogger().debug("Result: " + element);
|
||||
return UpdateCheckerResult.ERROR;
|
||||
}
|
||||
|
||||
if (compareVersion(version) == 1) {
|
||||
plugin.debug("No update found");
|
||||
plugin.getDebugLogger().debug("No update found");
|
||||
return UpdateCheckerResult.FALSE;
|
||||
} else {
|
||||
plugin.debug("Update found: " + version);
|
||||
plugin.getDebugLogger().debug("Update found: " + version);
|
||||
return UpdateCheckerResult.TRUE;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
plugin.debug("Failed to check for updates");
|
||||
plugin.debug(e);
|
||||
plugin.getDebugLogger().debug("Failed to check for updates");
|
||||
plugin.getDebugLogger().debug(e);
|
||||
return UpdateCheckerResult.ERROR;
|
||||
}
|
||||
}
|
||||
|
7
pom.xml
7
pom.xml
@ -10,6 +10,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>common</module>
|
||||
<module>plugin</module>
|
||||
<module>nms/interface</module>
|
||||
<module>nms/reflection</module>
|
||||
@ -296,6 +297,12 @@
|
||||
</dependency>
|
||||
|
||||
<!-- Internal shaded dependencies -->
|
||||
<!-- Common -->
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
<artifactId>shopchest-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<!-- NMS -->
|
||||
<dependency>
|
||||
<groupId>de.epiceric</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user