Try new way of handling maps in frames

This commit is contained in:
Aikar 2013-02-24 13:37:20 +11:00 committed by md_5
parent 1bd64e3e7a
commit 8237774639
7 changed files with 111 additions and 86 deletions

View File

@ -0,0 +1,89 @@
From d2a991ef24ccf92299160afc6a56128eed966733 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 19 Feb 2013 17:26:20 -0500
Subject: [PATCH] Only send maps in item frames upon tracking
Maps in item frames are full of bugs.
1) It sends an update of the Maps data to ALL players in the world, not just the players tracking it.
2) It sends an update EVERY tick, not every 10 ticks as intended.
To optimize performance of maps in item frames, we will only send it once a player tracks the ItemFrame until it completes, then that player will not receive more updates.
This means cursors will not dynamically update, but the map data should refresh every time the player moves away then back.
---
.../net/minecraft/server/EntityTrackerEntry.java | 25 ++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index a026c4c..75c146d 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -36,6 +36,7 @@ public class EntityTrackerEntry {
public boolean n = false;
public Set trackedPlayers = new HashSet();
+ public List<EntityPlayer> playersToUpdate = new java.util.ArrayList<EntityPlayer>(); // Spigot
public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) {
this.tracker = entity;
this.b = i;
@@ -73,17 +74,17 @@ public class EntityTrackerEntry {
this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
}
- if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) {
+ if (this.tracker instanceof EntityItemFrame) { // Spigot - has to be ran every tick for general frames or they may pop off?
EntityItemFrame i4 = (EntityItemFrame) this.tracker;
ItemStack i5 = i4.i();
- if (i5 != null && i5.getItem() instanceof ItemWorldMap) {
+ if (this.m++ % 10 == 0 && i5 != null && i5.getItem() instanceof ItemWorldMap && playersToUpdate.size() > 0) { // Spigot
WorldMap i7 = Item.MAP.getSavedMap(i5, this.tracker.world);
- Iterator j0 = list.iterator();
+ Iterator j0 = playersToUpdate.iterator(); // Spigot
while (j0.hasNext()) {
- EntityHuman j1 = (EntityHuman) j0.next();
- EntityPlayer j2 = (EntityPlayer) j1;
+ //EntityHuman j1 = (EntityHuman) j0.next(); // Spigot - unused
+ EntityPlayer j2 = (EntityPlayer) j0.next(); // Spigot
i7.a(j2, i5);
if (j2.playerConnection.lowPriorityCount() <= 5) {
@@ -91,7 +92,7 @@ public class EntityTrackerEntry {
if (j3 != null) {
j2.playerConnection.sendPacket(j3);
- }
+ } else { j0.remove(); } // Spigot
}
}
}
@@ -329,6 +330,17 @@ public class EntityTrackerEntry {
}
}
+ // Spigot start - add player to list to receive initial map updates.
+ if (this.tracker instanceof EntityItemFrame) {
+ EntityItemFrame i4 = (EntityItemFrame) this.tracker;
+ ItemStack i5 = i4.i();
+
+ if (i5 != null && i5.getItem() instanceof ItemWorldMap) {
+ this.playersToUpdate.add(entityplayer);
+ }
+ }
+ // Spigot end
+
if (this.tracker instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) this.tracker;
@@ -355,6 +367,7 @@ public class EntityTrackerEntry {
}
} else if (this.trackedPlayers.contains(entityplayer)) {
this.trackedPlayers.remove(entityplayer);
+ this.playersToUpdate.remove(entityplayer); // Spigot
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
}
}
--
1.8.1-rc2

View File

