Minor cleanup and untested disguise modify commands
This commit is contained in:
parent
7ab456c7e6
commit
77a7e91766
222
plugin.yml
222
plugin.yml
@ -1,103 +1,119 @@
|
|||||||
name: LibsDisguises
|
name: LibsDisguises
|
||||||
main: me.libraryaddict.disguise.LibsDisguises
|
main: me.libraryaddict.disguise.LibsDisguises
|
||||||
description: A disguise plugin with various disguises.
|
description: A disguise plugin with various disguises.
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
authors: [Byteflux, Navid K.]
|
authors: [Byteflux, Navid K.]
|
||||||
softdepend: [ProtocolLib]
|
softdepend: [ProtocolLib]
|
||||||
commands:
|
commands:
|
||||||
libsdisguises:
|
libsdisguises:
|
||||||
permission: libsdisguises.seecmd.libsdisguises
|
permission: libsdisguises.seecmd.libsdisguises
|
||||||
description: Main command for libsdisguises.
|
description: Main command for libsdisguises.
|
||||||
disguise:
|
disguise:
|
||||||
aliases: [d, dis]
|
aliases: [d, dis]
|
||||||
permission: libsdisguises.seecmd.disguise
|
permission: libsdisguises.seecmd.disguise
|
||||||
description: Disguise yourself as an entity.
|
description: Disguise yourself as an entity.
|
||||||
disguiseentity:
|
disguiseentity:
|
||||||
aliases: [dentity, disentity]
|
aliases: [dentity, disentity]
|
||||||
permission: libsdisguises.seecmd.disguiseentity
|
permission: libsdisguises.seecmd.disguiseentity
|
||||||
description: Disguise an entity as another entity.
|
description: Disguise an entity as another entity.
|
||||||
disguisehelp:
|
disguisehelp:
|
||||||
aliases: [dhelp, dishelp]
|
aliases: [dhelp, dishelp]
|
||||||
permission: libsdisguises.seecmd.disguisehelp
|
permission: libsdisguises.seecmd.disguisehelp
|
||||||
description: Help command for LibsDisguises.
|
description: Help command for LibsDisguises.
|
||||||
disguiseplayer:
|
disguiseplayer:
|
||||||
aliases: [dplayer, displayer]
|
aliases: [dplayer, displayer]
|
||||||
permission: libsdisguises.seecmd.disguiseplayer
|
permission: libsdisguises.seecmd.disguiseplayer
|
||||||
description: Disguise another player as an entity.
|
description: Disguise another player as an entity.
|
||||||
disguiseradius:
|
disguiseradius:
|
||||||
aliases: [disradius, dradius]
|
aliases: [disradius, dradius]
|
||||||
permission: libsdisguises.seecmd.disguiseradius
|
permission: libsdisguises.seecmd.disguiseradius
|
||||||
description: Disguise all entities within a radius as an entity.
|
description: Disguise all entities within a radius as an entity.
|
||||||
undisguise:
|
undisguise:
|
||||||
aliases: [u, und, undis]
|
aliases: [u, und, undis]
|
||||||
permission: libsdisguises.seecmd.undisguise
|
permission: libsdisguises.seecmd.undisguise
|
||||||
description: Undisguise yourself.
|
description: Undisguise yourself.
|
||||||
undisguiseentity:
|
undisguiseentity:
|
||||||
aliases: [undisentity, undentity]
|
aliases: [undisentity, undentity]
|
||||||
permission: libsdisguises.seecmd.undisguiseentity
|
permission: libsdisguises.seecmd.undisguiseentity
|
||||||
description: Undisguise an entity.
|
description: Undisguise an entity.
|
||||||
undisguiseplayer:
|
undisguiseplayer:
|
||||||
aliases: [undisplayer, undplayer]
|
aliases: [undisplayer, undplayer]
|
||||||
permission: libsdisguises.seecmd.undisguiseplayer
|
permission: libsdisguises.seecmd.undisguiseplayer
|
||||||
description: Undisguise a player.
|
description: Undisguise a player.
|
||||||
undisguiseradius:
|
undisguiseradius:
|
||||||
aliases: [undisradius, undradius]
|
aliases: [undisradius, undradius]
|
||||||
permission: libsdisguises.seecmd.undisguiseradius
|
permission: libsdisguises.seecmd.undisguiseradius
|
||||||
description: Undisguise all entities within a radius.
|
description: Undisguise all entities within a radius.
|
||||||
disguiseclone:
|
disguiseclone:
|
||||||
aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis]
|
aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis]
|
||||||
permission: libsdisguises.seecmd.disguiseclone
|
permission: libsdisguises.seecmd.disguiseclone
|
||||||
description: Copy a disguise (or entity) and use it later.
|
description: Copy a disguise (or entity) and use it later.
|
||||||
disguiseviewself:
|
disguiseviewself:
|
||||||
aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd]
|
aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd]
|
||||||
permission: libsdisguises.seecmd.viewself
|
permission: libsdisguises.seecmd.viewself
|
||||||
description: Toggle seeing your own disguise on or off.
|
description: Toggle seeing your own disguise on or off.
|
||||||
|
disguisemodify:
|
||||||
permissions:
|
aliases: [dmodify]
|
||||||
libsdisguises.reload:
|
permission: libsdisguises.seecmd.disguisemodify
|
||||||
description: Allows the user to reload LibsDisguises.
|
description: Modify your own disguise
|
||||||
default: op
|
disguisemodifyplayer:
|
||||||
libsdisguises.seethrough:
|
aliases: [dmodifyplayer]
|
||||||
description: Allows player to see through disguises.
|
permission: libsdisguises.seecmd.disguisemodifyplayer
|
||||||
default: false
|
description: Modify the disguise of a player
|
||||||
libsdisguises.seecmd:
|
disguisemodifyradius:
|
||||||
description: See all commands in tab-completion
|
aliases: [dmodifyradius]
|
||||||
default: true
|
permission: libsdisguises.seecmd.disguisemodifyradius
|
||||||
children:
|
description: Modify disguises in a radius
|
||||||
libsdisguises.seecmd.libsdisguises: true
|
disguisemodifyentity:
|
||||||
libsdisguises.seecmd.disguise: true
|
aliases: [dmodifyentity]
|
||||||
libsdisguises.seecmd.disguiseentity: true
|
permission: libsdisguises.seecmd.disguisemodifyentity
|
||||||
libsdisguises.seecmd.disguisehelp: true
|
description: Modify a disguise by right clicking them
|
||||||
libsdisguises.seecmd.disguiseplayer: true
|
|
||||||
libsdisguises.seecmd.disguiseradius: true
|
permissions:
|
||||||
libsdisguises.seecmd.undisguise: true
|
libsdisguises.reload:
|
||||||
libsdisguises.seecmd.undisguiseentity: true
|
description: Allows the user to reload LibsDisguises.
|
||||||
libsdisguises.seecmd.undisguiseplayer: true
|
default: op
|
||||||
libsdisguises.seecmd.undisguiseradius: true
|
libsdisguises.seethrough:
|
||||||
libsdisguises.seecmd.disguiseclone: true
|
description: Allows player to see through disguises.
|
||||||
libsdisguises.seecmd.disguiseviewself: true
|
default: false
|
||||||
libsdisguises.seecmd.libsdisguises:
|
libsdisguises.seecmd:
|
||||||
description: See the /libsdisguises command in tab-completion
|
description: See all commands in tab-completion
|
||||||
libsdisguises.seecmd.disguiseviewself:
|
default: true
|
||||||
description: See the /disguiseviewself command in tab-completion
|
children:
|
||||||
libsdisguises.seecmd.disguise:
|
libsdisguises.seecmd.libsdisguises: true
|
||||||
description: See the /disguise command in tab-completion
|
libsdisguises.seecmd.disguise: true
|
||||||
libsdisguises.seecmd.disguiseentity:
|
libsdisguises.seecmd.disguiseentity: true
|
||||||
description: See the /disguiseentity command in tab-completion
|
libsdisguises.seecmd.disguisehelp: true
|
||||||
libsdisguises.seecmd.disguisehelp:
|
libsdisguises.seecmd.disguiseplayer: true
|
||||||
description: See the /disguisehelp command in tab-completion
|
libsdisguises.seecmd.disguiseradius: true
|
||||||
libsdisguises.seecmd.disguiseplayer:
|
libsdisguises.seecmd.undisguise: true
|
||||||
description: See the /disguiseplayer command in tab-completion
|
libsdisguises.seecmd.undisguiseentity: true
|
||||||
libsdisguises.seecmd.disguiseradius:
|
libsdisguises.seecmd.undisguiseplayer: true
|
||||||
description: See the /disguiseradius command in tab-completion
|
libsdisguises.seecmd.undisguiseradius: true
|
||||||
libsdisguises.seecmd.undisguise:
|
libsdisguises.seecmd.disguiseclone: true
|
||||||
description: See the /undisguise command in tab-completion
|
libsdisguises.seecmd.disguiseviewself: true
|
||||||
libsdisguises.seecmd.undisguiseentity:
|
libsdisguises.seecmd.libsdisguises:
|
||||||
description: See the /undisguiseentity command in tab-completion
|
description: See the /libsdisguises command in tab-completion
|
||||||
libsdisguises.seecmd.undisguiseplayer:
|
libsdisguises.seecmd.disguiseviewself:
|
||||||
description: See the /undisguiseplayer command in tab-completion
|
description: See the /disguiseviewself command in tab-completion
|
||||||
libsdisguises.seecmd.undisguiseradius:
|
libsdisguises.seecmd.disguise:
|
||||||
description: See the /undisguiseradius command in tab-completion
|
description: See the /disguise command in tab-completion
|
||||||
libsdisguises.seecmd.disguiseclone:
|
libsdisguises.seecmd.disguiseentity:
|
||||||
description: See the /disguiseclone command in tab-completion
|
description: See the /disguiseentity command in tab-completion
|
||||||
|
libsdisguises.seecmd.disguisehelp:
|
||||||
|
description: See the /disguisehelp command in tab-completion
|
||||||
|
libsdisguises.seecmd.disguiseplayer:
|
||||||
|
description: See the /disguiseplayer command in tab-completion
|
||||||
|
libsdisguises.seecmd.disguiseradius:
|
||||||
|
description: See the /disguiseradius command in tab-completion
|
||||||
|
libsdisguises.seecmd.undisguise:
|
||||||
|
description: See the /undisguise command in tab-completion
|
||||||
|
libsdisguises.seecmd.undisguiseentity:
|
||||||
|
description: See the /undisguiseentity command in tab-completion
|
||||||
|
libsdisguises.seecmd.undisguiseplayer:
|
||||||
|
description: See the /undisguiseplayer command in tab-completion
|
||||||
|
libsdisguises.seecmd.undisguiseradius:
|
||||||
|
description: See the /undisguiseradius command in tab-completion
|
||||||
|
libsdisguises.seecmd.disguiseclone:
|
||||||
|
description: See the /disguiseclone command in tab-completion
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -41,6 +42,9 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.UpdateChecker;
|
import me.libraryaddict.disguise.utilities.UpdateChecker;
|
||||||
@ -50,6 +54,7 @@ public class DisguiseListener implements Listener {
|
|||||||
private String currentVersion;
|
private String currentVersion;
|
||||||
private HashMap<String, Boolean[]> disguiseClone = new HashMap<>();
|
private HashMap<String, Boolean[]> disguiseClone = new HashMap<>();
|
||||||
private HashMap<String, Disguise> disguiseEntity = new HashMap<>();
|
private HashMap<String, Disguise> disguiseEntity = new HashMap<>();
|
||||||
|
private HashMap<String, String[]> disguiseModify = new HashMap<>();
|
||||||
private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>();
|
private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>();
|
||||||
private String latestVersion;
|
private String latestVersion;
|
||||||
private LibsDisguises plugin;
|
private LibsDisguises plugin;
|
||||||
@ -310,79 +315,113 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRightClick(PlayerInteractEntityEvent event) {
|
public void onRightClick(PlayerInteractEntityEvent event) {
|
||||||
if (disguiseEntity.containsKey(event.getPlayer().getName()) || disguiseClone.containsKey(event.getPlayer().getName())) {
|
if (!disguiseEntity.containsKey(event.getPlayer().getName()) && !disguiseClone.containsKey(event.getPlayer().getName())) {
|
||||||
Player p = event.getPlayer();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
Player p = event.getPlayer();
|
||||||
disguiseRunnable.remove(p.getName()).cancel();
|
|
||||||
|
|
||||||
Entity entity = event.getRightClicked();
|
event.setCancelled(true);
|
||||||
String entityName;
|
disguiseRunnable.remove(p.getName()).cancel();
|
||||||
|
|
||||||
if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) {
|
Entity entity = event.getRightClicked();
|
||||||
entityName = entity.getName();
|
String entityName;
|
||||||
}
|
|
||||||
else {
|
|
||||||
entityName = DisguiseType.getType(entity).toReadable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disguiseClone.containsKey(p.getName())) {
|
if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) {
|
||||||
Boolean[] options = disguiseClone.remove(p.getName());
|
entityName = entity.getName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entityName = DisguiseType.getType(entity).toReadable();
|
||||||
|
}
|
||||||
|
|
||||||
DisguiseUtilities.createClonedDisguise(p, entity, options);
|
if (disguiseClone.containsKey(p.getName())) {
|
||||||
}
|
Boolean[] options = disguiseClone.remove(p.getName());
|
||||||
else if (disguiseEntity.containsKey(p.getName())) {
|
|
||||||
Disguise disguise = disguiseEntity.remove(p.getName());
|
|
||||||
|
|
||||||
if (disguise != null) {
|
DisguiseUtilities.createClonedDisguise(p, entity, options);
|
||||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
|
}
|
||||||
&& entity instanceof LivingEntity) {
|
else if (disguiseEntity.containsKey(p.getName())) {
|
||||||
p.sendMessage(ChatColor.RED
|
Disguise disguise = disguiseEntity.remove(p.getName());
|
||||||
+ "Can't disguise a living entity as a misc disguise. This has been disabled in the config!");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
|
||||||
disguise.getWatcher().setCustomName(((Player) entity).getDisplayName());
|
|
||||||
|
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
if (disguise != null) {
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
|
||||||
}
|
&& entity instanceof LivingEntity) {
|
||||||
}
|
p.sendMessage(ChatColor.RED
|
||||||
}
|
+ "Can't disguise a living entity as a misc disguise. This has been disabled in the config!");
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll(entity, disguise);
|
|
||||||
|
|
||||||
String disguiseName = "a ";
|
|
||||||
|
|
||||||
if (disguise instanceof PlayerDisguise) {
|
|
||||||
disguiseName = "the player " + ((PlayerDisguise) disguise).getName();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
disguiseName += disguise.getType().toReadable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
|
||||||
p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : "the ") + entityName
|
|
||||||
+ " as " + disguiseName + "!");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ")
|
|
||||||
+ entityName + " as " + disguiseName + "!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (DisguiseAPI.isDisguised(entity)) {
|
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
||||||
DisguiseAPI.undisguiseToAll(entity);
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
|
disguise.getWatcher().setCustomName(((Player) entity).getDisplayName());
|
||||||
|
|
||||||
p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName);
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseAPI.disguiseToAll(entity, disguise);
|
||||||
|
|
||||||
|
String disguiseName = "a ";
|
||||||
|
|
||||||
|
if (disguise instanceof PlayerDisguise) {
|
||||||
|
disguiseName = "the player " + ((PlayerDisguise) disguise).getName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!");
|
disguiseName += disguise.getType().toReadable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disguise.isDisguiseInUse()) {
|
||||||
|
p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : "the ") + entityName
|
||||||
|
+ " as " + disguiseName + "!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ")
|
||||||
|
+ entityName + " as " + disguiseName + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (DisguiseAPI.isDisguised(entity)) {
|
||||||
|
DisguiseAPI.undisguiseToAll(entity);
|
||||||
|
|
||||||
|
p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (disguiseModify.containsKey(p.getName())) {
|
||||||
|
String[] options = disguiseModify.remove(p.getName());
|
||||||
|
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise(p, entity);
|
||||||
|
|
||||||
|
if (disguise == null) {
|
||||||
|
p.sendMessage(ChatColor.RED + entityName + " is not disguised!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser.getPermissions(p,
|
||||||
|
"libsdisguises.disguiseentitymodify.");
|
||||||
|
|
||||||
|
if (!perms.containsKey(new DisguisePerm(disguise.getType()))) {
|
||||||
|
p.sendMessage(ChatColor.RED + "You do not have permission to modify this disguise");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DisguiseParser.callMethods(p, disguise, perms.get(new DisguisePerm(disguise.getType())), new ArrayList<String>(),
|
||||||
|
options);
|
||||||
|
p.sendMessage(ChatColor.RED + "Modified the disguise!");
|
||||||
|
}
|
||||||
|
catch (DisguiseParseException ex) {
|
||||||
|
if (ex.getMessage() != null) {
|
||||||
|
p.sendMessage(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,4 +577,25 @@ public class DisguiseListener implements Listener {
|
|||||||
disguiseEntity.put(player, disguise);
|
disguiseEntity.put(player, disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDisguiseModify(final String player, String[] args) {
|
||||||
|
if (disguiseRunnable.containsKey(player)) {
|
||||||
|
BukkitRunnable run = disguiseRunnable.remove(player);
|
||||||
|
run.cancel();
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
BukkitRunnable runnable = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
disguiseModify.remove(player);
|
||||||
|
disguiseRunnable.remove(player);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
runnable.runTaskLater(plugin, 20 * DisguiseConfig.getDisguiseEntityExpire());
|
||||||
|
|
||||||
|
disguiseRunnable.put(player, runnable);
|
||||||
|
disguiseModify.put(player, args);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@ import me.libraryaddict.disguise.commands.DisguiseCloneCommand;
|
|||||||
import me.libraryaddict.disguise.commands.DisguiseCommand;
|
import me.libraryaddict.disguise.commands.DisguiseCommand;
|
||||||
import me.libraryaddict.disguise.commands.DisguiseEntityCommand;
|
import me.libraryaddict.disguise.commands.DisguiseEntityCommand;
|
||||||
import me.libraryaddict.disguise.commands.DisguiseHelpCommand;
|
import me.libraryaddict.disguise.commands.DisguiseHelpCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.DisguiseModifyCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.DisguiseModifyEntityCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.DisguiseModifyPlayerCommand;
|
||||||
|
import me.libraryaddict.disguise.commands.DisguiseModifyRadiusCommand;
|
||||||
import me.libraryaddict.disguise.commands.DisguisePlayerCommand;
|
import me.libraryaddict.disguise.commands.DisguisePlayerCommand;
|
||||||
import me.libraryaddict.disguise.commands.DisguiseRadiusCommand;
|
import me.libraryaddict.disguise.commands.DisguiseRadiusCommand;
|
||||||
import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand;
|
import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand;
|
||||||
@ -35,8 +39,8 @@ import me.libraryaddict.disguise.commands.UndisguiseEntityCommand;
|
|||||||
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
|
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
|
||||||
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
|
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||||
@ -116,6 +120,10 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
registerCommand("disguiseclone", new DisguiseCloneCommand());
|
registerCommand("disguiseclone", new DisguiseCloneCommand());
|
||||||
registerCommand("libsdisguises", new LibsDisguisesCommand());
|
registerCommand("libsdisguises", new LibsDisguisesCommand());
|
||||||
registerCommand("disguiseviewself", new DisguiseViewSelfCommand());
|
registerCommand("disguiseviewself", new DisguiseViewSelfCommand());
|
||||||
|
registerCommand("disguisemodify", new DisguiseModifyCommand());
|
||||||
|
registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand());
|
||||||
|
registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand());
|
||||||
|
registerCommand("disguisemodifyradius", new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this);
|
||||||
|
@ -66,7 +66,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
return newArgs.toArray(new String[0]);
|
return newArgs.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermNode() {
|
public final String getPermNode() {
|
||||||
if (this instanceof DisguiseCommand) {
|
if (this instanceof DisguiseCommand) {
|
||||||
return "disguise";
|
return "disguise";
|
||||||
}
|
}
|
||||||
@ -79,8 +79,21 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
else if (this instanceof DisguiseRadiusCommand) {
|
else if (this instanceof DisguiseRadiusCommand) {
|
||||||
return "disguiseradius";
|
return "disguiseradius";
|
||||||
}
|
}
|
||||||
else
|
else if (this instanceof DisguiseModifyCommand) {
|
||||||
|
return "disguisemodify";
|
||||||
|
}
|
||||||
|
else if (this instanceof DisguiseModifyEntityCommand) {
|
||||||
|
return "disguisemodifyentity";
|
||||||
|
}
|
||||||
|
else if (this instanceof DisguiseModifyPlayerCommand) {
|
||||||
|
return "disguisemodifyplayer";
|
||||||
|
}
|
||||||
|
else if (this instanceof DisguiseModifyRadiusCommand) {
|
||||||
|
return "disguisemodifyradius";
|
||||||
|
}
|
||||||
|
else {
|
||||||
throw new UnsupportedOperationException("Unknown disguise command, perm node not found");
|
throw new UnsupportedOperationException("Unknown disguise command, perm node not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) {
|
protected HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) {
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
@ -27,7 +28,7 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
|||||||
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (!(sender instanceof Entity)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,16 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
|||||||
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getPermissions(sender).isEmpty()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sendCommandUsage(sender, getPermissions(sender));
|
sendCommandUsage(sender, getPermissions(sender));
|
||||||
return true;
|
return true;
|
||||||
@ -56,7 +61,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
|
|
||||||
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
|
sender.sendMessage(ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
|
||||||
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -64,6 +69,11 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
@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<String>();
|
ArrayList<String> tabs = new ArrayList<String>();
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return tabs;
|
||||||
|
}
|
||||||
|
|
||||||
String[] args = getArgs(origArgs);
|
String[] args = getArgs(origArgs);
|
||||||
|
|
||||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender);
|
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender);
|
||||||
|
@ -690,8 +690,16 @@ public class DisguiseParser {
|
|||||||
// Copy strings to their new range
|
// Copy strings to their new range
|
||||||
String[] newArgs = new String[args.length - toSkip];
|
String[] newArgs = new String[args.length - toSkip];
|
||||||
System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip);
|
System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip);
|
||||||
args = newArgs;
|
|
||||||
|
|
||||||
|
callMethods(sender, disguise, optionPermissions, usedOptions, newArgs);
|
||||||
|
|
||||||
|
// Alright. We've constructed our disguise.
|
||||||
|
return disguise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void callMethods(CommandSender sender, Disguise disguise, HashMap<ArrayList<String>, Boolean> optionPermissions,
|
||||||
|
ArrayList<String> usedOptions, String[] args)
|
||||||
|
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, DisguiseParseException {
|
||||||
Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
|
Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass());
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i += 2) {
|
for (int i = 0; i < args.length; i += 2) {
|
||||||
@ -970,8 +978,6 @@ public class DisguiseParser {
|
|||||||
methodToUse.invoke(disguise, value);
|
methodToUse.invoke(disguise, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Alright. We've constructed our disguise.
|
|
||||||
return disguise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, String methodName) {
|
private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, String methodName) {
|
||||||
|
Loading…
Reference in New Issue
Block a user