Stupid hashsets and hashmaps and their unability to equalsignorecase on strings

This commit is contained in:
libraryaddict
2014-06-21 02:12:32 +12:00
parent dc6348cf38
commit 01023a29ed
5 changed files with 16 additions and 13 deletions

View File

@@ -121,7 +121,7 @@ public class DisguiseUtilities {
public static void addGameProfile(String string, WrappedGameProfile 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) {
return gameProfiles.get(playerName);
return gameProfiles.get(playerName.toLowerCase());
}
public static HashMap<String, WrappedGameProfile> getGameProfiles() {
@@ -335,11 +335,14 @@ public class DisguiseUtilities {
}
public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) {
final boolean remove = getAddedByPlugins().contains(disguise.getName().toLowerCase());
return getProfileFromMojang(disguise.getName(), new LibsProfileLookup() {
@Override
public void onLookup(WrappedGameProfile gameProfile) {
getAddedByPlugins().remove(disguise.getName());
if (remove) {
getAddedByPlugins().remove(disguise.getName().toLowerCase());
}
if (DisguiseAPI.isDisguiseInUse(disguise)) {
DisguiseUtilities.refreshTrackers(disguise);
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
@@ -358,8 +361,8 @@ public class DisguiseUtilities {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
}
private static WrappedGameProfile getProfileFromMojang(String name, final Object runnable) {
final String playerName = name.toLowerCase();
private static WrappedGameProfile getProfileFromMojang(String origName, final Object runnable) {
final String playerName = origName.toLowerCase();
if (gameProfiles.containsKey(playerName)) {
if (gameProfiles.get(playerName) != null) {
return gameProfiles.get(playerName);
@@ -413,7 +416,7 @@ public class DisguiseUtilities {
}
runnables.get(playerName).add(runnable);
}
return ReflectionManager.getGameProfile(null, playerName);
return ReflectionManager.getGameProfile(null, origName);
}
/**
@@ -556,11 +559,11 @@ public class DisguiseUtilities {
@Deprecated
public static void removeGameprofile(String string) {
gameProfiles.remove(string);
removeGameProfile(string);
}
public static void removeGameProfile(String string) {
gameProfiles.remove(string);
gameProfiles.remove(string.toLowerCase());
}
public static void removeSelfDisguise(Player player) {

View File

@@ -14,6 +14,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.collect.ImmutableMap;
import org.bukkit.Art;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -85,7 +86,7 @@ public class ReflectionManager {
private static final Field pingField;
private static Map<Class<?>, String> primitiveTypes;
private static final Field trackerField;
/*
* This portion of code is originally Copyright (C) 2014-2014 Kane York.
*