Sort by name

This commit is contained in:
Andrew 2013-07-12 06:38:38 +12:00
parent 65e42e0132
commit 10595695c6
2 changed files with 32 additions and 35 deletions

View File

@ -6,18 +6,18 @@ import net.minecraft.server.v1_6_R2.IAttribute;
public class Values { public class Values {
private static HashMap<DisguiseType, HashMap<Integer, Object>> metaValues = new HashMap<DisguiseType, HashMap<Integer, Object>>();
private static HashMap<DisguiseType, HashMap<String, Double>> attributesValues = new HashMap<DisguiseType, HashMap<String, Double>>(); private static HashMap<DisguiseType, HashMap<String, Double>> attributesValues = new HashMap<DisguiseType, HashMap<String, Double>>();
private DisguiseType type; private static HashMap<DisguiseType, HashMap<Integer, Object>> metaValues = new HashMap<DisguiseType, HashMap<Integer, Object>>();
public static HashMap<String, Double> getAttributesValues(DisguiseType type) {
public Values(DisguiseType type) { if (type == DisguiseType.DONKEY || type == DisguiseType.MULE || type == DisguiseType.ZOMBIE_HORSE
this.type = type; || type == DisguiseType.SKELETON_HORSE)
metaValues.put(this.type, new HashMap<Integer, Object>()); type = DisguiseType.HORSE;
attributesValues.put(this.type, new HashMap<String, Double>()); if (type == DisguiseType.MINECART_CHEST || type == DisguiseType.MINECART_FURNACE || type == DisguiseType.MINECART_HOPPER
} || type == DisguiseType.MINECART_TNT || type == DisguiseType.MINECART_MOB_SPAWNER)
type = DisguiseType.MINECART_RIDEABLE;
public void setMetaValue(int no, Object value) { if (type == DisguiseType.WITHER_SKELETON)
metaValues.get(type).put(no, value); type = DisguiseType.SKELETON;
return attributesValues.get(type);
} }
public static HashMap<Integer, Object> getMetaValues(DisguiseType type) { public static HashMap<Integer, Object> getMetaValues(DisguiseType type) {
@ -32,19 +32,19 @@ public class Values {
return metaValues.get(type); return metaValues.get(type);
} }
private DisguiseType type;
public Values(DisguiseType type) {
this.type = type;
metaValues.put(this.type, new HashMap<Integer, Object>());
attributesValues.put(this.type, new HashMap<String, Double>());
}
public void setAttributesValue(IAttribute no, Double value) { public void setAttributesValue(IAttribute no, Double value) {
attributesValues.get(type).put(no.a(), value); attributesValues.get(type).put(no.a(), value);
} }
public static HashMap<String, Double> getAttributesValues(DisguiseType type) { public void setMetaValue(int no, Object value) {
if (type == DisguiseType.DONKEY || type == DisguiseType.MULE || type == DisguiseType.ZOMBIE_HORSE metaValues.get(type).put(no, value);
|| type == DisguiseType.SKELETON_HORSE)
type = DisguiseType.HORSE;
if (type == DisguiseType.MINECART_CHEST || type == DisguiseType.MINECART_FURNACE || type == DisguiseType.MINECART_HOPPER
|| type == DisguiseType.MINECART_TNT || type == DisguiseType.MINECART_MOB_SPAWNER)
type = DisguiseType.MINECART_RIDEABLE;
if (type == DisguiseType.WITHER_SKELETON)
type = DisguiseType.SKELETON;
return attributesValues.get(type);
} }
} }

View File

@ -1,9 +1,7 @@
package me.libraryaddict.disguise; package me.libraryaddict.disguise;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -24,7 +22,6 @@ import net.minecraft.server.v1_6_R2.GenericAttributes;
import net.minecraft.server.v1_6_R2.WatchableObject; import net.minecraft.server.v1_6_R2.WatchableObject;
import net.minecraft.server.v1_6_R2.World; import net.minecraft.server.v1_6_R2.World;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld; import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
@ -221,12 +218,11 @@ public class LibsDisguises extends JavaPlugin implements Listener {
registerValues(); registerValues();
} }
private String toReadable(String string) { @EventHandler
String[] strings = string.split("_"); public void onJoin(PlayerJoinEvent event) {
string = ""; Player p = event.getPlayer();
for (String s : strings) if (latestVersion != null && p.hasPermission(permission))
string += s.substring(0, 1) + s.substring(1).toLowerCase(); p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
return string;
} }
private void registerValues() { private void registerValues() {
@ -280,10 +276,11 @@ public class LibsDisguises extends JavaPlugin implements Listener {
} }
} }
@EventHandler private String toReadable(String string) {
public void onJoin(PlayerJoinEvent event) { String[] strings = string.split("_");
Player p = event.getPlayer(); string = "";
if (latestVersion != null && p.hasPermission(permission)) for (String s : strings)
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion)); string += s.substring(0, 1) + s.substring(1).toLowerCase();
return string;
} }
} }