From 39d01c1beafef95297662e79abff92165ca05259 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 28 May 2014 12:09:16 +1200 Subject: [PATCH] Use Collection with no or so that you can feed either in as a parameter --- .../libraryaddict/disguise/DisguiseAPI.java | 31 +++++++++++++++---- .../disguisetypes/TargetedDisguise.java | 1 - .../disguise/utilities/ClassGetter.java | 1 - 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index d61cbc6a..6703d986 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -51,17 +52,26 @@ public class DisguiseAPI { DisguiseUtilities.setupFakeDisguise(disguise); } - public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) { + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) { if (disguise.getEntity() != null) { disguise = disguise.clone(); } ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); - for (String name : playersToNotSeeDisguise) { - ((TargetedDisguise) disguise).addPlayer(name); + for (Object obj : playersToNotSeeDisguise) { + if (obj instanceof String) { + ((TargetedDisguise) disguise).addPlayer((String) obj); + } else if (obj instanceof Player) { + ((TargetedDisguise) disguise).addPlayer(((Player) obj).getName()); + } } disguiseEntity(entity, disguise); } + @Deprecated + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) { + disguiseIgnorePlayers(entity, disguise, playersToNotSeeDisguise); + } + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) { ArrayList names = new ArrayList(); for (Player p : playersToNotSeeDisguise) { @@ -109,17 +119,26 @@ public class DisguiseAPI { disguiseEntity(entity, disguise); } - public static void disguiseToPlayers(Entity entity, Disguise disguise, List playersToViewDisguise) { + public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise) { if (disguise.getEntity() != null) { disguise = disguise.clone(); } ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS); - for (String name : playersToViewDisguise) { - ((TargetedDisguise) disguise).addPlayer(name); + for (Object obj : playersToViewDisguise) { + if (obj instanceof String) { + ((TargetedDisguise) disguise).addPlayer((String) obj); + } else if (obj instanceof Player) { + ((TargetedDisguise) disguise).addPlayer(((Player) obj).getName()); + } } disguiseEntity(entity, disguise); } + @Deprecated + public static void disguiseToPlayers(Entity entity, Disguise disguise, List playersToViewDisguise) { + disguiseToPlayers(entity, disguise, playersToViewDisguise); + } + public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) { ArrayList names = new ArrayList(); for (Player p : playersToViewDisguise) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java index bb912ff7..dfc9fe79 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java @@ -15,7 +15,6 @@ public abstract class TargetedDisguise extends Disguise { } private List disguiseViewers = new ArrayList(); - private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; public void addPlayer(Player player) { diff --git a/src/me/libraryaddict/disguise/utilities/ClassGetter.java b/src/me/libraryaddict/disguise/utilities/ClassGetter.java index cc932613..3990089c 100644 --- a/src/me/libraryaddict/disguise/utilities/ClassGetter.java +++ b/src/me/libraryaddict/disguise/utilities/ClassGetter.java @@ -2,7 +2,6 @@ package me.libraryaddict.disguise.utilities; import org.bukkit.entity.Entity; -import java.io.IOException; import java.net.URL; import java.net.URLDecoder; import java.security.CodeSource;