Renable some disguises, fix player sleeping? I forgot what I did
This commit is contained in:
parent
acc21a6d6e
commit
bf3c11878a
@ -179,7 +179,7 @@ public class DisguiseAPI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ public class DisguiseListener implements Listener
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ public class LibsDisguises extends JavaPlugin
|
|||||||
System.out.print("[LibsDisguises] Development builds are available at (ProtocolLib) "
|
System.out.print("[LibsDisguises] Development builds are available at (ProtocolLib) "
|
||||||
+ "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/");
|
+ "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/");
|
||||||
|
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
return getPermissions(sender, "libsdisguises." + getClass().getSimpleName().replace("Command", "").toLowerCase() + ".");
|
return getPermissions(sender, "libsdisguises." + getClass().getSimpleName().replace("Command", "").toLowerCase() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HashMap<String, Boolean> getDisguisePermission(CommandSender sender, DisguiseType type)
|
protected HashMap<String, Boolean> getDisguiseOptions(CommandSender sender, DisguiseType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -135,7 +135,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +159,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions())
|
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions())
|
||||||
{
|
{
|
||||||
String perm = permission.getPermission().toLowerCase();
|
String perm = permission.getPermission().toLowerCase();
|
||||||
|
|
||||||
if (perm.startsWith(permissionNode) && (!perms.containsKey(perm) || !permission.getValue()))
|
if (perm.startsWith(permissionNode) && (!perms.containsKey(perm) || !permission.getValue()))
|
||||||
{
|
{
|
||||||
perms.put(perm, permission.getValue());
|
perms.put(perm, permission.getValue());
|
||||||
@ -192,6 +193,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dType != null)
|
if (dType != null)
|
||||||
{
|
{
|
||||||
HashMap<ArrayList<String>, Boolean> list;
|
HashMap<ArrayList<String>, Boolean> list;
|
||||||
@ -255,9 +257,11 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
options = getOptions(perm);
|
options = getOptions(perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options != null)
|
if (options != null)
|
||||||
{
|
{
|
||||||
HashMap<ArrayList<String>, Boolean> list;
|
HashMap<ArrayList<String>, Boolean> list;
|
||||||
|
|
||||||
if (rangeDisguises.containsKey(type))
|
if (rangeDisguises.containsKey(type))
|
||||||
{
|
{
|
||||||
list = rangeDisguises.get(type);
|
list = rangeDisguises.get(type);
|
||||||
@ -267,13 +271,16 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
list = new HashMap<>();
|
list = new HashMap<>();
|
||||||
rangeDisguises.put(type, list);
|
rangeDisguises.put(type, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm);
|
HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm);
|
||||||
|
|
||||||
list.put(map1.keySet().iterator().next(), map1.values().iterator().next());
|
list.put(map1.keySet().iterator().next(), map1.values().iterator().next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String perm : perms.keySet())
|
for (String perm : perms.keySet())
|
||||||
{
|
{
|
||||||
if (!perms.get(perm))
|
if (!perms.get(perm))
|
||||||
@ -281,6 +288,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
perm = perm.substring(permissionNode.length());
|
perm = perm.substring(permissionNode.length());
|
||||||
String disguiseType = perm.split("\\.")[0];
|
String disguiseType = perm.split("\\.")[0];
|
||||||
DisguiseType dType = null;
|
DisguiseType dType = null;
|
||||||
|
|
||||||
for (DisguiseType t : DisguiseType.values())
|
for (DisguiseType t : DisguiseType.values())
|
||||||
{
|
{
|
||||||
if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", "")))
|
if (t.name().replace("_", "").equalsIgnoreCase(disguiseType.replace("_", "")))
|
||||||
@ -289,6 +297,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dType != null)
|
if (dType != null)
|
||||||
{
|
{
|
||||||
singleDisguises.remove(dType);
|
singleDisguises.remove(dType);
|
||||||
@ -300,6 +309,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
boolean foundHim = false;
|
boolean foundHim = false;
|
||||||
Class entityClass = type.getEntityClass();
|
Class entityClass = type.getEntityClass();
|
||||||
|
|
||||||
switch (disguiseType)
|
switch (disguiseType)
|
||||||
{
|
{
|
||||||
case "mob":
|
case "mob":
|
||||||
@ -307,6 +317,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "animal":
|
case "animal":
|
||||||
case "animals":
|
case "animals":
|
||||||
@ -314,6 +325,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "monster":
|
case "monster":
|
||||||
case "monsters":
|
case "monsters":
|
||||||
@ -321,23 +333,27 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "misc":
|
case "misc":
|
||||||
if (type.isMisc())
|
if (type.isMisc())
|
||||||
{
|
{
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "ageable":
|
case "ageable":
|
||||||
if (Ageable.class.isAssignableFrom(entityClass))
|
if (Ageable.class.isAssignableFrom(entityClass))
|
||||||
{
|
{
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "*":
|
case "*":
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundHim)
|
if (foundHim)
|
||||||
{
|
{
|
||||||
rangeDisguises.remove(type);
|
rangeDisguises.remove(type);
|
||||||
@ -346,23 +362,29 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<>();
|
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<>();
|
||||||
|
|
||||||
for (DisguiseType type : DisguiseType.values())
|
for (DisguiseType type : DisguiseType.values())
|
||||||
{
|
{
|
||||||
HashMap<ArrayList<String>, Boolean> temp = new HashMap<>();
|
HashMap<ArrayList<String>, Boolean> temp = new HashMap<>();
|
||||||
|
|
||||||
if (singleDisguises.containsKey(type))
|
if (singleDisguises.containsKey(type))
|
||||||
{
|
{
|
||||||
temp.putAll(singleDisguises.get(type));
|
temp.putAll(singleDisguises.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rangeDisguises.containsKey(type))
|
if (rangeDisguises.containsKey(type))
|
||||||
{
|
{
|
||||||
temp.putAll(rangeDisguises.get(type));
|
temp.putAll(rangeDisguises.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!temp.isEmpty())
|
if (!temp.isEmpty())
|
||||||
{
|
{
|
||||||
map.put(type, temp);
|
map.put(type, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,8 +408,10 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
list.add(option);
|
list.add(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
|
HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
|
||||||
options.put(list, isRemove);
|
options.put(list, isRemove);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +467,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
sendCommandUsage(sender, map);
|
sendCommandUsage(sender, map);
|
||||||
throw new DisguiseParseException();
|
throw new DisguiseParseException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// How many args to skip due to the disugise being constructed
|
// How many args to skip due to the disugise being constructed
|
||||||
// Time to start constructing the disguise.
|
// Time to start constructing the disguise.
|
||||||
// We will need to check between all 3 kinds of disguises
|
// We will need to check between all 3 kinds of disguises
|
||||||
@ -450,6 +475,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
ArrayList<String> usedOptions = new ArrayList<>();
|
ArrayList<String> usedOptions = new ArrayList<>();
|
||||||
Disguise disguise = null;
|
Disguise disguise = null;
|
||||||
HashMap<ArrayList<String>, Boolean> optionPermissions;
|
HashMap<ArrayList<String>, Boolean> optionPermissions;
|
||||||
|
|
||||||
if (args[0].startsWith("@"))
|
if (args[0].startsWith("@"))
|
||||||
{
|
{
|
||||||
if (sender.hasPermission("libsdisguises.disguise.disguiseclone"))
|
if (sender.hasPermission("libsdisguises.disguise.disguiseclone"))
|
||||||
@ -486,6 +512,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguiseType == null)
|
if (disguiseType == null)
|
||||||
{
|
{
|
||||||
throw new DisguiseParseException(
|
throw new DisguiseParseException(
|
||||||
@ -509,7 +536,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
|
|
||||||
optionPermissions = map.get(disguiseType);
|
optionPermissions = map.get(disguiseType);
|
||||||
|
|
||||||
HashMap<String, Boolean> disguiseOptions = this.getDisguisePermission(sender, disguiseType);
|
HashMap<String, Boolean> disguiseOptions = this.getDisguiseOptions(sender, disguiseType);
|
||||||
|
|
||||||
if (disguiseType.isPlayer())
|
if (disguiseType.isPlayer())
|
||||||
{
|
{
|
||||||
@ -539,6 +566,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
if (disguiseType.isMob())
|
if (disguiseType.isMob())
|
||||||
{ // Its a mob, use the mob constructor
|
{ // Its a mob, use the mob constructor
|
||||||
boolean adult = true;
|
boolean adult = true;
|
||||||
|
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("baby") || args[1].equalsIgnoreCase("adult"))
|
if (args[1].equalsIgnoreCase("baby") || args[1].equalsIgnoreCase("adult"))
|
||||||
@ -549,6 +577,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
toSkip++;
|
toSkip++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disguise = new MobDisguise(disguiseType, adult);
|
disguise = new MobDisguise(disguiseType, adult);
|
||||||
}
|
}
|
||||||
else if (disguiseType.isMisc())
|
else if (disguiseType.isMisc())
|
||||||
@ -630,6 +659,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
if (!disguiseOptions.isEmpty() && miscId != -1)
|
if (!disguiseOptions.isEmpty() && miscId != -1)
|
||||||
{
|
{
|
||||||
String toCheck = "" + miscId;
|
String toCheck = "" + miscId;
|
||||||
|
|
||||||
if (miscData == 0 || miscData == -1)
|
if (miscData == 0 || miscData == -1)
|
||||||
{
|
{
|
||||||
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck))
|
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck))
|
||||||
@ -641,6 +671,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
toCheck += ":" + miscData;
|
toCheck += ":" + miscData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck))
|
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck))
|
||||||
{
|
{
|
||||||
throw new DisguiseParseException(
|
throw new DisguiseParseException(
|
||||||
@ -1000,7 +1031,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
methodToUse = null;
|
methodToUse = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,17 +1041,21 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
|
|||||||
{
|
{
|
||||||
throw storedEx;
|
throw storedEx;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new DisguiseParseException(ChatColor.RED + "Cannot find the option " + methodName);
|
throw new DisguiseParseException(ChatColor.RED + "Cannot find the option " + methodName);
|
||||||
}
|
}
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
throw new DisguiseParseException(ChatColor.RED + "No value was given for the option " + methodName);
|
throw new DisguiseParseException(ChatColor.RED + "No value was given for the option " + methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usedOptions.contains(methodName.toLowerCase()))
|
if (!usedOptions.contains(methodName.toLowerCase()))
|
||||||
{
|
{
|
||||||
usedOptions.add(methodName.toLowerCase());
|
usedOptions.add(methodName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(optionPermissions, usedOptions);
|
||||||
|
|
||||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass()))
|
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass()))
|
||||||
{
|
{
|
||||||
methodToUse.invoke(disguise.getWatcher(), value);
|
methodToUse.invoke(disguise.getWatcher(), value);
|
||||||
|
@ -12,39 +12,58 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
|
||||||
public class CloneDisguiseCommand extends BaseDisguiseCommand {
|
public class CloneDisguiseCommand extends BaseDisguiseCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
if (sender.hasPermission("libsdisguises.disguise.disguiseclone"))
|
||||||
|
{
|
||||||
boolean doEquipment = true;
|
boolean doEquipment = true;
|
||||||
boolean doSneak = false;
|
boolean doSneak = false;
|
||||||
boolean doSprint = false;
|
boolean doSprint = false;
|
||||||
for (String option : args) {
|
for (String option : args)
|
||||||
|
{
|
||||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip")
|
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip")
|
||||||
|| StringUtils.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
|| StringUtils.startsWithIgnoreCase(option, "ignoreEnquip"))
|
||||||
|
{
|
||||||
doEquipment = false;
|
doEquipment = false;
|
||||||
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
}
|
||||||
|
else if (option.equalsIgnoreCase("doSneakSprint"))
|
||||||
|
{
|
||||||
doSneak = true;
|
doSneak = true;
|
||||||
doSprint = true;
|
doSprint = true;
|
||||||
} else if (option.equalsIgnoreCase("doSneak")) {
|
}
|
||||||
|
else if (option.equalsIgnoreCase("doSneak"))
|
||||||
|
{
|
||||||
doSneak = true;
|
doSneak = true;
|
||||||
} else if (option.equalsIgnoreCase("doSprint")) {
|
}
|
||||||
|
else if (option.equalsIgnoreCase("doSprint"))
|
||||||
|
{
|
||||||
doSprint = true;
|
doSprint = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Unknown option '" + option
|
sender.sendMessage(ChatColor.DARK_RED + "Unknown option '" + option
|
||||||
+ "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'");
|
+ "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LibsDisguises.getInstance().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
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -54,7 +73,8 @@ public class CloneDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
* Send the player the information
|
* Send the player the information
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN
|
||||||
+ "Right click a entity to get a disguise reference you can pass to other disguise commands!");
|
+ "Right click a entity to get a disguise reference you can pass to other disguise commands!");
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN
|
||||||
|
@ -15,40 +15,61 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
|
||||||
public class DisguiseCommand extends BaseDisguiseCommand {
|
public class DisguiseCommand extends BaseDisguiseCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
disguise = parseDisguise(sender, args, getPermissions(sender));
|
disguise = parseDisguise(sender, args, getPermissions(sender));
|
||||||
} catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage() != null)
|
||||||
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace(System.out);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
catch (Exception ex)
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise())
|
||||||
|
{
|
||||||
|
if (disguise.getWatcher() instanceof LivingWatcher)
|
||||||
|
{
|
||||||
disguise.getWatcher().setCustomName(((Player) sender).getDisplayName());
|
disguise.getWatcher().setCustomName(((Player) sender).getDisplayName());
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
|
||||||
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible())
|
||||||
|
{
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
||||||
if (disguise.isDisguiseInUse()) {
|
|
||||||
|
if (disguise.isDisguiseInUse())
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Failed to disguise as a " + disguise.getType().toReadable());
|
sender.sendMessage(ChatColor.RED + "Failed to disguise as a " + disguise.getType().toReadable());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,16 +77,19 @@ public class DisguiseCommand extends BaseDisguiseCommand {
|
|||||||
* Send the player the information
|
* Send the player the information
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||||
|
{
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
|
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
||||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||||
if (allowedDisguises.contains("player")) {
|
if (allowedDisguises.contains("player"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,27 @@ import org.bukkit.entity.Player;
|
|||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class DisguiseViewSelf implements CommandExecutor {
|
public class DisguiseViewSelf implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (DisguiseAPI.isViewSelfToggled(player)) {
|
if (DisguiseAPI.isViewSelfToggled(player))
|
||||||
|
{
|
||||||
DisguiseAPI.setViewDisguiseToggled(player, false);
|
DisguiseAPI.setViewDisguiseToggled(player, false);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DisguiseAPI.setViewDisguiseToggled(player, true);
|
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise on!");
|
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise on!");
|
||||||
}
|
}
|
||||||
|
@ -14,24 +14,33 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
|
||||||
public class EntityDisguiseCommand extends BaseDisguiseCommand {
|
public class EntityDisguiseCommand extends BaseDisguiseCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
disguise = parseDisguise(sender, args, getPermissions(sender));
|
disguise = parseDisguise(sender, args, getPermissions(sender));
|
||||||
} catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage() != null)
|
||||||
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
}
|
||||||
ex.printStackTrace(System.out);
|
catch (IllegalAccessException | InvocationTargetException ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
||||||
@ -47,16 +56,19 @@ public class EntityDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
* @param map
|
* @param map
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||||
|
{
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");
|
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
||||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||||
if (allowedDisguises.contains("player")) {
|
if (allowedDisguises.contains("player"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>");
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,22 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
|
||||||
public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||||
|
{
|
||||||
|
|
||||||
private class EnumHelp {
|
private class EnumHelp
|
||||||
|
{
|
||||||
|
|
||||||
private String enumDescription;
|
private String enumDescription;
|
||||||
private String enumName;
|
private String enumName;
|
||||||
private String[] enums;
|
private String[] enums;
|
||||||
private String readableEnum;
|
private String readableEnum;
|
||||||
|
|
||||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, Enum[] enums) {
|
public EnumHelp(String enumName, String enumReadable, String enumDescription, Enum[] enums)
|
||||||
|
{
|
||||||
String[] strings = new String[enums.length];
|
String[] strings = new String[enums.length];
|
||||||
for (int i = 0; i < strings.length; i++) {
|
for (int i = 0; i < strings.length; i++)
|
||||||
|
{
|
||||||
strings[i] = toReadable(enums[i].name());
|
strings[i] = toReadable(enums[i].name());
|
||||||
}
|
}
|
||||||
this.enumName = enumName;
|
this.enumName = enumName;
|
||||||
@ -40,124 +44,177 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
this.readableEnum = enumReadable;
|
this.readableEnum = enumReadable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, String[] enums) {
|
public EnumHelp(String enumName, String enumReadable, String enumDescription, String[] enums)
|
||||||
|
{
|
||||||
this.enumName = enumName;
|
this.enumName = enumName;
|
||||||
this.enumDescription = enumDescription;
|
this.enumDescription = enumDescription;
|
||||||
this.enums = enums;
|
this.enums = enums;
|
||||||
this.readableEnum = enumReadable;
|
this.readableEnum = enumReadable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumDescription() {
|
public String getEnumDescription()
|
||||||
|
{
|
||||||
return enumDescription;
|
return enumDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumName() {
|
public String getEnumName()
|
||||||
|
{
|
||||||
return enumName;
|
return enumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEnums() {
|
public String[] getEnums()
|
||||||
|
{
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReadableEnum() {
|
public String getReadableEnum()
|
||||||
|
{
|
||||||
return readableEnum;
|
return readableEnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<EnumHelp> enumHelp = new ArrayList<>();
|
private ArrayList<EnumHelp> enumHelp = new ArrayList<>();
|
||||||
|
|
||||||
public HelpDisguiseCommand() {
|
public HelpDisguiseCommand()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
enumHelp.add(new EnumHelp("AnimalColor", "Animal colors", ChatColor.RED + "/disguisehelp AnimalColors "
|
enumHelp.add(new EnumHelp("AnimalColor", "Animal colors", ChatColor.RED + "/disguisehelp AnimalColors "
|
||||||
+ ChatColor.GREEN + "- View all the colors you can use for a animal color", AnimalColor.values()));
|
+ ChatColor.GREEN + "- View all the colors you can use for a animal color", AnimalColor.values()));
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace(System.out);
|
|
||||||
}
|
}
|
||||||
try {
|
catch (Exception ex)
|
||||||
enumHelp.add(new EnumHelp("Art", "Arts", ChatColor.RED + "/disguisehelp Art " + ChatColor.GREEN
|
{
|
||||||
+ "- View all the painting arts you can use on a painting disguise", (Enum[]) Class.forName("org.bukkit.Art")
|
ex.printStackTrace();
|
||||||
.getEnumConstants()));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
try {
|
try
|
||||||
enumHelp.add(new EnumHelp("HorseColor", "Horse colors", ChatColor.RED + "/disguisehelp HorseColors "
|
{
|
||||||
+ ChatColor.GREEN + "- View all the colors you can use for a horses color", (Enum[]) Class.forName(
|
enumHelp.add(new EnumHelp("Art", "Arts",
|
||||||
"org.bukkit.entity.Horse$Color").getEnumConstants()));
|
ChatColor.RED + "/disguisehelp Art " + ChatColor.GREEN
|
||||||
} catch (Exception ex) {
|
+ "- View all the painting arts you can use on a painting disguise",
|
||||||
|
(Enum[]) Class.forName("org.bukkit.Art").getEnumConstants()));
|
||||||
}
|
}
|
||||||
try {
|
catch (Exception ex)
|
||||||
enumHelp.add(new EnumHelp("HorseStyle", "Horse styles", ChatColor.RED + "/disguisehelp HorseStyles "
|
{
|
||||||
+ ChatColor.GREEN + "- View all the styles you can use for a horses style", (Enum[]) Class.forName(
|
|
||||||
"org.bukkit.entity.Horse$Style").getEnumConstants()));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
try {
|
try
|
||||||
enumHelp.add(new EnumHelp("OcelotType", "Ocelot types", ChatColor.RED + "/disguisehelp OcelotTypes "
|
{
|
||||||
+ ChatColor.GREEN + "- View all the ocelot types you can use for ocelots", (Enum[]) Class.forName(
|
enumHelp.add(new EnumHelp("HorseColor", "Horse colors",
|
||||||
"org.bukkit.entity.Ocelot$Type").getEnumConstants()));
|
ChatColor.RED + "/disguisehelp HorseColors " + ChatColor.GREEN
|
||||||
} catch (Exception ex) {
|
+ "- View all the colors you can use for a horses color",
|
||||||
|
(Enum[]) Class.forName("org.bukkit.entity.Horse$Color").getEnumConstants()));
|
||||||
}
|
}
|
||||||
try {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
enumHelp.add(new EnumHelp("HorseStyle", "Horse styles",
|
||||||
|
ChatColor.RED + "/disguisehelp HorseStyles " + ChatColor.GREEN
|
||||||
|
+ "- View all the styles you can use for a horses style",
|
||||||
|
(Enum[]) Class.forName("org.bukkit.entity.Horse$Style").getEnumConstants()));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
enumHelp.add(new EnumHelp("OcelotType", "Ocelot types",
|
||||||
|
ChatColor.RED + "/disguisehelp OcelotTypes " + ChatColor.GREEN
|
||||||
|
+ "- View all the ocelot types you can use for ocelots",
|
||||||
|
(Enum[]) Class.forName("org.bukkit.entity.Ocelot$Type").getEnumConstants()));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
ArrayList<String> enumReturns = new ArrayList<>();
|
ArrayList<String> enumReturns = new ArrayList<>();
|
||||||
for (PotionEffectType potionType : PotionEffectType.values()) {
|
for (PotionEffectType potionType : PotionEffectType.values())
|
||||||
if (potionType != null) {
|
{
|
||||||
|
if (potionType != null)
|
||||||
|
{
|
||||||
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
|
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
|
||||||
+ ChatColor.RED + ")");
|
+ ChatColor.RED + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect", ChatColor.RED + "/disguisehelp PotionEffect "
|
enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect",
|
||||||
+ ChatColor.GREEN + "- View all the potion effects you can set", enumReturns.toArray(new String[enumReturns
|
ChatColor.RED + "/disguisehelp PotionEffect " + ChatColor.GREEN + "- View all the potion effects you can set",
|
||||||
.size()])));
|
enumReturns.toArray(new String[enumReturns.size()])));
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace(System.out);
|
|
||||||
}
|
}
|
||||||
try {
|
catch (Exception ex)
|
||||||
enumHelp.add(new EnumHelp("Profession", "Villager professions", ChatColor.RED + "/disguisehelp Professions "
|
{
|
||||||
+ ChatColor.GREEN + "- View all the professions you can set on a villager", (Enum[]) Class.forName(
|
ex.printStackTrace();
|
||||||
"org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
|
try
|
||||||
+ "- View the five directions usable on player setsleeping disguise", Arrays.copyOf(BlockFace.values(), 5)));
|
{
|
||||||
enumHelp.add(new EnumHelp("RabbitType", "RabbitType", ChatColor.RED + "/disguisehelp RabbitType " + ChatColor.GREEN
|
enumHelp.add(new EnumHelp("Profession", "Villager professions",
|
||||||
+ "View the kinds of rabbits you can turn into", RabbitType.values()));
|
ChatColor.RED + "/disguisehelp Professions " + ChatColor.GREEN
|
||||||
|
+ "- View all the professions you can set on a villager",
|
||||||
|
(Enum[]) Class.forName("org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
enumHelp.add(new EnumHelp("Direction", "Directions",
|
||||||
|
ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
|
||||||
|
+ "- View the five directions usable on player setsleeping disguise",
|
||||||
|
Arrays.copyOf(BlockFace.values(), 5)));
|
||||||
|
enumHelp.add(new EnumHelp("RabbitType", "RabbitType",
|
||||||
|
ChatColor.RED + "/disguisehelp RabbitType " + ChatColor.GREEN + "View the kinds of rabbits you can turn into",
|
||||||
|
RabbitType.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) {
|
{
|
||||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> permMap = getPermissions(sender, "libsdisguises." + node
|
for (String node : new String[]
|
||||||
+ ".");
|
{
|
||||||
if (!permMap.isEmpty()) {
|
"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"
|
||||||
if (args.length == 0) {
|
})
|
||||||
|
{
|
||||||
|
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> permMap = getPermissions(sender,
|
||||||
|
"libsdisguises." + node + ".");
|
||||||
|
if (!permMap.isEmpty())
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
sendCommandUsage(sender, null);
|
sendCommandUsage(sender, null);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
EnumHelp help = null;
|
EnumHelp help = null;
|
||||||
for (EnumHelp s : enumHelp) {
|
for (EnumHelp s : enumHelp)
|
||||||
if (args[0].equalsIgnoreCase(s.getEnumName()) || args[0].equalsIgnoreCase(s.getEnumName() + "s")) {
|
{
|
||||||
|
if (args[0].equalsIgnoreCase(s.getEnumName()) || args[0].equalsIgnoreCase(s.getEnumName() + "s"))
|
||||||
|
{
|
||||||
help = s;
|
help = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (help != null) {
|
if (help != null)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + help.getReadableEnum() + ": " + ChatColor.GREEN
|
sender.sendMessage(ChatColor.RED + help.getReadableEnum() + ": " + ChatColor.GREEN
|
||||||
+ StringUtils.join(help.getEnums(), ChatColor.RED + ", " + ChatColor.GREEN));
|
+ StringUtils.join(help.getEnums(), ChatColor.RED + ", " + ChatColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DisguiseType type = null;
|
DisguiseType type = null;
|
||||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
for (DisguiseType disguiseType : DisguiseType.values())
|
||||||
|
{
|
||||||
if (args[0].equalsIgnoreCase(disguiseType.name())
|
if (args[0].equalsIgnoreCase(disguiseType.name())
|
||||||
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
type = disguiseType;
|
type = disguiseType;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == null) {
|
if (type == null)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!permMap.containsKey(type)) {
|
if (!permMap.containsKey(type))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!");
|
sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -165,67 +222,110 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
HashMap<String, ChatColor> map = new HashMap<>();
|
HashMap<String, ChatColor> map = new HashMap<>();
|
||||||
Class watcher = type.getWatcherClass();
|
Class watcher = type.getWatcherClass();
|
||||||
int ignored = 0;
|
int ignored = 0;
|
||||||
try {
|
try
|
||||||
for (Method method : this.getDisguiseWatcherMethods(watcher)) {
|
{
|
||||||
|
for (Method method : this.getDisguiseWatcherMethods(watcher))
|
||||||
|
{
|
||||||
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1
|
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1
|
||||||
&& method.getAnnotation(Deprecated.class) == null) {
|
&& method.getAnnotation(Deprecated.class) == null)
|
||||||
if (args.length < 2 || !args[1].equalsIgnoreCase("show")) {
|
{
|
||||||
|
if (args.length < 2 || !args[1].equalsIgnoreCase("show"))
|
||||||
|
{
|
||||||
boolean allowed = false;
|
boolean allowed = false;
|
||||||
for (ArrayList<String> key : permMap.get(type).keySet()) {
|
for (ArrayList<String> key : permMap.get(type).keySet())
|
||||||
if (permMap.get(type).get(key)) {
|
{
|
||||||
if (key.contains("*") || key.contains(method.getName().toLowerCase())) {
|
if (permMap.get(type).get(key))
|
||||||
allowed = true;
|
{
|
||||||
break;
|
if (key.contains("*") || key.contains(method.getName().toLowerCase()))
|
||||||
}
|
{
|
||||||
} else if (!key.contains(method.getName().toLowerCase())) {
|
|
||||||
allowed = true;
|
allowed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!allowed) {
|
else if (!key.contains(method.getName().toLowerCase()))
|
||||||
|
{
|
||||||
|
allowed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!allowed)
|
||||||
|
{
|
||||||
ignored++;
|
ignored++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Class c = method.getParameterTypes()[0];
|
Class c = method.getParameterTypes()[0];
|
||||||
String valueType = null;
|
String valueType = null;
|
||||||
if (c == String.class) {
|
if (c == String.class)
|
||||||
|
{
|
||||||
valueType = "String";
|
valueType = "String";
|
||||||
} else if (boolean.class == c) {
|
}
|
||||||
|
else if (boolean.class == c)
|
||||||
|
{
|
||||||
valueType = "True/False";
|
valueType = "True/False";
|
||||||
} else if (int.class == c) {
|
}
|
||||||
|
else if (int.class == c)
|
||||||
|
{
|
||||||
valueType = "Number";
|
valueType = "Number";
|
||||||
} else if (float.class == c || double.class == c) {
|
}
|
||||||
|
else if (float.class == c || double.class == c)
|
||||||
|
{
|
||||||
valueType = "Decimal";
|
valueType = "Decimal";
|
||||||
} else if (AnimalColor.class == c) {
|
}
|
||||||
|
else if (AnimalColor.class == c)
|
||||||
|
{
|
||||||
valueType = "Color";
|
valueType = "Color";
|
||||||
} else if (ItemStack.class == c) {
|
}
|
||||||
|
else if (ItemStack.class == c)
|
||||||
|
{
|
||||||
valueType = "Item (id:damage)";
|
valueType = "Item (id:damage)";
|
||||||
} else if (ItemStack[].class == c) {
|
}
|
||||||
|
else if (ItemStack[].class == c)
|
||||||
|
{
|
||||||
valueType = "4 items (id:damage,id,...)";
|
valueType = "4 items (id:damage,id,...)";
|
||||||
} else if (c.getSimpleName().equals("Style")) {
|
}
|
||||||
|
else if (c.getSimpleName().equals("Style"))
|
||||||
|
{
|
||||||
valueType = "Horse Style";
|
valueType = "Horse Style";
|
||||||
} else if (c.getSimpleName().equals("Color")) {
|
}
|
||||||
|
else if (c.getSimpleName().equals("Color"))
|
||||||
|
{
|
||||||
valueType = "Horse Color";
|
valueType = "Horse Color";
|
||||||
} else if (c.getSimpleName().equals("Type")) {
|
}
|
||||||
|
else if (c.getSimpleName().equals("Type"))
|
||||||
|
{
|
||||||
valueType = "Ocelot type";
|
valueType = "Ocelot type";
|
||||||
} else if (c.getSimpleName().equals("Profession")) {
|
}
|
||||||
|
else if (c.getSimpleName().equals("Profession"))
|
||||||
|
{
|
||||||
valueType = "Villager Profession";
|
valueType = "Villager Profession";
|
||||||
} else if (PotionEffectType.class == c) {
|
}
|
||||||
|
else if (PotionEffectType.class == c)
|
||||||
|
{
|
||||||
valueType = "Potion effect";
|
valueType = "Potion effect";
|
||||||
} else if (c == int[].class) {
|
}
|
||||||
|
else if (c == int[].class)
|
||||||
|
{
|
||||||
valueType = "number,number,number...";
|
valueType = "number,number,number...";
|
||||||
} else if (c == BlockFace.class) {
|
}
|
||||||
|
else if (c == BlockFace.class)
|
||||||
|
{
|
||||||
valueType = "direction";
|
valueType = "direction";
|
||||||
} else if (c == RabbitType.class) {
|
}
|
||||||
|
else if (c == RabbitType.class)
|
||||||
|
{
|
||||||
valueType = "rabbit type";
|
valueType = "rabbit type";
|
||||||
}
|
}
|
||||||
if (valueType != null) {
|
if (valueType != null)
|
||||||
|
{
|
||||||
ChatColor methodColor = ChatColor.YELLOW;
|
ChatColor methodColor = ChatColor.YELLOW;
|
||||||
Class<?> declaring = method.getDeclaringClass();
|
Class<?> declaring = method.getDeclaringClass();
|
||||||
if (declaring == LivingWatcher.class) {
|
if (declaring == LivingWatcher.class)
|
||||||
|
{
|
||||||
methodColor = ChatColor.AQUA;
|
methodColor = ChatColor.AQUA;
|
||||||
} else if (!(FlagWatcher.class.isAssignableFrom(declaring)) || declaring == FlagWatcher.class) {
|
}
|
||||||
|
else if (!(FlagWatcher.class.isAssignableFrom(declaring)) || declaring == FlagWatcher.class)
|
||||||
|
{
|
||||||
methodColor = ChatColor.GRAY;
|
methodColor = ChatColor.GRAY;
|
||||||
}
|
}
|
||||||
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + valueType
|
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + valueType
|
||||||
@ -235,19 +335,24 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace(System.out);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
||||||
for (int i = 0; i < methods.size(); i++) {
|
for (int i = 0; i < methods.size(); i++)
|
||||||
|
{
|
||||||
methods.set(i, map.get(methods.get(i)) + methods.get(i));
|
methods.set(i, map.get(methods.get(i)) + methods.get(i));
|
||||||
}
|
}
|
||||||
if (methods.isEmpty()) {
|
if (methods.isEmpty())
|
||||||
|
{
|
||||||
methods.add(ChatColor.RED + "No options with permission to use");
|
methods.add(ChatColor.RED + "No options with permission to use");
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + " options: "
|
sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + " options: "
|
||||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||||
if (ignored > 0) {
|
if (ignored > 0)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Ignored " + ignored
|
sender.sendMessage(ChatColor.RED + "Ignored " + ignored
|
||||||
+ " options you do not have permission to view. Add 'show' to view unusable options.");
|
+ " options you do not have permission to view. Add 'show' to view unusable options.");
|
||||||
}
|
}
|
||||||
@ -263,19 +368,21 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
* Send the player the information
|
* Send the player the information
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||||
sender.sendMessage(ChatColor.RED
|
{
|
||||||
+ "/disguisehelp <DisguiseType> "
|
sender.sendMessage(ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN
|
||||||
+ ChatColor.GREEN
|
|
||||||
+ "- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission to use");
|
+ "- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission to use");
|
||||||
for (EnumHelp s : enumHelp) {
|
for (EnumHelp s : enumHelp)
|
||||||
|
{
|
||||||
sender.sendMessage(s.getEnumDescription());
|
sender.sendMessage(s.getEnumDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toReadable(String string) {
|
public String toReadable(String string)
|
||||||
|
{
|
||||||
String[] split = string.split("_");
|
String[] split = string.split("_");
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++)
|
||||||
|
{
|
||||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
||||||
}
|
}
|
||||||
return StringUtils.join(split, "_");
|
return StringUtils.join(split, "_");
|
||||||
|
@ -8,27 +8,36 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
|
||||||
public class LibsDisguisesCommand implements CommandExecutor {
|
public class LibsDisguisesCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (args.length == 0) {
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN
|
if (args.length == 0)
|
||||||
+ "This server is running "
|
{
|
||||||
+ "Lib's Disguises v."
|
sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v."
|
||||||
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
|
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
|
||||||
+ " by libraryaddict, maintained by NavidK0.\n"
|
+ " by libraryaddict, maintained by NavidK0.\n"
|
||||||
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
|
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
|
||||||
} else if (args.length > 0) {
|
}
|
||||||
if (sender.hasPermission("libsdisguises.reload")) {
|
else if (args.length > 0)
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
{
|
||||||
|
if (sender.hasPermission("libsdisguises.reload"))
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("reload"))
|
||||||
|
{
|
||||||
LibsDisguises.getInstance().reload();
|
LibsDisguises.getInstance().reload();
|
||||||
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
|
sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,62 +16,81 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
|
||||||
public class PlayerDisguiseCommand extends BaseDisguiseCommand {
|
public class PlayerDisguiseCommand extends BaseDisguiseCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
|
{
|
||||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||||
if (map.isEmpty()) {
|
if (map.isEmpty())
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 0) {
|
if (args.length == 0)
|
||||||
|
{
|
||||||
sendCommandUsage(sender, map);
|
sendCommandUsage(sender, map);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the player");
|
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = Bukkit.getPlayer(args[0]);
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
if (player == null) {
|
if (player == null)
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String[] newArgs = new String[args.length - 1];
|
String[] newArgs = new String[args.length - 1];
|
||||||
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
disguise = parseDisguise(sender, newArgs, map);
|
disguise = parseDisguise(sender, newArgs, map);
|
||||||
} catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage() != null)
|
||||||
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace(System.out);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled())
|
||||||
sender.sendMessage(ChatColor.RED
|
{
|
||||||
+ "Can't disguise a living entity as a misc disguise. This has been disabled in the config!");
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise())
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
{
|
||||||
|
if (disguise.getWatcher() instanceof LivingWatcher)
|
||||||
|
{
|
||||||
disguise.getWatcher().setCustomName(player.getDisplayName());
|
disguise.getWatcher().setCustomName(player.getDisplayName());
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible())
|
||||||
|
{
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DisguiseAPI.disguiseToAll(player, disguise);
|
DisguiseAPI.disguiseToAll(player, disguise);
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse())
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
||||||
+ disguise.getType().toReadable() + "!");
|
+ disguise.getType().toReadable() + "!");
|
||||||
} else {
|
}
|
||||||
sender.sendMessage(ChatColor.RED + "Failed to disguise " + player.getName() + " as a "
|
else
|
||||||
+ disguise.getType().toReadable() + "!");
|
{
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Failed to disguise " + player.getName() + " as a " + disguise.getType().toReadable() + "!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -80,18 +99,21 @@ public class PlayerDisguiseCommand extends BaseDisguiseCommand {
|
|||||||
* Send the player the information
|
* Send the player the information
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||||
|
{
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
|
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
||||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||||
if (allowedDisguises.contains("player")) {
|
if (allowedDisguises.contains("player"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>");
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>");
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN
|
{
|
||||||
+ "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
|
sender.sendMessage(
|
||||||
|
ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import me.libraryaddict.disguise.utilities.ClassGetter;
|
|||||||
|
|
||||||
public class RadiusDisguiseCommand extends BaseDisguiseCommand
|
public class RadiusDisguiseCommand extends BaseDisguiseCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private int maxRadius = 30;
|
private int maxRadius = 30;
|
||||||
private ArrayList<Class> validClasses = new ArrayList<>();
|
private ArrayList<Class> validClasses = new ArrayList<>();
|
||||||
|
|
||||||
@ -152,7 +151,7 @@ public class RadiusDisguiseCommand extends BaseDisguiseCommand
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,22 +9,31 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
public class UndisguiseCommand implements CommandExecutor {
|
public class UndisguiseCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.undisguise")) {
|
if (sender.hasPermission("libsdisguises.undisguise"))
|
||||||
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
{
|
||||||
|
if (DisguiseAPI.isDisguised((Entity) sender))
|
||||||
|
{
|
||||||
DisguiseAPI.undisguiseToAll((Player) sender);
|
DisguiseAPI.undisguiseToAll((Player) sender);
|
||||||
sender.sendMessage(ChatColor.RED + "You are no longer disguised");
|
sender.sendMessage(ChatColor.RED + "You are no longer disguised");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are not disguised!");
|
sender.sendMessage(ChatColor.RED + "You are not disguised!");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,18 +7,24 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
|
||||||
public class UndisguiseEntityCommand implements CommandExecutor {
|
public class UndisguiseEntityCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
|
if (sender.hasPermission("libsdisguises.undisguiseentity"))
|
||||||
|
{
|
||||||
LibsDisguises.getInstance().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.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,27 +9,41 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
public class UndisguisePlayerCommand implements CommandExecutor {
|
public class UndisguisePlayerCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
{
|
||||||
if (args.length > 0) {
|
if (sender.hasPermission("libsdisguises.undisguiseplayer"))
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
Player p = Bukkit.getPlayer(args[0]);
|
Player p = Bukkit.getPlayer(args[0]);
|
||||||
if (p != null) {
|
if (p != null)
|
||||||
if (DisguiseAPI.isDisguised(p)) {
|
{
|
||||||
|
if (DisguiseAPI.isDisguised(p))
|
||||||
|
{
|
||||||
DisguiseAPI.undisguiseToAll(p);
|
DisguiseAPI.undisguiseToAll(p);
|
||||||
sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
|
sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "The player is not disguised!");
|
sender.sendMessage(ChatColor.RED + "The player is not disguised!");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Player not found");
|
sender.sendMessage(ChatColor.RED + "Player not found");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
|
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,56 +9,73 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
public class UndisguiseRadiusCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
|
||||||
private int maxRadius = 30;
|
private int maxRadius = 30;
|
||||||
|
|
||||||
public UndisguiseRadiusCommand(int maxRadius) {
|
public UndisguiseRadiusCommand(int maxRadius)
|
||||||
|
{
|
||||||
this.maxRadius = maxRadius;
|
this.maxRadius = maxRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNumeric(String string) {
|
private boolean isNumeric(String string)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Integer.parseInt(string);
|
Integer.parseInt(string);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
{
|
||||||
|
if (sender.getName().equals("CONSOLE"))
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseradius")) {
|
if (sender.hasPermission("libsdisguises.undisguiseradius"))
|
||||||
|
{
|
||||||
int radius = maxRadius;
|
int radius = maxRadius;
|
||||||
if (args.length > 0) {
|
if (args.length > 0)
|
||||||
if (!isNumeric(args[0])) {
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Error! " + ChatColor.GREEN + args[0] + ChatColor.RED
|
if (!isNumeric(args[0]))
|
||||||
+ " is not a number!");
|
{
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Error! " + ChatColor.GREEN + args[0] + ChatColor.RED + " is not a number!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
radius = Integer.parseInt(args[0]);
|
radius = Integer.parseInt(args[0]);
|
||||||
if (radius > maxRadius) {
|
if (radius > maxRadius)
|
||||||
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius
|
{
|
||||||
+ "! Don't want to make too much lag right?");
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||||
radius = maxRadius;
|
radius = maxRadius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int disguisedEntitys = 0;
|
int disguisedEntitys = 0;
|
||||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius))
|
||||||
if (entity == sender) {
|
{
|
||||||
|
if (entity == sender)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (DisguiseAPI.isDisguised(entity)) {
|
if (DisguiseAPI.isDisguised(entity))
|
||||||
|
{
|
||||||
DisguiseAPI.undisguiseToAll(entity);
|
DisguiseAPI.undisguiseToAll(entity);
|
||||||
disguisedEntitys++;
|
disguisedEntitys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
|
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -102,7 +102,7 @@ public abstract class Disguise
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the disguise if its a baby or not
|
// Set the disguise if its a baby or not
|
||||||
@ -355,7 +355,7 @@ public abstract class Disguise
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ public abstract class Disguise
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If we need to send a packet to update the exp position as it likes to gravitate client sided to
|
// If we need to send a packet to update the exp position as it likes to gravitate client sided to
|
||||||
@ -430,14 +430,14 @@ public abstract class Disguise
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,11 @@ public class FlagType<Y>
|
|||||||
|
|
||||||
public static FlagType<Integer> CREEPER_STATE = new FlagType<Integer>(CreeperWatcher.class, 0, -1);
|
public static FlagType<Integer> CREEPER_STATE = new FlagType<Integer>(CreeperWatcher.class, 0, -1);
|
||||||
|
|
||||||
public static FlagType<ItemStack> DROPPED_ITEM = new FlagType<ItemStack>(DroppedItemWatcher.class, 0,
|
public static FlagType<Optional<ItemStack>> DROPPED_ITEM = new FlagType<Optional<ItemStack>>(DroppedItemWatcher.class, 0,
|
||||||
new ItemStack(Material.AIR));
|
Optional.<ItemStack> of(new ItemStack(Material.STONE)));
|
||||||
|
|
||||||
public static FlagType<Optional> ENDER_CRYSTAL_BEAM = new FlagType<Optional>(EnderCrystalWatcher.class, 0, Optional.absent());
|
public static FlagType<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new FlagType<Optional<BlockPosition>>(EnderCrystalWatcher.class, 0,
|
||||||
|
Optional.<BlockPosition> absent());
|
||||||
|
|
||||||
public static FlagType<Boolean> ENDER_CRYSTAL_PLATE = new FlagType<Boolean>(EnderCrystalWatcher.class, 1, false);
|
public static FlagType<Boolean> ENDER_CRYSTAL_PLATE = new FlagType<Boolean>(EnderCrystalWatcher.class, 1, false);
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ public class FlagType<Y>
|
|||||||
|
|
||||||
public static FlagType<Byte> LIVING_HAND = new FlagType<Byte>(LivingWatcher.class, 0, (byte) 0);
|
public static FlagType<Byte> LIVING_HAND = new FlagType<Byte>(LivingWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static FlagType<Float> LIVING_HEALTH = new FlagType<Float>(LivingWatcher.class, 1, 0F);
|
public static FlagType<Float> LIVING_HEALTH = new FlagType<Float>(LivingWatcher.class, 1, 1F);
|
||||||
|
|
||||||
public static FlagType<Boolean> LIVING_POTION_AMBIENT = new FlagType<Boolean>(LivingWatcher.class, 3, false);
|
public static FlagType<Boolean> LIVING_POTION_AMBIENT = new FlagType<Boolean>(LivingWatcher.class, 3, false);
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ public class FlagType<Y>
|
|||||||
|
|
||||||
public static FlagType<Integer> PLAYER_SCORE = new FlagType<Integer>(PlayerWatcher.class, 1, 0);
|
public static FlagType<Integer> PLAYER_SCORE = new FlagType<Integer>(PlayerWatcher.class, 1, 0);
|
||||||
|
|
||||||
public static FlagType<Byte> PLAYER_SKIN = new FlagType<Byte>(PlayerWatcher.class, 2, (byte) 0);
|
public static FlagType<Byte> PLAYER_SKIN = new FlagType<Byte>(PlayerWatcher.class, 2, (byte) 127);
|
||||||
|
|
||||||
public static FlagType<Boolean> POLAR_BEAR_STANDING = new FlagType<Boolean>(PolarBearWatcher.class, 0, false);
|
public static FlagType<Boolean> POLAR_BEAR_STANDING = new FlagType<Boolean>(PolarBearWatcher.class, 0, false);
|
||||||
|
|
||||||
|
@ -28,22 +28,22 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|||||||
|
|
||||||
public class FlagWatcher
|
public class FlagWatcher
|
||||||
{
|
{
|
||||||
private boolean addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded();
|
private boolean _addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded();
|
||||||
/**
|
/**
|
||||||
* These are the entity values I need to add else it could crash them..
|
* These are the entity values I need to add else it could crash them..
|
||||||
*/
|
*/
|
||||||
private HashMap<Integer, Object> backupEntityValues = new HashMap<>();
|
private HashMap<Integer, Object> _backupEntityValues = new HashMap<>();
|
||||||
private TargetedDisguise disguise;
|
private TargetedDisguise _disguise;
|
||||||
private HashMap<Integer, Object> entityValues = new HashMap<>();
|
private HashMap<Integer, Object> _entityValues = new HashMap<>();
|
||||||
private EntityEquipment equipment;
|
private EntityEquipment _equipment;
|
||||||
private boolean hasDied;
|
private boolean _hasDied;
|
||||||
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
private HashSet<Integer> _modifiedEntityAnimations = new HashSet<>();
|
||||||
private List<WrappedWatchableObject> watchableObjects;
|
private List<WrappedWatchableObject> _watchableObjects;
|
||||||
|
|
||||||
public FlagWatcher(Disguise disguise)
|
public FlagWatcher(Disguise disguise)
|
||||||
{
|
{
|
||||||
this.disguise = (TargetedDisguise) disguise;
|
_disguise = (TargetedDisguise) disguise;
|
||||||
equipment = ReflectionManager.createEntityEquipment(disguise.getEntity());
|
_equipment = ReflectionManager.createEntityEquipment(disguise.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte addEntityAnimations(byte originalValue, byte entityValue)
|
private byte addEntityAnimations(byte originalValue, byte entityValue)
|
||||||
@ -52,7 +52,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
if ((entityValue & 1 << i) != 0 && !modifiedEntityAnimations.contains(i))
|
if ((entityValue & 1 << i) != 0 && !_modifiedEntityAnimations.contains(i))
|
||||||
{
|
{
|
||||||
valueByte = (byte) (valueByte | 1 << i);
|
valueByte = (byte) (valueByte | 1 << i);
|
||||||
}
|
}
|
||||||
@ -73,14 +73,14 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
cloned = new FlagWatcher(getDisguise());
|
cloned = new FlagWatcher(getDisguise());
|
||||||
}
|
}
|
||||||
|
|
||||||
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
cloned._entityValues = (HashMap<Integer, Object>) _entityValues.clone();
|
||||||
cloned.equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity());
|
cloned._equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity());
|
||||||
cloned.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
cloned._modifiedEntityAnimations = (HashSet<Integer>) _modifiedEntityAnimations.clone();
|
||||||
cloned.addEntityAnimations = addEntityAnimations;
|
cloned._addEntityAnimations = _addEntityAnimations;
|
||||||
|
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
@ -105,35 +105,38 @@ public class FlagWatcher
|
|||||||
|
|
||||||
Object value = null;
|
Object value = null;
|
||||||
|
|
||||||
if (entityValues.containsKey(id))
|
if (_entityValues.containsKey(id))
|
||||||
{
|
{
|
||||||
if (entityValues.get(id) == null)
|
if (_entityValues.get(id) == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = entityValues.get(id);
|
value = _entityValues.get(id);
|
||||||
}
|
}
|
||||||
else if (backupEntityValues.containsKey(id))
|
else if (_backupEntityValues.containsKey(id))
|
||||||
{
|
{
|
||||||
if (backupEntityValues.get(id) == null)
|
if (_backupEntityValues.get(id) == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = backupEntityValues.get(id);
|
value = _backupEntityValues.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
if (isEntityAnimationsAdded() && id == 0)
|
if (isEntityAnimationsAdded() && id == 0)
|
||||||
{
|
{
|
||||||
value = this.addEntityAnimations((byte) value, (byte) watch.getValue());
|
value = addEntityAnimations((byte) value, (byte) watch.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isDirty = watch.getDirtyState();
|
boolean isDirty = watch.getDirtyState();
|
||||||
|
|
||||||
watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value));
|
watch = ReflectionManager.createWatchable(id, value);
|
||||||
|
|
||||||
|
if (watch == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!isDirty)
|
if (!isDirty)
|
||||||
{
|
{
|
||||||
@ -144,7 +147,10 @@ public class FlagWatcher
|
|||||||
{
|
{
|
||||||
boolean isDirty = watch.getDirtyState();
|
boolean isDirty = watch.getDirtyState();
|
||||||
|
|
||||||
watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, watch.getValue()));
|
watch = ReflectionManager.createWatchable(id, watch.getValue());
|
||||||
|
|
||||||
|
if (watch == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!isDirty)
|
if (!isDirty)
|
||||||
{
|
{
|
||||||
@ -158,21 +164,24 @@ public class FlagWatcher
|
|||||||
if (sendAllCustom)
|
if (sendAllCustom)
|
||||||
{
|
{
|
||||||
// Its sending the entire meta data. Better add the custom meta
|
// Its sending the entire meta data. Better add the custom meta
|
||||||
for (Integer id : entityValues.keySet())
|
for (Integer id : _entityValues.keySet())
|
||||||
{
|
{
|
||||||
if (sentValues.contains(id))
|
if (sentValues.contains(id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object value = entityValues.get(id);
|
Object value = _entityValues.get(id);
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value));
|
WrappedWatchableObject watch = ReflectionManager.createWatchable(id, value);
|
||||||
|
|
||||||
|
if (watch == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
newList.add(watch);
|
newList.add(watch);
|
||||||
}
|
}
|
||||||
@ -192,9 +201,9 @@ public class FlagWatcher
|
|||||||
{
|
{
|
||||||
float newHealth = (Float) value;
|
float newHealth = (Float) value;
|
||||||
|
|
||||||
if (newHealth > 0 && hasDied)
|
if (newHealth > 0 && _hasDied)
|
||||||
{
|
{
|
||||||
hasDied = false;
|
_hasDied = false;
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(DisguiseUtilities.getPlugin(), new Runnable()
|
Bukkit.getScheduler().scheduleSyncDelayedTask(DisguiseUtilities.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@ -203,18 +212,18 @@ public class FlagWatcher
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(), disguise);
|
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(), _disguise);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
else if (newHealth <= 0 && !hasDied)
|
else if (newHealth <= 0 && !_hasDied)
|
||||||
{
|
{
|
||||||
hasDied = true;
|
_hasDied = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +248,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
protected TargetedDisguise getDisguise()
|
protected TargetedDisguise getDisguise()
|
||||||
{
|
{
|
||||||
return disguise;
|
return _disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getEntityFlag(int byteValue)
|
private boolean getEntityFlag(int byteValue)
|
||||||
@ -249,44 +258,44 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public EntityEquipment getEquipment()
|
public EntityEquipment getEquipment()
|
||||||
{
|
{
|
||||||
return equipment;
|
return _equipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInMainHand()
|
public ItemStack getItemInMainHand()
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
if (_equipment == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return equipment.getItemInMainHand();
|
return _equipment.getItemInMainHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInOffHand()
|
public ItemStack getItemInOffHand()
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
if (_equipment == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return equipment.getItemInOffHand();
|
return _equipment.getItemInOffHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack(EquipmentSlot slot)
|
public ItemStack getItemStack(EquipmentSlot slot)
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
if (_equipment == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch (slot)
|
switch (slot)
|
||||||
{
|
{
|
||||||
case CHEST:
|
case CHEST:
|
||||||
return equipment.getChestplate();
|
return _equipment.getChestplate();
|
||||||
case FEET:
|
case FEET:
|
||||||
return equipment.getBoots();
|
return _equipment.getBoots();
|
||||||
case HAND:
|
case HAND:
|
||||||
return equipment.getItemInMainHand();
|
return _equipment.getItemInMainHand();
|
||||||
case HEAD:
|
case HEAD:
|
||||||
return equipment.getHelmet();
|
return _equipment.getHelmet();
|
||||||
case LEGS:
|
case LEGS:
|
||||||
return equipment.getLeggings();
|
return _equipment.getLeggings();
|
||||||
case OFF_HAND:
|
case OFF_HAND:
|
||||||
return equipment.getItemInOffHand();
|
return _equipment.getItemInOffHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -294,9 +303,9 @@ public class FlagWatcher
|
|||||||
|
|
||||||
protected <Y> Y getValue(FlagType<Y> flagType)
|
protected <Y> Y getValue(FlagType<Y> flagType)
|
||||||
{
|
{
|
||||||
if (entityValues.containsKey(flagType.getIndex()))
|
if (_entityValues.containsKey(flagType.getIndex()))
|
||||||
{
|
{
|
||||||
return (Y) entityValues.get(flagType.getIndex());
|
return (Y) _entityValues.get(flagType.getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
return flagType.getDefault();
|
return flagType.getDefault();
|
||||||
@ -304,12 +313,12 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public List<WrappedWatchableObject> getWatchableObjects()
|
public List<WrappedWatchableObject> getWatchableObjects()
|
||||||
{
|
{
|
||||||
if (watchableObjects == null)
|
if (_watchableObjects == null)
|
||||||
{
|
{
|
||||||
rebuildWatchableObjects();
|
rebuildWatchableObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
return watchableObjects;
|
return _watchableObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCustomName()
|
public boolean hasCustomName()
|
||||||
@ -319,7 +328,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
protected boolean hasValue(FlagType no)
|
protected boolean hasValue(FlagType no)
|
||||||
{
|
{
|
||||||
return entityValues.containsKey(no.getIndex());
|
return _entityValues.containsKey(no.getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning()
|
public boolean isBurning()
|
||||||
@ -334,7 +343,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public boolean isEntityAnimationsAdded()
|
public boolean isEntityAnimationsAdded()
|
||||||
{
|
{
|
||||||
return addEntityAnimations;
|
return _addEntityAnimations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlyingWithElytra()
|
public boolean isFlyingWithElytra()
|
||||||
@ -374,25 +383,29 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public void rebuildWatchableObjects()
|
public void rebuildWatchableObjects()
|
||||||
{
|
{
|
||||||
watchableObjects = new ArrayList<>();
|
_watchableObjects = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i <= 31; i++)// TODO
|
for (int i = 0; i <= 31; i++)
|
||||||
{
|
{
|
||||||
WrappedWatchableObject watchable = null;
|
WrappedWatchableObject watchable = null;
|
||||||
|
|
||||||
if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null)
|
if (_entityValues.containsKey(i) && _entityValues.get(i) != null)
|
||||||
{
|
{
|
||||||
watchable = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(i, entityValues.get(i)));
|
watchable = ReflectionManager.createWatchable(i, _entityValues.get(i));
|
||||||
}
|
}
|
||||||
else if (this.backupEntityValues.containsKey(i) && this.backupEntityValues.get(i) != null)
|
else if (_backupEntityValues.containsKey(i) && _backupEntityValues.get(i) != null)
|
||||||
{
|
{
|
||||||
watchable = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(i, entityValues.get(i)));
|
watchable = ReflectionManager.createWatchable(i, _backupEntityValues.get(i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (watchable != null)
|
if (watchable == null)
|
||||||
{
|
continue;
|
||||||
watchableObjects.add(watchable);
|
|
||||||
}
|
_watchableObjects.add(watchable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,24 +420,26 @@ public class FlagWatcher
|
|||||||
|
|
||||||
for (FlagType data : dataValues)
|
for (FlagType data : dataValues)
|
||||||
{
|
{
|
||||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
if (!_entityValues.containsKey(data) || _entityValues.get(data) == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object value = entityValues.get(data);
|
Object value = _entityValues.get(data);
|
||||||
|
|
||||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == FlagType.ENTITY_META)
|
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == FlagType.ENTITY_META)
|
||||||
{
|
{
|
||||||
if (!PacketsManager.isStaticMetadataDisguiseType(disguise))
|
if (!PacketsManager.isStaticMetadataDisguiseType(_disguise))
|
||||||
{
|
{
|
||||||
value = addEntityAnimations((byte) value,
|
value = addEntityAnimations((byte) value,
|
||||||
WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
WrappedDataWatcher.getEntityWatcher(_disguise.getEntity()).getByte(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(
|
WrappedWatchableObject watch = ReflectionManager.createWatchable(data.getIndex(), value);
|
||||||
ReflectionManager.createDataWatcherItem(data.getIndex(), value));
|
|
||||||
|
if (watch == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
list.add(watch);
|
list.add(watch);
|
||||||
}
|
}
|
||||||
@ -446,7 +461,7 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,7 +469,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public void setAddEntityAnimations(boolean isEntityAnimationsAdded)
|
public void setAddEntityAnimations(boolean isEntityAnimationsAdded)
|
||||||
{
|
{
|
||||||
this.addEntityAnimations = isEntityAnimationsAdded;
|
_addEntityAnimations = isEntityAnimationsAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArmor(ItemStack[] itemstack)
|
public void setArmor(ItemStack[] itemstack)
|
||||||
@ -467,7 +482,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
protected void setBackupValue(FlagType no, Object value)
|
protected void setBackupValue(FlagType no, Object value)
|
||||||
{
|
{
|
||||||
backupEntityValues.put(no.getIndex(), value);
|
_backupEntityValues.put(no.getIndex(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBurning(boolean setBurning)
|
public void setBurning(boolean setBurning)
|
||||||
@ -496,7 +511,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
private void setEntityFlag(int byteValue, boolean flag)
|
private void setEntityFlag(int byteValue, boolean flag)
|
||||||
{
|
{
|
||||||
modifiedEntityAnimations.add(byteValue);
|
_modifiedEntityAnimations.add(byteValue);
|
||||||
|
|
||||||
byte b0 = (byte) getValue(FlagType.ENTITY_META);
|
byte b0 = (byte) getValue(FlagType.ENTITY_META);
|
||||||
|
|
||||||
@ -579,7 +594,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public void setItemStack(EquipmentSlot slot, ItemStack itemStack)
|
public void setItemStack(EquipmentSlot slot, ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
if (_equipment == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Itemstack which is null means that its not replacing the disguises itemstack.
|
// Itemstack which is null means that its not replacing the disguises itemstack.
|
||||||
@ -600,7 +615,7 @@ public class FlagWatcher
|
|||||||
itemToSend = ReflectionManager.getNmsItem(itemStack);
|
itemToSend = ReflectionManager.getNmsItem(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
setItemStack(equipment, slot, itemStack);
|
setItemStack(_equipment, slot, itemStack);
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
|
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
|
||||||
{
|
{
|
||||||
@ -620,7 +635,7 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,11 +667,11 @@ public class FlagWatcher
|
|||||||
|
|
||||||
protected <Y> void setValue(FlagType<Y> id, Y value)
|
protected <Y> void setValue(FlagType<Y> id, Y value)
|
||||||
{
|
{
|
||||||
entityValues.put(id.getIndex(), value);
|
_entityValues.put(id.getIndex(), value);
|
||||||
|
|
||||||
if (!DisguiseConfig.isMetadataPacketsEnabled())
|
if (!DisguiseConfig.isMetadataPacketsEnabled())
|
||||||
{
|
{
|
||||||
this.rebuildWatchableObjects();
|
rebuildWatchableObjects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
|||||||
|
|
||||||
public class MiscDisguise extends TargetedDisguise
|
public class MiscDisguise extends TargetedDisguise
|
||||||
{
|
{
|
||||||
|
|
||||||
private int id = -1, data = 0;
|
private int id = -1, data = 0;
|
||||||
|
|
||||||
public MiscDisguise(DisguiseType disguiseType)
|
public MiscDisguise(DisguiseType disguiseType)
|
||||||
@ -51,9 +50,10 @@ public class MiscDisguise extends TargetedDisguise
|
|||||||
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
|
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
|
||||||
break;
|
break;
|
||||||
case DROPPED_ITEM:
|
case DROPPED_ITEM:
|
||||||
|
|
||||||
if (id > 0)
|
if (id > 0)
|
||||||
{
|
{
|
||||||
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(id, Math.max(0, data)));
|
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(id, Math.max(1, data)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
|
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
|
||||||
|
@ -2,14 +2,14 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
//TODO: Add support for custom items instead of just stone
|
|
||||||
public class DroppedItemWatcher extends FlagWatcher
|
public class DroppedItemWatcher extends FlagWatcher
|
||||||
{
|
{
|
||||||
|
|
||||||
public DroppedItemWatcher(Disguise disguise)
|
public DroppedItemWatcher(Disguise disguise)
|
||||||
{
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
@ -17,12 +17,12 @@ public class DroppedItemWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public ItemStack getItemStack()
|
public ItemStack getItemStack()
|
||||||
{
|
{
|
||||||
return getValue(FlagType.DROPPED_ITEM);
|
return getValue(FlagType.DROPPED_ITEM).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemStack(ItemStack item)
|
public void setItemStack(ItemStack item)
|
||||||
{
|
{
|
||||||
setValue(FlagType.DROPPED_ITEM, item);
|
setValue(FlagType.DROPPED_ITEM, Optional.<ItemStack> of(item));
|
||||||
sendData(FlagType.DROPPED_ITEM);
|
sendData(FlagType.DROPPED_ITEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
f1 = f1 / f4 * 255.0F;
|
f1 = f1 / f4 * 255.0F;
|
||||||
@ -211,7 +211,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ public class PlayerWatcher extends LivingWatcher
|
|||||||
public PlayerWatcher(Disguise disguise)
|
public PlayerWatcher(Disguise disguise)
|
||||||
{
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
|
setValue(FlagType.PLAYER_SKIN, FlagType.PLAYER_SKIN.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -248,7 +250,7 @@ public class PlayerWatcher extends LivingWatcher
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class ClassGetter
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return players;
|
return players;
|
||||||
@ -807,7 +807,7 @@ public class DisguiseUtilities
|
|||||||
runnables.get(playerName).add(runnable);
|
runnables.get(playerName).add(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReflectionManager.getGameProfile(null, origName);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -895,7 +895,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
@ -941,7 +941,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
@ -954,7 +954,7 @@ public class DisguiseUtilities
|
|||||||
Exception ex)
|
Exception ex)
|
||||||
|
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1008,7 +1008,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
@ -1018,7 +1018,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1055,7 +1055,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
@ -1098,7 +1098,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
@ -1110,7 +1110,7 @@ public class DisguiseUtilities
|
|||||||
|
|
||||||
Exception ex)
|
Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1162,7 +1162,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code to stop player pushing in 1.9
|
// Code to stop player pushing in 1.9
|
||||||
@ -1204,7 +1204,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resend entity metadata else he will be invisible to himself until its resent
|
// Resend entity metadata else he will be invisible to himself until its resent
|
||||||
@ -1218,7 +1218,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
@ -1313,7 +1313,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the velocity packets
|
// Send the velocity packets
|
||||||
@ -1396,7 +1396,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1449,7 +1449,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1457,7 +1457,7 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
catch (InvocationTargetException e)
|
catch (InvocationTargetException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ public class Metrics
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1053,8 +1053,8 @@ public class PacketsManager
|
|||||||
|
|
||||||
if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise))
|
if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise))
|
||||||
{
|
{
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager
|
WrappedWatchableObject watch = ReflectionManager.createWatchable(0,
|
||||||
.createDataWatcherItem(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
|
WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
|
||||||
|
|
||||||
list.add(watch);
|
list.add(watch);
|
||||||
|
|
||||||
@ -1172,9 +1172,10 @@ public class PacketsManager
|
|||||||
*/
|
*/
|
||||||
public static boolean isStaticMetadataDisguiseType(Disguise disguise)
|
public static boolean isStaticMetadataDisguiseType(Disguise disguise)
|
||||||
{
|
{
|
||||||
return (disguise.getType() == DisguiseType.WOLF || disguise.getType() == DisguiseType.OCELOT
|
return false;
|
||||||
|
/* return (disguise.getType() == DisguiseType.WOLF || disguise.getType() == DisguiseType.OCELOT
|
||||||
|| disguise.getType() == DisguiseType.ENDERMAN || disguise.getType() == DisguiseType.SHULKER
|
|| disguise.getType() == DisguiseType.ENDERMAN || disguise.getType() == DisguiseType.SHULKER
|
||||||
|| disguise.getType() == DisguiseType.SPLASH_POTION || disguise.getType() == DisguiseType.FIREWORK
|
|| disguise.getType() == DisguiseType.SPLASH_POTION || disguise.getType() == DisguiseType.FIREWORK
|
||||||
|| disguise.getType() == DisguiseType.DROPPED_ITEM || disguise.getType() == DisguiseType.ENDER_CRYSTAL);
|
|| disguise.getType() == DisguiseType.DROPPED_ITEM || disguise.getType() == DisguiseType.ENDER_CRYSTAL);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,14 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.comphenix.protocol.wrappers.MinecraftKey;
|
import com.comphenix.protocol.wrappers.MinecraftKey;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
@ -71,7 +74,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +140,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -175,7 +178,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -226,7 +229,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -240,7 +243,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -254,7 +257,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -273,7 +276,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -289,7 +292,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (NoSuchMethodException e)
|
catch (NoSuchMethodException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -308,7 +311,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -351,7 +354,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -365,7 +368,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -379,7 +382,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -393,7 +396,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -414,7 +417,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -433,7 +436,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -455,7 +458,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -469,7 +472,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -485,7 +488,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (NoSuchMethodException e)
|
catch (NoSuchMethodException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -504,7 +507,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -521,7 +524,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (NoSuchFieldException e)
|
catch (NoSuchFieldException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -540,7 +543,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -562,7 +565,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (NoSuchMethodException e)
|
catch (NoSuchMethodException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -579,7 +582,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (NoSuchMethodException e)
|
catch (NoSuchMethodException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -598,7 +601,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -619,7 +622,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -645,7 +648,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -698,7 +701,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -723,7 +726,7 @@ public class ReflectionManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,12 +918,21 @@ public class ReflectionManager
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Object createDataWatcherItem(int id, Object value)
|
private static Object createDataWatcherItem(int id, Object value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Serializer serializer = Registry.get(value.getClass());
|
Serializer serializer;
|
||||||
|
|
||||||
|
if (value instanceof Optional)
|
||||||
|
{
|
||||||
|
serializer = Registry.get(((Optional) value).get().getClass(), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serializer = Registry.get(value.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
||||||
|
|
||||||
@ -938,6 +950,35 @@ public class ReflectionManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WrappedWatchableObject createWatchable(int index, Object obj)
|
||||||
|
{
|
||||||
|
if (obj instanceof Optional)
|
||||||
|
{
|
||||||
|
Object value = ((Optional) obj).get();
|
||||||
|
|
||||||
|
if (value instanceof BlockPosition)
|
||||||
|
{
|
||||||
|
value = BlockPosition.getConverter().getSpecific(value);
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
obj = Optional.of(value);
|
||||||
|
}
|
||||||
|
else if (value instanceof ItemStack)
|
||||||
|
{
|
||||||
|
value = ReflectionManager.getNmsItem((ItemStack) value);
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
obj = Optional.of(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WrappedWatchableObject(createDataWatcherItem(index, obj));
|
||||||
|
}
|
||||||
|
|
||||||
public static EntityEquipment createEntityEquipment(Entity entity)
|
public static EntityEquipment createEntityEquipment(Entity entity)
|
||||||
{
|
{
|
||||||
if (!(entity instanceof LivingEntity))
|
if (!(entity instanceof LivingEntity))
|
||||||
|
@ -6,53 +6,67 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class UpdateChecker {
|
public class UpdateChecker
|
||||||
|
{
|
||||||
|
|
||||||
private String latestVersion;
|
private String latestVersion;
|
||||||
|
|
||||||
private boolean checkHigher(String currentVersion, String newVersion) {
|
private boolean checkHigher(String currentVersion, String newVersion)
|
||||||
|
{
|
||||||
String current = toReadable(currentVersion);
|
String current = toReadable(currentVersion);
|
||||||
String newVers = toReadable(newVersion);
|
String newVers = toReadable(newVersion);
|
||||||
return current.compareTo(newVers) < 0;
|
return current.compareTo(newVers) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkUpdate(String currentVersion) {
|
public void checkUpdate(String currentVersion)
|
||||||
|
{
|
||||||
String version = getSpigotVersion();
|
String version = getSpigotVersion();
|
||||||
if (version != null) {
|
|
||||||
if (checkHigher(currentVersion, version)) {
|
if (version == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!checkHigher(currentVersion, version))
|
||||||
|
return;
|
||||||
|
|
||||||
latestVersion = version;
|
latestVersion = version;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLatestVersion() {
|
public String getLatestVersion()
|
||||||
|
{
|
||||||
return latestVersion;
|
return latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks spigot for the version
|
* Asks spigot for the version
|
||||||
*/
|
*/
|
||||||
private String getSpigotVersion() {
|
private String getSpigotVersion()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.getOutputStream().write(
|
con.getOutputStream().write(
|
||||||
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=81").getBytes("UTF-8"));
|
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=81").getBytes("UTF-8"));
|
||||||
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||||
if (version.length() <= 7) {
|
if (version.length() <= 7)
|
||||||
|
{
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
}
|
||||||
System.out.print("[LibsDisguises] Failed to check for a update on spigot. Now checking bukkit..");
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.out.print("[LibsDisguises] Failed to check for a update on spigot.");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toReadable(String version) {
|
private String toReadable(String version)
|
||||||
|
{
|
||||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||||
version = "";
|
version = "";
|
||||||
for (String s : split) {
|
for (String s : split)
|
||||||
|
{
|
||||||
version += String.format("%4s", s);
|
version += String.format("%4s", s);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
@ -150,7 +150,7 @@ public class PacketListenerViewDisguises extends PacketAdapter
|
|||||||
if (observer.isSprinting())
|
if (observer.isSprinting())
|
||||||
b = (byte) (b | 1 << 3);
|
b = (byte) (b | 1 << 3);
|
||||||
|
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, b));
|
WrappedWatchableObject watch = ReflectionManager.createWatchable(0, b);
|
||||||
|
|
||||||
watchableList.add(watch);
|
watchableList.add(watch);
|
||||||
packet.getWatchableCollectionModifier().write(0, watchableList);
|
packet.getWatchableCollectionModifier().write(0, watchableList);
|
||||||
|
Loading…
Reference in New Issue
Block a user