diff --git a/README.md b/README.md
index e1425e18..075cc6b3 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-LibsDisguises
+LibsDisguises (1.9+)
=============
-A disguise plugin made by libraryaddict which is pretty cool
+A disguise plugin made by libraryaddict which is pretty cool.
When posting an issue:
Please make sure you
1) Post a stack trace error, if no stack trace, then post the odd behavior
2) Post the exact steps you used in order to reproduce the issue.
-3) Give as much information as possible as to what the issue is and why it occured so that we can fix it.
+3) Give as much information as possible as to what the issue is and why it occurred so that we can fix it.
diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java
index c2353f3f..3edd16aa 100644
--- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java
+++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java
@@ -1,10 +1,20 @@
package me.libraryaddict.disguise;
import com.comphenix.protocol.reflect.FieldAccessException;
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import me.libraryaddict.disguise.commands.*;
+import com.comphenix.protocol.wrappers.WrappedDataWatcher;
+import com.comphenix.protocol.wrappers.WrappedWatchableObject;
+import me.libraryaddict.disguise.commands.DisguiseCloneCommand;
+import me.libraryaddict.disguise.commands.DisguiseCommand;
+import me.libraryaddict.disguise.commands.DisguiseEntityCommand;
+import me.libraryaddict.disguise.commands.DisguiseHelpCommand;
+import me.libraryaddict.disguise.commands.DisguisePlayerCommand;
+import me.libraryaddict.disguise.commands.DisguiseRadiusCommand;
+import me.libraryaddict.disguise.commands.DisguiseViewSelf;
+import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
+import me.libraryaddict.disguise.commands.UndisguiseCommand;
+import me.libraryaddict.disguise.commands.UndisguiseEntityCommand;
+import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
+import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
@@ -17,10 +27,11 @@ import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
import me.libraryaddict.disguise.utilities.DisguiseSound;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
+import me.libraryaddict.disguise.utilities.DisguiseValues;
+import me.libraryaddict.disguise.utilities.FakeBoundingBox;
+import me.libraryaddict.disguise.utilities.Metrics;
import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utilities.ReflectionManager;
-import me.libraryaddict.disguise.utilities.DisguiseValues;
-
import org.bukkit.Bukkit;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Damageable;
@@ -28,17 +39,15 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Zombie;
+import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
-import com.comphenix.protocol.wrappers.WrappedDataWatcher;
-import com.comphenix.protocol.wrappers.WrappedWatchableObject;
-import me.libraryaddict.disguise.utilities.FakeBoundingBox;
-import me.libraryaddict.disguise.utilities.Metrics;
-import org.bukkit.event.HandlerList;
+import java.io.IOException;
+import java.lang.reflect.Field;
public class LibsDisguises extends JavaPlugin {
- public static LibsDisguises instance; //I'm sorry Sun MicroSystems and all mighty Java God
+ private static LibsDisguises instance;
private DisguiseListener listener;
@Override
@@ -269,4 +278,13 @@ public class LibsDisguises extends JavaPlugin {
public DisguiseListener getListener() {
return listener;
}
+
+ /**
+ * External APIs shouldn't actually need this instance.
+ * DisguiseAPI should be enough to handle most cases.
+ * @return The instance of this plugin
+ */
+ public static LibsDisguises getInstance() {
+ return instance;
+ }
}
diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java
index 2bfb580f..b439873b 100644
--- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java
+++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java
@@ -1,19 +1,17 @@
package me.libraryaddict.disguise.commands;
-import java.util.ArrayList;
-import java.util.HashMap;
-
import me.libraryaddict.disguise.DisguiseConfig;
-import me.libraryaddict.disguise.DisguiseListener;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
-
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
+import java.util.ArrayList;
+import java.util.HashMap;
+
public class DisguiseCloneCommand extends BaseDisguiseCommand {
@Override
@@ -43,7 +41,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
return true;
}
}
- LibsDisguises.instance.getListener().setDisguiseClone(sender.getName(), new Boolean[]{doEquipment, doSneak, doSprint});
+ LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), new Boolean[]{doEquipment, doSneak, doSprint});
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire()
+ " seconds to grab the disguise reference!");
} else {
diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java
index 429ec01f..3f2497a6 100644
--- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java
+++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java
@@ -1,9 +1,5 @@
package me.libraryaddict.disguise.commands;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@@ -14,6 +10,10 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
public class DisguiseEntityCommand extends BaseDisguiseCommand {
@Override
@@ -34,7 +34,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
ex.printStackTrace(System.out);
return true;
}
- LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), disguise);
+ LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
return true;
diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
index 293dd2aa..8b79763f 100644
--- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
+++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
@@ -21,7 +21,7 @@ public class LibsDisguisesCommand implements CommandExecutor {
} else if (args.length > 0) {
if (sender.hasPermission("libsdisguises.reload")) {
if (args[0].equalsIgnoreCase("reload")) {
- LibsDisguises.instance.reload();
+ LibsDisguises.getInstance().reload();
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
return true;
} else {
diff --git a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java b/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java
index 7a182cb8..98ad3190 100644
--- a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java
+++ b/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java
@@ -1,8 +1,6 @@
package me.libraryaddict.disguise.commands;
-import me.libraryaddict.disguise.DisguiseListener;
import me.libraryaddict.disguise.LibsDisguises;
-
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -17,7 +15,7 @@ public class UndisguiseEntityCommand implements CommandExecutor {
return true;
}
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
- LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), null);
+ LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), null);
sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!");
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java
index f5616fd6..719e0073 100644
--- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java
+++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java
@@ -1,13 +1,12 @@
package me.libraryaddict.disguise.disguisetypes;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.UUID;
-
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.reflect.StructureModifier;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig;
+import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
@@ -16,27 +15,25 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
import me.libraryaddict.disguise.events.DisguiseEvent;
import me.libraryaddict.disguise.events.UndisguiseEvent;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
+import me.libraryaddict.disguise.utilities.DisguiseValues;
import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utilities.ReflectionManager;
-import me.libraryaddict.disguise.utilities.DisguiseValues;
-
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
-import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Horse.Variant;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.ProtocolLibrary;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.reflect.StructureModifier;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import me.libraryaddict.disguise.LibsDisguises;
+import java.util.UUID;
public abstract class Disguise {
@@ -743,7 +740,7 @@ public abstract class Disguise {
// Just return.
if (!event.isCancelled()) {
disguiseInUse = true;
- task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.instance, velocityRunnable, 1, 1);
+ task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
// Stick the disguise in the disguises bin
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
@@ -752,7 +749,7 @@ public abstract class Disguise {
// Resend the disguised entity's packet
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
// If he is a player, then self disguise himself
- Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.instance, new Runnable() {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
@Override
public void run() {
DisguiseUtilities.setupFakeDisguise(Disguise.this);
diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java
index a85df6ec..edbb5d59 100644
--- a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java
+++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java
@@ -174,7 +174,7 @@ public class PlayerDisguise extends TargetedDisguise {
if (skinToUse.length() > 16) {
this.skinToUse = skinToUse.substring(0, 16);
}
- if (LibsDisguises.instance.getConfig().getBoolean("ContactMojangServers", true)) {
+ if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) {
currentLookup = new LibsProfileLookup() {
@Override
public void onLookup(WrappedGameProfile gameProfile) {
@@ -208,7 +208,7 @@ public class PlayerDisguise extends TargetedDisguise {
this.skinToUse = null;
return this;
}
- if (LibsDisguises.instance.getConfig().getBoolean("ContactMojangServers", true)) {
+ if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) {
Validate.notEmpty(gameProfile.getName(), "Name must be set");
this.skinToUse = gameProfile.getName();
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);