mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-11 01:38:07 +02:00
Add dlist and fix dradius error
This commit is contained in:
parent
2af792bbf1
commit
bad4f555cf
@ -53,6 +53,10 @@ commands:
|
||||
aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd]
|
||||
permission: libsdisguises.seecmd.viewself
|
||||
description: Toggle seeing your own disguise on or off.
|
||||
disguiselist:
|
||||
aliases: [dlist]
|
||||
permission: libsdisguises.seecmd.disguiselist
|
||||
description: See a list of who is disguised as what.
|
||||
|
||||
permissions:
|
||||
libsdisguises.reload:
|
||||
@ -77,6 +81,7 @@ permissions:
|
||||
libsdisguises.seecmd.undisguiseradius: true
|
||||
libsdisguises.seecmd.disguiseclone: true
|
||||
libsdisguises.seecmd.disguiseviewself: true
|
||||
libsdisguises.seecmd.disguiselist: true
|
||||
libsdisguises.seecmd.libsdisguises:
|
||||
description: See the /libsdisguises command in tab-completion
|
||||
libsdisguises.seecmd.disguiseviewself:
|
||||
@ -101,3 +106,5 @@ permissions:
|
||||
description: See the /undisguiseradius command in tab-completion
|
||||
libsdisguises.seecmd.disguiseclone:
|
||||
description: See the /disguiseclone command in tab-completion
|
||||
libsdisguises.seecmd.disguiselist:
|
||||
description: See the /disguiselist command in tab-completion
|
||||
|
@ -112,6 +112,7 @@ public class LibsDisguises extends JavaPlugin
|
||||
getCommand("disguiseclone").setExecutor(new CloneDisguiseCommand());
|
||||
getCommand("libsdisguises").setExecutor(new LibsDisguisesCommand());
|
||||
getCommand("disguiseviewself").setExecutor(new DisguiseViewSelf());
|
||||
getCommand("disguiselist").setExecutor(new DisguiseListCommand());
|
||||
|
||||
registerValues();
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DisguiseListCommand implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||
{
|
||||
if (sender.hasPermission("libsdisguises.seecmd.disguiselist"))
|
||||
{
|
||||
String players = "";
|
||||
int numPlayers = 0;
|
||||
int numOther = 0;
|
||||
|
||||
// Go through all disguises
|
||||
for (UUID uuid: DisguiseUtilities.getDisguises().keySet())
|
||||
{
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
TargetedDisguise disguise = DisguiseUtilities.getMainDisguise(uuid);
|
||||
|
||||
if (player == null || !player.isOnline())
|
||||
{
|
||||
// Assume this is a non-player entity
|
||||
numOther++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a player
|
||||
numPlayers++;
|
||||
players += " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + "("
|
||||
+ disguise.getType().toReadable();
|
||||
|
||||
// Special treatment if the disguise is a player
|
||||
if (disguise.getType() == DisguiseType.PLAYER && disguise instanceof PlayerDisguise)
|
||||
players += ":" + ((PlayerDisguise)disguise).getName();
|
||||
|
||||
players += ")";
|
||||
}
|
||||
}
|
||||
|
||||
// Formatting
|
||||
players = "" + ChatColor.AQUA + numPlayers + ChatColor.DARK_AQUA
|
||||
+ " disguised players:" + players;
|
||||
String entities = ChatColor.DARK_AQUA + "Also " + ChatColor.AQUA
|
||||
+ numOther + ChatColor.DARK_AQUA + " other diguised entities.";
|
||||
|
||||
sender.sendMessage(new String[] {players, entities});
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -117,6 +117,11 @@ public class RadiusDisguiseCommand extends BaseDisguiseCommand
|
||||
+ (starting != 0 ? " and EntityType" : ""));
|
||||
return true;
|
||||
}
|
||||
else if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a radius as well as the disguise");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isNumeric(args[starting]))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user