Use Collection with no <String> or <Player> so that you can feed either in as a parameter
This commit is contained in:
parent
4e8b0da944
commit
39d01c1bea
@ -3,6 +3,7 @@ package me.libraryaddict.disguise;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -51,17 +52,26 @@ public class DisguiseAPI {
|
|||||||
DisguiseUtilities.setupFakeDisguise(disguise);
|
DisguiseUtilities.setupFakeDisguise(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise) {
|
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) {
|
||||||
if (disguise.getEntity() != null) {
|
if (disguise.getEntity() != null) {
|
||||||
disguise = disguise.clone();
|
disguise = disguise.clone();
|
||||||
}
|
}
|
||||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
|
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||||
for (String name : playersToNotSeeDisguise) {
|
for (Object obj : playersToNotSeeDisguise) {
|
||||||
((TargetedDisguise) disguise).addPlayer(name);
|
if (obj instanceof String) {
|
||||||
|
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||||
|
} else if (obj instanceof Player) {
|
||||||
|
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
disguiseEntity(entity, disguise);
|
disguiseEntity(entity, disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise) {
|
||||||
|
disguiseIgnorePlayers(entity, disguise, playersToNotSeeDisguise);
|
||||||
|
}
|
||||||
|
|
||||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) {
|
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) {
|
||||||
ArrayList<String> names = new ArrayList<String>();
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
for (Player p : playersToNotSeeDisguise) {
|
for (Player p : playersToNotSeeDisguise) {
|
||||||
@ -109,17 +119,26 @@ public class DisguiseAPI {
|
|||||||
disguiseEntity(entity, disguise);
|
disguiseEntity(entity, disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, List<String> playersToViewDisguise) {
|
public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise) {
|
||||||
if (disguise.getEntity() != null) {
|
if (disguise.getEntity() != null) {
|
||||||
disguise = disguise.clone();
|
disguise = disguise.clone();
|
||||||
}
|
}
|
||||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||||
for (String name : playersToViewDisguise) {
|
for (Object obj : playersToViewDisguise) {
|
||||||
((TargetedDisguise) disguise).addPlayer(name);
|
if (obj instanceof String) {
|
||||||
|
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||||
|
} else if (obj instanceof Player) {
|
||||||
|
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
disguiseEntity(entity, disguise);
|
disguiseEntity(entity, disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void disguiseToPlayers(Entity entity, Disguise disguise, List<String> playersToViewDisguise) {
|
||||||
|
disguiseToPlayers(entity, disguise, playersToViewDisguise);
|
||||||
|
}
|
||||||
|
|
||||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) {
|
public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) {
|
||||||
ArrayList<String> names = new ArrayList<String>();
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
for (Player p : playersToViewDisguise) {
|
for (Player p : playersToViewDisguise) {
|
||||||
|
@ -15,7 +15,6 @@ public abstract class TargetedDisguise extends Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<String> disguiseViewers = new ArrayList<String>();
|
private List<String> disguiseViewers = new ArrayList<String>();
|
||||||
|
|
||||||
private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS;
|
private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS;
|
||||||
|
|
||||||
public void addPlayer(Player player) {
|
public void addPlayer(Player player) {
|
||||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
|
Loading…
Reference in New Issue
Block a user