@ -1,64 +0,0 @@
From 2a34593e2cd2cff381e8d6d6e1a1427221cd24c4 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 2 Feb 2013 19:40:53 +1100
Subject: [PATCH] Send maps a lot less often to combat the lag they cause.
---
src/main/java/net/minecraft/server/EntityTrackerEntry.java | 2 +-
src/main/java/org/bukkit/craftbukkit/CraftServer.java | 1 +
src/main/java/org/bukkit/craftbukkit/Spigot.java | 1 +
src/main/resources/configurations/bukkit.yml | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index a026c4c..27a548f 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -73,7 +73,7 @@ public class EntityTrackerEntry {
this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
}
- if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) {
+ if (this.tracker instanceof EntityItemFrame && this.m % tracker.world.getServer().mapSendInterval == 0) {
EntityItemFrame i4 = (EntityItemFrame) this.tracker;
ItemStack i5 = i4.i();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1a3cc03..6c7fa4f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -179,6 +179,7 @@ public final class CraftServer implements Server {
public boolean ipFilter = false;
public boolean commandComplete = true;
public List<String> spamGuardExclusions;
+ public int mapSendInterval = 10000;
// Spigot end
static {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 3bfeb49..5827820 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -12,6 +12,7 @@ public class Spigot {
server.ipFilter = configuration.getBoolean("settings.filter-unsafe-ips", false);
server.commandComplete = configuration.getBoolean("settings.command-complete", true);
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
+ server.mapSendInterval = configuration.getInt("settings.map-send-interval", server.mapSendInterval);
server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 78e9a66..548f7c1 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -31,6 +31,7 @@ settings:
command-complete: true
spam-exclusions:
- /skill
+ map-send-interval: 10000
world-settings:
default:
growth-chunks-per-tick: 650
--
1.8.1-rc2

View File

@ -1,4 +1,4 @@
From 4cbd04e5c966b8ac72ca363ddb9f5c21307ffc0d Mon Sep 17 00:00:00 2001 From 45fe88e1961a395c0330f1056ef602444cb963eb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 16 Feb 2013 19:45:09 +1100 Date: Sat, 16 Feb 2013 19:45:09 +1100
Subject: [PATCH] Entity Activation Range# This feature gives 3 new Subject: [PATCH] Entity Activation Range# This feature gives 3 new
@ -123,7 +123,7 @@ index 21bd64a..a083ae4 100644
public Block getBlockAt(int x, int y, int z) { public Block getBlockAt(int x, int y, int z) {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 1ead152..a5b05ed 100644 index ad65bca..bc28d7b 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
@ -137,7 +137,7 @@ index 1ead152..a5b05ed 100644
public class Spigot { public class Spigot {
@@ -27,5 +30,151 @@ public class Spigot { @@ -26,5 +29,151 @@ public class Spigot {
if (server.chunkGCPeriod == 0) { if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!"); server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
} }
@ -309,10 +309,10 @@ index bb0c191..6a4a05e 100644
} }
} }
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 548f7c1..eea3265 100644 index 78e9a66..54e28db 100644
--- a/src/main/resources/configurations/bukkit.yml --- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml
@@ -47,6 +47,9 @@ world-settings: @@ -46,6 +46,9 @@ world-settings:
sugar-growth-modifier: 100 sugar-growth-modifier: 100
tree-growth-modifier: 100 tree-growth-modifier: 100
mushroom-growth-modifier: 100 mushroom-growth-modifier: 100

View File

@ -1,4 +1,4 @@
From fea4d2a2bb5531b602f0026fd9a34524dea9c142 Mon Sep 17 00:00:00 2001 From d8bd72d1293a2c074efa2dc4f5093a3d6f0a8351 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Sat, 16 Feb 2013 19:05:15 +1100 Date: Sat, 16 Feb 2013 19:05:15 +1100
Subject: [PATCH] Infrequently send tab list updates. Subject: [PATCH] Infrequently send tab list updates.
@ -36,7 +36,7 @@ index d13fa19..3fc66aa 100644
public void sendAll(Packet packet) { public void sendAll(Packet packet) {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index a5b05ed..8c67fc3 100644 index bc28d7b..dafbbc7 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -7,6 +7,7 @@ import org.bukkit.configuration.file.YamlConfiguration; @@ -7,6 +7,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
@ -47,7 +47,7 @@ index a5b05ed..8c67fc3 100644
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) { public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps")); commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -31,6 +32,7 @@ public class Spigot { @@ -30,6 +31,7 @@ public class Spigot {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!"); server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
} }
@ -56,13 +56,13 @@ index a5b05ed..8c67fc3 100644
/** /**
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index eea3265..a35f3dd 100644 index 54e28db..26e6566 100644
--- a/src/main/resources/configurations/bukkit.yml --- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml
@@ -32,6 +32,7 @@ settings: @@ -31,6 +31,7 @@ settings:
command-complete: true
spam-exclusions: spam-exclusions:
- /skill - /skill
map-send-interval: 10000
+ tab-ping: false + tab-ping: false
world-settings: world-settings:
default: default:

View File

@ -1,4 +1,4 @@
From 7e2dbccd84dfb0f01457e1ba3f0db86ad86fe2c8 Mon Sep 17 00:00:00 2001 From 2f462a8b4cf8db8ad8b18e93707fafecfe20a1e2 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Sat, 23 Feb 2013 08:58:35 +1100 Date: Sat, 23 Feb 2013 08:58:35 +1100
Subject: [PATCH] Metrics. Rewrite the Metrics system to be closer to the Subject: [PATCH] Metrics. Rewrite the Metrics system to be closer to the
@ -11,7 +11,7 @@ Subject: [PATCH] Metrics. Rewrite the Metrics system to be closer to the
create mode 100644 src/main/java/org/spigotmc/Metrics.java create mode 100644 src/main/java/org/spigotmc/Metrics.java
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 8c67fc3..5729cd6 100644 index dafbbc7..8c3cda5 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,13 +1,19 @@ @@ -1,13 +1,19 @@
@ -34,7 +34,7 @@ index 8c67fc3..5729cd6 100644
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) { public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps")); commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -33,6 +39,15 @@ public class Spigot { @@ -32,6 +38,15 @@ public class Spigot {
} }
tabPing = configuration.getBoolean("settings.tab-ping", tabPing); tabPing = configuration.getBoolean("settings.tab-ping", tabPing);

View File

@ -1,4 +1,4 @@
From 3cf07f7a095e0a3e6f751b7fe275416ed8d6fa9a Mon Sep 17 00:00:00 2001 From cd8026eec14b1b342f20cfad6f6f72cf4ef5d9a3 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Sat, 23 Feb 2013 12:33:20 +1100 Date: Sat, 23 Feb 2013 12:33:20 +1100
Subject: [PATCH] Watchdog Thread. Subject: [PATCH] Watchdog Thread.
@ -33,7 +33,7 @@ index 128016f..3a6b620 100644
this.isStopped = true; this.isStopped = true;
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 5729cd6..68c1b42 100644 index 8c3cda5..5a96c86 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
@ -65,9 +65,9 @@ index 5729cd6..68c1b42 100644
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage); server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage); server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
@@ -26,12 +31,21 @@ public class Spigot { @@ -25,12 +30,21 @@ public class Spigot {
server.commandComplete = configuration.getBoolean("settings.command-complete", true);
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions"); server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
server.mapSendInterval = configuration.getInt("settings.map-send-interval", server.mapSendInterval);
+ int configVersion = configuration.getInt("config-version"); + int configVersion = configuration.getInt("config-version");
+ switch (configVersion) { + switch (configVersion) {
@ -88,7 +88,7 @@ index 5729cd6..68c1b42 100644
} }
if (server.chunkGCPeriod == 0) { if (server.chunkGCPeriod == 0) {
@@ -194,4 +208,63 @@ public class Spigot { @@ -193,4 +207,63 @@ public class Spigot {
return (entity instanceof EntityArrow && !((EntityArrow) entity).inGround); return (entity instanceof EntityArrow && !((EntityArrow) entity).inGround);
} }

View File

@ -1,4 +1,4 @@
From 0afe6bde8bccf04189ddb6775d60bcfa0e3b8025 Mon Sep 17 00:00:00 2001 From 6ef28f7cbf0936ddb73d5ae8fde5e9b043070e74 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Thu, 14 Feb 2013 17:32:20 +1100 Date: Thu, 14 Feb 2013 17:32:20 +1100
Subject: [PATCH] Netty Subject: [PATCH] Netty
@ -222,7 +222,7 @@ index 58d30eb..e4e5049 100644
// CraftBukkit end // CraftBukkit end
this.pendingConnection = pendingconnection; this.pendingConnection = pendingconnection;
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 68c1b42..6c54638 100644 index 5a96c86..eb02e56 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -18,6 +18,8 @@ public class Spigot { @@ -18,6 +18,8 @@ public class Spigot {
@ -234,7 +234,7 @@ index 68c1b42..6c54638 100644
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) { public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps")); commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -54,6 +56,12 @@ public class Spigot { @@ -53,6 +55,12 @@ public class Spigot {
tabPing = configuration.getBoolean("settings.tab-ping", tabPing); tabPing = configuration.getBoolean("settings.tab-ping", tabPing);