1.9+ Initial Commit
LibsDisguises.instance is no longer exposed, replaced with LibsDisguises.getInstance()
This commit is contained in:
parent
321ecdb3c2
commit
9847ff035a
@ -1,10 +1,10 @@
|
|||||||
LibsDisguises
|
LibsDisguises (1.9+)
|
||||||
=============
|
=============
|
||||||
|
|
||||||
A disguise plugin made by libraryaddict which is pretty cool<br>
|
A disguise plugin made by libraryaddict which is pretty cool.<br>
|
||||||
|
|
||||||
When posting an issue:<br>
|
When posting an issue:<br>
|
||||||
Please make sure you<br>
|
Please make sure you<br>
|
||||||
1) Post a stack trace error, if no stack trace, then post the odd behavior<br>
|
1) Post a stack trace error, if no stack trace, then post the odd behavior<br>
|
||||||
2) Post the exact steps you used in order to reproduce the issue.<br>
|
2) Post the exact steps you used in order to reproduce the issue.<br>
|
||||||
3) Give as much information as possible as to what the issue is and why it occured so that we can fix it.<br>
|
3) Give as much information as possible as to what the issue is and why it occurred so that we can fix it.<br>
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
import java.io.IOException;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import java.lang.reflect.Field;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import me.libraryaddict.disguise.commands.DisguiseCloneCommand;
|
||||||
import me.libraryaddict.disguise.commands.*;
|
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.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
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.disguisetypes.watchers.ZombieWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
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.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Damageable;
|
import org.bukkit.entity.Damageable;
|
||||||
@ -28,17 +39,15 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import java.io.IOException;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import java.lang.reflect.Field;
|
||||||
import me.libraryaddict.disguise.utilities.FakeBoundingBox;
|
|
||||||
import me.libraryaddict.disguise.utilities.Metrics;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class LibsDisguises extends JavaPlugin {
|
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;
|
private DisguiseListener listener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -269,4 +278,13 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
public DisguiseListener getListener() {
|
public DisguiseListener getListener() {
|
||||||
return listener;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.DisguiseListener;
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,7 +41,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
|||||||
return true;
|
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()
|
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire()
|
||||||
+ " seconds to grab the disguise reference!");
|
+ " seconds to grab the disguise reference!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
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.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
@ -14,6 +10,10 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,7 +34,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
|||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace(System.out);
|
||||||
return true;
|
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()
|
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
|
||||||
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,7 +21,7 @@ public class LibsDisguisesCommand implements CommandExecutor {
|
|||||||
} else if (args.length > 0) {
|
} else if (args.length > 0) {
|
||||||
if (sender.hasPermission("libsdisguises.reload")) {
|
if (sender.hasPermission("libsdisguises.reload")) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
LibsDisguises.instance.reload();
|
LibsDisguises.getInstance().reload();
|
||||||
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseListener;
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -17,7 +15,7 @@ public class UndisguiseEntityCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
|
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!");
|
sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import com.comphenix.protocol.PacketType;
|
||||||
import java.util.HashMap;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import java.util.HashSet;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import java.util.Iterator;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
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.DisguiseEvent;
|
||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.UUID;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
|
||||||
|
|
||||||
public abstract class Disguise {
|
public abstract class Disguise {
|
||||||
|
|
||||||
@ -743,7 +740,7 @@ public abstract class Disguise {
|
|||||||
// Just return.
|
// Just return.
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
disguiseInUse = true;
|
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
|
// Stick the disguise in the disguises bin
|
||||||
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
|
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
|
||||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
||||||
@ -752,7 +749,7 @@ public abstract class Disguise {
|
|||||||
// Resend the disguised entity's packet
|
// Resend the disguised entity's packet
|
||||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
||||||
// If he is a player, then self disguise himself
|
// If he is a player, then self disguise himself
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.instance, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DisguiseUtilities.setupFakeDisguise(Disguise.this);
|
DisguiseUtilities.setupFakeDisguise(Disguise.this);
|
||||||
|
@ -174,7 +174,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
if (skinToUse.length() > 16) {
|
if (skinToUse.length() > 16) {
|
||||||
this.skinToUse = skinToUse.substring(0, 16);
|
this.skinToUse = skinToUse.substring(0, 16);
|
||||||
}
|
}
|
||||||
if (LibsDisguises.instance.getConfig().getBoolean("ContactMojangServers", true)) {
|
if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) {
|
||||||
currentLookup = new LibsProfileLookup() {
|
currentLookup = new LibsProfileLookup() {
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
@ -208,7 +208,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
this.skinToUse = null;
|
this.skinToUse = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (LibsDisguises.instance.getConfig().getBoolean("ContactMojangServers", true)) {
|
if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) {
|
||||||
Validate.notEmpty(gameProfile.getName(), "Name must be set");
|
Validate.notEmpty(gameProfile.getName(), "Name must be set");
|
||||||
this.skinToUse = gameProfile.getName();
|
this.skinToUse = gameProfile.getName();
|
||||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);
|
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);
|
||||||
|
Loading…
Reference in New Issue
Block a user