mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-11 01:38:07 +02:00
Changed Disguise/Undisguise player to support UUID's as well, including UUID's of non-players. Changed LibsMsg to reflect this
This commit is contained in:
parent
6dc4f29786
commit
bdad4c3f1d
@ -11,20 +11,17 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
|||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
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.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 java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||||
|
|
||||||
@ -47,7 +44,17 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = Bukkit.getPlayer(args[0]);
|
Entity player = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
if (args[0].contains("-")) {
|
||||||
|
try {
|
||||||
|
player = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||||
|
}
|
||||||
|
catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||||
@ -97,9 +104,13 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
DisguiseAPI.disguiseToAll(player, disguise);
|
DisguiseAPI.disguiseToAll(player, disguise);
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse()) {
|
||||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(player.getName(), disguise.getType().toReadable()));
|
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG
|
||||||
|
.get(player instanceof Player ? player.getName() : DisguiseType.getType(player).toReadable(),
|
||||||
|
disguise.getType().toReadable()));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL.get(player.getName(), disguise.getType().toReadable()));
|
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
||||||
|
.get(player instanceof Player ? player.getName() : DisguiseType.getType(player).toReadable(),
|
||||||
|
disguise.getType().toReadable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
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.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;
|
||||||
|
|
||||||
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) {
|
||||||
@ -52,13 +55,28 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
if (sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
Player p = Bukkit.getPlayer(args[0]);
|
Entity p = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (p == null) {
|
||||||
|
if (p == null) {
|
||||||
|
if (args[0].contains("-")) {
|
||||||
|
try {
|
||||||
|
p = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||||
|
}
|
||||||
|
catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
if (DisguiseAPI.isDisguised(p)) {
|
if (DisguiseAPI.isDisguised(p)) {
|
||||||
DisguiseAPI.undisguiseToAll(p);
|
DisguiseAPI.undisguiseToAll(p);
|
||||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(p.getName()));
|
sender.sendMessage(LibsMsg.UNDISG_PLAYER
|
||||||
|
.get(p instanceof Player ? p.getName() : DisguiseType.getType(p).toReadable()));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(p.getName()));
|
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL
|
||||||
|
.get(p instanceof Player ? p.getName() : DisguiseType.getType(p).toReadable()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||||
|
@ -1317,7 +1317,7 @@ public class DisguiseUtilities {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the player is in a team already
|
// If the player is in a team already and the team isn't one controlled by Lib's Disguises
|
||||||
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName()
|
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName()
|
||||||
.endsWith("_LDP"))) {
|
.endsWith("_LDP"))) {
|
||||||
// If we're creating a scoreboard
|
// If we're creating a scoreboard
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.ChatColor;
|
|||||||
public enum LibsMsg {
|
public enum LibsMsg {
|
||||||
BLOWN_DISGUISE(ChatColor.RED + "Your disguise was blown!"),
|
BLOWN_DISGUISE(ChatColor.RED + "Your disguise was blown!"),
|
||||||
CAN_USE_DISGS(ChatColor.DARK_GREEN + "You can use the disguises: %s"),
|
CAN_USE_DISGS(ChatColor.DARK_GREEN + "You can use the disguises: %s"),
|
||||||
CANNOT_FIND_PLAYER(ChatColor.RED + "Cannot find the player '%s'"),
|
CANNOT_FIND_PLAYER(ChatColor.RED + "Cannot find the player/uuid '%s'"),
|
||||||
CLICK_TIMER(ChatColor.RED + "Right click a entity in the next %s seconds to grab the disguise reference!"),
|
CLICK_TIMER(ChatColor.RED + "Right click a entity in the next %s seconds to grab the disguise reference!"),
|
||||||
CLONE_HELP1(
|
CLONE_HELP1(
|
||||||
ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other disguise commands!"),
|
ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other disguise commands!"),
|
||||||
@ -76,7 +76,7 @@ public enum LibsMsg {
|
|||||||
DMODRADIUS_NOPERM(ChatColor.RED + "No permission to modify %s disguises!"),
|
DMODRADIUS_NOPERM(ChatColor.RED + "No permission to modify %s disguises!"),
|
||||||
DMODRADIUS_UNRECOGNIZED(ChatColor.RED + "Unrecognised DisguiseType %s"),
|
DMODRADIUS_UNRECOGNIZED(ChatColor.RED + "Unrecognised DisguiseType %s"),
|
||||||
DMODRADIUS_USABLE(ChatColor.DARK_GREEN + "DisguiseTypes usable are: %s" + ChatColor.DARK_GREEN + "."),
|
DMODRADIUS_USABLE(ChatColor.DARK_GREEN + "DisguiseTypes usable are: %s" + ChatColor.DARK_GREEN + "."),
|
||||||
DPLAYER_SUPPLY(ChatColor.RED + "You need to supply a disguise as well as the player"),
|
DPLAYER_SUPPLY(ChatColor.RED + "You need to supply a disguise as well as the player/uuid"),
|
||||||
DRADIUS_ENTITIES(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"),
|
DRADIUS_ENTITIES(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"),
|
||||||
DRADIUS_HELP1(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"),
|
DRADIUS_HELP1(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"),
|
||||||
DRADIUS_HELP3(
|
DRADIUS_HELP3(
|
||||||
|
Loading…
Reference in New Issue
Block a user