added getAddress interface for Player

By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-10 17:24:35 -05:00
parent 6f77375dc5
commit f3d9273819
2 changed files with 18 additions and 3 deletions

View File

@ -183,7 +183,8 @@ public enum Material {
GreenRecord(2257);
private final int id;
private static final Map<Integer, Material> lookup = new HashMap<Integer, Material>();
private static final Map<Integer, Material> lookupId = new HashMap<Integer, Material>();
private static final Map<String, Material> lookupName = new HashMap<String, Material>();
private Material(final int id) {
this.id = id;
@ -194,12 +195,18 @@ public enum Material {
}
public static Material getMaterial(final int id) {
return lookup.get(id);
return lookupId.get(id);
}
public static Material getMaterial(final String name) {
return lookupName.get(name);
}
static {
for (Material material : values()) {
lookup.put(material.getID(), material);
lookupId.put(material.getID(), material);
lookupName.put(material.name(), material);
}
}
}

View File

@ -1,6 +1,8 @@
package org.bukkit;
import java.net.InetSocketAddress;
/**
* Represents a player, connected or not
*
@ -19,4 +21,10 @@ public interface Player extends HumanEntity {
* @param message Message to be displayed
*/
public void sendMessage(String message);
/**
* Gets the socket address of this player
* @return the player's address
*/
public InetSocketAddress getAddress();
}