Change the way entity interaction works for commands to a cleaner method
This commit is contained in:
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands.utils;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.commands.interactions.DisguiseCloneInteraction;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
@@ -17,6 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
@@ -24,44 +26,48 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
||||
boolean doEquipment = true;
|
||||
boolean doSneak = false;
|
||||
boolean doSprint = false;
|
||||
Player player = null;
|
||||
if (!sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
||||
|
||||
if (args.length > 0) {
|
||||
player = Bukkit.getPlayerExact(args[0]);
|
||||
}
|
||||
|
||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||
String option = args[i];
|
||||
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||
doEquipment = false;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||
doSneak = true;
|
||||
doSprint = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||
doSneak = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||
doSprint = true;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
||||
|
||||
if (player != null) {
|
||||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||
} else {
|
||||
LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options);
|
||||
|
||||
sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean doEquipment = true;
|
||||
boolean doSneak = false;
|
||||
boolean doSprint = false;
|
||||
Player player = null;
|
||||
|
||||
if (args.length > 0) {
|
||||
player = Bukkit.getPlayerExact(args[0]);
|
||||
}
|
||||
|
||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||
String option = args[i];
|
||||
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||
doEquipment = false;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||
doSneak = true;
|
||||
doSprint = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||
doSneak = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||
doSprint = true;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
||||
|
||||
if (player != null) {
|
||||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||
} else {
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options),
|
||||
DisguiseConfig.getDisguiseCloneExpire());
|
||||
|
||||
sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user