Remove TagAPI patches.

This commit is contained in:
md_5 2013-02-22 19:30:23 +11:00
parent d08be2dbc9
commit 125729df15
4 changed files with 3 additions and 229 deletions

View File

@ -1,25 +0,0 @@
From db9d11eeb2b1c429c6ba281d8f2ffabf3e3c5721 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Wed, 20 Feb 2013 20:16:40 +1100
Subject: [PATCH] TagAPI
---
src/main/java/org/bukkit/plugin/SimplePluginManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 4049d3a..9560cec 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -354,7 +354,7 @@ public final class SimplePluginManager implements PluginManager {
public boolean isPluginEnabled(String name) {
Plugin plugin = getPlugin(name);
- return isPluginEnabled(plugin);
+ return name.equals("TagAPI") || isPluginEnabled(plugin);
}
/**
--
1.8.1-rc2

View File

@ -1,201 +0,0 @@
From b46a1d3cb2371706ba49c9cf6c1b8919dc6edaa8 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 19 Feb 2013 18:30:10 +1100
Subject: [PATCH] Implement TagAPI into Spigot - much more efficient and only a
dozen lines of code.
---
.../net/minecraft/server/EntityTrackerEntry.java | 12 +++-
.../java/net/minecraft/server/MinecraftServer.java | 1 +
.../org/kitteh/tag/PlayerReceiveNameTagEvent.java | 49 +++++++++++++++
src/main/java/org/kitteh/tag/TagAPI.java | 73 ++++++++++++++++++++++
4 files changed, 132 insertions(+), 3 deletions(-)
create mode 100644 src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
create mode 100644 src/main/java/org/kitteh/tag/TagAPI.java
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 27a548f..d95d5af 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -301,7 +301,7 @@ public class EntityTrackerEntry {
// CraftBukkit end
this.trackedPlayers.add(entityplayer);
- Packet packet = this.b();
+ Packet packet = this.b(entityplayer); // Spigot
entityplayer.playerConnection.sendPacket(packet);
if (!this.tracker.getDataWatcher().d()) {
@@ -370,7 +370,7 @@ public class EntityTrackerEntry {
}
}
- private Packet b() {
+ private Packet b(EntityPlayer target) { // Spigot
if (this.tracker.dead) {
// CraftBukkit start - remove useless error spam, just return
// System.out.println("Fetching addPacket for removed entity");
@@ -381,7 +381,13 @@ public class EntityTrackerEntry {
if (this.tracker instanceof EntityItem) {
return new Packet23VehicleSpawn(this.tracker, 2, 1);
} else if (this.tracker instanceof EntityPlayer) {
- return new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
+ // Spigot start
+ Packet20NamedEntitySpawn packet = new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
+ org.kitteh.tag.PlayerReceiveNameTagEvent event = new org.kitteh.tag.PlayerReceiveNameTagEvent(target.getBukkitEntity(), ((EntityPlayer) tracker).getBukkitEntity());
+ tracker.world.getServer().getPluginManager().callEvent(event);
+ packet.b = event.getTag();
+ return packet;
+ // Spigot end
} else {
if (this.tracker instanceof EntityMinecart) {
EntityMinecart entityminecart = (EntityMinecart) this.tracker;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 99a6cf4..69564cd 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -512,6 +512,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.methodProfiler.b();
this.methodProfiler.b();
+ org.kitteh.tag.TagAPI.tick(); // Spigot
}
public void r() {
diff --git a/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java b/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
new file mode 100644
index 0000000..2ea9e07
--- /dev/null
+++ b/src/main/java/org/kitteh/tag/PlayerReceiveNameTagEvent.java
@@ -0,0 +1,49 @@
+package org.kitteh.tag;
+
+import org.apache.commons.lang.Validate;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+
+public class PlayerReceiveNameTagEvent extends PlayerEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+ private boolean modified;
+ private final Player named;
+ private String tag;
+
+ public PlayerReceiveNameTagEvent(Player who, Player named) {
+ super(who);
+ this.modified = false;
+ this.named = named;
+ this.tag = named.getName();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ public Player getNamedPlayer() {
+ return named;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public boolean isModified() {
+ return modified;
+ }
+
+ public boolean setTag(String newTag) {
+ Validate.notNull(newTag, "New nametag cannot be null!");
+ tag = newTag;
+ modified = true;
+ return (newTag.length() < 16) ? true : false;
+ }
+}
diff --git a/src/main/java/org/kitteh/tag/TagAPI.java b/src/main/java/org/kitteh/tag/TagAPI.java
new file mode 100644
index 0000000..1e2693c
--- /dev/null
+++ b/src/main/java/org/kitteh/tag/TagAPI.java
@@ -0,0 +1,73 @@
+package org.kitteh.tag;
+
+import com.google.common.base.Preconditions;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import org.bukkit.entity.Player;
+
+public class TagAPI {
+
+ private static Set<DelayedShowTask> tasks = new HashSet<DelayedShowTask>();
+
+ private static class DelayedShowTask {
+
+ private final Map<Player, Player> pairs = new HashMap<Player, Player>();
+ private int countdown = 2;
+ }
+
+ public static void tick() {
+ for (Iterator<DelayedShowTask> iter = tasks.iterator(); iter.hasNext();) {
+ DelayedShowTask task = iter.next();
+ if (--task.countdown == 0) {
+ iter.remove();
+ for (Map.Entry<Player, Player> pair : task.pairs.entrySet()) {
+ if (pair.getKey() != null && pair.getValue() != null) {
+ pair.getValue().showPlayer(pair.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ public static void refreshPlayer(Player player) {
+ Preconditions.checkArgument(player != null, "player");
+ Preconditions.checkArgument(player.isOnline(), "offline");
+
+ DelayedShowTask task = new DelayedShowTask();
+ for (Player otherGuy : player.getWorld().getPlayers()) {
+ if (player != otherGuy && otherGuy.canSee(player)) {
+ otherGuy.hidePlayer(player);
+ task.pairs.put(otherGuy, player);
+ }
+ }
+
+ tasks.add(task);
+ }
+
+ public static void refreshPlayer(Player player, Player forWhom) {
+ Preconditions.checkArgument(player != null, "player");
+ Preconditions.checkArgument(forWhom != null, "forWhom");
+ Preconditions.checkArgument(player != forWhom, "self");
+ DelayedShowTask task = new DelayedShowTask();
+
+ if (forWhom.canSee(player) && player.getWorld() == forWhom.getWorld()) {
+ forWhom.hidePlayer(player);
+ task.pairs.put(forWhom, player);
+ }
+
+ tasks.add(task);
+ }
+
+ public static void refreshPlayer(Player player, Set<Player> forWhom) {
+ Preconditions.checkArgument(player != null, "player");
+ Preconditions.checkArgument(forWhom != null, "forWhom");
+ for (Player whom : forWhom) {
+ if (player != whom) {
+ refreshPlayer(player, whom);
+ }
+ }
+ }
+}
--
1.8.1-rc2

View File

@ -1,4 +1,4 @@
From 4217d76754fcff68bd39d9d70625b8df90a5df09 Mon Sep 17 00:00:00 2001
From 67f4933a29bc5317157dbb033c8400ca26df6909 Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 20 Feb 2013 23:07:53 -0500
Subject: [PATCH] Optimize getTileEntities performance

View File

@ -1,4 +1,4 @@
From 18c3488b099973cb0c3b6acefe23baecf4acf9bd Mon Sep 17 00:00:00 2001
From 58eaa4790c1875741e06017f81a32801cfc3f4ad Mon Sep 17 00:00:00 2001
From: shakytom <tom.roberts00@gmail.com>
Date: Wed, 20 Feb 2013 22:34:38 -0500
Subject: [PATCH] Improved tile entity lookup for chunk sending
@ -26,5 +26,5 @@ index 8d61ca6..28f462b 100644
}
--
1.8.1.1
1.8.1-rc2