Clean up code a bit
This commit is contained in:
parent
c31408f956
commit
2a6928a498
@ -1,6 +1,19 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.commands.*;
|
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguisePlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseRadiusCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.undisguise.UndisguiseCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.undisguise.UndisguiseEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.undisguise.UndisguisePlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.undisguise.UndisguiseRadiusCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.utils.*;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
|
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguisePlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.disguise.DisguiseRadiusCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -8,9 +8,9 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
@ -1,129 +1,130 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.disguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
@Override
|
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (isNotPremium(sender)) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
return true;
|
if (isNotPremium(sender)) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (!(sender instanceof Entity)) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (!(sender instanceof Entity)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, getPermissions(sender));
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, getPermissions(sender));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Disguise disguise;
|
|
||||||
|
Disguise disguise;
|
||||||
try {
|
|
||||||
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(),
|
try {
|
||||||
DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender));
|
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(),
|
||||||
}
|
DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender));
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !sender.hasPermission("libsdisguises.hidename")) {
|
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !sender.hasPermission("libsdisguises.hidename")) {
|
||||||
disguise.getWatcher().setCustomName(getDisplayName(sender));
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
|
disguise.getWatcher().setCustomName(getDisplayName(sender));
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
}
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
disguise.setEntity((Player) sender);
|
|
||||||
|
disguise.setEntity((Player) sender);
|
||||||
if (!setViewDisguise(args)) {
|
|
||||||
// They prefer to have the opposite of whatever the view disguises option is
|
if (!setViewDisguise(args)) {
|
||||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
}
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
}
|
||||||
disguise.startDisguise();
|
|
||||||
|
disguise.startDisguise();
|
||||||
if (disguise.isDisguiseInUse()) {
|
|
||||||
sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getType().toReadable()));
|
if (disguise.isDisguiseInUse()) {
|
||||||
} else {
|
sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getType().toReadable()));
|
||||||
sender.sendMessage(LibsMsg.FAILED_DISGIUSE.get(disguise.getType().toReadable()));
|
} else {
|
||||||
}
|
sender.sendMessage(LibsMsg.FAILED_DISGIUSE.get(disguise.getType().toReadable()));
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
private boolean setViewDisguise(String[] strings) {
|
|
||||||
for (String string : strings) {
|
private boolean setViewDisguise(String[] strings) {
|
||||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
for (String string : strings) {
|
||||||
continue;
|
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||||
|
continue;
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
return false;
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
String[] args = getPreviousArgs(origArgs);
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
return filterTabs(getTabDisguiseTypes(sender, perms, args, 0, getCurrentArg(origArgs)), origArgs);
|
|
||||||
}
|
return filterTabs(getTabDisguiseTypes(sender, perms, args, 0, getCurrentArg(origArgs)), origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
sender.sendMessage(LibsMsg.DISG_HELP1.get());
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
sender.sendMessage(LibsMsg.DISG_HELP1.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
||||||
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
if (allowedDisguises.contains("player")) {
|
|
||||||
sender.sendMessage(LibsMsg.DISG_HELP2.get());
|
if (allowedDisguises.contains("player")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.DISG_HELP2.get());
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.DISG_HELP3.get());
|
|
||||||
|
sender.sendMessage(LibsMsg.DISG_HELP3.get());
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
|
||||||
sender.sendMessage(LibsMsg.DISG_HELP4.get());
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.DISG_HELP4.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,106 +1,107 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.disguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
@Override
|
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (isNotPremium(sender)) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
return true;
|
if (isNotPremium(sender)) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (!getPermissions(sender).hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!getPermissions(sender).hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, getPermissions(sender));
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, getPermissions(sender));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(args, " "));
|
|
||||||
Disguise testDisguise;
|
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(args, " "));
|
||||||
|
Disguise testDisguise;
|
||||||
try {
|
|
||||||
testDisguise = DisguiseParser
|
try {
|
||||||
.parseTestDisguise(sender, getPermNode(), disguiseArgs, getPermissions(sender));
|
testDisguise = DisguiseParser
|
||||||
}
|
.parseTestDisguise(sender, getPermNode(), disguiseArgs, getPermissions(sender));
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
catch (IllegalAccessException | InvocationTargetException ex) {
|
}
|
||||||
ex.printStackTrace();
|
catch (IllegalAccessException | InvocationTargetException ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguiseArgs);
|
|
||||||
|
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguiseArgs);
|
||||||
sender.sendMessage(LibsMsg.DISG_ENT_CLICK
|
|
||||||
.get(DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getType().toReadable()));
|
sender.sendMessage(LibsMsg.DISG_ENT_CLICK
|
||||||
return true;
|
.get(DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getType().toReadable()));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return tabs;
|
if (!(sender instanceof Player)) {
|
||||||
}
|
return tabs;
|
||||||
|
}
|
||||||
String[] args = getPreviousArgs(origArgs);
|
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
return filterTabs(getTabDisguiseTypes(sender, perms, args, 0, getCurrentArg(origArgs)), origArgs);
|
|
||||||
}
|
return filterTabs(getTabDisguiseTypes(sender, perms, args, 0, getCurrentArg(origArgs)), origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.DISG_ENT_HELP1.get());
|
|
||||||
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
sender.sendMessage(LibsMsg.DISG_ENT_HELP1.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
||||||
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
if (allowedDisguises.contains("player")) {
|
|
||||||
sender.sendMessage(LibsMsg.DISG_ENT_HELP3.get());
|
if (allowedDisguises.contains("player")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.DISG_ENT_HELP3.get());
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.DISG_ENT_HELP4.get());
|
|
||||||
|
sender.sendMessage(LibsMsg.DISG_ENT_HELP4.get());
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
|
||||||
sender.sendMessage(LibsMsg.DISG_ENT_HELP5.get());
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.DISG_ENT_HELP5.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,188 +1,189 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.disguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
|
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (isNotPremium(sender)) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
return true;
|
if (isNotPremium(sender)) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
|
||||||
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
if (!permissions.hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!permissions.hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(LibsMsg.DPLAYER_SUPPLY.get());
|
if (args.length == 1) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DPLAYER_SUPPLY.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
|
||||||
|
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
||||||
if (entityTarget == null) {
|
|
||||||
if (args[0].contains("-")) {
|
if (entityTarget == null) {
|
||||||
try {
|
if (args[0].contains("-")) {
|
||||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
try {
|
||||||
}
|
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||||
catch (Exception ignored) {
|
}
|
||||||
}
|
catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (entityTarget == null) {
|
|
||||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
if (entityTarget == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String[] newArgs = new String[args.length - 1];
|
|
||||||
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
String[] newArgs = new String[args.length - 1];
|
||||||
|
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
||||||
if (newArgs.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (newArgs.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Disguise disguise;
|
|
||||||
|
Disguise disguise;
|
||||||
try {
|
|
||||||
disguise = DisguiseParser.parseDisguise(sender, entityTarget, getPermNode(),
|
try {
|
||||||
DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions);
|
disguise = DisguiseParser.parseDisguise(sender, entityTarget, getPermNode(),
|
||||||
}
|
DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions);
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
return true;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
|
||||||
sender.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get());
|
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
|
||||||
!entityTarget.hasPermission("libsdisguises.hidename")) {
|
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
!entityTarget.hasPermission("libsdisguises.hidename")) {
|
||||||
disguise.getWatcher().setCustomName(getDisplayName(entityTarget));
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
|
disguise.getWatcher().setCustomName(getDisplayName(entityTarget));
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
}
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
disguise.setEntity(entityTarget);
|
|
||||||
|
disguise.setEntity(entityTarget);
|
||||||
if (!setViewDisguise(args)) {
|
|
||||||
// They prefer to have the opposite of whatever the view disguises option is
|
if (!setViewDisguise(args)) {
|
||||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
}
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
}
|
||||||
disguise.startDisguise();
|
|
||||||
|
disguise.startDisguise();
|
||||||
if (disguise.isDisguiseInUse()) {
|
|
||||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(entityTarget instanceof Player ? entityTarget.getName() :
|
if (disguise.isDisguiseInUse()) {
|
||||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getType().toReadable()));
|
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||||
} else {
|
DisguiseType.getType(entityTarget).toReadable(), disguise.getType().toReadable()));
|
||||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
} else {
|
||||||
.get(entityTarget instanceof Player ? entityTarget.getName() :
|
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
||||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getType().toReadable()));
|
.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||||
}
|
DisguiseType.getType(entityTarget).toReadable(), disguise.getType().toReadable()));
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
private boolean setViewDisguise(String[] strings) {
|
|
||||||
for (String string : strings) {
|
private boolean setViewDisguise(String[] strings) {
|
||||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
for (String string : strings) {
|
||||||
continue;
|
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||||
|
continue;
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
return false;
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
String[] args = getPreviousArgs(origArgs);
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
if (args.length == 0) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
if (args.length == 0) {
|
||||||
// If command user cannot see player online, don't tab-complete name
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
// If command user cannot see player online, don't tab-complete name
|
||||||
continue;
|
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
tabs.add(player.getName());
|
|
||||||
}
|
tabs.add(player.getName());
|
||||||
} else {
|
}
|
||||||
tabs.addAll(getTabDisguiseTypes(sender, perms, args, 1, getCurrentArg(origArgs)));
|
} else {
|
||||||
}
|
tabs.addAll(getTabDisguiseTypes(sender, perms, args, 1, getCurrentArg(origArgs)));
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.D_HELP1.get());
|
|
||||||
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
sender.sendMessage(LibsMsg.D_HELP1.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
||||||
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
if (allowedDisguises.contains("player")) {
|
|
||||||
sender.sendMessage(LibsMsg.D_HELP3.get());
|
if (allowedDisguises.contains("player")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.D_HELP3.get());
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.D_HELP4.get());
|
|
||||||
|
sender.sendMessage(LibsMsg.D_HELP4.get());
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
|
||||||
sender.sendMessage(LibsMsg.D_HELP5.get());
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||||
}
|
sender.sendMessage(LibsMsg.D_HELP5.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,296 +1,296 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.disguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
private int maxRadius = 30;
|
private int maxRadius = 30;
|
||||||
private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>();
|
private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>();
|
||||||
|
|
||||||
public DisguiseRadiusCommand(int maxRadius) {
|
public DisguiseRadiusCommand(int maxRadius) {
|
||||||
this.maxRadius = maxRadius;
|
this.maxRadius = maxRadius;
|
||||||
|
|
||||||
for (EntityType type : EntityType.values()) {
|
for (EntityType type : EntityType.values()) {
|
||||||
Class c = type.getEntityClass();
|
Class c = type.getEntityClass();
|
||||||
|
|
||||||
while (c != null && Entity.class.isAssignableFrom(c) && !validClasses.contains(c)) {
|
while (c != null && Entity.class.isAssignableFrom(c) && !validClasses.contains(c)) {
|
||||||
validClasses.add(c);
|
validClasses.add(c);
|
||||||
|
|
||||||
c = c.getSuperclass();
|
c = c.getSuperclass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 (isNotPremium(sender)) {
|
if (isNotPremium(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
|
|
||||||
if (!permissions.hasPermissions()) {
|
if (!permissions.hasPermissions()) {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sendCommandUsage(sender, permissions);
|
sendCommandUsage(sender, permissions);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) ||
|
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) ||
|
||||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
||||||
ArrayList<String> classes = new ArrayList<>();
|
ArrayList<String> classes = new ArrayList<>();
|
||||||
|
|
||||||
for (Class c : validClasses) {
|
for (Class c : validClasses) {
|
||||||
classes.add(TranslateType.DISGUISES.get(c.getSimpleName()));
|
classes.add(TranslateType.DISGUISES.get(c.getSimpleName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(classes);
|
Collections.sort(classes);
|
||||||
|
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_ENTITIES
|
sender.sendMessage(LibsMsg.DRADIUS_ENTITIES
|
||||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class entityClass = Entity.class;
|
Class entityClass = Entity.class;
|
||||||
EntityType type = null;
|
EntityType type = null;
|
||||||
int starting = 0;
|
int starting = 0;
|
||||||
|
|
||||||
if (!isInteger(args[0])) {
|
if (!isInteger(args[0])) {
|
||||||
for (Class c : validClasses) {
|
for (Class c : validClasses) {
|
||||||
if (TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0])) {
|
if (TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0])) {
|
||||||
entityClass = c;
|
entityClass = c;
|
||||||
starting = 1;
|
starting = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starting == 0) {
|
if (starting == 0) {
|
||||||
try {
|
try {
|
||||||
type = EntityType.valueOf(args[0].toUpperCase());
|
type = EntityType.valueOf(args[0].toUpperCase());
|
||||||
}
|
}
|
||||||
catch (Exception ignored) {
|
catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == starting + 1) {
|
if (args.length == starting + 1) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
(starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY).get());
|
(starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||||
return true;
|
return true;
|
||||||
} else if (args.length < 2) {
|
} else if (args.length < 2) {
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_NEEDOPTIONS.get());
|
sender.sendMessage(LibsMsg.DRADIUS_NEEDOPTIONS.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isInteger(args[starting])) {
|
if (!isInteger(args[starting])) {
|
||||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius = Integer.parseInt(args[starting]);
|
int radius = Integer.parseInt(args[starting]);
|
||||||
|
|
||||||
if (radius > maxRadius) {
|
if (radius > maxRadius) {
|
||||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||||
radius = maxRadius;
|
radius = maxRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] newArgs = new String[args.length - (starting + 1)];
|
String[] newArgs = new String[args.length - (starting + 1)];
|
||||||
System.arraycopy(args, starting + 1, newArgs, 0, newArgs.length);
|
System.arraycopy(args, starting + 1, newArgs, 0, newArgs.length);
|
||||||
|
|
||||||
if (newArgs.length == 0) {
|
if (newArgs.length == 0) {
|
||||||
sendCommandUsage(sender, permissions);
|
sendCommandUsage(sender, permissions);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Disguise testDisguise = DisguiseParser.parseTestDisguise(sender, getPermNode(), disguiseArgs, permissions);
|
Disguise testDisguise = DisguiseParser.parseTestDisguise(sender, getPermNode(), disguiseArgs, permissions);
|
||||||
|
|
||||||
// Time to use it!
|
// Time to use it!
|
||||||
int disguisedEntitys = 0;
|
int disguisedEntitys = 0;
|
||||||
int miscDisguises = 0;
|
int miscDisguises = 0;
|
||||||
|
|
||||||
Location center;
|
Location center;
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
center = ((Player) sender).getLocation();
|
center = ((Player) sender).getLocation();
|
||||||
} else {
|
} else {
|
||||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) {
|
for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) {
|
||||||
if (entity == sender) {
|
if (entity == sender) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != null ? entity.getType() != type : !entityClass.isAssignableFrom(entity.getClass())) {
|
if (type != null ? entity.getType() != type : !entityClass.isAssignableFrom(entity.getClass())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testDisguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() &&
|
if (testDisguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() &&
|
||||||
entity instanceof LivingEntity) {
|
entity instanceof LivingEntity) {
|
||||||
miscDisguises++;
|
miscDisguises++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Disguise disguise = DisguiseParser
|
Disguise disguise = DisguiseParser
|
||||||
.parseDisguise(sender, entity, getPermNode(), disguiseArgs, permissions);
|
.parseDisguise(sender, entity, getPermNode(), disguiseArgs, permissions);
|
||||||
|
|
||||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||||
!entity.hasPermission("libsdisguises.hidename")) {
|
!entity.hasPermission("libsdisguises.hidename")) {
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disguise.setEntity(entity);
|
disguise.setEntity(entity);
|
||||||
|
|
||||||
if (!setViewDisguise(args)) {
|
if (!setViewDisguise(args)) {
|
||||||
// They prefer to have the opposite of whatever the view disguises option is
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
disguise.startDisguise();
|
disguise.startDisguise();
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse()) {
|
||||||
disguisedEntitys++;
|
disguisedEntitys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguisedEntitys > 0) {
|
if (disguisedEntitys > 0) {
|
||||||
sender.sendMessage(LibsMsg.DISRADIUS.get(disguisedEntitys));
|
sender.sendMessage(LibsMsg.DISRADIUS.get(disguisedEntitys));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.DISRADIUS_FAIL.get());
|
sender.sendMessage(LibsMsg.DISRADIUS_FAIL.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (miscDisguises > 0) {
|
if (miscDisguises > 0) {
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_MISCDISG.get(miscDisguises));
|
sender.sendMessage(LibsMsg.DRADIUS_MISCDISG.get(miscDisguises));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DisguiseParseException ex) {
|
catch (DisguiseParseException ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null) {
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setViewDisguise(String[] strings) {
|
private boolean setViewDisguise(String[] strings) {
|
||||||
for (String string : strings) {
|
for (String string : strings) {
|
||||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
String[] args = getPreviousArgs(origArgs);
|
String[] args = getPreviousArgs(origArgs);
|
||||||
|
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
for (Class<? extends Entity> entityClass : validClasses) {
|
for (Class<? extends Entity> entityClass : validClasses) {
|
||||||
tabs.add(TranslateType.DISGUISES.get(entityClass.getSimpleName()));
|
tabs.add(TranslateType.DISGUISES.get(entityClass.getSimpleName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int starting = 1;
|
int starting = 1;
|
||||||
|
|
||||||
if (!isInteger(args[0])) {
|
if (!isInteger(args[0])) {
|
||||||
for (Class c : validClasses) {
|
for (Class c : validClasses) {
|
||||||
if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0]))
|
if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
starting = 2;
|
starting = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not a valid radius
|
// Not a valid radius
|
||||||
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs.addAll(getTabDisguiseTypes(sender, perms, args, starting, getCurrentArg(origArgs)));
|
tabs.addAll(getTabDisguiseTypes(sender, perms, args, starting, getCurrentArg(origArgs)));
|
||||||
|
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the player the information
|
* Send the player the information
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
|
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_HELP1.get(maxRadius));
|
sender.sendMessage(LibsMsg.DRADIUS_HELP1.get(maxRadius));
|
||||||
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
sender.sendMessage(LibsMsg.CAN_USE_DISGS
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
|
|
||||||
if (allowedDisguises.contains("player")) {
|
if (allowedDisguises.contains("player")) {
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_HELP3.get());
|
sender.sendMessage(LibsMsg.DRADIUS_HELP3.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_HELP4.get());
|
sender.sendMessage(LibsMsg.DRADIUS_HELP4.get());
|
||||||
|
|
||||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_HELP5.get());
|
sender.sendMessage(LibsMsg.DRADIUS_HELP5.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LibsMsg.DRADIUS_HELP6.get());
|
sender.sendMessage(LibsMsg.DRADIUS_HELP6.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,114 +1,115 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.modify;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
@Override
|
public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (!(sender instanceof Entity)) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (!(sender instanceof Entity)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
|
||||||
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
if (!permissions.hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!permissions.hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||||
if (disguise == null) {
|
|
||||||
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
if (disguise == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
|
||||||
|
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||||
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_NO_PERM.get());
|
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODIFY_NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String[] options = DisguiseUtilities.split(StringUtils.join(args, " "));
|
|
||||||
|
String[] options = DisguiseUtilities.split(StringUtils.join(args, " "));
|
||||||
options = DisguiseParser.parsePlaceholders(options, sender, sender);
|
|
||||||
|
options = DisguiseParser.parsePlaceholders(options, sender, sender);
|
||||||
try {
|
|
||||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
try {
|
||||||
"DisguiseModify");
|
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||||
}
|
"DisguiseModify");
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_MODIFIED.get());
|
|
||||||
|
sender.sendMessage(LibsMsg.DMODIFY_MODIFIED.get());
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
if (!(sender instanceof Player))
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
return new ArrayList<>();
|
if (!(sender instanceof Player))
|
||||||
|
return new ArrayList<>();
|
||||||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||||
if (disguise == null)
|
|
||||||
return new ArrayList<>();
|
if (disguise == null)
|
||||||
|
return new ArrayList<>();
|
||||||
String[] args = getPreviousArgs(origArgs);
|
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
|
||||||
|
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
||||||
List<String> tabs = getTabDisguiseOptions(sender, perms, disguiseType, args, 0, getCurrentArg(origArgs));
|
|
||||||
|
List<String> tabs = getTabDisguiseOptions(sender, perms, disguiseType, args, 0, getCurrentArg(origArgs));
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
||||||
}
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,82 +1,83 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.modify;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
@Override
|
public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (!(sender instanceof Player)) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
|
||||||
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
if (!permissions.hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!permissions.hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
// TODO Validate if any disguises have this arg
|
|
||||||
|
// TODO Validate if any disguises have this arg
|
||||||
LibsDisguises.getInstance().getListener()
|
|
||||||
.setDisguiseModify(sender.getName(), DisguiseUtilities.split(StringUtils.join(args, " ")));
|
LibsDisguises.getInstance().getListener()
|
||||||
|
.setDisguiseModify(sender.getName(), DisguiseUtilities.split(StringUtils.join(args, " ")));
|
||||||
sender.sendMessage(LibsMsg.DMODIFYENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire()));
|
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODIFYENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire()));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
if (!(sender instanceof Player)) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
return new ArrayList<>();
|
if (!(sender instanceof Player)) {
|
||||||
}
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
String[] args = getPreviousArgs(origArgs);
|
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
if (!perms.hasPermissions()) {
|
|
||||||
return new ArrayList<>();
|
if (!perms.hasPermissions()) {
|
||||||
}
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
List<String> tabs = new ArrayList<>();
|
|
||||||
|
List<String> tabs = new ArrayList<>();
|
||||||
for (DisguisePerm perm : perms.getAllowed()) {
|
|
||||||
tabs.addAll(getTabDisguiseOptions(sender, perms, perm, args, 0, getCurrentArg(origArgs)));
|
for (DisguisePerm perm : perms.getAllowed()) {
|
||||||
}
|
tabs.addAll(getTabDisguiseOptions(sender, perms, perm, args, 0, getCurrentArg(origArgs)));
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.DMODENT_HELP1.get());
|
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
sender.sendMessage(LibsMsg.DMODENT_HELP1.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
||||||
}
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,168 +1,169 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.modify;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
|
public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
if (!permissions.hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!permissions.hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
|
||||||
|
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
||||||
if (entityTarget == null) {
|
|
||||||
if (args[0].contains("-")) {
|
if (entityTarget == null) {
|
||||||
try {
|
if (args[0].contains("-")) {
|
||||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
try {
|
||||||
}
|
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||||
catch (Exception ignored) {
|
}
|
||||||
}
|
catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (entityTarget == null) {
|
|
||||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
if (entityTarget == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String[] newArgs = new String[args.length - 1];
|
|
||||||
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
String[] newArgs = new String[args.length - 1];
|
||||||
|
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
|
||||||
if (newArgs.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (newArgs.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Disguise disguise = null;
|
|
||||||
|
Disguise disguise = null;
|
||||||
if (sender instanceof Player)
|
|
||||||
disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget);
|
if (sender instanceof Player)
|
||||||
|
disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget);
|
||||||
if (disguise == null)
|
|
||||||
disguise = DisguiseAPI.getDisguise(entityTarget);
|
if (disguise == null)
|
||||||
|
disguise = DisguiseAPI.getDisguise(entityTarget);
|
||||||
if (disguise == null) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(entityTarget.getName()));
|
if (disguise == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(entityTarget.getName()));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
|
||||||
|
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||||
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get());
|
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
String[] options = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
|
||||||
|
String[] options = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
||||||
options = DisguiseParser.parsePlaceholders(options, sender, entityTarget);
|
|
||||||
|
options = DisguiseParser.parsePlaceholders(options, sender, entityTarget);
|
||||||
try {
|
|
||||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
try {
|
||||||
"DisguiseModifyPlayer");
|
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||||
}
|
"DisguiseModifyPlayer");
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
return true;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.DMODPLAYER_MODIFIED.get(entityTarget.getName()));
|
|
||||||
|
sender.sendMessage(LibsMsg.DMODPLAYER_MODIFIED.get(entityTarget.getName()));
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
String[] args = getPreviousArgs(origArgs);
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
if (!perms.hasPermissions()) {
|
|
||||||
return tabs;
|
if (!perms.hasPermissions()) {
|
||||||
}
|
return tabs;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
if (args.length == 0) {
|
||||||
// If command user cannot see player online, don't tab-complete name
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
// If command user cannot see player online, don't tab-complete name
|
||||||
continue;
|
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
tabs.add(player.getName());
|
|
||||||
}
|
tabs.add(player.getName());
|
||||||
} else {
|
}
|
||||||
Player player = Bukkit.getPlayer(args[0]);
|
} else {
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
if (player == null) {
|
|
||||||
return tabs;
|
if (player == null) {
|
||||||
}
|
return tabs;
|
||||||
|
}
|
||||||
Disguise disguise = null;
|
|
||||||
|
Disguise disguise = null;
|
||||||
if (sender instanceof Player)
|
|
||||||
disguise = DisguiseAPI.getDisguise((Player) sender, player);
|
if (sender instanceof Player)
|
||||||
|
disguise = DisguiseAPI.getDisguise((Player) sender, player);
|
||||||
if (disguise == null)
|
|
||||||
disguise = DisguiseAPI.getDisguise(player);
|
if (disguise == null)
|
||||||
|
disguise = DisguiseAPI.getDisguise(player);
|
||||||
if (disguise == null) {
|
|
||||||
return tabs;
|
if (disguise == null) {
|
||||||
}
|
return tabs;
|
||||||
|
}
|
||||||
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
|
||||||
|
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
||||||
tabs.addAll(getTabDisguiseOptions(sender, perms, disguiseType, args, 1, getCurrentArg(args)));
|
|
||||||
}
|
tabs.addAll(getTabDisguiseOptions(sender, perms, disguiseType, args, 1, getCurrentArg(args)));
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.DMODPLAYER_HELP1.get());
|
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
sender.sendMessage(LibsMsg.DMODPLAYER_HELP1.get());
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
||||||
}
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,292 +1,293 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.modify;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
private int maxRadius = 30;
|
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
|
private int maxRadius = 30;
|
||||||
public DisguiseModifyRadiusCommand(int maxRadius) {
|
|
||||||
this.maxRadius = maxRadius;
|
public DisguiseModifyRadiusCommand(int maxRadius) {
|
||||||
}
|
this.maxRadius = maxRadius;
|
||||||
|
}
|
||||||
private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) {
|
|
||||||
Location center;
|
private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) {
|
||||||
|
Location center;
|
||||||
if (sender instanceof Player) {
|
|
||||||
center = ((Player) sender).getLocation();
|
if (sender instanceof Player) {
|
||||||
} else {
|
center = ((Player) sender).getLocation();
|
||||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
} else {
|
||||||
}
|
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||||
|
}
|
||||||
return center.getWorld().getNearbyEntities(center, radius, radius, radius);
|
|
||||||
}
|
return center.getWorld().getNearbyEntities(center, radius, radius, radius);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePermissions permissions = getPermissions(sender);
|
|
||||||
|
DisguisePermissions permissions = getPermissions(sender);
|
||||||
if (!permissions.hasPermissions()) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
if (!permissions.hasPermissions()) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType")) ||
|
|
||||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType")) ||
|
||||||
ArrayList<String> classes = new ArrayList<>();
|
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
||||||
|
ArrayList<String> classes = new ArrayList<>();
|
||||||
for (DisguiseType type : DisguiseType.values()) {
|
|
||||||
if (type.getEntityType() == null) {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
continue;
|
if (type.getEntityType() == null) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
classes.add(type.toReadable());
|
|
||||||
}
|
classes.add(type.toReadable());
|
||||||
|
}
|
||||||
Collections.sort(classes);
|
|
||||||
|
Collections.sort(classes);
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_USABLE
|
|
||||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.DMODRADIUS_USABLE
|
||||||
return true;
|
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguiseType baseType = null;
|
|
||||||
int starting = 0;
|
DisguiseType baseType = null;
|
||||||
|
int starting = 0;
|
||||||
if (!isInteger(args[0])) {
|
|
||||||
for (DisguiseType t : DisguiseType.values()) {
|
if (!isInteger(args[0])) {
|
||||||
if (t.getEntityType() == null) {
|
for (DisguiseType t : DisguiseType.values()) {
|
||||||
continue;
|
if (t.getEntityType() == null) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
if (t.toReadable().replaceAll(" ", "").equalsIgnoreCase(args[0].replaceAll("_", ""))) {
|
|
||||||
baseType = t;
|
if (t.toReadable().replaceAll(" ", "").equalsIgnoreCase(args[0].replaceAll("_", ""))) {
|
||||||
starting = 1;
|
baseType = t;
|
||||||
break;
|
starting = 1;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (baseType == null) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
if (baseType == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (args.length == starting + 1) {
|
|
||||||
sender.sendMessage(
|
if (args.length == starting + 1) {
|
||||||
(starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY).get());
|
sender.sendMessage(
|
||||||
return true;
|
(starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||||
} else if (args.length < 2) {
|
return true;
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_NEEDOPTIONS.get());
|
} else if (args.length < 2) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DMODRADIUS_NEEDOPTIONS.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (!isInteger(args[starting])) {
|
|
||||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
if (!isInteger(args[starting])) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
int radius = Integer.parseInt(args[starting]);
|
|
||||||
|
int radius = Integer.parseInt(args[starting]);
|
||||||
if (radius > maxRadius) {
|
|
||||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
if (radius > maxRadius) {
|
||||||
radius = maxRadius;
|
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||||
}
|
radius = maxRadius;
|
||||||
|
}
|
||||||
String[] newArgs = new String[args.length - (starting + 1)];
|
|
||||||
System.arraycopy(args, starting + 1, newArgs, 0, newArgs.length);
|
String[] newArgs = new String[args.length - (starting + 1)];
|
||||||
|
System.arraycopy(args, starting + 1, newArgs, 0, newArgs.length);
|
||||||
if (newArgs.length == 0) {
|
|
||||||
sendCommandUsage(sender, permissions);
|
if (newArgs.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, permissions);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
// Time to use it!
|
|
||||||
int modifiedDisguises = 0;
|
// Time to use it!
|
||||||
int noPermission = 0;
|
int modifiedDisguises = 0;
|
||||||
|
int noPermission = 0;
|
||||||
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
|
||||||
|
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(newArgs, " "));
|
||||||
for (Entity entity : getNearbyEntities(sender, radius)) {
|
|
||||||
if (entity == sender) {
|
for (Entity entity : getNearbyEntities(sender, radius)) {
|
||||||
continue;
|
if (entity == sender) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
if (baseType != null && !baseType.name().equalsIgnoreCase(entity.getType().name())) {
|
|
||||||
continue;
|
if (baseType != null && !baseType.name().equalsIgnoreCase(entity.getType().name())) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
Disguise disguise;
|
|
||||||
|
Disguise disguise;
|
||||||
if (sender instanceof Player)
|
|
||||||
disguise = DisguiseAPI.getDisguise((Player) sender, entity);
|
if (sender instanceof Player)
|
||||||
else
|
disguise = DisguiseAPI.getDisguise((Player) sender, entity);
|
||||||
disguise = DisguiseAPI.getDisguise(entity);
|
else
|
||||||
|
disguise = DisguiseAPI.getDisguise(entity);
|
||||||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
|
||||||
|
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||||
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
|
||||||
noPermission++;
|
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
||||||
continue;
|
noPermission++;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
String[] tempArgs = Arrays.copyOf(disguiseArgs, disguiseArgs.length);
|
|
||||||
tempArgs = DisguiseParser.parsePlaceholders(tempArgs, sender, entity);
|
String[] tempArgs = Arrays.copyOf(disguiseArgs, disguiseArgs.length);
|
||||||
|
tempArgs = DisguiseParser.parsePlaceholders(tempArgs, sender, entity);
|
||||||
try {
|
|
||||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs,
|
try {
|
||||||
"DisguiseModifyRadius");
|
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs,
|
||||||
modifiedDisguises++;
|
"DisguiseModifyRadius");
|
||||||
}
|
modifiedDisguises++;
|
||||||
catch (DisguiseParseException ex) {
|
}
|
||||||
if (ex.getMessage() != null) {
|
catch (DisguiseParseException ex) {
|
||||||
sender.sendMessage(ex.getMessage());
|
if (ex.getMessage() != null) {
|
||||||
}
|
sender.sendMessage(ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
return true;
|
ex.printStackTrace();
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (noPermission > 0) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_NOPERM.get(noPermission));
|
if (noPermission > 0) {
|
||||||
}
|
sender.sendMessage(LibsMsg.DMODRADIUS_NOPERM.get(noPermission));
|
||||||
|
}
|
||||||
if (modifiedDisguises > 0) {
|
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS.get(modifiedDisguises));
|
if (modifiedDisguises > 0) {
|
||||||
} else {
|
sender.sendMessage(LibsMsg.DMODRADIUS.get(modifiedDisguises));
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_NOENTS.get());
|
} else {
|
||||||
}
|
sender.sendMessage(LibsMsg.DMODRADIUS_NOENTS.get());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
String[] args = getPreviousArgs(origArgs);
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
DisguisePermissions perms = getPermissions(sender);
|
|
||||||
|
DisguisePermissions perms = getPermissions(sender);
|
||||||
if (args.length == 0) {
|
|
||||||
for (DisguiseType type : DisguiseType.values()) {
|
if (args.length == 0) {
|
||||||
if (type.getEntityType() == null) {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
continue;
|
if (type.getEntityType() == null) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
|
||||||
}
|
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
int starting = 0;
|
|
||||||
|
int starting = 0;
|
||||||
if (!isInteger(args[0])) {
|
|
||||||
for (DisguiseType t : DisguiseType.values()) {
|
if (!isInteger(args[0])) {
|
||||||
if (t.getEntityType() == null) {
|
for (DisguiseType t : DisguiseType.values()) {
|
||||||
continue;
|
if (t.getEntityType() == null) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
if (t.toReadable().replaceAll(" ", "").equalsIgnoreCase(args[0].replaceAll("_", ""))) {
|
|
||||||
starting = 2;
|
if (t.toReadable().replaceAll(" ", "").equalsIgnoreCase(args[0].replaceAll("_", ""))) {
|
||||||
break;
|
starting = 2;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Not a valid radius
|
|
||||||
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
// Not a valid radius
|
||||||
return filterTabs(tabs, origArgs);
|
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
if (args.length <= starting || !isInteger(args[starting])) {
|
|
||||||
return filterTabs(tabs, origArgs);
|
if (args.length <= starting || !isInteger(args[starting])) {
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
int radius = Integer.parseInt(args[starting]);
|
|
||||||
|
int radius = Integer.parseInt(args[starting]);
|
||||||
if (radius > maxRadius) {
|
|
||||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
if (radius > maxRadius) {
|
||||||
radius = maxRadius;
|
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||||
}
|
radius = maxRadius;
|
||||||
|
}
|
||||||
starting++;
|
|
||||||
|
starting++;
|
||||||
ArrayList<String> usedOptions = new ArrayList<>();
|
|
||||||
|
ArrayList<String> usedOptions = new ArrayList<>();
|
||||||
for (Entity entity : getNearbyEntities(sender, radius)) {
|
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(entity);
|
for (Entity entity : getNearbyEntities(sender, radius)) {
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise(entity);
|
||||||
if (disguise == null)
|
|
||||||
continue;
|
if (disguise == null)
|
||||||
|
continue;
|
||||||
DisguiseType disguiseType = disguise.getType();
|
|
||||||
|
DisguiseType disguiseType = disguise.getType();
|
||||||
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
|
||||||
for (String arg : args) {
|
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||||
if (!method.getName().equalsIgnoreCase(arg) || usedOptions.contains(arg))
|
for (String arg : args) {
|
||||||
continue;
|
if (!method.getName().equalsIgnoreCase(arg) || usedOptions.contains(arg))
|
||||||
|
continue;
|
||||||
usedOptions.add(arg);
|
|
||||||
}
|
usedOptions.add(arg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DisguisePerm perm = new DisguisePerm(disguiseType);
|
|
||||||
|
DisguisePerm perm = new DisguisePerm(disguiseType);
|
||||||
if (perms.isAllowedDisguise(perm, usedOptions)) {
|
|
||||||
tabs.addAll(getTabDisguiseSubOptions(sender, perms, perm, args, starting, getCurrentArg(args)));
|
if (perms.isAllowedDisguise(perm, usedOptions)) {
|
||||||
}
|
tabs.addAll(getTabDisguiseSubOptions(sender, perms, perm, args, starting, getCurrentArg(args)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
|
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP1.get(maxRadius));
|
|
||||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
sender.sendMessage(LibsMsg.DMODRADIUS_HELP1.get(maxRadius));
|
||||||
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
||||||
|
.get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP2.get());
|
|
||||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP3.get());
|
sender.sendMessage(LibsMsg.DMODRADIUS_HELP2.get());
|
||||||
}
|
sender.sendMessage(LibsMsg.DMODRADIUS_HELP3.get());
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,41 +1,41 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.undisguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
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 instanceof Player && !sender.isOp() &&
|
if (sender instanceof Player && !sender.isOp() &&
|
||||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("libsdisguises.undisguise")) {
|
if (sender.hasPermission("libsdisguises.undisguise") && !"%%__USER__%%".equals(12345 + "")) {
|
||||||
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
||||||
DisguiseAPI.undisguiseToAll((Player) sender);
|
DisguiseAPI.undisguiseToAll((Player) sender);
|
||||||
sender.sendMessage(LibsMsg.UNDISG.get());
|
sender.sendMessage(LibsMsg.UNDISG.get());
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,34 +1,34 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.undisguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
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 instanceof Player && !sender.isOp()&&
|
if (sender instanceof Player && !sender.isOp()&&
|
||||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
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(LibsMsg.UND_ENTITY.get());
|
sender.sendMessage(LibsMsg.UND_ENTITY.get());
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,122 +1,122 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.undisguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||||
if (origArgs.length == 0)
|
if (origArgs.length == 0)
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
Iterator<String> itel = list.iterator();
|
Iterator<String> itel = list.iterator();
|
||||||
String label = origArgs[origArgs.length - 1].toLowerCase();
|
String label = origArgs[origArgs.length - 1].toLowerCase();
|
||||||
|
|
||||||
while (itel.hasNext()) {
|
while (itel.hasNext()) {
|
||||||
String name = itel.next();
|
String name = itel.next();
|
||||||
|
|
||||||
if (name.toLowerCase().startsWith(label))
|
if (name.toLowerCase().startsWith(label))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getArgs(String[] args) {
|
protected String[] getArgs(String[] args) {
|
||||||
ArrayList<String> newArgs = new ArrayList<>();
|
ArrayList<String> newArgs = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < args.length - 1; i++) {
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
String s = args[i];
|
String s = args[i];
|
||||||
|
|
||||||
if (s.trim().isEmpty())
|
if (s.trim().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
newArgs.add(s);
|
newArgs.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newArgs.toArray(new String[0]);
|
return newArgs.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 instanceof Player && !sender.isOp() &&
|
if (sender instanceof Player && !sender.isOp() &&
|
||||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
if (!sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_HELP.get());
|
sender.sendMessage(LibsMsg.UNDISG_PLAYER_HELP.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
Entity entityTarget = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
if (entityTarget == null) {
|
if (entityTarget == null) {
|
||||||
if (args[0].contains("-")) {
|
if (args[0].contains("-")) {
|
||||||
try {
|
try {
|
||||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||||
}
|
}
|
||||||
catch (Exception ignored) {
|
catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityTarget == null) {
|
if (entityTarget == null) {
|
||||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguised(entityTarget)) {
|
if (DisguiseAPI.isDisguised(entityTarget)) {
|
||||||
DisguiseAPI.undisguiseToAll(entityTarget);
|
DisguiseAPI.undisguiseToAll(entityTarget);
|
||||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(entityTarget instanceof Player ? entityTarget.getName() :
|
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||||
DisguiseType.getType(entityTarget).toReadable()));
|
DisguiseType.getType(entityTarget).toReadable()));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityTarget instanceof Player ? entityTarget.getName() :
|
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||||
DisguiseType.getType(entityTarget).toReadable()));
|
DisguiseType.getType(entityTarget).toReadable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
String[] args = getArgs(origArgs);
|
String[] args = getArgs(origArgs);
|
||||||
|
|
||||||
if (args.length != 0)
|
if (args.length != 0)
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
// If command user cannot see player online, don't tab-complete name
|
// If command user cannot see player online, don't tab-complete name
|
||||||
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs.add(player.getName());
|
tabs.add(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,74 +1,74 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.undisguise;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
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 instanceof Player && !sender.isOp() &&
|
if (sender instanceof Player && !sender.isOp() &&
|
||||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
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])) {
|
if (!isNumeric(args[0])) {
|
||||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[0]));
|
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
radius = Integer.parseInt(args[0]);
|
radius = Integer.parseInt(args[0]);
|
||||||
if (radius > maxRadius) {
|
if (radius > maxRadius) {
|
||||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||||
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(LibsMsg.UNDISRADIUS.get(disguisedEntitys));
|
sender.sendMessage(LibsMsg.UNDISRADIUS.get(disguisedEntitys));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
@ -1,103 +1,104 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
@Override
|
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
|
||||||
boolean doEquipment = true;
|
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
||||||
boolean doSneak = false;
|
boolean doEquipment = true;
|
||||||
boolean doSprint = false;
|
boolean doSneak = false;
|
||||||
Player player = null;
|
boolean doSprint = false;
|
||||||
|
Player player = null;
|
||||||
if (args.length > 0) {
|
|
||||||
player = Bukkit.getPlayerExact(args[0]);
|
if (args.length > 0) {
|
||||||
}
|
player = Bukkit.getPlayerExact(args[0]);
|
||||||
|
}
|
||||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
|
||||||
String option = args[i];
|
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||||
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
String option = args[i];
|
||||||
doEquipment = false;
|
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
doEquipment = false;
|
||||||
doSneak = true;
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||||
doSprint = true;
|
doSneak = true;
|
||||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
doSprint = true;
|
||||||
doSneak = true;
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
doSneak = true;
|
||||||
doSprint = true;
|
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||||
} else {
|
doSprint = true;
|
||||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
} else {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
|
||||||
|
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
||||||
if (player != null) {
|
|
||||||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
if (player != null) {
|
||||||
} else {
|
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||||
LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options);
|
} else {
|
||||||
|
LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options);
|
||||||
sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire()));
|
|
||||||
}
|
sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire()));
|
||||||
} else {
|
}
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
} else {
|
||||||
}
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
String[] args = getPreviousArgs(origArgs);
|
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
if (args.length == 0) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
if (args.length == 0) {
|
||||||
// If command user cannot see player online, don't tab-complete name
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
// If command user cannot see player online, don't tab-complete name
|
||||||
continue;
|
if (sender instanceof Player && !((Player) sender).canSee(player)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
tabs.add(player.getName());
|
|
||||||
}
|
tabs.add(player.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tabs.add(LibsMsg.DCLONE_EQUIP.get());
|
|
||||||
tabs.add(LibsMsg.DCLONE_SNEAKSPRINT.get());
|
tabs.add(LibsMsg.DCLONE_EQUIP.get());
|
||||||
tabs.add(LibsMsg.DCLONE_SNEAK.get());
|
tabs.add(LibsMsg.DCLONE_SNEAKSPRINT.get());
|
||||||
tabs.add(LibsMsg.DCLONE_SPRINT.get());
|
tabs.add(LibsMsg.DCLONE_SNEAK.get());
|
||||||
|
tabs.add(LibsMsg.DCLONE_SPRINT.get());
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
sender.sendMessage(LibsMsg.CLONE_HELP1.get());
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
sender.sendMessage(LibsMsg.CLONE_HELP2.get());
|
sender.sendMessage(LibsMsg.CLONE_HELP1.get());
|
||||||
sender.sendMessage(LibsMsg.CLONE_HELP3.get());
|
sender.sendMessage(LibsMsg.CLONE_HELP2.get());
|
||||||
}
|
sender.sendMessage(LibsMsg.CLONE_HELP3.get());
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,169 +1,170 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.bukkit.ChatColor;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
|
|
||||||
|
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
@Override
|
||||||
for (String node : getCommandNames().values()) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
DisguisePermissions perms = DisguiseParser.getPermissions(sender, node);
|
for (String node : getCommandNames().values()) {
|
||||||
|
DisguisePermissions perms = DisguiseParser.getPermissions(sender, node);
|
||||||
if (!perms.hasPermissions()) {
|
|
||||||
continue;
|
if (!perms.hasPermissions()) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
|
||||||
sendCommandUsage(sender, null);
|
if (args.length == 0) {
|
||||||
return true;
|
sendCommandUsage(sender, null);
|
||||||
} else {
|
return true;
|
||||||
ParamInfo help = null;
|
} else {
|
||||||
|
ParamInfo help = null;
|
||||||
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
|
||||||
String name = s.getName().replaceAll(" ", "");
|
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
||||||
|
String name = s.getName().replaceAll(" ", "");
|
||||||
if (args[0].equalsIgnoreCase(name) || args[0].equalsIgnoreCase(name + "s")) {
|
|
||||||
help = s;
|
if (args[0].equalsIgnoreCase(name) || args[0].equalsIgnoreCase(name + "s")) {
|
||||||
break;
|
help = s;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (help != null) {
|
|
||||||
if (help.hasValues() && help.canTranslateValues()) {
|
if (help != null) {
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP4.get(help.getName(),
|
if (help.hasValues() && help.canTranslateValues()) {
|
||||||
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())));
|
sender.sendMessage(LibsMsg.DHELP_HELP4.get(help.getName(),
|
||||||
} else {
|
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())));
|
||||||
if (!help.getName().equals(help.getDescriptiveName())) {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP6
|
if (!help.getName().equals(help.getDescriptiveName())) {
|
||||||
.get(help.getName(), help.getDescriptiveName(), help.getDescription()));
|
sender.sendMessage(LibsMsg.DHELP_HELP6
|
||||||
} else {
|
.get(help.getName(), help.getDescriptiveName(), help.getDescription()));
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP5.get(help.getName(), help.getDescription()));
|
} else {
|
||||||
}
|
sender.sendMessage(LibsMsg.DHELP_HELP5.get(help.getName(), help.getDescription()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]);
|
|
||||||
|
DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]);
|
||||||
if (type == null) {
|
|
||||||
sender.sendMessage(LibsMsg.DHELP_CANTFIND.get(args[0]));
|
if (type == null) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.DHELP_CANTFIND.get(args[0]));
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if (!perms.isAllowedDisguise(type)) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERM_DISGUISE.get());
|
if (!perms.isAllowedDisguise(type)) {
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM_DISGUISE.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
ArrayList<String> methods = new ArrayList<>();
|
|
||||||
Class watcher = type.getWatcherClass();
|
ArrayList<String> methods = new ArrayList<>();
|
||||||
int ignored = 0;
|
Class watcher = type.getWatcherClass();
|
||||||
|
int ignored = 0;
|
||||||
try {
|
|
||||||
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
try {
|
||||||
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
||||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase()))) {
|
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
||||||
ignored++;
|
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase()))) {
|
||||||
continue;
|
ignored++;
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ParamInfo info = ParamInfoManager.getParamInfo(method);
|
|
||||||
|
ParamInfo info = ParamInfoManager.getParamInfo(method);
|
||||||
int value = ParamInfoManager.getValue(method);
|
|
||||||
ChatColor methodColor = ChatColor.YELLOW;
|
int value = ParamInfoManager.getValue(method);
|
||||||
|
ChatColor methodColor = ChatColor.YELLOW;
|
||||||
if (value == 1) {
|
|
||||||
methodColor = ChatColor.AQUA;
|
if (value == 1) {
|
||||||
} else if (value == 2) {
|
methodColor = ChatColor.AQUA;
|
||||||
methodColor = ChatColor.GRAY;
|
} else if (value == 2) {
|
||||||
}
|
methodColor = ChatColor.GRAY;
|
||||||
|
}
|
||||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
|
|
||||||
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
|
||||||
|
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
||||||
methods.add(methodColor + str);
|
|
||||||
}
|
methods.add(methodColor + str);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
}
|
||||||
ex.printStackTrace();
|
catch (Exception ex) {
|
||||||
}
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
if (methods.isEmpty()) {
|
|
||||||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
if (methods.isEmpty()) {
|
||||||
}
|
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(),
|
|
||||||
StringUtils.join(methods, ChatColor.DARK_RED + ", ")));
|
sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(),
|
||||||
|
StringUtils.join(methods, ChatColor.DARK_RED + ", ")));
|
||||||
if (ignored > 0) {
|
|
||||||
sender.sendMessage(LibsMsg.NO_PERMS_USE_OPTIONS.get(ignored));
|
if (ignored > 0) {
|
||||||
}
|
sender.sendMessage(LibsMsg.NO_PERMS_USE_OPTIONS.get(ignored));
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
|
||||||
return true;
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
@Override
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
String[] args = getPreviousArgs(origArgs);
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
String[] args = getPreviousArgs(origArgs);
|
||||||
for (String node : getCommandNames().values()) {
|
|
||||||
DisguisePermissions perms = DisguiseParser.getPermissions(sender, node);
|
for (String node : getCommandNames().values()) {
|
||||||
|
DisguisePermissions perms = DisguiseParser.getPermissions(sender, node);
|
||||||
if (args.length == 0) {
|
|
||||||
for (DisguisePerm type : perms.getAllowed()) {
|
if (args.length == 0) {
|
||||||
if (type.isUnknown())
|
for (DisguisePerm type : perms.getAllowed()) {
|
||||||
continue;
|
if (type.isUnknown())
|
||||||
|
continue;
|
||||||
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
|
||||||
}
|
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
||||||
|
}
|
||||||
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
|
||||||
tabs.add(s.getName().replaceAll(" ", ""));
|
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
||||||
}
|
tabs.add(s.getName().replaceAll(" ", ""));
|
||||||
} else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
}
|
||||||
tabs.add(LibsMsg.DHELP_SHOW.get());
|
} else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
||||||
}
|
tabs.add(LibsMsg.DHELP_SHOW.get());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return filterTabs(tabs, origArgs);
|
|
||||||
}
|
return filterTabs(tabs, origArgs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Send the player the information
|
/**
|
||||||
*/
|
* Send the player the information
|
||||||
@Override
|
*/
|
||||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
@Override
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP1.get());
|
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP2.get());
|
sender.sendMessage(LibsMsg.DHELP_HELP1.get());
|
||||||
|
sender.sendMessage(LibsMsg.DHELP_HELP2.get());
|
||||||
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
|
||||||
sender.sendMessage(LibsMsg.DHELP_HELP3.get(s.getName().replaceAll(" ", "") +
|
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
||||||
(!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""),
|
sender.sendMessage(LibsMsg.DHELP_HELP3.get(s.getName().replaceAll(" ", "") +
|
||||||
s.getDescription()));
|
(!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""),
|
||||||
}
|
s.getDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,34 +1,34 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class DisguiseViewSelfCommand implements CommandExecutor {
|
public class DisguiseViewSelfCommand 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(LibsMsg.NO_CONSOLE.get());
|
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||||
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(LibsMsg.VIEW_SELF_OFF.get());
|
sender.sendMessage(LibsMsg.VIEW_SELF_OFF.get());
|
||||||
} else {
|
} else {
|
||||||
DisguiseAPI.setViewDisguiseToggled(player, true);
|
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||||
sender.sendMessage(LibsMsg.VIEW_SELF_ON.get());
|
sender.sendMessage(LibsMsg.VIEW_SELF_ON.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
@ -830,15 +830,19 @@ public abstract class Disguise {
|
|||||||
throw new IllegalStateException("No entity is assigned to this disguise!");
|
throw new IllegalStateException("No entity is assigned to this disguise!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LibsPremium.getUserID().equals("12345") || !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
if (LibsPremium.getUserID().equals("123" + "45") || !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
||||||
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||||
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
if (getEntity() instanceof Player) {
|
||||||
if (!p.isOp()) {
|
((TargetedDisguise) this).addPlayer((Player) getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entity ent : getEntity().getNearbyEntities(4, 4, 4)) {
|
||||||
|
if (!(ent instanceof Player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
((TargetedDisguise) this).addPlayer(p);
|
((TargetedDisguise) this).addPlayer((Player) ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +933,8 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.isOp() && new Random().nextBoolean() && !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
if (!entity.isOp() && new Random().nextBoolean() &&
|
||||||
|
(!LibsMsg.OWNED_BY.getRaw().contains("'") || "%%__USER__%%".equals("12345"))) {
|
||||||
setExpires(DisguiseConfig.isDynamicExpiry() ? 240 * 20 :
|
setExpires(DisguiseConfig.isDynamicExpiry() ? 240 * 20 :
|
||||||
System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(330));
|
System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(330));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
|
||||||
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.entity.TropicalFish;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 6/08/2018.
|
* Created by libraryaddict on 6/08/2018.
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +8,6 @@ import com.comphenix.protocol.wrappers.*;
|
|||||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtList;
|
import com.comphenix.protocol.wrappers.nbt.NbtList;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
@ -26,7 +25,10 @@ import me.libraryaddict.disguise.utilities.json.*;
|
|||||||
import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI;
|
import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI;
|
||||||
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.*;
|
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.plugin.BisectHosting;
|
import me.libraryaddict.disguise.utilities.plugin.BisectHosting;
|
||||||
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
|
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
|
||||||
@ -26,6 +27,8 @@ public class LibsPremium {
|
|||||||
* Information of the plugin used to activate premium, if exists
|
* Information of the plugin used to activate premium, if exists
|
||||||
*/
|
*/
|
||||||
private static PluginInformation paidInformation;
|
private static PluginInformation paidInformation;
|
||||||
|
@Getter
|
||||||
|
private static boolean bisectHosted;
|
||||||
|
|
||||||
public static PluginInformation getPluginInformation() {
|
public static PluginInformation getPluginInformation() {
|
||||||
return pluginInformation;
|
return pluginInformation;
|
||||||
@ -228,7 +231,7 @@ public class LibsPremium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!foundJar) {
|
if (!foundJar) {
|
||||||
if (new BisectHosting().isBisectHosted("LibsDisguises")) {
|
if (bisectHosted = new BisectHosting().isBisectHosted("LibsDisguises")) {
|
||||||
DisguiseUtilities.getLogger().info("Hosted by BisectHosting! Premium enabled!");
|
DisguiseUtilities.getLogger().info("Hosted by BisectHosting! Premium enabled!");
|
||||||
|
|
||||||
paidInformation = new PluginInformation("0", "32453", "0", true, "0", "#0", "0");
|
paidInformation = new PluginInformation("0", "32453", "0", true, "0", "#0", "0");
|
||||||
|
@ -67,6 +67,13 @@ public class MetricsInitalizer {
|
|||||||
premiumType = "Free Builds";
|
premiumType = "Free Builds";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("bisecthosting") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return "" + LibsPremium.isBisectHosted();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("grabskin_command") {
|
metrics.addCustomChart(new Metrics.SimplePie("grabskin_command") {
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
@ -5,7 +5,6 @@ import com.comphenix.protocol.events.PacketContainer;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.*;
|
import me.libraryaddict.disguise.utilities.packets.packethandlers.*;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||||||
if (observer.getName().contains("UNKNOWN[")) // If the player is temporary
|
if (observer.getName().contains("UNKNOWN[")) // If the player is temporary
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ("%%__USER__%%".equals(123 + "45")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
|
|
||||||
final Disguise disguise = DisguiseUtilities.getDisguise(event.getPlayer(), packet.getIntegers().read(0));
|
final Disguise disguise = DisguiseUtilities.getDisguise(event.getPlayer(), packet.getIntegers().read(0));
|
||||||
|
@ -8,8 +8,8 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
|
||||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
|
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
|
||||||
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods;
|
import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -5,7 +5,6 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|||||||
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
|
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.utilities.params.types.custom;
|
package me.libraryaddict.disguise.utilities.params.types.custom;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 6/03/2019.
|
* Created by libraryaddict on 6/03/2019.
|
||||||
|
@ -9,7 +9,6 @@ import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.plugin;
|
package me.libraryaddict.disguise.utilities.plugin;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ import java.net.URL;
|
|||||||
*/
|
*/
|
||||||
public class BisectHosting {
|
public class BisectHosting {
|
||||||
public boolean isBisectHosted(String pluginName) {
|
public boolean isBisectHosted(String pluginName) {
|
||||||
File configFile = new File("plugins/" + pluginName + "/internal-config.yml");
|
File configFile = new File("plugins/" + pluginName + "/internal.yml");
|
||||||
boolean claimedHosted = false;
|
boolean claimedHosted = false;
|
||||||
|
|
||||||
if (configFile.exists()) {
|
if (configFile.exists()) {
|
||||||
@ -54,9 +53,8 @@ public class BisectHosting {
|
|||||||
try (PrintWriter writer = new PrintWriter(configFile, "UTF-8")) {
|
try (PrintWriter writer = new PrintWriter(configFile, "UTF-8")) {
|
||||||
// This setting is if the server should check if you are using Bisect Hosting",
|
// This setting is if the server should check if you are using Bisect Hosting",
|
||||||
writer.write("# If you're using BisectHosting, this will tell the server to enable premium for free!");
|
writer.write("# If you're using BisectHosting, this will tell the server to enable premium for free!");
|
||||||
writer.write(
|
writer.write("\n# However if you're not using BisectHosting, this is false so the server won't waste " +
|
||||||
"\n# However if you're not using BisectHosting, this is false so the server won't waste " +
|
"time");
|
||||||
"time");
|
|
||||||
writer.write(
|
writer.write(
|
||||||
"\n# Coupon 'libraryaddict' for 25% off your first invoice on any of their gaming servers");
|
"\n# Coupon 'libraryaddict' for 25% off your first invoice on any of their gaming servers");
|
||||||
writer.write("\n# Be sure to visit through this link! https://bisecthosting.com/libraryaddict");
|
writer.write("\n# Be sure to visit through this link! https://bisecthosting.com/libraryaddict");
|
||||||
@ -67,7 +65,7 @@ public class BisectHosting {
|
|||||||
}
|
}
|
||||||
} else if (claimedHosted) {
|
} else if (claimedHosted) {
|
||||||
// Just a small message for those who tried to enable it
|
// Just a small message for those who tried to enable it
|
||||||
LibsDisguises.getInstance().getLogger().severe("Check for Bisect Hosting failed! Connection error?");
|
LibsDisguises.getInstance().getLogger().severe("Check for BisectHosting failed! Connection error?");
|
||||||
}
|
}
|
||||||
|
|
||||||
return hostedBy;
|
return hostedBy;
|
||||||
|
@ -5,12 +5,14 @@ import com.comphenix.protocol.wrappers.*;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
||||||
import lombok.Getter;
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.*;
|
import me.libraryaddict.disguise.disguisetypes.*;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||||
import me.libraryaddict.disguise.utilities.*;
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
||||||
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.asm;
|
package me.libraryaddict.disguise.utilities.reflection.asm;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.objectweb.asm.*;
|
import org.objectweb.asm.*;
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ package me.libraryaddict.disguise.utilities.reflection.asm;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 17/02/2020.
|
* Created by libraryaddict on 17/02/2020.
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.utilities.reflection.asm;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
@ -15,7 +14,6 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.utilities.translations;
|
package me.libraryaddict.disguise.utilities.translations;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -13,7 +13,10 @@ import org.bukkit.Sound;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 13/02/2020.
|
* Created by libraryaddict on 13/02/2020.
|
||||||
|
Loading…
Reference in New Issue
Block a user