cleanup + moved legacy chestshop support

This commit is contained in:
Gabriele C
2015-10-04 14:33:21 +02:00
parent 4324a1a89a
commit 5576b117c9
12 changed files with 16 additions and 554 deletions
+9 -41
View File
@@ -65,7 +65,6 @@ public class AuthMe extends JavaPlugin {
private JsonCache playerBackup;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
public boolean legacyChestShop = false;
public boolean antibotMod = false;
public boolean delayedAntiBot = true;
@@ -192,9 +191,6 @@ public class AuthMe extends JavaPlugin {
// Check Multiverse
checkMultiverse();
// Check ChestShop
checkChestShop();
// Check Essentials
checkEssentials();
@@ -242,12 +238,6 @@ public class AuthMe extends JavaPlugin {
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
}
// Legacy chestshop hook
if (legacyChestShop) {
pm.registerEvents(new AuthMeChestShopListener(this), this);
ConsoleLogger.info("Hooked successfully with ChestShop!");
}
// Reload support hook
if (Settings.reloadSupport) {
if (database != null) {
@@ -425,34 +415,6 @@ public class AuthMe extends JavaPlugin {
}
}
// Check the version of the ChestShop plugin
public void checkChestShop() {
if (Settings.legacyChestShop && server.getPluginManager().isPluginEnabled("ChestShop")) {
String rawver = com.Acrobot.ChestShop.ChestShop.getVersion();
double version;
try {
version = Double.valueOf(rawver.split(" ")[0]);
} catch (NumberFormatException nfe) {
try {
version = Double.valueOf(rawver.split("t")[0]);
} catch (NumberFormatException nfee) {
legacyChestShop = false;
return;
}
}
if (version >= 3.813) {
return;
}
if (version < 3.50) {
ConsoleLogger.showError("Please Update your ChestShop version! Bugs may occur!");
return;
}
legacyChestShop = true;
} else {
legacyChestShop = false;
}
}
// Get the Multiverse plugin
public void checkMultiverse() {
if (Settings.multiverse && server.getPluginManager().isPluginEnabled("Multiverse-Core")) {
@@ -506,10 +468,16 @@ public class AuthMe extends JavaPlugin {
}
}
// Check the presence of the ProtocolLib plugin
public void checkProtocolLib() {
if (server.getPluginManager().isPluginEnabled("ProtocolLib")) {
inventoryProtector = new AuthMeInventoryListener(this);
ProtocolLibrary.getProtocolManager().addPacketListener(inventoryProtector);
if (Settings.protectInventoryBeforeLogInEnabled) {
if (server.getPluginManager().isPluginEnabled("ProtocolLib")) {
inventoryProtector = new AuthMeInventoryListener(this);
ProtocolLibrary.getProtocolManager().addPacketListener(inventoryProtector);
} else {
ConsoleLogger.showError("WARNING!!! The protectInventory feature requires ProtocolLib! Disabling it...");
Settings.protectInventoryBeforeLogInEnabled = false;
}
}
}
@@ -1,25 +0,0 @@
package fr.xephi.authme.listener;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class AuthMeChestShopListener implements Listener {
public AuthMe plugin;
public AuthMeChestShopListener(AuthMe plugin) {
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPreTransaction(PreTransactionEvent event) {
if (Utils.checkAuth(event.getClient()))
return;
event.setCancelled(TransactionOutcome.OTHER);
}
}
@@ -56,10 +56,6 @@ public class AuthMeServerListener implements Listener {
ConsoleLogger.info("Multiverse-Core has been disabled, unhook!");
return;
}
if (pluginName.equalsIgnoreCase("ChestShop")) {
plugin.legacyChestShop = false;
ConsoleLogger.info("ChestShop has been disabled, unhook!");
}
if (pluginName.equalsIgnoreCase("CombatTagPlus")) {
plugin.combatTagPlus = null;
ConsoleLogger.info("CombatTagPlus has been disabled, unhook!");
@@ -81,8 +77,6 @@ public class AuthMeServerListener implements Listener {
plugin.checkEssentials();
if (pluginName.equalsIgnoreCase("Multiverse-Core"))
plugin.checkMultiverse();
if (pluginName.equalsIgnoreCase("ChestShop"))
plugin.checkChestShop();
if (pluginName.equalsIgnoreCase("CombatTagPlus"))
plugin.checkCombatTagPlus();
if (pluginName.equalsIgnoreCase("Vault"))
@@ -60,7 +60,7 @@ public final class Settings extends YamlConfiguration {
protectInventoryBeforeLogInEnabled, isBackupActivated,
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
useCaptcha, emailRegistration, multiverse, legacyChestShop, bungee,
useCaptcha, emailRegistration, multiverse, bungee,
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge,
purgePlayerDat, purgeEssentialsFile, supportOldPassword,
@@ -222,7 +222,6 @@ public final class Settings extends YamlConfiguration {
saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
multiverse = configFile.getBoolean("Hooks.multiverse", true);
legacyChestShop = configFile.getBoolean("Hooks.legacyChestshop", false);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
getForcedWorlds = configFile.getStringList("settings.restrictions.ForceSpawnOnTheseWorlds");
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
@@ -462,12 +461,13 @@ public final class Settings extends YamlConfiguration {
changes = true;
}
if (contains("Hooks.chestshop")) {
if (getBoolean("Hooks.chestshop")) {
set("Hooks.legacyChestshop", true);
}
set("Hooks.chestshop", null);
changes = true;
}
if (contains("Hooks.legacyChestshop")) {
set("Hooks.legacyChestshop", null);
changes = true;
}
if (!contains("Email.generateImage")) {
set("Email.generateImage", true);
changes = true;