diff --git a/pom.xml b/pom.xml
index 8aa0f9e..8ede3ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
net.md-5
iTag
- 1.1.0-SNAPSHOT
+ 1.1.2-SNAPSHOT
jar
iTag
@@ -41,8 +41,9 @@
com.comphenix.protocol
ProtocolLib
- 3.6.3-SNAPSHOT
- compile
+ 3.6.5-SNAPSHOT
+ system
+ D:/civcraftsvn/trunk/lib/ProtocolLib.jar
org.bukkit
diff --git a/src/main/java/net/md_5/itag/iTag.java b/src/main/java/net/md_5/itag/iTag.java
index 2afb41b..1c25235 100644
--- a/src/main/java/net/md_5/itag/iTag.java
+++ b/src/main/java/net/md_5/itag/iTag.java
@@ -8,13 +8,17 @@
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.google.common.base.Preconditions;
+
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+
import lombok.Getter;
+
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -27,9 +31,8 @@
public class iTag extends JavaPlugin implements Listener
{
-
@Getter
- private static iTag instance;
+ public static iTag instance;
private TagAPI tagAPI;
private Map entityIdMap;
private static final int[] uuidSplit = new int[]
@@ -42,7 +45,7 @@ public void onEnable()
{
instance = this;
entityIdMap = new HashMap();
- tagAPI = new TagAPI( this );
+ setTagAPI(new TagAPI( this ));
for ( Player player : getServer().getOnlinePlayers() )
{
@@ -101,7 +104,7 @@ public void onDisable()
entityIdMap.clear();
entityIdMap = null;
- tagAPI = null;
+ setTagAPI(null);
instance = null;
}
@@ -132,10 +135,9 @@ private WrappedGameProfile getSentName(int sentEntityId, WrappedGameProfile sent
}
AsyncPlayerReceiveNameTagEvent newEvent = new AsyncPlayerReceiveNameTagEvent( destinationPlayer, namedPlayer, oldEvent.getTag(), UUID.fromString( builtUUID.toString() ) );
getServer().getPluginManager().callEvent( newEvent );
-
WrappedGameProfile newProfile = new WrappedGameProfile( newEvent.getUUID(), newEvent.getTag().substring( 0, Math.min( newEvent.getTag().length(), 16 ) ) );
if (sent.getProperties().containsKey("textures"))
- newProfile.getProperties().putAll("textures", sent.getProperties().get("textures"));
+ newProfile.getProperties().putAll("textures", sent.getProperties().get("textures"));
return newProfile;
}
@@ -168,6 +170,19 @@ public void run()
}, 2 );
}
}
+
+ public void refreshPlayer(Player player, Collection extends Player> forWhom)
+ {
+ Preconditions.checkState( isEnabled(), "Not Enabled!" );
+ Preconditions.checkNotNull( player, "player" );
+ Preconditions.checkNotNull( forWhom, "forWhom" );
+
+ for ( Player playerFor : forWhom )
+ {
+ refreshPlayer( player, playerFor );
+ refreshPlayer( playerFor, player );
+ }
+ }
public void refreshPlayer(Player player, Set forWhom)
{
@@ -178,6 +193,15 @@ public void refreshPlayer(Player player, Set forWhom)
for ( Player playerFor : forWhom )
{
refreshPlayer( player, playerFor );
+ refreshPlayer( playerFor, player );
}
}
-}
+
+ public TagAPI getTagAPI() {
+ return tagAPI;
+ }
+
+ public void setTagAPI(TagAPI tagAPI) {
+ this.tagAPI = tagAPI;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/kitteh/tag/AsyncPlayerReceiveNameTagEvent.java b/src/main/java/org/kitteh/tag/AsyncPlayerReceiveNameTagEvent.java
index b7526f2..2455974 100644
--- a/src/main/java/org/kitteh/tag/AsyncPlayerReceiveNameTagEvent.java
+++ b/src/main/java/org/kitteh/tag/AsyncPlayerReceiveNameTagEvent.java
@@ -38,6 +38,20 @@ public AsyncPlayerReceiveNameTagEvent(Player who, Player namedPlayer, String ini
this.tagModified = namedPlayer.getName().equals( initialName );
this.UUID = uuid;
}
+
+ public Player getPlayer() {
+
+ Preconditions.checkNotNull( this.player, "player" );
+ return this.player;
+
+ }
+
+ public Player getNamedPlayer() {
+
+ Preconditions.checkNotNull( this.namedPlayer, "namedPlayer" );
+ return this.namedPlayer;
+
+ }
public boolean setTag(String tag)
{
@@ -48,6 +62,19 @@ public boolean setTag(String tag)
return tag.length() < 16;
}
+
+ public String getTag() {
+
+ Preconditions.checkNotNull( this.tag, "tag" );
+ return this.tag;
+ }
+
+ public UUID getUUID()
+ {
+ Preconditions.checkNotNull( this.UUID, "uuid" );
+
+ return this.UUID;
+ }
public void setUUID(UUID uuid)
{
diff --git a/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java b/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
index 0d7834a..49c622d 100644
--- a/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
+++ b/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
@@ -1,7 +1,9 @@
package org.kitteh.tag;
import com.google.common.base.Preconditions;
+
import lombok.Getter;
+
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
@@ -38,6 +40,12 @@ public boolean setTag(String tag)
return tag.length() < 16;
}
+
+ public String getTag() {
+
+ Preconditions.checkNotNull( this.tag, "tag" );
+ return this.tag;
+ }
@Override
public HandlerList getHandlers()
diff --git a/src/main/java/org/kitteh/tag/TagAPI.java b/src/main/java/org/kitteh/tag/TagAPI.java
index 4c34c26..f515e70 100644
--- a/src/main/java/org/kitteh/tag/TagAPI.java
+++ b/src/main/java/org/kitteh/tag/TagAPI.java
@@ -1,22 +1,32 @@
package org.kitteh.tag;
+import com.avaje.ebean.EbeanServer;
import com.google.common.base.Throwables;
+
import java.io.File;
+import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
-import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
import java.util.regex.Pattern;
+
import lombok.Delegate;
import lombok.Getter;
import net.md_5.itag.iTag;
+
+import org.bukkit.Server;
+import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
+import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.InvalidDescriptionException;
import org.bukkit.plugin.InvalidPluginException;
import org.bukkit.plugin.Plugin;
@@ -24,7 +34,6 @@
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.RegisteredListener;
-import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.plugin.UnknownDependencyException;
public class TagAPI extends PluginBase implements PluginLoader
@@ -71,15 +80,15 @@ private interface Excludes
private final iTag parent;
@Getter
private PluginDescriptionFile description;
- private List plugins;
- private Map lookupNames;
+// private List plugins;
+// private Map lookupNames;
public TagAPI(iTag parent)
{
this.parent = parent;
- plugins = (List) getObj( SimplePluginManager.class, parent.getServer().getPluginManager(), "plugins" );
- lookupNames = (Map) getObj( SimplePluginManager.class, parent.getServer().getPluginManager(), "lookupNames" );
+// plugins = (List) getObj( SimplePluginManager.class, parent.getServer().getPluginManager(), "plugins" );
+// lookupNames = (Map) getObj( SimplePluginManager.class, parent.getServer().getPluginManager(), "lookupNames" );
StringWriter write = new StringWriter();
parent.getDescription().save( write );
@@ -93,8 +102,8 @@ public TagAPI(iTag parent)
throw Throwables.propagate( ex );
}
- plugins.add( this );
- lookupNames.put( getName(), this );
+// plugins.add( this );
+// lookupNames.put( getName(), this );
}
public PluginLoader getPluginLoader()
@@ -104,44 +113,146 @@ public PluginLoader getPluginLoader()
public void disablePlugin(Plugin plugin)
{
- plugins.remove( plugin );
- lookupNames.remove( plugin.getName() );
+// plugins.remove( plugin );
+// lookupNames.remove( plugin.getName() );
}
- private static Object getObj(Class> clazz, Object owner, String name)
- {
- try
- {
- Field field = clazz.getDeclaredField( name );
- field.setAccessible( true );
- return field.get( owner );
- } catch ( Exception ex )
- {
- throw Throwables.propagate( ex );
- }
- }
+// private static Object getObj(Class> clazz, Object owner, String name)
+// {
+// try
+// {
+// Field field = clazz.getDeclaredField( name );
+// field.setAccessible( true );
+// return field.get( owner );
+// } catch ( Exception ex )
+// {
+// throw Throwables.propagate( ex );
+// }
+// }
- public static void refreshPlayer(Player player)
+ public void refreshPlayer(Player player)
{
- if ( iTag.getInstance() != null )
+ if ( parent != null )
{
- iTag.getInstance().refreshPlayer( player );
+ parent.refreshPlayer( player );
}
}
- public static void refreshPlayer(Player player, Player forWhom)
+ public void refreshPlayer(Player player, Player forWhom)
{
- if ( iTag.getInstance() != null )
+ if ( parent != null )
{
- iTag.getInstance().refreshPlayer( player, forWhom );
+ parent.refreshPlayer( player, forWhom );
}
}
- public static void refreshPlayer(Player player, Set forWhom)
+ public void refreshPlayer(Player player, Set forWhom)
{
- if ( iTag.getInstance() != null )
+ if ( parent != null )
{
- iTag.getInstance().refreshPlayer( player, forWhom );
+ parent.refreshPlayer( player, forWhom );
}
}
+
+ public FileConfiguration getConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public File getDataFolder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public EbeanServer getDatabase() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ChunkGenerator getDefaultWorldGenerator(String arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PluginDescriptionFile getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Logger getLogger() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public InputStream getResource(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Server getServer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isEnabled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isNaggable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void onDisable() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onEnable() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onLoad() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void reloadConfig() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void saveConfig() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void saveDefaultConfig() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void saveResource(String arg0, boolean arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setNaggable(boolean arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List onTabComplete(CommandSender arg0, Command arg1,
+ String arg2, String[] arg3) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean onCommand(CommandSender arg0, Command arg1, String arg2,
+ String[] arg3) {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 8d406c5..476a125 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: iTag
-version: 1.1.0
+version: 1.1.2
description: Name tag API which is backwards compatible with TagAPI
author: md_5