Add backwards support for 1.11.2, bugfixes, update to 1.12
This commit is contained in:
@@ -1,24 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.command.CraftBlockCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@@ -28,6 +9,20 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private int maxRadius = 30;
|
||||
@@ -49,7 +44,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
center = ((Player) sender).getLocation();
|
||||
}
|
||||
else {
|
||||
center = ((CraftBlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
}
|
||||
|
||||
return center.getWorld().getNearbyEntities(center, radius, radius, radius);
|
||||
|
@@ -1,24 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.command.CraftBlockCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
@@ -30,6 +11,24 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private int maxRadius = 30;
|
||||
@@ -72,8 +71,9 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "EntityTypes usable are: " + ChatColor.GREEN
|
||||
+ StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + ".");
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "EntityTypes usable are: " + ChatColor.GREEN + StringUtils.join(classes,
|
||||
ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,11 +105,10 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the radius"
|
||||
+ (starting != 0 ? " and EntityType" : ""));
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the radius" + (starting != 0 ?
|
||||
" and EntityType" : ""));
|
||||
return true;
|
||||
}
|
||||
else if (args.length < 2) {
|
||||
} else if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a radius as well as the disguise");
|
||||
return true;
|
||||
}
|
||||
@@ -122,7 +121,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -158,9 +158,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (sender instanceof Player) {
|
||||
center = ((Player) sender).getLocation();
|
||||
}
|
||||
else {
|
||||
center = ((CraftBlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
} else {
|
||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
}
|
||||
|
||||
for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) {
|
||||
@@ -169,8 +168,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
|
||||
&& entity instanceof LivingEntity) {
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
|
||||
miscDisguises++;
|
||||
continue;
|
||||
}
|
||||
@@ -196,14 +194,13 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (disguisedEntitys > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find any entities to disguise!");
|
||||
}
|
||||
|
||||
if (miscDisguises > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to disguise " + miscDisguises
|
||||
+ " entities because the option to disguise a living entity as a non-living has been disabled in the config");
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Failed to disguise " + miscDisguises + " entities because the option to disguise a living entity as a non-living has been disabled in the config");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -244,8 +241,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (String type : getAllowedDisguises(perms)) {
|
||||
tabs.add(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
DisguisePerm disguiseType = DisguiseParser.getDisguisePerm(args[starting]);
|
||||
|
||||
@@ -256,13 +252,12 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? starting + 2
|
||||
: starting + 1; i < args.length; i++) {
|
||||
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? starting + 2 :
|
||||
starting + 1; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
|
||||
if (!method.getName().equalsIgnoreCase(arg))
|
||||
@@ -288,8 +283,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -301,7 +295,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
disguiseType.getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -316,31 +311,34 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at " + maxRadius + " blocks!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at " + maxRadius + " blocks!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN + StringUtils.join(
|
||||
allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
|
||||
String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")";
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>")
|
||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
}
|
||||
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby"
|
||||
+ optional + ">").replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional
|
||||
+ "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">")
|
||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,8 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibVersion;
|
||||
import me.libraryaddict.disguise.utilities.LibsVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -59,7 +58,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
||||
+ "/libsdisguises reload" + ChatColor.DARK_GREEN
|
||||
+ " to reload the config. All disguises will be blown by doing this.");
|
||||
|
||||
if (LibVersion.isPremium()) {
|
||||
if (LibsVersion.isPremium()) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "This server supports the plugin developer!");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user