Stupid hashsets and hashmaps and their unability to equalsignorecase on strings
This commit is contained in:
parent
dc6348cf38
commit
01023a29ed
@ -10,7 +10,6 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.commands.*;
|
import me.libraryaddict.disguise.commands.*;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
@ -447,7 +447,7 @@ public abstract class Disguise {
|
|||||||
|
|
||||||
if (isPlayerDisguise()) {
|
if (isPlayerDisguise()) {
|
||||||
String name = ((PlayerDisguise) this).getName();
|
String name = ((PlayerDisguise) this).getName();
|
||||||
if (!DisguiseUtilities.getAddedByPlugins().contains(name)) {
|
if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) {
|
||||||
for (HashSet<TargetedDisguise> disguise : disguises.values()) {
|
for (HashSet<TargetedDisguise> disguise : disguises.values()) {
|
||||||
for (Disguise d : disguise) {
|
for (Disguise d : disguise) {
|
||||||
if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) {
|
if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) {
|
||||||
@ -455,7 +455,7 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DisguiseUtilities.getGameProfiles().remove(name);
|
DisguiseUtilities.getGameProfiles().remove(name.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
public static DisguiseType getType(EntityType entityType) {
|
public static DisguiseType getType(EntityType entityType) {
|
||||||
try {
|
try {
|
||||||
return DisguiseType.valueOf(entityType.name());
|
return valueOf(entityType.name().toUpperCase());
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
public static void addGameProfile(String string, WrappedGameProfile gameProfile) {
|
public static void addGameProfile(String string, WrappedGameProfile gameProfile) {
|
||||||
getGameProfiles().put(string, gameProfile);
|
getGameProfiles().put(string, gameProfile);
|
||||||
addedByPlugins.add(string);
|
getAddedByPlugins().add(string.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,7 +291,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static WrappedGameProfile getGameProfile(String playerName) {
|
public static WrappedGameProfile getGameProfile(String playerName) {
|
||||||
return gameProfiles.get(playerName);
|
return gameProfiles.get(playerName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, WrappedGameProfile> getGameProfiles() {
|
public static HashMap<String, WrappedGameProfile> getGameProfiles() {
|
||||||
@ -335,11 +335,14 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) {
|
public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) {
|
||||||
|
final boolean remove = getAddedByPlugins().contains(disguise.getName().toLowerCase());
|
||||||
return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
|
return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
getAddedByPlugins().remove(disguise.getName());
|
if (remove) {
|
||||||
|
getAddedByPlugins().remove(disguise.getName().toLowerCase());
|
||||||
|
}
|
||||||
if (DisguiseAPI.isDisguiseInUse(disguise)) {
|
if (DisguiseAPI.isDisguiseInUse(disguise)) {
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
|
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
|
||||||
@ -358,8 +361,8 @@ public class DisguiseUtilities {
|
|||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WrappedGameProfile getProfileFromMojang(String name, final Object runnable) {
|
private static WrappedGameProfile getProfileFromMojang(String origName, final Object runnable) {
|
||||||
final String playerName = name.toLowerCase();
|
final String playerName = origName.toLowerCase();
|
||||||
if (gameProfiles.containsKey(playerName)) {
|
if (gameProfiles.containsKey(playerName)) {
|
||||||
if (gameProfiles.get(playerName) != null) {
|
if (gameProfiles.get(playerName) != null) {
|
||||||
return gameProfiles.get(playerName);
|
return gameProfiles.get(playerName);
|
||||||
@ -413,7 +416,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
runnables.get(playerName).add(runnable);
|
runnables.get(playerName).add(runnable);
|
||||||
}
|
}
|
||||||
return ReflectionManager.getGameProfile(null, playerName);
|
return ReflectionManager.getGameProfile(null, origName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -556,11 +559,11 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void removeGameprofile(String string) {
|
public static void removeGameprofile(String string) {
|
||||||
gameProfiles.remove(string);
|
removeGameProfile(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeGameProfile(String string) {
|
public static void removeGameProfile(String string) {
|
||||||
gameProfiles.remove(string);
|
gameProfiles.remove(string.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeSelfDisguise(Player player) {
|
public static void removeSelfDisguise(Player player) {
|
||||||
|
@ -14,6 +14,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
Loading…
Reference in New Issue
Block a user