mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-03 01:10:37 +01:00
Move async checks to their own patch so we can add more of them.
This commit is contained in:
parent
a028c277bf
commit
cca2920506
@ -1,6 +1,6 @@
|
||||
From 05108bcbeddcf5681feb3d5f7c986ce738cccbb8 Mon Sep 17 00:00:00 2001
|
||||
From 308eaa2dbd96b59ee9bdc253390679070bfd1533 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Mar 2013 09:39:40 +1100
|
||||
Date: Sat, 23 Mar 2013 17:57:27 +1100
|
||||
Subject: [PATCH] Spigot Changes
|
||||
|
||||
The set of changes which provide core Spigot functionality, which would otherwise be a mess to try and apply individually.
|
||||
@ -28,9 +28,8 @@ The set of changes which provide core Spigot functionality, which would otherwis
|
||||
.../java/org/bukkit/craftbukkit/CraftWorld.java | 68 ++++++++++++-
|
||||
src/main/java/org/bukkit/craftbukkit/Spigot.java | 20 ++++
|
||||
.../craftbukkit/chunkio/ChunkIOProvider.java | 2 +-
|
||||
.../org/bukkit/craftbukkit/entity/CraftPlayer.java | 7 ++
|
||||
src/main/resources/configurations/bukkit.yml | 25 +++++
|
||||
25 files changed, 392 insertions(+), 78 deletions(-)
|
||||
24 files changed, 385 insertions(+), 78 deletions(-)
|
||||
create mode 100644 src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
@ -978,28 +977,6 @@ index 48cf5ba..1d4764c 100644
|
||||
return;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 70111e7..1871d3e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -213,10 +213,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void kickPlayer(String message) {
|
||||
+ // Spigot start
|
||||
+ kickPlayer(message, false);
|
||||
+ }
|
||||
+
|
||||
+ public void kickPlayer(String message, boolean async){
|
||||
if (getHandle().playerConnection == null) return;
|
||||
+ if (!async && !Bukkit.isPrimaryThread()) throw new IllegalStateException("Cannot kick player from asynchronous thread!"); // Spigot
|
||||
|
||||
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
public void setCompassTarget(Location loc) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
|
||||
index 61a95e3..58501ea 100644
|
||||
--- a/src/main/resources/configurations/bukkit.yml
|
||||
|
@ -1,12 +1,13 @@
|
||||
From 60bfde2f20cab9fade83e6f34af2a2ee5ed168c9 Mon Sep 17 00:00:00 2001
|
||||
From 67cddbc9856c267a110cf7531b8fde518e327613 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Thu, 7 Mar 2013 20:12:46 +1100
|
||||
Subject: [PATCH] Thread safety. Adds thread safety for chunk load / unload
|
||||
methods.
|
||||
Subject: [PATCH] Async Operation Catching
|
||||
|
||||
Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.
|
||||
---
|
||||
src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 3 +++
|
||||
src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 1 +
|
||||
2 files changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 9343d46..b569dc4 100644
|
||||
@ -36,6 +37,18 @@ index 9343d46..b569dc4 100644
|
||||
chunkLoadCount++;
|
||||
if (generate) {
|
||||
// Use the default variant of loadChunk when generate == true.
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 70111e7..59e63ef 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -213,6 +213,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void kickPlayer(String message) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous player kick!");
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
||||
--
|
||||
1.8.1-rc2
|
||||
|
@ -1,15 +1,15 @@
|
||||
From 63bf5cad042a511332edc488e25b53df78c64919 Mon Sep 17 00:00:00 2001
|
||||
From 82330dae19c04ca1d92033b449536f4f79d1e322 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Feb 2013 12:33:20 +1100
|
||||
Subject: [PATCH] Watchdog Thread.
|
||||
|
||||
---
|
||||
.../java/net/minecraft/server/MinecraftServer.java | 2 +
|
||||
src/main/java/org/bukkit/craftbukkit/Spigot.java | 78 +++++++++++++++++-
|
||||
src/main/java/org/spigotmc/RestartCommand.java | 23 ++++++
|
||||
src/main/java/org/spigotmc/WatchdogThread.java | 93 ++++++++++++++++++++++
|
||||
src/main/resources/configurations/bukkit.yml | 3 +
|
||||
5 files changed, 197 insertions(+), 2 deletions(-)
|
||||
.../java/net/minecraft/server/MinecraftServer.java | 2 +
|
||||
src/main/java/org/bukkit/craftbukkit/Spigot.java | 123 +++++++++++++++++----
|
||||
src/main/java/org/spigotmc/RestartCommand.java | 23 ++++
|
||||
src/main/java/org/spigotmc/WatchdogThread.java | 93 ++++++++++++++++
|
||||
src/main/resources/configurations/bukkit.yml | 3 +
|
||||
5 files changed, 222 insertions(+), 22 deletions(-)
|
||||
create mode 100644 src/main/java/org/spigotmc/RestartCommand.java
|
||||
create mode 100644 src/main/java/org/spigotmc/WatchdogThread.java
|
||||
|
||||
@ -34,7 +34,7 @@ index 28135f4..3689a3d 100644
|
||||
this.isStopped = true;
|
||||
} catch (Throwable throwable1) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
index b00c885..dcfac79 100644
|
||||
index b00c885..d445c2e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -44,20 +44,29 @@ index b00c885..dcfac79 100644
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.server.*;
|
||||
@@ -8,9 +9,11 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -8,21 +9,24 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
-import java.util.logging.Logger;
|
||||
+import net.minecraft.server.EntityPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
+import org.bukkit.entity.Player;
|
||||
import org.spigotmc.Metrics;
|
||||
+import org.spigotmc.RestartCommand;
|
||||
+import org.spigotmc.WatchdogThread;
|
||||
|
||||
public class Spigot {
|
||||
static AxisAlignedBB maxBB = AxisAlignedBB.a(0,0,0,0,0,0);
|
||||
@@ -23,6 +26,7 @@ public class Spigot {
|
||||
- static AxisAlignedBB maxBB = AxisAlignedBB.a(0,0,0,0,0,0);
|
||||
- static AxisAlignedBB miscBB = AxisAlignedBB.a(0,0,0,0,0,0);
|
||||
- static AxisAlignedBB animalBB = AxisAlignedBB.a(0,0,0,0,0,0);
|
||||
- static AxisAlignedBB monsterBB = AxisAlignedBB.a(0,0,0,0,0,0);
|
||||
|
||||
+ static AxisAlignedBB maxBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
+ static AxisAlignedBB miscBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
+ static AxisAlignedBB animalBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
+ static AxisAlignedBB monsterBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
public static boolean tabPing = false;
|
||||
private static Metrics metrics;
|
||||
|
||||
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
|
||||
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
|
||||
@ -91,7 +100,100 @@ index b00c885..dcfac79 100644
|
||||
}
|
||||
|
||||
if (server.chunkGCPeriod == 0) {
|
||||
@@ -265,4 +280,63 @@ public class Spigot {
|
||||
@@ -59,6 +74,7 @@ public class Spigot {
|
||||
/**
|
||||
* Initializes an entities type on construction to specify what group this
|
||||
* entity is in for activation ranges.
|
||||
+ *
|
||||
* @param entity
|
||||
* @return group id
|
||||
*/
|
||||
@@ -80,21 +96,20 @@ public class Spigot {
|
||||
* @return boolean If it should always tick.
|
||||
*/
|
||||
public static boolean initializeEntityActivationState(Entity entity, CraftWorld world) {
|
||||
- if ( (entity.activationType == 3 && world.miscEntityActivationRange == 0)
|
||||
- || (entity.activationType == 2 && world.animalEntityActivationRange == 0)
|
||||
- || (entity.activationType == 1 && world.monsterEntityActivationRange == 0)
|
||||
- || entity instanceof EntityHuman
|
||||
- || entity instanceof EntityItemFrame
|
||||
- || entity instanceof EntityProjectile
|
||||
- || entity instanceof EntityEnderDragon
|
||||
- || entity instanceof EntityComplexPart
|
||||
- || entity instanceof EntityWither
|
||||
- || entity instanceof EntityFireball
|
||||
- || entity instanceof EntityWeather
|
||||
- || entity instanceof EntityTNTPrimed
|
||||
- || entity instanceof EntityEnderCrystal
|
||||
- || entity instanceof EntityFireworks
|
||||
- ) {
|
||||
+ if ((entity.activationType == 3 && world.miscEntityActivationRange == 0)
|
||||
+ || (entity.activationType == 2 && world.animalEntityActivationRange == 0)
|
||||
+ || (entity.activationType == 1 && world.monsterEntityActivationRange == 0)
|
||||
+ || entity instanceof EntityHuman
|
||||
+ || entity instanceof EntityItemFrame
|
||||
+ || entity instanceof EntityProjectile
|
||||
+ || entity instanceof EntityEnderDragon
|
||||
+ || entity instanceof EntityComplexPart
|
||||
+ || entity instanceof EntityWither
|
||||
+ || entity instanceof EntityFireball
|
||||
+ || entity instanceof EntityWeather
|
||||
+ || entity instanceof EntityTNTPrimed
|
||||
+ || entity instanceof EntityEnderCrystal
|
||||
+ || entity instanceof EntityFireworks) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,6 +119,7 @@ public class Spigot {
|
||||
/**
|
||||
* Utility method to grow an AABB without creating a new AABB or touching
|
||||
* the pool, so we can re-use ones we have.
|
||||
+ *
|
||||
* @param target
|
||||
* @param source
|
||||
* @param x
|
||||
@@ -122,6 +138,7 @@ public class Spigot {
|
||||
/**
|
||||
* Find what entities are in range of the players in the world and set
|
||||
* active if in range.
|
||||
+ *
|
||||
* @param world
|
||||
*/
|
||||
public static void activateEntities(World world) {
|
||||
@@ -160,6 +177,7 @@ public class Spigot {
|
||||
|
||||
/**
|
||||
* Checks for the activation state of all entities in this chunk.
|
||||
+ *
|
||||
* @param chunk
|
||||
*/
|
||||
private static void activateChunkEntities(Chunk chunk) {
|
||||
@@ -195,6 +213,7 @@ public class Spigot {
|
||||
/**
|
||||
* If an entity is not in range, do some more checks to see if we should
|
||||
* give it a shot.
|
||||
+ *
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@@ -205,7 +224,7 @@ public class Spigot {
|
||||
}
|
||||
if (!(entity instanceof EntityArrow)) {
|
||||
if (!entity.onGround || entity.passenger != null
|
||||
- || entity.vehicle != null) {
|
||||
+ || entity.vehicle != null) {
|
||||
return true;
|
||||
}
|
||||
} else if (!((EntityArrow) entity).inGround) {
|
||||
@@ -235,6 +254,7 @@ public class Spigot {
|
||||
|
||||
/**
|
||||
* Checks if the entity is active for this tick.
|
||||
+ *
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@@ -265,4 +285,63 @@ public class Spigot {
|
||||
SpigotTimings.checkIfActiveTimer.stopTiming();
|
||||
return isActive;
|
||||
}
|
||||
@ -104,8 +206,8 @@ index b00c885..dcfac79 100644
|
||||
+ System.out.println("Attempting to restart with " + startupScript);
|
||||
+
|
||||
+ // Kick all players
|
||||
+ for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
+ ((org.bukkit.craftbukkit.entity.CraftPlayer) p).kickPlayer("Server is restarting", true);
|
||||
+ for (EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
|
||||
+ p.playerConnection.disconnect("Server is restarting");
|
||||
+ }
|
||||
+ // Give the socket a chance to send the packets
|
||||
+ try {
|
||||
@ -130,15 +232,15 @@ index b00c885..dcfac79 100644
|
||||
+ // This will be done AFTER the server has completely halted
|
||||
+ Thread shutdownHook = new Thread() {
|
||||
+ @Override
|
||||
+ public void run(){
|
||||
+ public void run() {
|
||||
+ try {
|
||||
+ String os = System.getProperty("os.name").toLowerCase();
|
||||
+ if (os.contains("win")) {
|
||||
+ Runtime.getRuntime().exec("cmd /c start " + file.getPath());
|
||||
+ } else {
|
||||
+ Runtime.getRuntime().exec(new String[] { "sh", file.getPath()});
|
||||
+ Runtime.getRuntime().exec(new String[]{"sh", file.getPath()});
|
||||
+ }
|
||||
+ } catch (Exception e){
|
||||
+ } catch (Exception e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 38f144fcd9d44015bb3db3530742c12708b49dfe Mon Sep 17 00:00:00 2001
|
||||
From f9ec6953de1d80b95eea4b195973b9dda36f5e0f Mon Sep 17 00:00:00 2001
|
||||
From: EdGruberman <ed@rjump.com>
|
||||
Date: Fri, 22 Feb 2013 09:23:51 -0700
|
||||
Subject: [PATCH] Return bed location itself instead of next to bed; Fixes
|
||||
@ -9,10 +9,10 @@ Subject: [PATCH] Return bed location itself instead of next to bed; Fixes
|
||||
1 file changed, 20 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 1871d3e..2e58bf0 100644
|
||||
index 59e63ef..3c34a4c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -632,10 +632,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -626,10 +626,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
ChunkCoordinates bed = getHandle().getBed();
|
||||
|
||||
if (world != null && bed != null) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 9e7503dbe6691e74f3ef4d864b459da13597cb29 Mon Sep 17 00:00:00 2001
|
||||
From bc6b6883004dfcf9bae2842933ae9603f720412b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 20 Feb 2013 11:58:47 -0500
|
||||
Subject: [PATCH] Entity Tracking Ranges
|
||||
@ -83,10 +83,10 @@ index 3bfc669..804da57 100644
|
||||
|
||||
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
|
||||
index dcfac79..beab433 100644
|
||||
index d445c2e..3bfd29b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -339,4 +339,30 @@ public class Spigot {
|
||||
@@ -344,4 +344,30 @@ public class Spigot {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 2e0bd90323900b7b0e85d8b8fdefac11564a6aa7 Mon Sep 17 00:00:00 2001
|
||||
From f081be9a6ac0b77c3776bfb3c058a65db932e80f Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Mar 2013 11:15:11 +1100
|
||||
Subject: [PATCH] BungeeCord Support
|
||||
@ -33,11 +33,11 @@ index 58687ed..ae73a43 100644
|
||||
+ // Spigot end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
index beab433..9a01674 100644
|
||||
index 3bfd29b..bce217e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -23,6 +23,7 @@ public class Spigot {
|
||||
|
||||
static AxisAlignedBB monsterBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||
public static boolean tabPing = false;
|
||||
private static Metrics metrics;
|
||||
+ public static List<String> bungeeIPs;
|
||||
|
@ -1,4 +1,4 @@
|
||||
From d8572c7da59ef43d0adf53e4dff7400b00bb9e12 Mon Sep 17 00:00:00 2001
|
||||
From 4a8f60ad4f5babc013cd49f510bea117f9356cc3 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Mar 2013 13:04:45 +1100
|
||||
Subject: [PATCH] Texture Pack Resolutions
|
||||
@ -25,7 +25,7 @@ index 3689a3d..9a78084 100644
|
||||
|
||||
public abstract boolean T();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
index 9a01674..cf17b5a 100644
|
||||
index bce217e..8fd635f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -24,6 +24,7 @@ public class Spigot {
|
||||
@ -45,10 +45,10 @@ index 9a01674..cf17b5a 100644
|
||||
if (metrics == null) {
|
||||
try {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 2e58bf0..d7a3bc7 100644
|
||||
index 3c34a4c..8361614 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -834,7 +834,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -828,7 +828,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void setTexturePack(String url) {
|
||||
Validate.notNull(url, "Texture pack URL cannot be null");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user