[Highly Experimental - CAUTION] Implement spigot.yml. A large portion of Spigot was rewritten in this commit, so USE WITH CAUTION, production usage is NOT recommended. Take backups, be safe, and enjoy!

This commit is contained in:
md_5 2013-06-22 15:06:53 +10:00
commit f90b460b99
61 changed files with 2002 additions and 2352 deletions

View File

@ -1,4 +1,4 @@
From 1f73a2aab42801c0755013847e2e01944aea94ca Mon Sep 17 00:00:00 2001
From 2dd1e832500d42db77b2e7f905e6d2c7287ed664 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:34:54 +1000
Subject: [PATCH] POM Changes
@ -114,6 +114,19 @@ index 4ead01e..8c9f66b 100644
<executions>
<execution>
<phase>package</phase>
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6cb50b7..00326c1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -208,7 +208,7 @@ public final class CraftServer implements Server {
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel"));
- updater.setEnabled(configuration.getBoolean("auto-updater.enabled"));
+ updater.setEnabled(false); // Spigot
updater.setSuggestChannels(configuration.getBoolean("auto-updater.suggest-channels"));
updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index f905d17..9304637 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java

View File

@ -1,100 +1,272 @@
From 21486d9d244f3c22b6e8643c9495592493bcc1f9 Mon Sep 17 00:00:00 2001
From 30196d52fe8630bfa0dd6ccf218e2a0461310fc8 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 14 May 2013 12:06:27 +1000
Date: Sat, 22 Jun 2013 14:06:41 +1000
Subject: [PATCH] Spigot Configuration
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 7261dc9..10ce69d 100644
index 7261dc9..59444cb 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -55,6 +55,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@@ -89,6 +89,11 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
if (this.G() < 0) {
this.setPort(this.propertyManager.getInt("server-port", 25565));
}
+ // Spigot start
+ this.a((PlayerList) (new DedicatedPlayerList(this)));
+ org.spigotmc.SpigotConfig.init();
+ org.spigotmc.SpigotConfig.registerCommands();
+ // Spigot end
this.getLogger().info("Loading properties");
this.propertyManager = new PropertyManager(this.options, this.getLogger()); // CraftBukkit - CLI argument support
+ this.a((PlayerList) (new DedicatedPlayerList(this))); // Spigot - moved up from below
if (this.I()) {
this.d("127.0.0.1");
} else {
@@ -103,7 +104,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
this.getLogger().info("Generating keypair");
this.a(MinecraftEncryption.b());
@@ -103,7 +108,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
return false;
}
- this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit // Spigot - moved to top of method
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // Spigot - Moved up
if (!this.getOnlineMode()) {
this.getLogger().warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3a4ddea..e67f520 100644
index 3a4ddea..de052bd 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -111,7 +111,7 @@ public abstract class World implements IBlockAccess {
@@ -99,6 +99,7 @@ public abstract class World implements IBlockAccess {
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
final Object chunkLock = new Object();
+ public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
public CraftWorld getWorld() {
return this.world;
@@ -110,6 +111,7 @@ public abstract class World implements IBlockAccess {
// Changed signature
public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, IConsoleLogManager iconsolelogmanager, ChunkGenerator gen, org.bukkit.World.Environment env) {
+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig( s ); // Spigot
this.generator = gen;
- this.world = new CraftWorld((WorldServer) this, gen, env);
+ this.world = new CraftWorld((WorldServer) this, gen, env, s); // Spigot
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
// CraftBukkit end
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6cb50b7..2956e75 100644
index 00326c1..6e6fe1c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -145,7 +145,7 @@ public final class CraftServer implements Server {
protected final MinecraftServer console;
protected final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
- private YamlConfiguration configuration;
+ public YamlConfiguration configuration; // Spigot
private final Yaml yaml = new Yaml(new SafeConstructor());
private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap();
private final AutoUpdater updater;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index c0fb528..e6fdbe5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -67,8 +67,14 @@ public class CraftWorld implements World {
private int chunkGCTickCount;
@@ -556,6 +556,7 @@ public final class CraftServer implements Server {
playerList.getIPBans().load();
playerList.getNameBans().load();
private static final Random rand = new Random();
-
+
+ // Spigot start
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
+ this( world, gen, env, "default" );
+ org.spigotmc.SpigotConfig.init(); // Spigot
for (WorldServer world : console.worlds) {
world.difficulty = difficulty;
world.setSpawnFlags(monsters, animals);
@@ -570,11 +571,13 @@ public final class CraftServer implements Server {
} else {
world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
}
+ world.spigotConfig.init(); // Spigot
}
pluginManager.clearPlugins();
commandMap.clearCommands();
resetRecipes();
+ org.spigotmc.SpigotConfig.registerCommands(); // Spigot
int pollCount = 0;
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
new file mode 100644
index 0000000..1d915fb
--- /dev/null
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -0,0 +1,114 @@
+package org.spigotmc;
+
+import com.google.common.base.Throwables;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class SpigotConfig
+{
+
+ private static final File CONFIG_FILE = new File( "spigot.yml" );
+ private static final String HEADER = "This is the main configuration file for Spigot.\n"
+ + "As you can see, there's tons to configure. Some options may impact gameplay, so use\n"
+ + "with caution, and make sure you know what each option does before configuring.\n"
+ + "For a reference for any variable inside this file, check out the Spigot wiki at\n"
+ + "http://www.spigotmc.org/wiki/spigot-configuration/\n"
+ + "\n"
+ + "If you need help with the configuration or have any questions related to Spigot,\n"
+ + "join us at the IRC or drop by our forums and leave a post.\n"
+ + "\n"
+ + "IRC: #spigot @ irc.esper.net ( http://webchat.esper.net/?channel=spigot )\n"
+ + "Forums: http://www.spigotmc.org/forum/\n";
+ /*========================================================================*/
+ static YamlConfiguration config;
+ static int version;
+ static Map<String, Command> commands;
+ /*========================================================================*/
+
+ public static void init()
+ {
+ config = YamlConfiguration.loadConfiguration( CONFIG_FILE );
+ config.options().header( HEADER );
+ config.options().copyDefaults( true );
+
+ commands = new HashMap<String, Command>();
+
+ version = getInt( "config-version", 1 );
+ readConfig( SpigotConfig.class, null );
+ }
+
+ public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env, String name) {
+ // Spigot end
this.world = world;
this.generator = gen;
@@ -77,6 +83,23 @@ public class CraftWorld implements World {
if (server.chunkGCPeriod > 0) {
chunkGCTickCount = rand.nextInt(server.chunkGCPeriod);
}
+ // Spigot start
+ org.bukkit.configuration.file.YamlConfiguration configuration = server.configuration;
+ name = name.replaceAll( " ", "_" );
+
+ // Load defaults first
+ boolean info = configuration.getBoolean( "world-settings.default.info", true );
+
+ // Override defaults with world specific, if they exist
+ info = configuration.getBoolean( "world-settings." + name + ".info", info );
+
+ if ( info )
+ public static void registerCommands()
+ {
+ for ( Map.Entry<String, Command> entry : commands.entrySet() )
+ {
+ server.getLogger().info( "-------------- Spigot ----------------" );
+ server.getLogger().info( "-------- World Settings For [" + name + "] --------" );
+ server.getLogger().info( "-------------------------------------------------" );
+ MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "Spigot", entry.getValue() );
+ }
+ // Spigot end
}
public Block getBlockAt(int x, int y, int z) {
+ }
+
+ static void readConfig(Class<?> clazz, Object instance)
+ {
+ for ( Method method : clazz.getDeclaredMethods() )
+ {
+ if ( Modifier.isPrivate( method.getModifiers() ) )
+ {
+ if ( method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE )
+ {
+ try
+ {
+ method.setAccessible( true );
+ method.invoke( instance );
+ } catch ( InvocationTargetException ex )
+ {
+ Throwables.propagate( ex.getCause() );
+ } catch ( ReflectiveOperationException ex )
+ {
+ Bukkit.getLogger().log( Level.SEVERE, "Error invoking " + method, ex );
+ }
+ }
+ }
+ }
+
+ try
+ {
+ config.save( CONFIG_FILE );
+ } catch ( IOException ex )
+ {
+ Bukkit.getLogger().log( Level.SEVERE, "Could not save " + CONFIG_FILE, ex );
+ }
+ }
+
+ private static boolean getBoolean(String path, boolean def)
+ {
+ config.addDefault( path, def );
+ return config.getBoolean( path, config.getBoolean( path ) );
+ }
+
+ private static int getInt(String path, int def)
+ {
+ config.addDefault( path, def );
+ return config.getInt( path, config.getInt( path ) );
+ }
+
+ private static <T> List getList(String path, T def)
+ {
+ config.addDefault( path, def );
+ return (List<T>) config.getList( path, config.getList( path ) );
+ }
+
+ private static String getString(String path, String def)
+ {
+ config.addDefault( path, def );
+ return config.getString( path, config.getString( path ) );
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
new file mode 100644
index 0000000..3f8562f
--- /dev/null
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -0,0 +1,66 @@
+package org.spigotmc;
+
+import java.util.List;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class SpigotWorldConfig
+{
+
+ private final String worldName;
+ private final YamlConfiguration config;
+ private boolean verbose;
+
+ public SpigotWorldConfig(String worldName)
+ {
+ this.worldName = worldName;
+ this.config = SpigotConfig.config;
+ init();
+ }
+
+ public void init()
+ {
+ this.verbose = getBoolean( "verbose", true );
+
+ log( "-------- World Settings For [" + worldName + "] --------" );
+ SpigotConfig.readConfig( SpigotWorldConfig.class, this );
+ }
+
+ private void log(String s)
+ {
+ if ( verbose )
+ {
+ Bukkit.getLogger().info( s );
+ }
+ }
+
+ private boolean getBoolean(String path, boolean def)
+ {
+ config.addDefault( "world-settings.default." + path, def );
+ return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) );
+ }
+
+ private double getDouble(String path, double def)
+ {
+ config.addDefault( "world-settings.default." + path, def );
+ return config.getDouble( "world-settings." + worldName + "." + path, config.getDouble( "world-settings.default." + path ) );
+ }
+
+ private int getInt(String path, int def)
+ {
+ config.addDefault( "world-settings.default." + path, def );
+ return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) );
+ }
+
+ private <T> List getList(String path, T def)
+ {
+ config.addDefault( "world-settings.default." + path, def );
+ return (List<T>) config.getList( "world-settings." + worldName + "." + path, config.getList( "world-settings.default." + path ) );
+ }
+
+ private String getString(String path, String def)
+ {
+ config.addDefault( "world-settings.default." + path, def );
+ return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
+ }
+}
--
1.8.1.2

View File

@ -1,11 +1,11 @@
From 11e91bebc30bae349454231d0c0e120918de03aa Mon Sep 17 00:00:00 2001
From a4f3a529237119d805302947bd76ddb384bd9379 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 12:56:02 +1000
Subject: [PATCH] Better Chunk Tick Selection
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index e67f520..96190de 100644
index de052bd..bc692dd 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -66,13 +66,35 @@ public abstract class World implements IBlockAccess {
@ -45,24 +45,24 @@ index e67f520..96190de 100644
public BiomeBase getBiome(int i, int j) {
if (this.isLoaded(i, 0, j)) {
@@ -115,6 +137,11 @@ public abstract class World implements IBlockAccess {
@@ -117,6 +139,11 @@ public abstract class World implements IBlockAccess {
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
// CraftBukkit end
+ // Spigot start
+ this.chunkTickRadius = (byte) ( ( this.getServer().getViewDistance() < 7 ) ? this.getServer().getViewDistance() : 7 );
+ this.chunkTickList = new gnu.trove.map.hash.TLongShortHashMap( world.growthPerTick * 5, 0.7f, Long.MIN_VALUE, Short.MIN_VALUE );
+ this.chunkTickList = new gnu.trove.map.hash.TLongShortHashMap( spigotConfig.chunksPerTick * 5, 0.7f, Long.MIN_VALUE, Short.MIN_VALUE );
+ this.chunkTickList.setAutoCompactionFactor( 0 );
+ // Spigot end
this.O = this.random.nextInt(12000);
this.H = new int['\u8000'];
@@ -1954,24 +1981,44 @@ public abstract class World implements IBlockAccess {
@@ -1956,24 +1983,44 @@ public abstract class World implements IBlockAccess {
int j;
int k;
+ // Spigot start
+ int optimalChunks = this.getWorld().growthPerTick;
+ int optimalChunks = spigotConfig.chunksPerTick;
+ // Quick conditions to allow us to exist early
+ if ( optimalChunks <= 0 || players.isEmpty() )
+ {
@ -147,40 +147,22 @@ index 49360c1..6c3fcf1 100644
block.a(this, k2 + k, i3 + chunksection.getYPosition(), l2 + l, this.random);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index e6fdbe5..a9b4e71 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -67,7 +67,10 @@ public class CraftWorld implements World {
private int chunkGCTickCount;
private static final Random rand = new Random();
-
+ // Spigot start
+ public int growthPerTick = 650;
+ // Spigot end
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 3f8562f..123fb7a 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -63,4 +63,11 @@ public class SpigotWorldConfig
config.addDefault( "world-settings.default." + path, def );
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
}
+
// Spigot start
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) {
this( world, gen, env, "default" );
@@ -89,14 +92,17 @@ public class CraftWorld implements World {
// Load defaults first
boolean info = configuration.getBoolean( "world-settings.default.info", true );
+ growthPerTick = configuration.getInt( "world-settings.default.growth-chunks-per-tick", growthPerTick );
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
+ growthPerTick = configuration.getInt( "world-settings." + name + ".growth-chunks-per-tick", growthPerTick );
if ( info )
{
server.getLogger().info( "-------------- Spigot ----------------" );
server.getLogger().info( "-------- World Settings For [" + name + "] --------" );
+ server.getLogger().info( "Growth Per Tick: " + growthPerTick );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
+ public int chunksPerTick;
+ private void chunksPerTick()
+ {
+ chunksPerTick = getInt( "chunks-per-tick", 650 );
+ log( "Chunks to Grow per Tick: " + chunksPerTick );
+ }
}
--
1.8.1.2

View File

@ -0,0 +1,177 @@
From abf5bc5b131b439231197b1a3159b0dcdc3c82ec Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:17:20 +1000
Subject: [PATCH] Crop Growth Rates
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index 4392cb2..8e041c2 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
@@ -768,4 +768,16 @@ public class Block {
return 0;
}
// CraftBukkit end
+
+ // Spigot start
+ public static float range(float min, float value, float max) {
+ if (value < min) {
+ return min;
+ }
+ if (value > max) {
+ return max;
+ }
+ return value;
+ }
+ // Spigot end
}
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
index 83cc09d..4376051 100644
--- a/src/main/java/net/minecraft/server/BlockCactus.java
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
@@ -23,7 +23,7 @@ public class BlockCactus extends Block {
if (l < 3) {
int i1 = world.getData(i, j, k);
- if (i1 == 15) {
+ if (i1 >= (byte) range(3, (world.growthOdds / world.spigotConfig.cactusModifier * 15) + 0.5F, 15)) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this.id, 0); // CraftBukkit
world.setData(i, j, k, 0, 4);
this.doPhysics(world, i, j + 1, k, this.id);
diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java
index 14a1c3b..d3b6095 100644
--- a/src/main/java/net/minecraft/server/BlockCrops.java
+++ b/src/main/java/net/minecraft/server/BlockCrops.java
@@ -28,7 +28,7 @@ public class BlockCrops extends BlockFlower {
if (l < 7) {
float f = this.k(world, i, j, k);
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
+ if (random.nextInt((int) (world.growthOdds / world.spigotConfig.wheatModifier * (25.0F / f)) + 1) == 0) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this.id, ++l); // CraftBukkit
}
}
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
index 6f9301d..2ccc0b8 100644
--- a/src/main/java/net/minecraft/server/BlockGrass.java
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
@@ -32,7 +32,8 @@ public class BlockGrass extends Block {
}
// CraftBukkit end
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
- for (int l = 0; l < 4; ++l) {
+ int numGrowth = Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); // Spigot
+ for (int l = 0; l < numGrowth; ++l) { // Spigot
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;
int k1 = k + random.nextInt(3) - 1;
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
index 872ad00..abc31ac 100644
--- a/src/main/java/net/minecraft/server/BlockMushroom.java
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
@@ -27,7 +27,7 @@ public class BlockMushroom extends BlockFlower {
public void a(World world, int i, int j, int k, Random random) {
final int sourceX = i, sourceY = j, sourceZ = k; // CraftBukkit
- if (random.nextInt(25) == 0) {
+ if (random.nextInt(Math.max(1, (int) world.growthOdds / world.spigotConfig.mushroomModifier * 25)) == 0) { // Spigot
byte b0 = 4;
int l = 5;
diff --git a/src/main/java/net/minecraft/server/BlockMycel.java b/src/main/java/net/minecraft/server/BlockMycel.java
index 1de8c83..fa11d1c 100644
--- a/src/main/java/net/minecraft/server/BlockMycel.java
+++ b/src/main/java/net/minecraft/server/BlockMycel.java
@@ -32,7 +32,8 @@ public class BlockMycel extends Block {
}
// CraftBukkit end
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
- for (int l = 0; l < 4; ++l) {
+ int numGrowth = Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); // Spigot
+ for (int l = 0; l < numGrowth; ++l) { // Spigot
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;
int k1 = k + random.nextInt(3) - 1;
diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java
index 8657860..cf52501 100644
--- a/src/main/java/net/minecraft/server/BlockReed.java
+++ b/src/main/java/net/minecraft/server/BlockReed.java
@@ -23,7 +23,7 @@ public class BlockReed extends Block {
if (l < 3) {
int i1 = world.getData(i, j, k);
- if (i1 == 15) {
+ if (i1 >= (byte) range(3, (world.growthOdds / world.spigotConfig.caneModifier * 15) + 0.5F, 15)) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this.id, 0); // CraftBukkit
world.setData(i, j, k, 0, 4);
} else {
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java
index 3b00939..ea34899 100644
--- a/src/main/java/net/minecraft/server/BlockSapling.java
+++ b/src/main/java/net/minecraft/server/BlockSapling.java
@@ -26,7 +26,7 @@ public class BlockSapling extends BlockFlower {
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
super.a(world, i, j, k, random);
- if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(7) == 0) {
+ if (world.getLightLevel(i, j + 1, k) >= 9 && (random.nextInt(Math.max(2, (int) ((world.growthOdds / world.spigotConfig.saplingModifier * 7) + 0.5F))) == 0)) { // Spigot
this.grow(world, i, j, k, random, false, null, null); // CraftBukkit - added bonemeal, player and itemstack
}
}
diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java
index 8339a35..c7e2344 100644
--- a/src/main/java/net/minecraft/server/BlockStem.java
+++ b/src/main/java/net/minecraft/server/BlockStem.java
@@ -27,7 +27,7 @@ public class BlockStem extends BlockFlower {
if (world.getLightLevel(i, j + 1, k) >= 9) {
float f = this.m(world, i, j, k);
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
+ if (random.nextInt((int) (world.growthOdds / (this.id == Block.PUMPKIN_STEM.id ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) * (25.0F / f)) + 1) == 0) { // Spigot
int l = world.getData(i, j, k);
if (l < 7) {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 123fb7a..3ec38a1 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -70,4 +70,36 @@ public class SpigotWorldConfig
chunksPerTick = getInt( "chunks-per-tick", 650 );
log( "Chunks to Grow per Tick: " + chunksPerTick );
}
+
+ // Crop growth rates
+ public int cactusModifier;
+ public int caneModifier;
+ public int melonModifier;
+ public int mushroomModifier;
+ public int pumpkinModifier;
+ public int saplingModifier;
+ public int wheatModifier;
+ private void growthModifiers()
+ {
+ cactusModifier = getInt( "growth.cactus-modifier", 100 );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ caneModifier = getInt( "growth.cane-modifier", 100 );
+ log( "Cane Growth Modifier: " + caneModifier + "%" );
+
+ melonModifier = getInt( "growth.melon-modifier", 100 );
+ log( "Melon Growth Modifier: " + melonModifier + "%" );
+
+ mushroomModifier = getInt( "growth.mushroom-modifier", 100 );
+ log( "Mushroom Growth Modifier: " + mushroomModifier + "%" );
+
+ pumpkinModifier = getInt( "growth.pumpkin-modifier", 100 );
+ log( "Pumpkin Growth Modifier: " + pumpkinModifier + "%" );
+
+ saplingModifier = getInt( "growth.sapling-modifier", 100 );
+ log( "Sapling Growth Modifier: " + saplingModifier + "%" );
+
+ wheatModifier = getInt( "growth.wheat-modifier", 100 );
+ log( "Wheat Growth Modifier: " + wheatModifier + "%" );
+ }
}
--
1.8.1.2

View File

@ -1,445 +0,0 @@
From 6e1048caeaaa323e667d8bf92aa28f5ffed810e3 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 13:55:57 +1000
Subject: [PATCH] Spigot Changes
diff --git a/.gitignore b/.gitignore
index c3faf57..346b232 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,5 @@
/src/main/resources/achievement
/src/main/resources/lang
+
+/dependency-reduced-pom.xml
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index 4392cb2..8e041c2 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
@@ -768,4 +768,16 @@ public class Block {
return 0;
}
// CraftBukkit end
+
+ // Spigot start
+ public static float range(float min, float value, float max) {
+ if (value < min) {
+ return min;
+ }
+ if (value > max) {
+ return max;
+ }
+ return value;
+ }
+ // Spigot end
}
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
index 83cc09d..eed8ded 100644
--- a/src/main/java/net/minecraft/server/BlockCactus.java
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
@@ -23,7 +23,7 @@ public class BlockCactus extends Block {
if (l < 3) {
int i1 = world.getData(i, j, k);
- if (i1 == 15) {
+ if (i1 >= (byte) range(3, (world.growthOdds / world.getWorld().cactusGrowthModifier * 15) + 0.5F, 15)) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this.id, 0); // CraftBukkit
world.setData(i, j, k, 0, 4);
this.doPhysics(world, i, j + 1, k, this.id);
diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java
index 14a1c3b..0aee7af 100644
--- a/src/main/java/net/minecraft/server/BlockCrops.java
+++ b/src/main/java/net/minecraft/server/BlockCrops.java
@@ -28,7 +28,7 @@ public class BlockCrops extends BlockFlower {
if (l < 7) {
float f = this.k(world, i, j, k);
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
+ if (random.nextInt((int) (world.growthOdds / world.getWorld().wheatGrowthModifier * (25.0F / f)) + 1) == 0) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this.id, ++l); // CraftBukkit
}
}
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
index 6f9301d..2ccc0b8 100644
--- a/src/main/java/net/minecraft/server/BlockGrass.java
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
@@ -32,7 +32,8 @@ public class BlockGrass extends Block {
}
// CraftBukkit end
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
- for (int l = 0; l < 4; ++l) {
+ int numGrowth = Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); // Spigot
+ for (int l = 0; l < numGrowth; ++l) { // Spigot
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;
int k1 = k + random.nextInt(3) - 1;
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
index 872ad00..6e135a4 100644
--- a/src/main/java/net/minecraft/server/BlockMushroom.java
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
@@ -27,7 +27,7 @@ public class BlockMushroom extends BlockFlower {
public void a(World world, int i, int j, int k, Random random) {
final int sourceX = i, sourceY = j, sourceZ = k; // CraftBukkit
- if (random.nextInt(25) == 0) {
+ if (random.nextInt(Math.max(1, (int) world.growthOdds / world.getWorld().mushroomGrowthModifier * 25)) == 0) { // Spigot
byte b0 = 4;
int l = 5;
diff --git a/src/main/java/net/minecraft/server/BlockMycel.java b/src/main/java/net/minecraft/server/BlockMycel.java
index 1de8c83..fa11d1c 100644
--- a/src/main/java/net/minecraft/server/BlockMycel.java
+++ b/src/main/java/net/minecraft/server/BlockMycel.java
@@ -32,7 +32,8 @@ public class BlockMycel extends Block {
}
// CraftBukkit end
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
- for (int l = 0; l < 4; ++l) {
+ int numGrowth = Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); // Spigot
+ for (int l = 0; l < numGrowth; ++l) { // Spigot
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;
int k1 = k + random.nextInt(3) - 1;
diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java
index 8657860..50c5200 100644
--- a/src/main/java/net/minecraft/server/BlockReed.java
+++ b/src/main/java/net/minecraft/server/BlockReed.java
@@ -23,7 +23,7 @@ public class BlockReed extends Block {
if (l < 3) {
int i1 = world.getData(i, j, k);
- if (i1 == 15) {
+ if (i1 >= (byte) range(3, (world.growthOdds / world.getWorld().sugarGrowthModifier * 15) + 0.5F, 15)) { // Spigot
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this.id, 0); // CraftBukkit
world.setData(i, j, k, 0, 4);
} else {
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java
index 3b00939..4ab0fb9 100644
--- a/src/main/java/net/minecraft/server/BlockSapling.java
+++ b/src/main/java/net/minecraft/server/BlockSapling.java
@@ -26,7 +26,7 @@ public class BlockSapling extends BlockFlower {
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
super.a(world, i, j, k, random);
- if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(7) == 0) {
+ if (world.getLightLevel(i, j + 1, k) >= 9 && (random.nextInt(Math.max(2, (int) ((world.growthOdds / world.getWorld().aggregateTicks / world.getWorld().treeGrowthModifier * 7) + 0.5F))) == 0)) { // Spigot
this.grow(world, i, j, k, random, false, null, null); // CraftBukkit - added bonemeal, player and itemstack
}
}
diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java
index 8339a35..c17ce36 100644
--- a/src/main/java/net/minecraft/server/BlockStem.java
+++ b/src/main/java/net/minecraft/server/BlockStem.java
@@ -27,7 +27,7 @@ public class BlockStem extends BlockFlower {
if (world.getLightLevel(i, j + 1, k) >= 9) {
float f = this.m(world, i, j, k);
- if (random.nextInt((int) (25.0F / f) + 1) == 0) {
+ if (random.nextInt((int) (world.growthOdds / (this.id == Block.PUMPKIN_STEM.id ? world.getWorld().pumpkinGrowthModifier : world.getWorld().melonGrowthModifier) * (25.0F / f)) + 1) == 0) { // Spigot
int l = world.getData(i, j, k);
if (l < 7) {
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 018c314..f6885d6 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -845,8 +845,20 @@ public class PlayerConnection extends Connection {
this.chat(s, packet3chat.a_());
+ // Spigot start
+ boolean isCounted = true;
+ if (server.spamGuardExclusions != null) {
+ for (String excluded : server.spamGuardExclusions) {
+ if (s.startsWith(excluded)) {
+ isCounted = false;
+ break;
+ }
+ }
+ }
// This section stays because it is only applicable to packets
- if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.name)) { // CraftBukkit use thread-safe spam
+ if (isCounted && chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.name)) { // CraftBukkit use thread-safe spam
+ // Spigot end
+ // CraftBukkit start
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
@@ -967,7 +979,7 @@ public class PlayerConnection extends Connection {
}
try {
- this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
+ if (server.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
return;
}
@@ -1554,8 +1566,9 @@ public class PlayerConnection extends Connection {
flag = false;
} else {
for (i = 0; i < packet130updatesign.lines[j].length(); ++i) {
- if (SharedConstants.allowedCharacters.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) {
+ if (!SharedConstants.isAllowedChatCharacter(packet130updatesign.lines[j].charAt(i))) {
flag = false;
+ break;
}
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index b7e327b..0e3a6a1 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -307,7 +307,7 @@ public abstract class PlayerList {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s1);
} else if (!this.isWhitelisted(s)) {
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, cserver.whitelistMessage); // Spigot
} else {
String s2 = socketaddress.toString();
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 6c3fcf1..4a8d3f4 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -37,6 +37,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
private static final StructurePieceTreasure[] S = new StructurePieceTreasure[] { new StructurePieceTreasure(Item.STICK.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.WOOD.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.LOG.id, 0, 1, 3, 10), new StructurePieceTreasure(Item.STONE_AXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_AXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.STONE_PICKAXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_PICKAXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.APPLE.id, 0, 2, 3, 5), new StructurePieceTreasure(Item.BREAD.id, 0, 2, 3, 3)};
private ArrayList T = new ArrayList();
private IntHashMap entitiesById;
+ private int aggregateTicks = 1; // Spigot
// CraftBukkit start
public final int dimension;
@@ -295,6 +296,10 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
}
protected void g() {
+ // Spigot start
+ if (--this.aggregateTicks != 0) return;
+ aggregateTicks = this.getWorld().aggregateTicks;
+ // Spigot end
super.g();
int i = 0;
int j = 0;
@@ -412,7 +417,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
if (block != null && block.isTicking()) {
++i;
this.growthOdds = (iter.value() < 1) ? this.modifiedOdds : 100; // Spigot - grow fast if no players are in this chunk (value = player count)
- block.a(this, k2 + k, i3 + chunksection.getYPosition(), l2 + l, this.random);
+ for ( int c = 0; c < ( ( block.id == Block.SAPLING.id ) ? 1 : getWorld().aggregateTicks ); c++ ) block.a(this, k2 + k, i3 + chunksection.getYPosition(), l2 + l, this.random);
}
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2956e75..c234cac 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -166,6 +166,13 @@ public final class CraftServer implements Server {
private final class BooleanWrapper {
private boolean value = true;
}
+ // Spigot start
+ public String whitelistMessage = "You are not white-listed on this server!";
+ public String stopMessage = "Server restarting. Brb";
+ public boolean logCommands = true;
+ public boolean commandComplete = true;
+ public List<String> spamGuardExclusions;
+ // Spigot end
static {
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
@@ -208,12 +215,20 @@ public final class CraftServer implements Server {
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel"));
- updater.setEnabled(configuration.getBoolean("auto-updater.enabled"));
+ updater.setEnabled(false);
updater.setSuggestChannels(configuration.getBoolean("auto-updater.suggest-channels"));
updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
updater.check(serverVersion);
+ // Spigot start
+ Spigot.initialize(this, commandMap, configuration);
+
+ try {
+ configuration.save(getConfigFile());
+ } catch (IOException e) {
+ }
+ // Spigot end
loadPlugins();
enablePlugins(PluginLoadOrder.STARTUP);
}
@@ -535,6 +550,7 @@ public final class CraftServer implements Server {
((DedicatedServer) console).propertyManager = config;
+ ((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling")); // Spigot
boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals());
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty > 0);
int difficulty = config.getInt("difficulty", console.worlds.get(0).difficulty);
@@ -600,6 +616,7 @@ public final class CraftServer implements Server {
"This plugin is not properly shutting down its async tasks when it is being reloaded. This may cause conflicts with the newly loaded version of the plugin"
));
}
+ Spigot.initialize(this, commandMap, configuration); // Spigot
loadPlugins();
enablePlugins(PluginLoadOrder.STARTUP);
enablePlugins(PluginLoadOrder.POSTWORLD);
@@ -1326,7 +1343,7 @@ public final class CraftServer implements Server {
public List<String> tabCompleteCommand(Player player, String message) {
List<String> completions = null;
try {
- completions = getCommandMap().tabComplete(player, message.substring(1));
+ completions = (commandComplete) ? getCommandMap().tabComplete(player, message.substring(1)) : null; // Spigot
} catch (CommandException ex) {
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a9b4e71..9789ba4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -69,6 +69,17 @@ public class CraftWorld implements World {
private static final Random rand = new Random();
// Spigot start
public int growthPerTick = 650;
+ public boolean randomLightingUpdates = false;
+ public int mobSpawnRange = 4;
+ public int aggregateTicks = 4;
+ // Crop growth rates:
+ public int wheatGrowthModifier = 100;
+ public int cactusGrowthModifier = 100;
+ public int melonGrowthModifier = 100;
+ public int pumpkinGrowthModifier = 100;
+ public int sugarGrowthModifier = 100;
+ public int treeGrowthModifier = 100;
+ public int mushroomGrowthModifier = 100;
// Spigot end
// Spigot start
@@ -93,16 +104,46 @@ public class CraftWorld implements World {
// Load defaults first
boolean info = configuration.getBoolean( "world-settings.default.info", true );
growthPerTick = configuration.getInt( "world-settings.default.growth-chunks-per-tick", growthPerTick );
+ randomLightingUpdates = configuration.getBoolean( "world-settings.default.random-light-updates", randomLightingUpdates );
+ mobSpawnRange = configuration.getInt( "world-settings.default.mob-spawn-range", mobSpawnRange );
+ aggregateTicks = Math.max( 1, configuration.getInt( "world-settings.default.aggregate-chunkticks", aggregateTicks ) );
+ wheatGrowthModifier = configuration.getInt( "world-settings.default.wheat-growth-modifier", wheatGrowthModifier );
+ cactusGrowthModifier = configuration.getInt( "world-settings.default.cactus-growth-modifier", cactusGrowthModifier );
+ melonGrowthModifier = configuration.getInt( "world-settings.default.melon-growth-modifier", melonGrowthModifier );
+ pumpkinGrowthModifier = configuration.getInt( "world-settings.default.pumpkin-growth-modifier", pumpkinGrowthModifier );
+ sugarGrowthModifier = configuration.getInt( "world-settings.default.sugar-growth-modifier", sugarGrowthModifier );
+ treeGrowthModifier = configuration.getInt( "world-settings.default.tree-growth-modifier", treeGrowthModifier );
+ mushroomGrowthModifier = configuration.getInt( "world-settings.default.mushroom-growth-modifier", mushroomGrowthModifier );
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
growthPerTick = configuration.getInt( "world-settings." + name + ".growth-chunks-per-tick", growthPerTick );
+ randomLightingUpdates = configuration.getBoolean( "world-settings." + name + ".random-light-updates", randomLightingUpdates );
+ mobSpawnRange = configuration.getInt( "world-settings." + name + ".mob-spawn-range", mobSpawnRange );
+ aggregateTicks = Math.max( 1, configuration.getInt( "world-settings." + name + ".aggregate-chunkticks", aggregateTicks ) );
+ wheatGrowthModifier = configuration.getInt( "world-settings." + name + ".wheat-growth-modifier", wheatGrowthModifier );
+ cactusGrowthModifier = configuration.getInt( "world-settings." + name + ".cactus-growth-modifier", cactusGrowthModifier );
+ melonGrowthModifier = configuration.getInt( "world-settings." + name + ".melon-growth-modifier", melonGrowthModifier );
+ pumpkinGrowthModifier = configuration.getInt( "world-settings." + name + ".pumpkin-growth-modifier", pumpkinGrowthModifier );
+ sugarGrowthModifier = configuration.getInt( "world-settings." + name + ".sugar-growth-modifier", sugarGrowthModifier );
+ treeGrowthModifier = configuration.getInt( "world-settings." + name + ".tree-growth-modifier", treeGrowthModifier );
+ mushroomGrowthModifier = configuration.getInt( "world-settings." + name + ".mushroom-growth-modifier", mushroomGrowthModifier );
if ( info )
{
server.getLogger().info( "-------------- Spigot ----------------" );
server.getLogger().info( "-------- World Settings For [" + name + "] --------" );
server.getLogger().info( "Growth Per Tick: " + growthPerTick );
+ server.getLogger().info( "Random Lighting Updates: " + randomLightingUpdates );
+ server.getLogger().info( "Mob Spawn Range: " + mobSpawnRange );
+ server.getLogger().info( "Aggregate Ticks: " + aggregateTicks );
+ server.getLogger().info( "Wheat Growth Modifier: " + wheatGrowthModifier );
+ server.getLogger().info( "Cactus Growth Modifier: " + cactusGrowthModifier );
+ server.getLogger().info( "Melon Growth Modifier: " + melonGrowthModifier );
+ server.getLogger().info( "Pumpkin Growth Modifier: " + pumpkinGrowthModifier );
+ server.getLogger().info( "Sugar Growth Modifier: " + sugarGrowthModifier );
+ server.getLogger().info( "Tree Growth Modifier: " + treeGrowthModifier );
+ server.getLogger().info( "Mushroom Growth Modifier: " + mushroomGrowthModifier );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
new file mode 100644
index 0000000..2cd806e
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -0,0 +1,19 @@
+package org.bukkit.craftbukkit;
+
+import org.bukkit.command.SimpleCommandMap;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class Spigot {
+
+ public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
+ server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
+ server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
+ server.logCommands = configuration.getBoolean("settings.log-commands", true);
+ server.commandComplete = configuration.getBoolean("settings.command-complete", true);
+ server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
+
+ if (server.chunkGCPeriod == 0) {
+ server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
index c896ba2..e99cb22 100644
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
@@ -40,7 +40,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
// See if someone already loaded this chunk while we were working on it (API, etc)
if (queuedChunk.provider.chunks.containsKey(queuedChunk.coords)) {
// Make sure it isn't queued for unload, we need it
- queuedChunk.provider.unloadQueue.remove(queuedChunk.coords);
+ queuedChunk.provider.unloadQueue.remove(x, z);
return;
}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 61a95e3..67c6c5e 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -25,6 +25,30 @@ settings:
query-plugins: true
deprecated-verbose: default
shutdown-message: Server closed
+ whitelist-message: You are not white-listed on this server!
+ log-commands: true
+ command-complete: true
+ spam-exclusions:
+ - /skill
+world-settings:
+ default:
+ growth-chunks-per-tick: 650
+ mob-spawn-range: 4
+ random-light-updates: false
+ aggregate-chunkticks: 4
+ wheat-growth-modifier: 100
+ cactus-growth-modifier: 100
+ melon-growth-modifier: 100
+ pumpkin-growth-modifier: 100
+ sugar-growth-modifier: 100
+ tree-growth-modifier: 100
+ mushroom-growth-modifier: 100
+ info: true
+ world:
+ growth-chunks-per-tick: 1000
+ world_nether:
+ growth-chunks-per-tick: 0
+ random-light-updates: true
spawn-limits:
monsters: 70
animals: 15
--
1.8.1.2

View File

@ -1,14 +1,14 @@
From 40e0140e1cf0aa8874a75e36bcf4aa32ac69a25f Mon Sep 17 00:00:00 2001
From fbb1eeb9f5d6d721eed18bbe1ffae9cc31dd8ae5 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 12:17:37 +1000
Subject: [PATCH] More Efficient GetCubes
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 96190de..dcad74f 100644
index bc692dd..afe3e4d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1043,19 +1043,47 @@ public abstract class World implements IBlockAccess {
@@ -1045,19 +1045,47 @@ public abstract class World implements IBlockAccess {
int i1 = MathHelper.floor(axisalignedbb.c);
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);

View File

@ -1,87 +1,86 @@
From e5f922057b09dca486eb700c38c9cf890ac4849e Mon Sep 17 00:00:00 2001
From 6c8715e0ffd4ce12e51b1505bab0af4908744c2e Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:22:07 +1000
Subject: [PATCH] Proxy IP Filter
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
index 0686ba0..fcd4136 100644
index 0686ba0..1254e63 100644
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -28,6 +28,7 @@ class ThreadLoginVerifier extends Thread {
public void run() {
try {
+ if (org.bukkit.craftbukkit.Spigot.filterIp(pendingConnection)) return; // Spigot
+ if (org.spigotmc.SpamHaus.filterIp(pendingConnection)) return; // Spigot
String s = (new BigInteger(MinecraftEncryption.a(PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).F().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream()));
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 2cd806e..fd90979 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,19 +1,49 @@
package org.bukkit.craftbukkit;
diff --git a/src/main/java/org/spigotmc/SpamHaus.java b/src/main/java/org/spigotmc/SpamHaus.java
new file mode 100644
index 0000000..55d8d12
--- /dev/null
+++ b/src/main/java/org/spigotmc/SpamHaus.java
@@ -0,0 +1,44 @@
+package org.spigotmc;
+
+import java.net.InetAddress;
+import net.minecraft.server.PendingConnection;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.file.YamlConfiguration;
public class Spigot {
+ private static boolean filterIps;
+
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
server.logCommands = configuration.getBoolean("settings.log-commands", true);
server.commandComplete = configuration.getBoolean("settings.command-complete", true);
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
+ filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
}
+public class SpamHaus
+{
+
+ public static boolean filterIp(PendingConnection con) {
+ if (filterIps) {
+ try {
+ private SpamHaus()
+ {
+ }
+
+ public static boolean filterIp(PendingConnection con)
+ {
+ if ( SpigotConfig.preventProxies )
+ {
+ try
+ {
+ InetAddress address = con.getSocket().getInetAddress();
+ String ip = address.getHostAddress();
+
+ if (!address.isLoopbackAddress()) {
+ String[] split = ip.split("\\.");
+ if ( !address.isLoopbackAddress() )
+ {
+ String[] split = ip.split( "\\." );
+ StringBuilder lookup = new StringBuilder();
+ for (int i = split.length - 1; i >= 0; i--) {
+ lookup.append(split[i]);
+ lookup.append(".");
+ for ( int i = split.length - 1; i >= 0; i-- )
+ {
+ lookup.append( split[i] );
+ lookup.append( "." );
+ }
+ lookup.append("xbl.spamhaus.org.");
+ if (InetAddress.getByName(lookup.toString()) != null) {
+ con.disconnect("Your IP address (" + ip + ") is flagged as unsafe by spamhaus.org/xbl");
+ lookup.append( "xbl.spamhaus.org." );
+ if ( InetAddress.getByName( lookup.toString() ) != null )
+ {
+ con.disconnect( "Your IP address (" + ip + ") is flagged as unsafe by spamhaus.org/xbl" );
+ return true;
+ }
+ }
+ } catch (Exception ex) {
+ } catch ( Exception ex )
+ {
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 1d915fb..56ac067 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -111,4 +111,10 @@ public class SpigotConfig
config.addDefault( path, def );
return config.getString( path, config.getString( path ) );
}
+
+ public static boolean preventProxies;
+ private static void preventProxies()
+ {
+ preventProxies = getBoolean( "settings.prevent-proxies", false );
+ }
}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 67c6c5e..b445808 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -30,6 +30,7 @@ settings:
command-complete: true
spam-exclusions:
- /skill
+ filter-unsafe-ips: false
world-settings:
default:
growth-chunks-per-tick: 650
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 7822f8ff9ad9fc4ef9b4a9a3e3e105107de2f4a0 Mon Sep 17 00:00:00 2001
From 7ec8ae26036858173a7c318944efa17ad2100cea Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:46:33 +1100
Subject: [PATCH] Merge tweaks and configuration
@ -6,7 +6,7 @@ Subject: [PATCH] Merge tweaks and configuration
This allows the merging of Experience orbs, as well as the configuration of the merge radius of items. Additionally it refactors the merge algorithm to be a better experience for players.
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index 0225f53..294ab8f 100644
index 0225f53..048e8fa 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -114,7 +114,10 @@ public class EntityItem extends Entity {
@ -15,7 +15,7 @@ index 0225f53..294ab8f 100644
private void g() {
- Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
+ // Spigot start
+ double radius = world.getWorld().itemMergeRadius;
+ double radius = world.spigotConfig.itemMerge;
+ Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
+ // Spigot end
@ -41,17 +41,17 @@ index 0225f53..294ab8f 100644
}
} else {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index dcad74f..a0c61a1 100644
index afe3e4d..97da2cd 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -955,6 +955,23 @@ public abstract class World implements IBlockAccess {
@@ -957,6 +957,23 @@ public abstract class World implements IBlockAccess {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
+ // Spigot start
+ else if (entity instanceof EntityExperienceOrb) {
+ EntityExperienceOrb xp = (EntityExperienceOrb) entity;
+ double radius = this.getWorld().expMergeRadius;
+ double radius = spigotConfig.expMerge;
+ if (radius > 0) {
+ List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
+ for (Entity e : entities) {
@ -68,60 +68,29 @@ index dcad74f..a0c61a1 100644
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 9789ba4..d0e6d6f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -80,6 +80,9 @@ public class CraftWorld implements World {
public int sugarGrowthModifier = 100;
public int treeGrowthModifier = 100;
public int mushroomGrowthModifier = 100;
+ // Merge radius:
+ public double itemMergeRadius = 3.5;
+ public double expMergeRadius = 3.5;
// Spigot end
// Spigot start
@@ -114,6 +117,8 @@ public class CraftWorld implements World {
sugarGrowthModifier = configuration.getInt( "world-settings.default.sugar-growth-modifier", sugarGrowthModifier );
treeGrowthModifier = configuration.getInt( "world-settings.default.tree-growth-modifier", treeGrowthModifier );
mushroomGrowthModifier = configuration.getInt( "world-settings.default.mushroom-growth-modifier", mushroomGrowthModifier );
+ itemMergeRadius = configuration.getDouble("world-settings.default.item-merge-radius", itemMergeRadius);
+ expMergeRadius = configuration.getDouble("world-settings.default.exp-merge-radius", expMergeRadius);
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
@@ -128,6 +133,8 @@ public class CraftWorld implements World {
sugarGrowthModifier = configuration.getInt( "world-settings." + name + ".sugar-growth-modifier", sugarGrowthModifier );
treeGrowthModifier = configuration.getInt( "world-settings." + name + ".tree-growth-modifier", treeGrowthModifier );
mushroomGrowthModifier = configuration.getInt( "world-settings." + name + ".mushroom-growth-modifier", mushroomGrowthModifier );
+ itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius);
+ expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius);
if ( info )
{
@@ -144,6 +151,8 @@ public class CraftWorld implements World {
server.getLogger().info( "Sugar Growth Modifier: " + sugarGrowthModifier );
server.getLogger().info( "Tree Growth Modifier: " + treeGrowthModifier );
server.getLogger().info( "Mushroom Growth Modifier: " + mushroomGrowthModifier );
+ server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
+ server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index b445808..56873b6 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -37,6 +37,8 @@ world-settings:
mob-spawn-range: 4
random-light-updates: false
aggregate-chunkticks: 4
+ item-merge-radius: 3.5
+ exp-merge-radius: 3.5
wheat-growth-modifier: 100
cactus-growth-modifier: 100
melon-growth-modifier: 100
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 3ec38a1..8a6d656 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -102,4 +102,18 @@ public class SpigotWorldConfig
wheatModifier = getInt( "growth.wheat-modifier", 100 );
log( "Wheat Growth Modifier: " + wheatModifier + "%" );
}
+
+ public double itemMerge;
+ private void itemMerge()
+ {
+ itemMerge = getDouble("merge-radius.item", 2.5 );
+ log( "Item Merge Radius: " + itemMerge );
+ }
+
+ public double expMerge;
+ private void expMerge()
+ {
+ expMerge = getDouble("merge-radius.exp", 3.0 );
+ log( "Experience Merge Radius: " + expMerge );
+ }
}
--
1.8.1.2

View File

@ -1,119 +1,107 @@
From a11aa1e2aecca3e245bb003b7caf9e4287e14271 Mon Sep 17 00:00:00 2001
From aa15e3095f30c11c90f034e2b1b9ebbe08337c56 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:29:43 +1100
Subject: [PATCH] LongHash Tweaks.
Date: Fri, 21 Jun 2013 17:13:47 +1000
Subject: [PATCH] LongHash Tweaks
This commit adds a flat array based cache to the LongHash(Set/Map) classes leading to excellent efficiency for servers where most activity is centered around the origin (0,0)
diff --git a/src/main/java/org/bukkit/craftbukkit/util/FlatMap.java b/src/main/java/org/bukkit/craftbukkit/util/FlatMap.java
new file mode 100644
index 0000000..e8a7725
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/util/FlatMap.java
@@ -0,0 +1,34 @@
+package org.bukkit.craftbukkit.util;
+
+public class FlatMap<V> {
+
+ private static final int FLAT_LOOKUP_SIZE = 512;
+ private final Object[][] flatLookup = new Object[FLAT_LOOKUP_SIZE * 2][FLAT_LOOKUP_SIZE * 2];
+
+ public void put(long msw, long lsw, V value) {
+ long acx = Math.abs(msw);
+ long acz = Math.abs(lsw);
+ if (acx < FLAT_LOOKUP_SIZE && acz < FLAT_LOOKUP_SIZE) {
+ flatLookup[(int) (msw + FLAT_LOOKUP_SIZE)][(int) (lsw + FLAT_LOOKUP_SIZE)] = value;
+ }
+ }
+
+ public void put(long key, V value) {
+ put(LongHash.msw(key), LongHash.lsw(key), value);
+
+ }
+
+ public V get(long msw, long lsw) {
+ long acx = Math.abs(msw);
+ long acz = Math.abs(lsw);
+ if (acx < FLAT_LOOKUP_SIZE && acz < FLAT_LOOKUP_SIZE) {
+ return (V) flatLookup[(int) (msw + FLAT_LOOKUP_SIZE)][(int) (lsw + FLAT_LOOKUP_SIZE)];
+ } else {
+ return null;
+ }
+ }
+
+ public V get(long key) {
+ return get(LongHash.msw(key), LongHash.lsw(key));
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
index 22c96c5..331d570 100644
index 22c96c5..7c3005e 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
@@ -31,6 +31,8 @@ public class LongHashSet {
@@ -31,6 +31,7 @@ public class LongHashSet {
private int elements;
private long[] values;
private int modCount;
+ private static final Object PRESENT = new Object();
+ private final FlatMap<Object> flat = new FlatMap<Object>();
+ private org.spigotmc.FlatMap<Boolean> flat = new org.spigotmc.FlatMap<Boolean>(); // Spigot
public LongHashSet() {
this(INITIAL_SIZE);
@@ -56,10 +58,12 @@ public class LongHashSet {
@@ -56,10 +57,22 @@ public class LongHashSet {
}
public boolean contains(int msw, int lsw) {
+ if (flat.get(msw, lsw) != null) return true; // Spigot
+ // Spigot start
+ if ( flat.contains( msw, lsw ) )
+ {
+ return true;
+ }
+ // Spigot end
return contains(LongHash.toLong(msw, lsw));
}
public boolean contains(long value) {
+ if (flat.get(value) != null) return true; // Spigot
+ // Spigot start
+ if ( flat.contains( value ) )
+ {
+ return true;
+ }
+ // Spigot end
int hash = hash(value);
int index = (hash & 0x7FFFFFFF) % values.length;
int offset = 1;
@@ -82,6 +86,7 @@ public class LongHashSet {
@@ -82,6 +95,7 @@ public class LongHashSet {
}
public boolean add(long value) {
+ flat.put(value, PRESENT); // Spigot
+ flat.put( value, Boolean.TRUE ); // Spigot
int hash = hash(value);
int index = (hash & 0x7FFFFFFF) % values.length;
int offset = 1;
@@ -125,10 +130,11 @@ public class LongHashSet {
@@ -125,10 +139,18 @@ public class LongHashSet {
}
public void remove(int msw, int lsw) {
+ flat.put(msw, lsw, null); // Spigot
remove(LongHash.toLong(msw, lsw));
- remove(LongHash.toLong(msw, lsw));
+ // Spigot start
+ flat.remove(msw, lsw);
+ remove0(LongHash.toLong(msw, lsw));
}
- public boolean remove(long value) {
+ private boolean remove(long value) { // Spigot
public boolean remove(long value) {
+ flat.remove(value);
+ return remove0(value);
+ }
+
+ private boolean remove0(long value) {
+ // Spigot end
int hash = hash(value);
int index = (hash & 0x7FFFFFFF) % values.length;
int offset = 1;
@@ -161,6 +183,7 @@ public class LongHashSet {
freeEntries = values.length;
modCount++;
+ flat = new org.spigotmc.FlatMap<Boolean>();
}
public long[] toArray() {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java b/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java
index 01861cc..dbd33fa 100644
index 01861cc..08b543b 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java
@@ -28,6 +28,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
private transient V[][] values;
private transient int modCount;
private transient int size;
+ private final FlatMap<V> flat = new FlatMap<V>(); // Spigot
+ private transient org.spigotmc.FlatMap<V> flat = new org.spigotmc.FlatMap<V>(); // Spigot
public LongObjectHashMap() {
initialize();
@@ -61,6 +62,8 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
@@ -61,6 +62,13 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
}
public V get(long key) {
+ V val = flat.get(key); // Spigot
+ if (val != null) return val; // Spigot
+ // Spigot start
+ V val = flat.get( key );
+ if ( val != null )
+ {
+ return val;
+ }
+ // Spigot end
int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1));
long[] inner = keys[index];
if (inner == null) return null;
@@ -78,6 +81,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
@@ -78,6 +86,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
}
public V put(long key, V value) {
@ -121,14 +109,92 @@ index 01861cc..dbd33fa 100644
int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1));
long[] innerKeys = keys[index];
V[] innerValues = values[index];
@@ -124,6 +128,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
@@ -124,6 +133,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
}
public V remove(long key) {
+ flat.put(key, null); // Spigot
+ flat.remove(key); // Spigot
int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1));
long[] inner = keys[index];
if (inner == null) {
@@ -174,6 +184,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
size = 0;
Arrays.fill(keys, null);
Arrays.fill(values, null);
+ flat = new org.spigotmc.FlatMap<V>();
}
public Set<Long> keySet() {
diff --git a/src/main/java/org/spigotmc/FlatMap.java b/src/main/java/org/spigotmc/FlatMap.java
new file mode 100644
index 0000000..9416f6e
--- /dev/null
+++ b/src/main/java/org/spigotmc/FlatMap.java
@@ -0,0 +1,64 @@
+package org.spigotmc;
+
+import org.bukkit.craftbukkit.util.LongHash;
+
+public class FlatMap<V>
+{
+
+ private static final int FLAT_LOOKUP_SIZE = 512;
+ private final Object[][] flatLookup = new Object[ FLAT_LOOKUP_SIZE * 2 ][ FLAT_LOOKUP_SIZE * 2 ];
+
+ public void put(long msw, long lsw, V value)
+ {
+ long acx = Math.abs( msw );
+ long acz = Math.abs( lsw );
+ if ( acx < FLAT_LOOKUP_SIZE && acz < FLAT_LOOKUP_SIZE )
+ {
+ flatLookup[(int) ( msw + FLAT_LOOKUP_SIZE )][(int) ( lsw + FLAT_LOOKUP_SIZE )] = value;
+ }
+ }
+
+ public void put(long key, V value)
+ {
+ put( LongHash.msw( key ), LongHash.lsw( key ), value );
+
+ }
+
+ public void remove(long key)
+ {
+ put( key, null );
+ }
+
+ public void remove(long msw, long lsw)
+ {
+ put( msw, lsw, null );
+ }
+
+ public boolean contains(long msw, long lsw)
+ {
+ return get( msw, lsw ) != null;
+ }
+
+ public boolean contains(long key)
+ {
+ return get( key ) != null;
+ }
+
+ public V get(long msw, long lsw)
+ {
+ long acx = Math.abs( msw );
+ long acz = Math.abs( lsw );
+ if ( acx < FLAT_LOOKUP_SIZE && acz < FLAT_LOOKUP_SIZE )
+ {
+ return (V) flatLookup[(int) ( msw + FLAT_LOOKUP_SIZE )][(int) ( lsw + FLAT_LOOKUP_SIZE )];
+ } else
+ {
+ return null;
+ }
+ }
+
+ public V get(long key)
+ {
+ return get( LongHash.msw( key ), LongHash.lsw( key ) );
+ }
+}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 10ca32f973eaccc4eab615b966b195c90555c916 Mon Sep 17 00:00:00 2001
From a8c529d46c95e00dc30e16fec26a5af608e2db78 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] Async Operation Catching
@ -46,10 +46,10 @@ index 5c03732..5f3c780 100644
this.trackedPlayers.remove(entityplayer);
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index a0c61a1..1afc717 100644
index d7e5301..e353caa 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -924,6 +924,7 @@ public abstract class World implements IBlockAccess {
@@ -926,6 +926,7 @@ public abstract class World implements IBlockAccess {
}
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
@ -57,7 +57,7 @@ index a0c61a1..1afc717 100644
if (entity == null) return false;
// CraftBukkit end
@@ -1030,6 +1031,7 @@ public abstract class World implements IBlockAccess {
@@ -1032,6 +1033,7 @@ public abstract class World implements IBlockAccess {
}
public void removeEntity(Entity entity) {
@ -65,7 +65,7 @@ index a0c61a1..1afc717 100644
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
@@ -2447,6 +2449,7 @@ public abstract class World implements IBlockAccess {
@@ -2449,6 +2451,7 @@ public abstract class World implements IBlockAccess {
}
public void a(List list) {
@ -74,10 +74,10 @@ index a0c61a1..1afc717 100644
Entity entity = null;
for (int i = 0; i < list.size(); ++i) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d0e6d6f..d49393d 100644
index c0fb528..edc59b1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -239,6 +239,7 @@ public class CraftWorld implements World {
@@ -160,6 +160,7 @@ public class CraftWorld implements World {
}
public boolean unloadChunkRequest(int x, int z, boolean safe) {
@ -85,7 +85,7 @@ index d0e6d6f..d49393d 100644
if (safe && isChunkInUse(x, z)) {
return false;
}
@@ -249,6 +250,7 @@ public class CraftWorld implements World {
@@ -170,6 +171,7 @@ public class CraftWorld implements World {
}
public boolean unloadChunk(int x, int z, boolean save, boolean safe) {
@ -93,7 +93,7 @@ index d0e6d6f..d49393d 100644
if (safe && isChunkInUse(x, z)) {
return false;
}
@@ -316,6 +318,7 @@ public class CraftWorld implements World {
@@ -237,6 +239,7 @@ public class CraftWorld implements World {
}
public boolean loadChunk(int x, int z, boolean generate) {

View File

@ -1,4 +1,4 @@
From 7b1f1f56d04030711b34d012ffc342f5fe9c9bb4 Mon Sep 17 00:00:00 2001
From 25fa2cfa4437bbbe2eb832d7ec12070d8842a087 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:52:41 +1100
Subject: [PATCH] View Distance
@ -19,60 +19,34 @@ index 0dfd190..c543bed 100644
} else {
this.e = i;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4a8d3f4..5375cb3 100644
index 6c3fcf1..614a17f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -49,7 +49,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -48,7 +48,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit end
this.server = minecraftserver;
this.tracker = new EntityTracker(this);
- this.manager = new PlayerChunkMap(this, minecraftserver.getPlayerList().o());
+ this.manager = new PlayerChunkMap(this, getWorld().viewDistance); // Spigot
+ this.manager = new PlayerChunkMap(this, spigotConfig.viewDistance); // Spigot
if (this.entitiesById == null) {
this.entitiesById = new IntHashMap();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d49393d..4d022bd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -83,6 +83,7 @@ public class CraftWorld implements World {
// Merge radius:
public double itemMergeRadius = 3.5;
public double expMergeRadius = 3.5;
+ public int viewDistance;
// Spigot end
// Spigot start
@@ -136,6 +137,9 @@ public class CraftWorld implements World {
itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius);
expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius);
+ viewDistance = Bukkit.getServer().getViewDistance();
+ viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index ea7c211..81879e6 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -116,4 +116,11 @@ public class SpigotWorldConfig
expMerge = getDouble("merge-radius.exp", 3.0 );
log( "Experience Merge Radius: " + expMerge );
}
+
if ( info )
{
server.getLogger().info( "-------------- Spigot ----------------" );
@@ -153,6 +157,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Mushroom Growth Modifier: " + mushroomGrowthModifier );
server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
+ server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 56873b6..fe257e2 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -50,6 +50,7 @@ world-settings:
world:
growth-chunks-per-tick: 1000
world_nether:
+ view-distance: 5
growth-chunks-per-tick: 0
random-light-updates: true
spawn-limits:
+ public int viewDistance;
+ private void viewDistance()
+ {
+ viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
+ log( "View Distance: " + viewDistance );
+ }
}
--
1.8.1.2

View File

@ -1,14 +1,14 @@
From a0681b71d66fe6a689ce28fd157ca6d7c07ff3a9 Mon Sep 17 00:00:00 2001
From 27aa389075a5b22ffad6e7c8d4d42b9315aa1bc0 Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 16 Jan 2013 15:27:22 -0600
Subject: [PATCH] Sync Free Chunk Reference Cache
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1afc717..c00aa57 100644
index e353caa..a81e06d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -299,15 +299,13 @@ public abstract class World implements IBlockAccess {
@@ -301,15 +301,13 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start
public Chunk getChunkAt(int i, int j) {

View File

@ -1,4 +1,4 @@
From 1925b6e7b2f1f3f5673a20d5fd5e72c6c3effe2a Mon Sep 17 00:00:00 2001
From ac8a1f6656ae9cd13e08c9e25b379769c9a6c7ae Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 12:28:17 +1100
Subject: [PATCH] Highly Optimized Tick Loop
@ -75,19 +75,6 @@ index 3e134fb..3c80340 100644
} else {
this.a((CrashReport) null);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index fd90979..67477f4 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -10,6 +10,8 @@ public class Spigot {
private static boolean filterIps;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
+ commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
+
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
server.logCommands = configuration.getBoolean("settings.log-commands", true);
diff --git a/src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java b/src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java
new file mode 100644
index 0000000..f114a31
@ -129,6 +116,28 @@ index 0000000..f114a31
+ return true;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 56ac067..d22e8e5 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -14,6 +14,7 @@ import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.craftbukkit.command.TicksPerSecondCommand;
public class SpigotConfig
{
@@ -117,4 +118,9 @@ public class SpigotConfig
{
preventProxies = getBoolean( "settings.prevent-proxies", false );
}
+
+ private static void tpsCommand()
+ {
+ commands.put( "tps", new TicksPerSecondCommand( "tps" ) );
+ }
}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 5f3f94a427dbc6c59a8cb7c9171f4961699ec34f Mon Sep 17 00:00:00 2001
From 6a85506600fad57b57f604edc72a6ef581d12845 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
Subject: [PATCH] Improved Timings System
@ -213,10 +213,10 @@ index 3c80340..db396b3 100644
this.methodProfiler.b();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index f6885d6..86a0acc 100644
index 018c314..8deba1b 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -968,6 +968,7 @@ public class PlayerConnection extends Connection {
@@ -956,6 +956,7 @@ public class PlayerConnection extends Connection {
// CraftBukkit end
private void handleCommand(String s) {
@ -224,7 +224,7 @@ index f6885d6..86a0acc 100644
// CraftBukkit start
CraftPlayer player = this.getPlayer();
@@ -975,19 +976,23 @@ public class PlayerConnection extends Connection {
@@ -963,19 +964,23 @@ public class PlayerConnection extends Connection {
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -233,7 +233,7 @@ index f6885d6..86a0acc 100644
}
try {
if (server.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
@ -266,7 +266,7 @@ index db3fc42..ffa9bb6 100644
private static Map b = new HashMap();
protected World world;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index c00aa57..4a5894a 100644
index a81e06d..da069f7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
@ -277,16 +277,16 @@ index c00aa57..4a5894a 100644
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.CraftServer;
@@ -122,6 +123,8 @@ public abstract class World implements IBlockAccess {
int lastZAccessed = Integer.MIN_VALUE;
@@ -123,6 +124,8 @@ public abstract class World implements IBlockAccess {
final Object chunkLock = new Object();
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+
public CraftWorld getWorld() {
return this.world;
}
@@ -199,6 +202,7 @@ public abstract class World implements IBlockAccess {
@@ -201,6 +204,7 @@ public abstract class World implements IBlockAccess {
this.a();
this.getServer().addWorld(this.world); // CraftBukkit
@ -294,7 +294,7 @@ index c00aa57..4a5894a 100644
}
protected abstract IChunkProvider j();
@@ -1271,6 +1275,7 @@ public abstract class World implements IBlockAccess {
@@ -1273,6 +1277,7 @@ public abstract class World implements IBlockAccess {
this.f.clear();
this.methodProfiler.c("regular");
@ -302,7 +302,7 @@ index c00aa57..4a5894a 100644
for (i = 0; i < this.entityList.size(); ++i) {
entity = (Entity) this.entityList.get(i);
@@ -1293,7 +1298,9 @@ public abstract class World implements IBlockAccess {
@@ -1295,7 +1300,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.a("tick");
if (!entity.dead) {
try {
@ -312,7 +312,7 @@ index c00aa57..4a5894a 100644
} catch (Throwable throwable1) {
crashreport = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails = crashreport.a("Entity being ticked");
@@ -1318,7 +1325,9 @@ public abstract class World implements IBlockAccess {
@@ -1320,7 +1327,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
}
@ -322,7 +322,7 @@ index c00aa57..4a5894a 100644
this.N = true;
Iterator iterator = this.tileEntityList.iterator();
@@ -1333,8 +1342,11 @@ public abstract class World implements IBlockAccess {
@@ -1335,8 +1344,11 @@ public abstract class World implements IBlockAccess {
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
try {
@ -334,7 +334,7 @@ index c00aa57..4a5894a 100644
crashreport = CrashReport.a(throwable2, "Ticking tile entity");
crashreportsystemdetails = crashreport.a("Tile entity being ticked");
tileentity.a(crashreportsystemdetails);
@@ -1354,6 +1366,8 @@ public abstract class World implements IBlockAccess {
@@ -1356,6 +1368,8 @@ public abstract class World implements IBlockAccess {
}
}
@ -343,7 +343,7 @@ index c00aa57..4a5894a 100644
this.N = false;
if (!this.b.isEmpty()) {
this.tileEntityList.removeAll(this.b);
@@ -1392,6 +1406,7 @@ public abstract class World implements IBlockAccess {
@@ -1394,6 +1408,7 @@ public abstract class World implements IBlockAccess {
this.a.clear();
}
@ -351,7 +351,7 @@ index c00aa57..4a5894a 100644
this.methodProfiler.b();
this.methodProfiler.b();
}
@@ -1414,6 +1429,7 @@ public abstract class World implements IBlockAccess {
@@ -1416,6 +1431,7 @@ public abstract class World implements IBlockAccess {
byte b0 = 32;
if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
@ -359,7 +359,7 @@ index c00aa57..4a5894a 100644
entity.U = entity.locX;
entity.V = entity.locY;
entity.W = entity.locZ;
@@ -1475,6 +1491,7 @@ public abstract class World implements IBlockAccess {
@@ -1477,6 +1493,7 @@ public abstract class World implements IBlockAccess {
entity.passenger = null;
}
}
@ -368,10 +368,10 @@ index c00aa57..4a5894a 100644
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 5375cb3..7b8e70c 100644
index 614a17f..69d955f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -184,9 +184,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -183,9 +183,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
long time = this.worldData.getTime();
if (this.getGameRules().getBoolean("doMobSpawning") && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
@ -384,7 +384,7 @@ index 5375cb3..7b8e70c 100644
this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks();
int j = this.a(1.0F);
@@ -197,21 +200,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -196,21 +199,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.worldData.setTime(this.worldData.getTime() + 1L);
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);

View File

@ -1,47 +1,47 @@
From d270363d40175512df3af1f7dbbb4722d6ab684a Mon Sep 17 00:00:00 2001
From 90de56da643bde4b842cc958a4b449634bb9ba8c Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Thu, 16 May 2013 18:51:05 +1000
Subject: [PATCH] Orebfuscator
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index 17d837d..d38eb4d 100644
index 17d837d..c7cd0ca 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -94,6 +94,7 @@ public class EntityFallingBlock extends Entity {
}
this.world.setAir(i, j, k);
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
}
if (this.onGround) {
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index ef220c1..ae1cee9 100644
index ef220c1..2063769 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -240,6 +240,7 @@ public class Explosion {
j = chunkposition.y;
k = chunkposition.z;
l = this.world.getTypeId(i, j, k);
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
if (flag) {
double d0 = (double) ((float) i + this.world.random.nextFloat());
double d1 = (double) ((float) j + this.world.random.nextFloat());
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
index d11c0ea..7711629 100644
index d11c0ea..efe102e 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -46,6 +46,7 @@ public class Packet51MapChunk extends Packet {
this.d = chunkmap.c;
this.c = chunkmap.b;
+ org.spigotmc.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot
+ chunk.world.spigotConfig.antiXrayInstance.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot
try {
this.inflatedBuffer = chunkmap.a;
diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
index 129dc4f..ce28495 100644
index 129dc4f..a2cd9b0 100644
--- a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
+++ b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
@@ -28,6 +28,7 @@ public class Packet56MapChunkBulk extends Packet {
@ -79,7 +79,7 @@ index 129dc4f..ce28495 100644
+ int finalBufferSize = 0;
+ // Obfuscate all sections
+ for (int i = 0; i < a.length; i++) {
+ org.spigotmc.OrebfuscatorManager.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
+ world.spigotConfig.antiXrayInstance.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
+ finalBufferSize += inflatedBuffers[i].length;
+ }
+
@ -95,110 +95,45 @@ index 129dc4f..ce28495 100644
Deflater deflater = localDeflater.get();
deflater.reset();
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index 1243d1d..e45bcd2 100644
index 1243d1d..9ec8997 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -184,6 +184,7 @@ public class PlayerInteractManager {
this.o = j1;
}
}
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c234cac..82dfef1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -163,6 +163,12 @@ public final class CraftServer implements Server {
private final BooleanWrapper online = new BooleanWrapper();
public CraftScoreboardManager scoreboardManager;
+ // Orebfuscator use
+ public boolean orebfuscatorEnabled = false;
+ public int orebfuscatorEngineMode = 1;
+ public List<String> orebfuscatorDisabledWorlds;
+ public List<Short> orebfuscatorBlocks;
+
private final class BooleanWrapper {
private boolean value = true;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4d022bd..0a39ed3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -84,6 +84,7 @@ public class CraftWorld implements World {
public double itemMergeRadius = 3.5;
public double expMergeRadius = 3.5;
public int viewDistance;
+ public boolean obfuscated = false;
// Spigot end
// Spigot start
@@ -139,6 +140,7 @@ public class CraftWorld implements World {
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
+ obfuscated = world.getServer().orebfuscatorEnabled && !world.getServer().orebfuscatorDisabledWorlds.contains( name );
if ( info )
{
@@ -158,6 +160,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
server.getLogger().info( "View distance: " + viewDistance );
+ server.getLogger().info( "Orebfuscator: " + obfuscated );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 67477f4..e5004b3 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -19,6 +19,14 @@ public class Spigot {
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
+ server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
+ server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
+ server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
+ server.orebfuscatorBlocks = configuration.getShortList("orebfuscator.blocks");
+ if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
+ server.orebfuscatorEngineMode = 1;
+ }
+
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
diff --git a/src/main/java/org/spigotmc/OrebfuscatorManager.java b/src/main/java/org/spigotmc/OrebfuscatorManager.java
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
new file mode 100644
index 0000000..aa1ddfc
index 0000000..c29b789
--- /dev/null
+++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java
@@ -0,0 +1,204 @@
+++ b/src/main/java/org/spigotmc/AntiXray.java
@@ -0,0 +1,203 @@
+package org.spigotmc;
+
+import gnu.trove.set.TByteSet;
+import gnu.trove.set.hash.TByteHashSet;
+import net.minecraft.server.Block;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.World;
+
+public class OrebfuscatorManager
+public class AntiXray
+{
+
+ private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" );
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" );
+ /*========================================================================*/
+ // Used to keep track of which blocks to obfuscate
+ private static final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
+ private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
+ // Used to select a random replacement ore
+ private static byte[] replacementOres;
+ private byte[] replacementOres;
+
+ static
+ public AntiXray(SpigotWorldConfig config)
+ {
+ // Set all listed blocks as true to be obfuscated
+ for ( short id : MinecraftServer.getServer().server.orebfuscatorBlocks )
+ for ( int id : config.blocks )
+ {
+ obfuscateBlocks[id] = true;
+ }
@ -227,9 +162,9 @@ index 0000000..aa1ddfc
+ * Starts the timings handler, then updates all blocks within the set radius
+ * of the given coordinate, revealing them if they are hidden ores.
+ */
+ public static void updateNearbyBlocks(World world, int x, int y, int z)
+ public void updateNearbyBlocks(World world, int x, int y, int z)
+ {
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ update.startTiming();
+ updateNearbyBlocks( world, x, y, z, 2 ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
@ -241,9 +176,9 @@ index 0000000..aa1ddfc
+ * Starts the timings handler, and then removes all non exposed ores from
+ * the chunk buffer.
+ */
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ {
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ obfuscate.startTiming();
+ obfuscate( chunkX, chunkY, bitmask, buffer, world );
@ -254,10 +189,10 @@ index 0000000..aa1ddfc
+ /**
+ * Removes all non exposed ores from the chunk buffer.
+ */
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ public void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ {
+ // If the world is marked as obfuscated
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ // Initial radius to search around for air
+ int initialRadius = 1;
@ -297,7 +232,7 @@ index 0000000..aa1ddfc
+ // On the otherhand, if radius is 0, or the nearby blocks are all non air, we can obfuscate
+ if ( initialRadius == 0 || !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
+ {
+ switch ( world.getServer().orebfuscatorEngineMode )
+ switch ( world.spigotConfig.engineMode )
+ {
+ case 1:
+ // Replace with stone
@ -328,7 +263,7 @@ index 0000000..aa1ddfc
+ }
+ }
+
+ private static void updateNearbyBlocks(World world, int x, int y, int z, int radius)
+ private void updateNearbyBlocks(World world, int x, int y, int z, int radius)
+ {
+ // If the block in question is loaded
+ if ( world.isLoaded( x, y, z ) )
@ -380,20 +315,43 @@ index 0000000..aa1ddfc
+ || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
+ }
+}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index fe257e2..7860ccc 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -81,3 +81,9 @@ database:
driver: org.sqlite.JDBC
password: walrus
url: jdbc:sqlite:{DIR}{NAME}.db
+orebfuscator:
+ enable: false
+ engine-mode: 1
+ disabled-worlds:
+ - world_the_end
+ blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 81879e6..0a304e8 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -1,5 +1,6 @@
package org.spigotmc;
+import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -123,4 +124,25 @@ public class SpigotWorldConfig
viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
log( "View Distance: " + viewDistance );
}
+
+ public boolean antiXray = true;
+ public int engineMode = 1;
+ public List<Integer> blocks = Arrays.asList( new Integer[]
+ {
+ 1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
+ } );
+ public AntiXray antiXrayInstance;
+ private void antiXray()
+ {
+ antiXray = getBoolean( "anti-xray.enabled", antiXray );
+ log( "Anti X-Ray: " + antiXray );
+
+ engineMode = getInt( "anti-xray.engine-mode", engineMode );
+ log( "\tEngine Mode: " + engineMode );
+
+ blocks = getList( "anti-xray.blocks", blocks );
+ log( "\tBlocks: " + blocks );
+
+ antiXrayInstance = new AntiXray( this );
+ }
}
--
1.8.1.2

View File

@ -0,0 +1,141 @@
From d1a43b7d46685cdaa095ef806f9300db709c5d84 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:29:54 +1000
Subject: [PATCH] Fix Mob Spawning Relative to View Distance
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7416edc..e8d30c5 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -33,6 +33,7 @@ public class Chunk {
public int p;
private int u;
boolean q;
+ protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
@@ -560,6 +561,15 @@ public class Chunk {
entity.ak = k;
entity.al = this.z;
this.entitySlices[k].add(entity);
+ // Spigot start - increment creature type count
+ for ( EnumCreatureType creatureType : EnumCreatureType.values() )
+ {
+ if ( creatureType.a().isAssignableFrom( entity.getClass() ) )
+ {
+ this.entityCount.adjustOrPutValue( creatureType.a(), 1, 1 );
+ }
+ }
+ // Spigot end
}
public void b(Entity entity) {
@@ -576,6 +586,15 @@ public class Chunk {
}
this.entitySlices[i].remove(entity);
+ // Spigot start - decrement creature type count
+ for ( EnumCreatureType creatureType : EnumCreatureType.values() )
+ {
+ if ( creatureType.a().isAssignableFrom( entity.getClass() ) )
+ {
+ this.entityCount.adjustValue( creatureType.a(), -1 );
+ }
+ }
+ // Spigot end
}
public boolean d(int i, int j, int k) {
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 056100f..bec0d91 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -26,6 +26,23 @@ public final class SpawnerCreature {
return new ChunkPosition(k, i1, l);
}
+ // Spigot start - get entity count only from chunks being processed in b
+ private static int getEntityCount(WorldServer server, Class oClass)
+ {
+ int i = 0;
+ for ( Long coord : b.keySet() )
+ {
+ int x = LongHash.msw( coord );
+ int z = LongHash.lsw( coord );
+ if ( !server.chunkProviderServer.unloadQueue.contains( coord ) && server.isChunkLoaded( x, z ) )
+ {
+ i += server.getChunkAt( x, z ).entityCount.get( oClass );
+ }
+ }
+ return i;
+ }
+ // Spigot end
+
public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) {
if (!flag && !flag1) {
return 0;
@@ -41,6 +58,11 @@ public final class SpawnerCreature {
j = MathHelper.floor(entityhuman.locZ / 16.0D);
byte b0 = 8;
+ // Spigot Start
+ b0 = worldserver.spigotConfig.mobSpawnRange;
+ b0 = ( b0 > worldserver.spigotConfig.viewDistance ) ? (byte) worldserver.spigotConfig.viewDistance : b0;
+ b0 = ( b0 > 8 ) ? 8 : b0;
+ // Spigot End
for (int l = -b0; l <= b0; ++l) {
for (int i1 = -b0; i1 <= b0; ++i1) {
@@ -88,13 +110,15 @@ public final class SpawnerCreature {
if (limit == 0) {
continue;
}
+ int mobcnt = 0;
// CraftBukkit end
- if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
+ if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && (mobcnt = getEntityCount(worldserver, enumcreaturetype.a())) <= limit * b.size() / 256) { // Spigot - use per-world limits and use all loaded chunks
Iterator iterator = b.keySet().iterator();
+ int moblimit = (limit * b.size() / 256) - mobcnt + 1; // Spigot - up to 1 more than limit
label110:
- while (iterator.hasNext()) {
+ while (iterator.hasNext() && (moblimit > 0)) { // Spigot - while more allowed
// CraftBukkit start
long key = ((Long) iterator.next()).longValue();
@@ -158,6 +182,13 @@ public final class SpawnerCreature {
a(entityliving, worldserver, f, f1, f2);
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
// CraftBukkit end
+ // Spigot start
+ if ( --moblimit <= 0 )
+ {
+ // If we're past limit, stop spawn
+ continue label110;
+ }
+ // Spigot end
if (j2 >= entityliving.by()) {
continue label110;
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 0a304e8..6c2a430 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -145,4 +145,11 @@ public class SpigotWorldConfig
antiXrayInstance = new AntiXray( this );
}
+
+ public byte mobSpawnRange;
+ private void mobSpawnRange()
+ {
+ mobSpawnRange = (byte) getInt( "mob-spawn-range", 4 );
+ log( "Mob Spawn Range: " + mobSpawnRange );
+ }
}
--
1.8.1.2

View File

@ -1,106 +0,0 @@
From e5c58163b2c1be562f43b9b90132400d7af1b507 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 29 Jan 2013 13:25:53 -0500
Subject: [PATCH] Only count entities in chunks being processed for the spawn
wave. Fixes mob spawn issues.
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 056100f..3529074 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -16,6 +16,7 @@ public final class SpawnerCreature {
private static LongObjectHashMap<Boolean> b = new LongObjectHashMap<Boolean>(); // CraftBukkit - HashMap -> LongObjectHashMap
protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class};
+ private static byte spawnRadius = 0; // Spigot
protected static ChunkPosition getRandomPosition(World world, int i, int j) {
Chunk chunk = world.getChunkAt(i, j);
@@ -26,6 +27,26 @@ public final class SpawnerCreature {
return new ChunkPosition(k, i1, l);
}
+ // Spigot start - get entity count only from chunks being processed in b
+ public static final int getEntityCount(WorldServer server, Class oClass) {
+ int i = 0;
+ for (Long coord : b.keySet()) {
+ int x = LongHash.msw(coord);
+ int z = LongHash.lsw(coord);
+ if (!server.chunkProviderServer.unloadQueue.contains(x,z) && server.isChunkLoaded(x, z)) {
+ for (List<Entity> entitySlice : server.getChunkAt(x, z).entitySlices) {
+ for (Entity entity : entitySlice) {
+ if (oClass.isAssignableFrom(entity.getClass())) {
+ ++i;
+ }
+ }
+ }
+ }
+ }
+ return i;
+ }
+ // Spigot end
+
public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) {
if (!flag && !flag1) {
return 0;
@@ -34,13 +55,24 @@ public final class SpawnerCreature {
int i;
int j;
+ // Spigot start - limit radius to spawn distance (chunks aren't loaded)
+ if (spawnRadius == 0) {
+ spawnRadius = (byte) worldserver.getWorld().mobSpawnRange;
+ if (spawnRadius > (byte) worldserver.getServer().getViewDistance()) {
+ spawnRadius = (byte) worldserver.getServer().getViewDistance();
+ }
+ if (spawnRadius > 8) {
+ spawnRadius = 8;
+ }
+ }
+ // Spigot end
for (i = 0; i < worldserver.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) worldserver.players.get(i);
int k = MathHelper.floor(entityhuman.locX / 16.0D);
j = MathHelper.floor(entityhuman.locZ / 16.0D);
- byte b0 = 8;
+ byte b0 = spawnRadius; // Spigot - replace 8 with view distance constrained value
for (int l = -b0; l <= b0; ++l) {
for (int i1 = -b0; i1 <= b0; ++i1) {
@@ -88,13 +120,15 @@ public final class SpawnerCreature {
if (limit == 0) {
continue;
}
+ int mobcnt = 0;
// CraftBukkit end
- if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
+ if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && (mobcnt = getEntityCount(worldserver, enumcreaturetype.a())) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits and use all loaded chunks
Iterator iterator = b.keySet().iterator();
+ int moblimit = (limit * b.size() / 256) - mobcnt + 1; // CraftBukkit - up to 1 more than limit
label110:
- while (iterator.hasNext()) {
+ while (iterator.hasNext() && (moblimit > 0)) { // Spigot - while more allowed
// CraftBukkit start
long key = ((Long) iterator.next()).longValue();
@@ -158,6 +192,12 @@ public final class SpawnerCreature {
a(entityliving, worldserver, f, f1, f2);
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
// CraftBukkit end
+ // Spigot start
+ moblimit--;
+ if (moblimit <= 0) { // If we're past limit, stop spawn
+ continue label110;
+ }
+ // Spigot end
if (j2 >= entityliving.by()) {
continue label110;
}
--
1.8.1.2

View File

@ -1,14 +1,14 @@
From 4cc67e6337594077f65722dff9e59db7ea30204f Mon Sep 17 00:00:00 2001
From 6231d399bc448b884b4b85b68f3ef632605b1ebd Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 09:20:19 +1100
Subject: [PATCH] Handle Null Tile Entities
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 4a5894a..3c6b51a 100644
index da069f7..d4d8f04 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1333,6 +1333,13 @@ public abstract class World implements IBlockAccess {
@@ -1335,6 +1335,13 @@ public abstract class World implements IBlockAccess {
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();

View File

@ -1,4 +1,4 @@
From b09d78b7f1cb674b6dffba57888d241c94ee16c6 Mon Sep 17 00:00:00 2001
From df64c572448edbe8dcefa1eeaaccc7a389f626f7 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Feb 2013 05:10:21 -0500
Subject: [PATCH] Entity Activation Range
@ -9,7 +9,7 @@ This will drastically cut down on tick timings for entities that are not in rang
This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 978b6ef..401edcc 100644
index 978b6ef..438a26a 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -88,7 +88,7 @@ public abstract class Entity {
@ -28,7 +28,7 @@ index 978b6ef..401edcc 100644
+ // Spigot start
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
+ public final byte activationType = org.bukkit.craftbukkit.Spigot.initializeEntityActivationType(this);
+ public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
+ public final boolean defaultActivationState;
+ public long activatedTick = 0;
+ public void inactiveTick() { }
@ -42,7 +42,7 @@ index 978b6ef..401edcc 100644
if (world != null) {
this.dimension = world.worldProvider.dimension;
+ // Spigot start
+ this.defaultActivationState = org.bukkit.craftbukkit.Spigot.initializeEntityActivationState(this, world.getWorld());
+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, world.spigotConfig);
+ } else {
+ this.defaultActivationState = false;
}
@ -118,33 +118,25 @@ index 58a4acb..35f3fea 100644
public EntityLiving(World world) {
super(world);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3c6b51a..6de55ba 100644
index 3a6a63d..5866abb 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.util.LongHashSet;
+import org.bukkit.craftbukkit.Spigot; // Spigot
import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
@@ -1275,6 +1276,7 @@ public abstract class World implements IBlockAccess {
@@ -1277,6 +1277,7 @@ public abstract class World implements IBlockAccess {
this.f.clear();
this.methodProfiler.c("regular");
+ org.bukkit.craftbukkit.Spigot.activateEntities(this); // Spigot
+ org.spigotmc.ActivationRange.activateEntities(this); // Spigot
timings.entityTick.startTiming(); // Spigot
for (i = 0; i < this.entityList.size(); ++i) {
entity = (Entity) this.entityList.get(i);
@@ -1435,8 +1437,13 @@ public abstract class World implements IBlockAccess {
@@ -1437,8 +1438,13 @@ public abstract class World implements IBlockAccess {
int j = MathHelper.floor(entity.locZ);
byte b0 = 32;
- if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
- entity.tickTimer.startTiming(); // Spigot
+ // Spigot start
+ if (!Spigot.checkIfActive(entity)) {
+ if (!org.spigotmc.ActivationRange.checkIfActive(entity)) {
+ entity.ticksLived++;
+ entity.inactiveTick();
+ } else {
@ -153,65 +145,28 @@ index 3c6b51a..6de55ba 100644
entity.U = entity.locX;
entity.V = entity.locY;
entity.W = entity.locZ;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0a39ed3..ebf1a67 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -85,6 +85,10 @@ public class CraftWorld implements World {
public double expMergeRadius = 3.5;
public int viewDistance;
public boolean obfuscated = false;
+ // Activation ranges:
+ public int miscEntityActivationRange = 16;
+ public int animalEntityActivationRange = 32;
+ public int monsterEntityActivationRange = 32;
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
index f6e507e..4328ecf 100644
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
@@ -29,6 +29,9 @@ public class SpigotTimings {
// Spigot start
@@ -119,8 +123,11 @@ public class CraftWorld implements World {
sugarGrowthModifier = configuration.getInt( "world-settings.default.sugar-growth-modifier", sugarGrowthModifier );
treeGrowthModifier = configuration.getInt( "world-settings.default.tree-growth-modifier", treeGrowthModifier );
mushroomGrowthModifier = configuration.getInt( "world-settings.default.mushroom-growth-modifier", mushroomGrowthModifier );
- itemMergeRadius = configuration.getDouble("world-settings.default.item-merge-radius", itemMergeRadius);
- expMergeRadius = configuration.getDouble("world-settings.default.exp-merge-radius", expMergeRadius);
+ itemMergeRadius = configuration.getDouble( "world-settings.default.item-merge-radius", itemMergeRadius );
+ expMergeRadius = configuration.getDouble( "world-settings.default.exp-merge-radius", expMergeRadius );
+ miscEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-misc" );
+ animalEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-animals" );
+ monsterEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-monsters" );
public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
@@ -135,8 +142,11 @@ public class CraftWorld implements World {
sugarGrowthModifier = configuration.getInt( "world-settings." + name + ".sugar-growth-modifier", sugarGrowthModifier );
treeGrowthModifier = configuration.getInt( "world-settings." + name + ".tree-growth-modifier", treeGrowthModifier );
mushroomGrowthModifier = configuration.getInt( "world-settings." + name + ".mushroom-growth-modifier", mushroomGrowthModifier );
- itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius);
- expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius);
+ itemMergeRadius = configuration.getDouble( "world-settings." + name + ".item-merge-radius", itemMergeRadius );
+ expMergeRadius = configuration.getDouble( "world-settings." + name + ".exp-merge-radius", expMergeRadius );
+ miscEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-misc", miscEntityActivationRange );
+ animalEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-animals", animalEntityActivationRange );
+ monsterEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-monsters", monsterEntityActivationRange );
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
@@ -161,6 +171,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "Orebfuscator: " + obfuscated );
+ server.getLogger().info( "Entity Activation Range: An " + animalEntityActivationRange + " / Mo " + monsterEntityActivationRange + " / Mi " + miscEntityActivationRange );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index e5004b3..2fc33f8 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,12 +1,43 @@
package org.bukkit.craftbukkit;
import java.net.InetAddress;
+ public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
+ public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
+
public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
new file mode 100644
index 0000000..93ce20e
--- /dev/null
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -0,0 +1,296 @@
+package org.spigotmc;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.server.AxisAlignedBB;
@ -238,33 +193,17 @@ index e5004b3..2fc33f8 100644
+import net.minecraft.server.EntityWither;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PendingConnection;
+import net.minecraft.server.World;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.file.YamlConfiguration;
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);
private static boolean filterIps;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
@@ -24,12 +55,230 @@ public class Spigot {
server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
server.orebfuscatorBlocks = configuration.getShortList("orebfuscator.blocks");
if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
- server.orebfuscatorEngineMode = 1;
+ server.orebfuscatorEngineMode = 1;
}
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.SpigotTimings;
+
+ }
+public class ActivationRange
+{
+
+ 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 );
+
+ /**
+ * Initializes an entities type on construction to specify what group this
@ -273,12 +212,16 @@ index e5004b3..2fc33f8 100644
+ * @param entity
+ * @return group id
+ */
+ public static byte initializeEntityActivationType(Entity entity) {
+ if (entity instanceof EntityMonster || entity instanceof EntitySlime) {
+ public static byte initializeEntityActivationType(Entity entity)
+ {
+ if ( entity instanceof EntityMonster || entity instanceof EntitySlime )
+ {
+ return 1; // Monster
+ } else if (entity instanceof EntityCreature || entity instanceof EntityAmbient) {
+ } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbient )
+ {
+ return 2; // Animal
+ } else {
+ } else
+ {
+ return 3; // Misc
+ }
+ }
@ -290,10 +233,11 @@ index e5004b3..2fc33f8 100644
+ * @param world
+ * @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)
+ public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
+ {
+ if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
+ || ( entity.activationType == 2 && config.animalActivationRange == 0 )
+ || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
+ || entity instanceof EntityHuman
+ || entity instanceof EntityProjectile
+ || entity instanceof EntityEnderDragon
@ -303,7 +247,8 @@ index e5004b3..2fc33f8 100644
+ || entity instanceof EntityWeather
+ || entity instanceof EntityTNTPrimed
+ || entity instanceof EntityEnderCrystal
+ || entity instanceof EntityFireworks) {
+ || entity instanceof EntityFireworks )
+ {
+ return true;
+ }
+
@ -320,7 +265,8 @@ index e5004b3..2fc33f8 100644
+ * @param y
+ * @param z
+ */
+ public static void growBB(AxisAlignedBB target, AxisAlignedBB source, int x, int y, int z) {
+ public static void growBB(AxisAlignedBB target, AxisAlignedBB source, int x, int y, int z)
+ {
+ target.a = source.a - x;
+ target.b = source.b - y;
+ target.c = source.c - z;
@ -335,33 +281,38 @@ index e5004b3..2fc33f8 100644
+ *
+ * @param world
+ */
+ public static void activateEntities(World world) {
+ public static void activateEntities(World world)
+ {
+ SpigotTimings.entityActivationCheckTimer.startTiming();
+ final int miscActivationRange = world.getWorld().miscEntityActivationRange;
+ final int animalActivationRange = world.getWorld().animalEntityActivationRange;
+ final int monsterActivationRange = world.getWorld().monsterEntityActivationRange;
+ final int miscActivationRange = world.spigotConfig.miscActivationRange;
+ final int animalActivationRange = world.spigotConfig.animalActivationRange;
+ final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
+
+ int maxRange = Math.max(monsterActivationRange, animalActivationRange);
+ maxRange = Math.max(maxRange, miscActivationRange);
+ maxRange = Math.min((world.getWorld().viewDistance << 4) - 8, maxRange);
+ int maxRange = Math.max( monsterActivationRange, animalActivationRange );
+ maxRange = Math.max( maxRange, miscActivationRange );
+ maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );
+
+ for (Entity player : new ArrayList<Entity>(world.players)) {
+ for ( Entity player : new ArrayList<Entity>( world.players ) )
+ {
+
+ player.activatedTick = MinecraftServer.currentTick;
+ growBB(maxBB, player.boundingBox, maxRange, 256, maxRange);
+ growBB(miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange);
+ growBB(animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange);
+ growBB(monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange);
+ growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
+ growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
+ growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
+ growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );
+
+ int i = MathHelper.floor(maxBB.a / 16.0D);
+ int j = MathHelper.floor(maxBB.d / 16.0D);
+ int k = MathHelper.floor(maxBB.c / 16.0D);
+ int l = MathHelper.floor(maxBB.f / 16.0D);
+ int i = MathHelper.floor( maxBB.a / 16.0D );
+ int j = MathHelper.floor( maxBB.d / 16.0D );
+ int k = MathHelper.floor( maxBB.c / 16.0D );
+ int l = MathHelper.floor( maxBB.f / 16.0D );
+
+ for (int i1 = i; i1 <= j; ++i1) {
+ for (int j1 = k; j1 <= l; ++j1) {
+ if (world.getWorld().isChunkLoaded(i1, j1)) {
+ activateChunkEntities(world.getChunkAt(i1, j1));
+ for ( int i1 = i; i1 <= j; ++i1 )
+ {
+ for ( int j1 = k; j1 <= l; ++j1 )
+ {
+ if ( world.getWorld().isChunkLoaded( i1, j1 ) )
+ {
+ activateChunkEntities( world.getChunkAt( i1, j1 ) );
+ }
+ }
+ }
@ -374,28 +325,37 @@ index e5004b3..2fc33f8 100644
+ *
+ * @param chunk
+ */
+ private static void activateChunkEntities(Chunk chunk) {
+ for (List<Entity> slice : chunk.entitySlices) {
+ for (Entity entity : slice) {
+ if (MinecraftServer.currentTick > entity.activatedTick) {
+ if (entity.defaultActivationState) {
+ private static void activateChunkEntities(Chunk chunk)
+ {
+ for ( List<Entity> slice : chunk.entitySlices )
+ {
+ for ( Entity entity : slice )
+ {
+ if ( MinecraftServer.currentTick > entity.activatedTick )
+ {
+ if ( entity.defaultActivationState )
+ {
+ entity.activatedTick = MinecraftServer.currentTick;
+ continue;
+ }
+ switch (entity.activationType) {
+ switch ( entity.activationType )
+ {
+ case 1:
+ if (monsterBB.a(entity.boundingBox)) {
+ if ( monsterBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick;
+ }
+ break;
+ case 2:
+ if (animalBB.a(entity.boundingBox)) {
+ if ( animalBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick;
+ }
+ break;
+ case 3:
+ default:
+ if (miscBB.a(entity.boundingBox)) {
+ if ( miscBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick;
+ }
+ }
@ -411,37 +371,49 @@ index e5004b3..2fc33f8 100644
+ * @param entity
+ * @return
+ */
+ public static boolean checkEntityImmunities(Entity entity) {
+ public static boolean checkEntityImmunities(Entity entity)
+ {
+ // quick checks.
+ if (entity.inWater /* isInWater */ || entity.fireTicks > 0) {
+ if ( entity.inWater /* isInWater */ || entity.fireTicks > 0 )
+ {
+ return true;
+ }
+ if (!(entity instanceof EntityArrow)) {
+ if (!entity.onGround || entity.passenger != null
+ || entity.vehicle != null) {
+ if ( !( entity instanceof EntityArrow ) )
+ {
+ if ( !entity.onGround || entity.passenger != null
+ || entity.vehicle != null )
+ {
+ return true;
+ }
+ } else if (!((EntityArrow) entity).inGround) {
+ } else if ( !( (EntityArrow) entity ).inGround )
+ {
+ return true;
+ }
+ // special cases.
+ if (entity instanceof EntityLiving) {
+ if ( entity instanceof EntityLiving )
+ {
+ EntityLiving living = (EntityLiving) entity;
+ if (living.attackTicks > 0 || living.hurtTicks > 0 || living.effects.size() > 0) {
+ if ( living.attackTicks > 0 || living.hurtTicks > 0 || living.effects.size() > 0 )
+ {
+ return true;
+ }
+ if (entity instanceof EntityCreature && ((EntityCreature) entity).target != null) {
+ if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).target != null )
+ {
+ return true;
+ }
+ if (entity instanceof EntityVillager && ((EntityVillager) entity).n()) {
+ if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).n() )
+ {
+ return true;
+ }
+ if (entity instanceof EntityAnimal) {
+ if ( entity instanceof EntityAnimal )
+ {
+ EntityAnimal animal = (EntityAnimal) entity;
+ if (animal.isBaby() || animal.r() /*love*/) {
+ if ( animal.isBaby() || animal.r() /*love*/ )
+ {
+ return true;
+ }
+ if (entity instanceof EntitySheep && ((EntitySheep) entity).isSheared()) {
+ if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).isSheared() )
+ {
+ return true;
+ }
+ }
@ -455,63 +427,60 @@ index e5004b3..2fc33f8 100644
+ * @param entity
+ * @return
+ */
+ public static boolean checkIfActive(Entity entity) {
+ public static boolean checkIfActive(Entity entity)
+ {
+ SpigotTimings.checkIfActiveTimer.startTiming();
+ boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
+
+ // Should this entity tick?
+ if (!isActive) {
+ if ((MinecraftServer.currentTick - entity.activatedTick - 1) % 20 == 0) {
+ if ( !isActive )
+ {
+ if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
+ {
+ // Check immunities every 20 ticks.
+ if (checkEntityImmunities(entity)) {
+ if ( checkEntityImmunities( entity ) )
+ {
+ // Triggered some sort of immunity, give 20 full ticks before we check again.
+ entity.activatedTick = MinecraftServer.currentTick + 20;
+ }
+ isActive = true;
+ }
+ // Add a little performance juice to active entities. Skip 1/4 if not immune.
+ } else if (!entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities(entity)) {
+ } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
+ {
+ isActive = false;
+ }
+ int x = MathHelper.floor(entity.locX);
+ int z = MathHelper.floor(entity.locZ);
+ int x = MathHelper.floor( entity.locX );
+ int z = MathHelper.floor( entity.locZ );
+ // Make sure not on edge of unloaded chunk
+ if (isActive && !entity.world.areChunksLoaded(x, 0, z, 16)) {
+ if ( isActive && !entity.world.areChunksLoaded( x, 0, z, 16 ) )
+ {
+ isActive = false;
+ }
+ SpigotTimings.checkIfActiveTimer.stopTiming();
+ return isActive;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 6c2a430..8b2c1d7 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -152,4 +152,15 @@ public class SpigotWorldConfig
mobSpawnRange = (byte) getInt( "mob-spawn-range", 4 );
log( "Mob Spawn Range: " + mobSpawnRange );
}
public static boolean filterIp(PendingConnection con) {
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
index f6e507e..4328ecf 100644
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
@@ -29,6 +29,9 @@ public class SpigotTimings {
public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
+ public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
+ public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
+
public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 7860ccc..9c64871 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -46,6 +46,9 @@ world-settings:
sugar-growth-modifier: 100
tree-growth-modifier: 100
mushroom-growth-modifier: 100
+ entity-activation-range-animals: 32
+ entity-activation-range-monsters: 32
+ entity-activation-range-misc: 16
info: true
world:
growth-chunks-per-tick: 1000
+ public int animalActivationRange = 32;
+ public int monsterActivationRange = 32;
+ public int miscActivationRange = 16;
+ private void activationRange()
+ {
+ animalActivationRange = getInt( "entity-activation-range.animals", animalActivationRange );
+ monsterActivationRange = getInt( "entity-activation-range.monsters", monsterActivationRange );
+ miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
+ log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange );
+ }
}
--
1.8.1.2

View File

@ -1,61 +1,9 @@
From 2ba22ed3cb7fcfbf52fd7bade08af98b4152e9cb Mon Sep 17 00:00:00 2001
From a32d38cde53297cbbb1b3f674ccf493d22778ba5 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Feb 2013 08:58:35 +1100
Subject: [PATCH] Metrics
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 2fc33f8..2532aa2 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,8 +1,10 @@
package org.bukkit.craftbukkit;
+import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
import net.minecraft.server.AxisAlignedBB;
import net.minecraft.server.Chunk;
import net.minecraft.server.Entity;
@@ -29,8 +31,10 @@ import net.minecraft.server.MathHelper;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PendingConnection;
import net.minecraft.server.World;
+import org.bukkit.Bukkit;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.spigotmc.Metrics;
public class Spigot {
@@ -39,6 +43,8 @@ public class Spigot {
static AxisAlignedBB animalBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
static AxisAlignedBB monsterBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
private static boolean filterIps;
+ 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"));
@@ -62,6 +68,16 @@ public class Spigot {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
+ tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
+
+ if (metrics == null) {
+ try {
+ metrics = new Metrics();
+ metrics.start();
+ } catch (IOException ex) {
+ Bukkit.getServer().getLogger().log(Level.SEVERE, "Could not start metrics service", ex);
+ }
+ }
}
/**
diff --git a/src/main/java/org/spigotmc/Metrics.java b/src/main/java/org/spigotmc/Metrics.java
new file mode 100644
index 0000000..f1690a2
@ -708,6 +656,37 @@ index 0000000..f1690a2
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index d22e8e5..8f53ca9 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -36,6 +36,7 @@ public class SpigotConfig
static int version;
static Map<String, Command> commands;
/*========================================================================*/
+ private static Metrics metrics;
public static void init()
{
@@ -55,6 +56,18 @@ public class SpigotConfig
{
MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "Spigot", entry.getValue() );
}
+
+ if ( metrics == null )
+ {
+ try
+ {
+ metrics = new Metrics();
+ metrics.start();
+ } catch ( IOException ex )
+ {
+ Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex );
+ }
+ }
}
static void readConfig(Class<?> clazz, Object instance)
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 38b16a25eb92ac69f11bc50e958ad1eaf48471b7 Mon Sep 17 00:00:00 2001
From 3c8f2ccaa98803166178f16290fce2b8626e6ebb 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.
@ -24,169 +24,150 @@ index db396b3..d197f06 100644
this.stop();
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 2532aa2..6a164ca 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit;
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
new file mode 100644
index 0000000..a5c4549
--- /dev/null
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -0,0 +1,111 @@
+package org.spigotmc;
+
+import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -20,6 +21,7 @@ import net.minecraft.server.EntityFireworks;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
+import java.util.List;
+import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntitySheep;
import net.minecraft.server.EntitySlime;
@@ -29,12 +31,15 @@ import net.minecraft.server.EntityWeather;
import net.minecraft.server.EntityWither;
import net.minecraft.server.MathHelper;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.Packet255KickDisconnect;
import net.minecraft.server.PendingConnection;
import net.minecraft.server.World;
import org.bukkit.Bukkit;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.Metrics;
+import org.spigotmc.RestartCommand;
+import org.spigotmc.WatchdogThread;
public class Spigot {
@@ -48,6 +53,7 @@ public class Spigot {
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
+ commandMap.register("restart", new RestartCommand("restart"));
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
@@ -56,6 +62,17 @@ public class Spigot {
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
+ int configVersion = configuration.getInt("config-version");
+ switch (configVersion) {
+ case 0:
+ configuration.set("settings.timeout-time", 30);
+ case 1:
+ configuration.set("settings.timeout-time", 60);
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+public class RestartCommand extends Command
+{
+
+ public RestartCommand(String name)
+ {
+ super( name );
+ this.description = "Restarts the server";
+ this.usageMessage = "/restart";
+ this.setPermission( "bukkit.command.restart" );
+ }
+
+ @Override
+ public boolean execute(CommandSender sender, String currentAlias, String[] args)
+ {
+ if ( testPermission( sender ) )
+ {
+ restart();
+ }
+ configuration.set("config-version", 2);
+ return true;
+ }
+
+ WatchdogThread.doStart(configuration.getInt("settings.timeout-time", 60), configuration.getBoolean("settings.restart-on-crash", false));
+
server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
@@ -297,6 +314,66 @@ public class Spigot {
return isActive;
}
+ public static void restart() {
+ try {
+ String startupScript = MinecraftServer.getServer().server.configuration.getString("settings.restart-script-location", "");
+ final File file = new File(startupScript);
+ if (file.isFile()) {
+ System.out.println("Attempting to restart with " + startupScript);
+ public static void restart()
+ {
+ try
+ {
+ final File file = new File( SpigotConfig.restartScript );
+ if ( file.isFile() )
+ {
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
+
+ // Kick all players
+ for (EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
+ p.playerConnection.networkManager.queue(new Packet255KickDisconnect("Server is restarting"));
+ for ( EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players )
+ {
+ p.playerConnection.networkManager.queue( new Packet255KickDisconnect( "Server is restarting" ) );
+ p.playerConnection.networkManager.d();
+ }
+ // Give the socket a chance to send the packets
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ex) {
+ try
+ {
+ Thread.sleep( 100 );
+ } catch ( InterruptedException ex )
+ {
+ }
+ // Close the socket so we can rebind with the new process
+ MinecraftServer.getServer().ae().a();
+
+ // Give time for it to kick in
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ex) {
+ try
+ {
+ Thread.sleep( 100 );
+ } catch ( InterruptedException ex )
+ {
+ }
+
+ // Actually shutdown
+ try {
+ try
+ {
+ MinecraftServer.getServer().stop();
+ } catch (Throwable t) {
+ } catch ( Throwable t )
+ {
+ }
+
+ // This will be done AFTER the server has completely halted
+ Thread shutdownHook = new Thread() {
+ Thread shutdownHook = new Thread()
+ {
+ @Override
+ 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()});
+ 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()
+ } );
+ }
+ } catch (Exception e) {
+ } catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ shutdownHook.setDaemon(true);
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ } else {
+ System.out.println("Startup script '" + startupScript + "' does not exist! Stopping server.");
+ shutdownHook.setDaemon( true );
+ Runtime.getRuntime().addShutdownHook( shutdownHook );
+ } else
+ {
+ System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
+ }
+ System.exit(0);
+ } catch (Exception ex) {
+ System.exit( 0 );
+ } catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
public static boolean filterIp(PendingConnection con) {
if (filterIps) {
try {
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
new file mode 100644
index 0000000..2d5c89f
--- /dev/null
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -0,0 +1,23 @@
+package org.spigotmc;
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.craftbukkit.Spigot;
+
+public class RestartCommand extends Command {
+
+ public RestartCommand(String name) {
+ super(name);
+ this.description = "Restarts the server";
+ this.usageMessage = "/restart";
+ this.setPermission("bukkit.command.restart");
+ }
+
+ @Override
+ public boolean execute(CommandSender sender, String currentAlias, String[] args) {
+ if (testPermission(sender)) {
+ Spigot.restart();
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 8f53ca9..b7f3896 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -136,4 +136,16 @@ public class SpigotConfig
{
commands.put( "tps", new TicksPerSecondCommand( "tps" ) );
}
+
+ public static int timeoutTime = 60;
+ public static boolean restartOnCrash = true;
+ public static String restartScript = "./start.sh";
+ private static void watchdog()
+ {
+ timeoutTime = getInt( "settings.timeout-time", timeoutTime );
+ restartOnCrash = getBoolean( "settings.restart-on-crash", restartOnCrash );
+ restartScript = getString( "settings.restart-script", restartScript );
+ commands.put( "restart", new RestartCommand( "restart" ) );
+ WatchdogThread.doStart( timeoutTime, restartOnCrash );
+ }
}
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
new file mode 100644
index 0000000..10390b8
index 0000000..38ef9b7
--- /dev/null
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +1,93 @@
@@ -0,0 +1,110 @@
+package org.spigotmc;
+
+import java.lang.management.ManagementFactory;
@ -195,9 +176,9 @@ index 0000000..10390b8
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.Spigot;
+
+public class WatchdogThread extends Thread {
+public class WatchdogThread extends Thread
+{
+
+ private static WatchdogThread instance;
+ private final long timeoutTime;
@ -205,95 +186,98 @@ index 0000000..10390b8
+ private volatile long lastTick;
+ private volatile boolean stopping;
+
+ private WatchdogThread(long timeoutTime, boolean restart) {
+ super("Spigot Watchdog Thread");
+ private WatchdogThread(long timeoutTime, boolean restart)
+ {
+ super( "Spigot Watchdog Thread" );
+ this.timeoutTime = timeoutTime;
+ this.restart = restart;
+ }
+
+ public static void doStart(int timeoutTime, boolean restart) {
+ if (instance == null) {
+ instance = new WatchdogThread(timeoutTime * 1000L, restart);
+ public static void doStart(int timeoutTime, boolean restart)
+ {
+ if ( instance == null )
+ {
+ instance = new WatchdogThread( timeoutTime * 1000L, restart );
+ instance.start();
+ }
+ }
+
+ public static void tick() {
+ public static void tick()
+ {
+ instance.lastTick = System.currentTimeMillis();
+ }
+
+ public static void doStop() {
+ if (instance != null) {
+ public static void doStop()
+ {
+ if ( instance != null )
+ {
+ instance.stopping = true;
+ }
+ }
+
+ @Override
+ public void run() {
+ while (!stopping) {
+ public void run()
+ {
+ while ( !stopping )
+ {
+ //
+ if (lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime) {
+ if ( lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime )
+ {
+ Logger log = Bukkit.getServer().getLogger();
+ log.log(Level.SEVERE, "The server has stopped responding!");
+ log.log(Level.SEVERE, "Please report this to http://www.spigotmc.org/");
+ log.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports");
+ log.log(Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion());
+ log.log( Level.SEVERE, "The server has stopped responding!" );
+ log.log( Level.SEVERE, "Please report this to http://www.spigotmc.org/" );
+ log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
+ log.log( Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion() );
+ //
+ log.log(Level.SEVERE, "Current Thread State:");
+ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
+ for (ThreadInfo thread : threads) {
+ if (thread.getThreadState() != State.WAITING) {
+ log.log(Level.SEVERE, "------------------------------");
+ log.log( Level.SEVERE, "Current Thread State:" );
+ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads( true, true );
+ for ( ThreadInfo thread : threads )
+ {
+ if ( thread.getThreadState() != State.WAITING )
+ {
+ log.log( Level.SEVERE, "------------------------------" );
+ //
+ log.log(Level.SEVERE, "Current Thread: " + thread.getThreadName());
+ log.log(Level.SEVERE, "\tPID: " + thread.getThreadId()
+ log.log( Level.SEVERE, "Current Thread: " + thread.getThreadName() );
+ log.log( Level.SEVERE, "\tPID: " + thread.getThreadId()
+ + " | Suspended: " + thread.isSuspended()
+ + " | Native: " + thread.isInNative()
+ + " | State: " + thread.getThreadState());
+ if (thread.getLockedMonitors().length != 0) {
+ log.log(Level.SEVERE, "\tThread is waiting on monitor(s):");
+ for (MonitorInfo monitor : thread.getLockedMonitors()) {
+ log.log(Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame());
+ + " | State: " + thread.getThreadState() );
+ if ( thread.getLockedMonitors().length != 0 )
+ {
+ log.log( Level.SEVERE, "\tThread is waiting on monitor(s):" );
+ for ( MonitorInfo monitor : thread.getLockedMonitors() )
+ {
+ log.log( Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame() );
+ }
+ }
+ log.log(Level.SEVERE, "\tStack:");
+ log.log( Level.SEVERE, "\tStack:" );
+ //
+ StackTraceElement[] stack = thread.getStackTrace();
+ for (int line = 0; line < stack.length; line++) {
+ log.log(Level.SEVERE, "\t\t" + stack[line].toString());
+ for ( int line = 0; line < stack.length; line++ )
+ {
+ log.log( Level.SEVERE, "\t\t" + stack[line].toString() );
+ }
+ }
+ }
+ log.log(Level.SEVERE, "------------------------------");
+ log.log( Level.SEVERE, "------------------------------" );
+
+ if (restart) {
+ Spigot.restart();
+ if ( restart )
+ {
+ RestartCommand.restart();
+ }
+ break;
+ }
+
+ try {
+ sleep(10000);
+ } catch (InterruptedException ex) {
+ try
+ {
+ sleep( 10000 );
+ } catch ( InterruptedException ex )
+ {
+ interrupt();
+ }
+ }
+ }
+}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 9c64871..3d4272b 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -31,6 +31,9 @@ settings:
spam-exclusions:
- /skill
filter-unsafe-ips: false
+ timeout-time: 30
+ restart-on-crash: false
+ restart-script-location: /path/to/server/start.sh
world-settings:
default:
growth-chunks-per-tick: 650
--
1.8.1.2

View File

@ -1,35 +1,8 @@
From 5146e6a561c2858de9a0d2a44dadde9db0b7a8a6 Mon Sep 17 00:00:00 2001
From 7186970386ca7b9887fc79e00510154f2b248d86 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:47:32 +1000
Date: Fri, 21 Jun 2013 18:23:00 +1000
Subject: [PATCH] Netty
Implement an uber efficient network engine based on the
Java NIO framework Netty. This is basically a complete rewrite of the
Minecraft network engine with many distinct advantages. First and foremost,
there will no longer be the horrid, and redundant case of 2, or even at
times, 3 threads per a connection. Instead low level select/epoll based NIO
is used. The number of threads used for network reading and writing will
scale automatically to the number of cores for use on your server. In most
cases this will be around 8 threads for a 4 core server, much better than the
up to 1000 threads that could be in use at one time with the old engine. To
facilitate asynchronous packet sending or receiving (currently only chat), a
thread pool of 16 threads is kept handy. == Plugin incompatibilities As a
side effect of this change, plugins which rely on very specific
implementation level details within Minecraft are broken. At this point in
time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib
you are advised to update to the latest build, where full support is enabled.
If you are a user of TagAPI, support has not yet been added, so you will need
to install the updated ProtocolLib so that TagAPI may use its functions. ==
Stability The code within this commit has been very lightly tested in
production (300 players for approximately 24 hours), however it is not
guaranteed to be free from all bugs. If you experence weird connection
behaviour, reporting the bug and steps to reproduce are advised. You are also
free to downgrade to the latest recommend build, which is guaranteed to be
stable. == Summary This commit provides a reduction in threads, which gives
the CPU / operating system more time to allocate to the main server threads,
as well as various other side benefits such as chat thread pooling and a
slight reduction in latency. This commit is licensed under the Creative
Commons Attribution-ShareAlike 3.0 Unported license.
diff --git a/pom.xml b/pom.xml
index 8c9f66b..a33020e 100644
@ -53,10 +26,10 @@ index 8c9f66b..a33020e 100644
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 10ce69d..e4f1cbe 100644
index 59444cb..e101f95 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -96,7 +96,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@@ -100,7 +100,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
this.getLogger().info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.G());
try {
@ -131,7 +104,7 @@ index 1862863..5a24f2a 100644
+ public void setSocketAddress(SocketAddress address) { k = address; } // Spigot
}
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
index 7711629..9cf625d 100644
index efe102e..e488fa8 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -42,7 +42,7 @@ public class Packet51MapChunk extends Packet {
@ -144,7 +117,7 @@ index 7711629..9cf625d 100644
this.d = chunkmap.c;
this.c = chunkmap.b;
diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
index ce28495..fb34d4a 100644
index a2cd9b0..f586415 100644
--- a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
+++ b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
@@ -24,7 +24,7 @@ public class Packet56MapChunkBulk extends Packet {
@ -210,10 +183,10 @@ index 17cfacc..a945892 100644
this.b = true;
} catch (Exception exception) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 82dfef1..2485ef9 100644
index 6e6fe1c..68694de 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1389,4 +1389,20 @@ public final class CraftServer implements Server {
@@ -1369,4 +1369,20 @@ public final class CraftServer implements Server {
public CraftScoreboardManager getScoreboardManager() {
return scoreboardManager;
}
@ -236,14 +209,13 @@ index 82dfef1..2485ef9 100644
}
diff --git a/src/main/java/org/spigotmc/MultiplexingServerConnection.java b/src/main/java/org/spigotmc/MultiplexingServerConnection.java
new file mode 100644
index 0000000..c8ea80a
index 0000000..386c2f8
--- /dev/null
+++ b/src/main/java/org/spigotmc/MultiplexingServerConnection.java
@@ -0,0 +1,126 @@
@@ -0,0 +1,136 @@
+package org.spigotmc;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
@ -257,41 +229,38 @@ index 0000000..c8ea80a
+import net.minecraft.server.ServerConnection;
+import org.bukkit.Bukkit;
+
+public class MultiplexingServerConnection extends ServerConnection {
+public class MultiplexingServerConnection extends ServerConnection
+{
+
+ private static final boolean NETTY_DISABLED = Boolean.getBoolean("org.spigotmc.netty.disabled");
+ private final Collection<ServerConnection> children = new HashSet<ServerConnection>();
+ private final List<PendingConnection> pending = Collections.synchronizedList(new ArrayList<PendingConnection>());
+ private final List<PendingConnection> pending = Collections.synchronizedList( new ArrayList<PendingConnection>() );
+ private final HashMap<InetAddress, Long> throttle = new HashMap<InetAddress, Long>();
+
+ public MultiplexingServerConnection(MinecraftServer ms) {
+ super(ms);
+ public MultiplexingServerConnection(MinecraftServer ms)
+ {
+ super( ms );
+
+ // Add primary connection
+ start(ms.server.getIp(), ms.server.getPort());
+ // Add all other connections
+ for (InetSocketAddress address : ms.server.getSecondaryHosts()) {
+ start(address.getAddress().getHostAddress(), address.getPort());
+ }
+ }
+
+ private void start(String ipAddress, int port) {
+ try {
+ // Calculate address, can't use isEmpty due to Java 5
+ InetAddress socketAddress = (ipAddress.length() == 0) ? null : InetAddress.getByName(ipAddress);
+ // Say hello to the log
+ d().getLogger().info("Starting listener #" + children.size() + " on " + (socketAddress == null ? "*" : ipAddress) + ":" + port);
+ // Start connection: Netty / non Netty
+ ServerConnection listener = (NETTY_DISABLED) ? new DedicatedServerConnection(d(), socketAddress, port) : new org.spigotmc.netty.NettyServerConnection(d(), socketAddress, port);
+ // Register with other connections
+ children.add(listener);
+ // Gotta catch em all
+ } catch (Throwable t) {
+ // Just print some info to the log
+ t.printStackTrace();
+ d().getLogger().warning("**** FAILED TO BIND TO PORT!");
+ d().getLogger().warning("The exception was: {0}", t);
+ d().getLogger().warning("Perhaps a server is already running on that port?");
+ for ( SpigotConfig.Listener listener : SpigotConfig.listeners )
+ {
+ try
+ {
+ // Calculate address, can't use isEmpty due to Java 5
+ InetAddress socketAddress = ( listener.host.length() == 0 ) ? null : InetAddress.getByName( listener.host );
+ // Say hello to the log
+ d().getLogger().info( "Starting listener #" + children.size() + " on " + ( socketAddress == null ? "*" : listener.host ) + ":" + listener.port );
+ // Start connection: Netty / non Netty
+ ServerConnection l = ( listener.netty ) ? new DedicatedServerConnection( d(), socketAddress, listener.port ) : new org.spigotmc.netty.NettyServerConnection( d(), socketAddress, listener.port );
+ // Register with other connections
+ children.add( l );
+ // Gotta catch em all
+ } catch ( Throwable t )
+ {
+ // Just print some info to the log
+ t.printStackTrace();
+ d().getLogger().warning( "**** FAILED TO BIND TO PORT!" );
+ d().getLogger().warning( "The exception was: {0}", t );
+ d().getLogger().warning( "Perhaps a server is already running on that port?" );
+ }
+ }
+ }
+
@ -299,8 +268,10 @@ index 0000000..c8ea80a
+ * close.
+ */
+ @Override
+ public void a() {
+ for (ServerConnection child : children) {
+ public void a()
+ {
+ for ( ServerConnection child : children )
+ {
+ child.a();
+ }
+ }
@ -310,20 +281,25 @@ index 0000000..c8ea80a
+ * called from the main server thread a few times a tick.
+ */
+ @Override
+ public void b() {
+ public void b()
+ {
+ super.b(); // pulse PlayerConnections
+ for (int i = 0; i < pending.size(); ++i) {
+ PendingConnection connection = pending.get(i);
+ for ( int i = 0; i < pending.size(); ++i )
+ {
+ PendingConnection connection = pending.get( i );
+
+ try {
+ try
+ {
+ connection.c();
+ } catch (Exception ex) {
+ connection.disconnect("Internal server error");
+ Bukkit.getServer().getLogger().log(Level.WARNING, "Failed to handle packet: " + ex, ex);
+ } catch ( Exception ex )
+ {
+ connection.disconnect( "Internal server error" );
+ Bukkit.getServer().getLogger().log( Level.WARNING, "Failed to handle packet: " + ex, ex );
+ }
+
+ if (connection.b) {
+ pending.remove(i--);
+ if ( connection.b )
+ {
+ pending.remove( i-- );
+ }
+ }
+ }
@ -334,10 +310,13 @@ index 0000000..c8ea80a
+ *
+ * @param address the address to remove
+ */
+ public void unThrottle(InetAddress address) {
+ if (address != null) {
+ synchronized (throttle) {
+ throttle.remove(address);
+ public void unThrottle(InetAddress address)
+ {
+ if ( address != null )
+ {
+ synchronized ( throttle )
+ {
+ throttle.remove( address );
+ }
+ }
+ }
@ -348,24 +327,89 @@ index 0000000..c8ea80a
+ * @param address
+ * @return Whether they must be disconnected
+ */
+ public boolean throttle(InetAddress address) {
+ public boolean throttle(InetAddress address)
+ {
+ long currentTime = System.currentTimeMillis();
+ synchronized (throttle) {
+ Long value = throttle.get(address);
+ if (value != null && !address.isLoopbackAddress() && currentTime - value < d().server.getConnectionThrottle()) {
+ throttle.put(address, currentTime);
+ synchronized ( throttle )
+ {
+ Long value = throttle.get( address );
+ if ( value != null && !address.isLoopbackAddress() && currentTime - value < d().server.getConnectionThrottle() )
+ {
+ throttle.put( address, currentTime );
+ return true;
+ }
+
+ throttle.put(address, currentTime);
+ throttle.put( address, currentTime );
+ }
+ return false;
+ }
+
+ public void register(PendingConnection conn) {
+ pending.add(conn);
+ public void register(PendingConnection conn)
+ {
+ pending.add( conn );
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index b7f3896..910d0de 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -6,6 +6,8 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -148,4 +150,47 @@ public class SpigotConfig
commands.put( "restart", new RestartCommand( "restart" ) );
WatchdogThread.doStart( timeoutTime, restartOnCrash );
}
+
+ public static class Listener
+ {
+
+ public String host;
+ public int port;
+ public boolean netty;
+ public long connectionThrottle;
+
+ public Listener(String host, int port, boolean netty, long connectionThrottle)
+ {
+ this.host = host;
+ this.port = port;
+ this.netty = netty;
+ this.connectionThrottle = connectionThrottle;
+ }
+ }
+ public static List<Listener> listeners = new ArrayList<Listener>();
+ public static int nettyThreads;
+ private static void listeners()
+ {
+ Map<String, Object> def = new HashMap<String, Object>();
+ def.put( "host", "default" );
+ def.put( "port", "default" );
+ def.put( "netty", true );
+ def.put( "throttle", "default" );
+
+ config.addDefault( "listeners", Collections.singletonList( def ) );
+ for ( Map<String, Object> info : (List<Map<String, Object>>) config.getList( "listeners" ) )
+ {
+ String host = (String) info.get( "host" );
+ if ( "default".equals( host ) )
+ {
+ host = Bukkit.getIp();
+ }
+ int port = ( info.get( "port" ) instanceof Integer ) ? (Integer) info.get( "port" ) : Bukkit.getPort();
+ boolean netty = (Boolean) info.get( "netty" );
+ long connectionThrottle = ( info.get( "throttle" ) instanceof Number ) ? ( (Number) info.get( "throttle" ) ).longValue() : Bukkit.getConnectionThrottle();
+ listeners.add( new Listener( host, port, netty, connectionThrottle ) );
+ }
+
+ nettyThreads = getInt( "settings.netty-threads", 3 );
+ }
}
diff --git a/src/main/java/org/spigotmc/netty/CipherBase.java b/src/main/java/org/spigotmc/netty/CipherBase.java
new file mode 100644
index 0000000..c75a60f
@ -784,10 +828,10 @@ index 0000000..fdef0c8
+}
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
new file mode 100644
index 0000000..575db8b
index 0000000..f232efd
--- /dev/null
+++ b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
@@ -0,0 +1,100 @@
@@ -0,0 +1,104 @@
+package org.spigotmc.netty;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -797,6 +841,7 @@ index 0000000..575db8b
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.timeout.ReadTimeoutHandler;
@ -820,11 +865,15 @@ index 0000000..575db8b
+{
+
+ private final ChannelFuture socket;
+ private static EventLoopGroup group;
+
+ public NettyServerConnection(final MinecraftServer ms, InetAddress host, int port)
+ {
+ super( ms );
+ int threads = Integer.getInteger( "org.spigotmc.netty.threads", 3 );
+ if ( group == null )
+ {
+ group = new NioEventLoopGroup( org.spigotmc.SpigotConfig.nettyThreads, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread - %1$d" ).build() );
+ }
+ socket = new ServerBootstrap().channel( NioServerSocketChannel.class ).childHandler( new ChannelInitializer()
+ {
+ @Override
@ -853,8 +902,7 @@ index 0000000..575db8b
+ .addLast( "encoder", new PacketEncoder( networkManager ) )
+ .addLast( "manager", networkManager );
+ }
+ } ).childOption( ChannelOption.TCP_NODELAY, false ).group( new NioEventLoopGroup( threads, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread - %1$d" ).build() ) ).localAddress( host, port ).bind();
+ MinecraftServer.getServer().getLogger().info( "Using Netty NIO with " + threads + " threads for network connections." );
+ } ).childOption( ChannelOption.TCP_NODELAY, false ).group( group ).localAddress( host, port ).bind();
+ }
+
+ /**
@ -1499,20 +1547,6 @@ index 0000000..d3a9cab
+ */
+ DATA;
+}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 3d4272b..53db120 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -13,6 +13,9 @@
# Bug tracker: http://leaky.bukkit.org/
+#listeners:
+# - address: 127.0.0.1
+# port: 25577
settings:
allow-end: true
warn-on-overload: true
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From d0c3da40bb7be3c11ed8bfc098549dc5e3ddb97d Mon Sep 17 00:00:00 2001
From f52dba2bbbe1ac2d868fc37d95d8a33e4e17a46e Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Mon, 4 Mar 2013 18:45:52 +1100
Subject: [PATCH] PlayerItemDamageEvent

View File

@ -1,45 +0,0 @@
From 22c7f9a277249291f162a01327fad44bf3d3cbd1 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
BUKKIT-3604
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 7cae665..8ec84e1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -628,10 +628,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
ChunkCoordinates bed = getHandle().getBed();
if (world != null && bed != null) {
- bed = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced());
- if (bed != null) {
+ if (getHandle().isRespawnForced()) {
return new Location(world, bed.x, bed.y, bed.z);
}
+
+ int cx = bed.x >> 4;
+ int cz = bed.z >> 4;
+ boolean before = world.isChunkLoaded(cx, cz);
+
+ if (!before) {
+ world.loadChunk(cx, cz);
+ }
+
+ Location location = null;
+ if (world.getBlockTypeIdAt(bed.x, bed.y, bed.z) == Block.BED.id) {
+ location = new Location(world, bed.x, bed.y, bed.z);
+ }
+
+ if (!before) {
+ world.unloadChunk(cx, cz);
+ }
+
+ return location;
}
return null;
}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 25514a2f378763e974783799c57dee62c67c1d20 Mon Sep 17 00:00:00 2001
From dbd0d8f7e14ce0dbe01087ea315ef44fc26193ab Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 17 Mar 2013 19:02:50 +1100
Subject: [PATCH] Faster UUID for entities
@ -6,7 +6,7 @@ Subject: [PATCH] Faster UUID for entities
It is overkill to create a new SecureRandom on each entity create and then use it to make a new Entity ID for every entity instance created. Instead we will just use a pseudo random UUID based off the random instance we already have.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 401edcc..a2a4f5a 100644
index 438a26a..97b2522 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -154,7 +154,7 @@ public abstract class Entity {

View File

@ -1,30 +0,0 @@
From 2f87ffb2fd330295fe5b602fc19cb3b0e0656570 Mon Sep 17 00:00:00 2001
From: EdGruberman <ed@rjump.com>
Date: Tue, 12 Feb 2013 16:17:31 -0700
Subject: [PATCH] Remove dependency on CraftPlayer.getBedSpawnLocation; Fixes
BUKKIT-3604
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 0e3a6a1..305855b 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -495,7 +495,14 @@ public abstract class PlayerList {
if (exitWorld != null) {
if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
// THE_END -> NORMAL; use bed if available, otherwise default spawn
- exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
+ ChunkCoordinates chunkcoordinates = entityplayer.getBed();
+ CraftWorld spawnWorld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
+ if (spawnWorld != null && chunkcoordinates != null) {
+ ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(spawnWorld.getHandle(), chunkcoordinates, entityplayer.isRespawnForced());
+ if (chunkcoordinates1 != null) {
+ exit = new Location(spawnWorld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5);
+ }
+ }
if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
exit = exitWorld.getWorld().getSpawnLocation();
}
--
1.8.1.2

View File

@ -1,36 +0,0 @@
From 7a8988d8f7c6f44262bee0be69d684109e2a863c Mon Sep 17 00:00:00 2001
From: Yariv Livay <yarivlivay@gmail.com>
Date: Sat, 2 Mar 2013 09:36:52 +1100
Subject: [PATCH] BUKKIT-3661, fixed missing HangingBreakEvent when
EntityHanging moves
diff --git a/src/main/java/net/minecraft/server/EntityHanging.java b/src/main/java/net/minecraft/server/EntityHanging.java
index f697d85..1dfb02f 100644
--- a/src/main/java/net/minecraft/server/EntityHanging.java
+++ b/src/main/java/net/minecraft/server/EntityHanging.java
@@ -260,6 +260,21 @@ public abstract class EntityHanging extends Entity {
if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
if (dead) return; // CraftBukkit
+ // CraftBukkit start
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ PaintingBreakEvent paintingEvent = null;
+ if (this instanceof EntityPainting) {
+ // Fire old painting event until it can be removed
+ paintingEvent = new PaintingBreakEvent((Painting) this.getBukkitEntity(), PaintingBreakEvent.RemoveCause.valueOf(event.getCause().name()));
+ paintingEvent.setCancelled(event.isCancelled());
+ this.world.getServer().getPluginManager().callEvent(paintingEvent);
+ }
+ if (event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
+ return;
+ }
+ // CraftBukkit end
this.die();
this.h();
}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 111f52275cda2c1d1f575424d2a407f6da589556 Mon Sep 17 00:00:00 2001
From 62299e26a81eebde726d18656f2eebf061d099dd Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Mon, 18 Mar 2013 20:01:44 +1100
Subject: [PATCH] Prevent NPE in CraftSign

View File

@ -1,22 +0,0 @@
From 89d5b237ade0d53899f7ef9e99d45bae78e88f21 Mon Sep 17 00:00:00 2001
From: Yariv Livay <yarivlivay@gmail.com>
Date: Mon, 25 Feb 2013 22:26:36 +0200
Subject: [PATCH] Adds BUKKIT-3667, Faux sleepers wake up normally
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 7de5b48..9925d1b 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -429,7 +429,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void a(boolean flag, boolean flag1, boolean flag2) {
- if (this.fauxSleeping && !this.sleeping) return; // CraftBukkit - Can't leave bed if not in one!
+ if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one!
if (this.isSleeping()) {
this.o().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 3));
--
1.8.1.2

View File

@ -0,0 +1,103 @@
From 17fbd3f0e6586b3b59b8bbd9f4327e4a09512b24 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
This will let you configure how far to track entities in range from players, so that the entity does not render on the client if out of this range.
This has multiple benefits:
1) Less bandwidth. Not sending update packets for entities that are not even close to a player, or even close enough to clearly see.
2) Less lag by maps in item frames - Default range is 160 blocks... Many players can track that item frame and cause lag and not even see it.
3) Less lag in general - Less work for the server to do
4) Less client lag - Not trying to render distant item frames and paintings and entities will reduce entity count on the client, which is major for shop/town worlds which may use tons of item frames.
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
index d7efe3e..59586c2 100644
--- a/src/main/java/net/minecraft/server/EntityTracker.java
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
@@ -90,6 +90,7 @@ public class EntityTracker {
public void addEntity(Entity entity, int i, int j, boolean flag) {
if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity track!"); // Spigot
+ i = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, i); // Spigot
if (i > this.d) {
i = this.d;
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 8b2c1d7..89d716c 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -163,4 +163,19 @@ public class SpigotWorldConfig
miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange );
}
+
+ public int playerTrackingRange = 48;
+ public int animalTrackingRange = 48;
+ public int monsterTrackingRange = 48;
+ public int miscTrackingRange = 32;
+ public int maxTrackingRange = 64;
+ private void trackingRange()
+ {
+ playerTrackingRange = getInt( "entity-tracking-range.players", playerTrackingRange );
+ animalTrackingRange = getInt( "entity-tracking-range.animals", animalTrackingRange );
+ monsterTrackingRange = getInt( "entity-tracking-range.monsters", monsterTrackingRange );
+ miscTrackingRange = getInt( "entity-tracking-range.misc", miscTrackingRange );
+ maxTrackingRange = getInt( "entity-tracking-range.other", maxTrackingRange );
+ log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + maxTrackingRange );
+ }
}
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
new file mode 100644
index 0000000..bc6438d
--- /dev/null
+++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -0,0 +1,45 @@
+package org.spigotmc;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityExperienceOrb;
+import net.minecraft.server.EntityGhast;
+import net.minecraft.server.EntityItem;
+import net.minecraft.server.EntityItemFrame;
+import net.minecraft.server.EntityPainting;
+import net.minecraft.server.EntityPlayer;
+
+public class TrackingRange
+{
+
+ /**
+ * Gets the range an entity should be 'tracked' by players and visible in
+ * the client.
+ *
+ * @param entity
+ * @param defaultRange Default range defined by Mojang
+ * @return
+ */
+ public static int getEntityTrackingRange(Entity entity, int defaultRange)
+ {
+ SpigotWorldConfig config = entity.world.spigotConfig;
+ int range = defaultRange;
+ if ( entity instanceof EntityPlayer )
+ {
+ range = config.playerTrackingRange;
+ } else if ( entity.defaultActivationState || entity instanceof EntityGhast )
+ {
+ range = defaultRange;
+ } else if ( entity.activationType == 1 )
+ {
+ range = config.monsterTrackingRange;
+ } else if ( entity.activationType == 2 )
+ {
+ range = config.animalTrackingRange;
+ } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb )
+ {
+ range = config.miscTrackingRange;
+ }
+
+ return Math.min( config.maxTrackingRange, range );
+ }
+}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From c3be564e248a414047f94a896f9ee545f47805df Mon Sep 17 00:00:00 2001
From 150ae92bc058a84187b9c27bd4f65ff27728638d 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
@ -6,7 +6,7 @@ Subject: [PATCH] BungeeCord Support
- Allows BungeeCord to set the players real IP address very early in the login process, so that the BungeeCord proxy IP is never even seen by a plugin.
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
index a945892..7ef9a6f 100644
index a945892..e78781e 100644
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
@@ -221,4 +221,17 @@ public class PendingConnection extends Connection {
@ -17,7 +17,7 @@ index a945892..7ef9a6f 100644
+ // Spigot start
+ @Override
+ public void a(Packet250CustomPayload pcp) {
+ if (pcp.tag.equals("BungeeCord") && org.bukkit.craftbukkit.Spigot.bungeeIPs.contains(getSocket().getInetAddress().getHostAddress())) {
+ if (pcp.tag.equals("BungeeCord") && org.spigotmc.SpigotConfig.bungee && org.spigotmc.SpigotConfig.bungeeAddresses.contains(getSocket().getInetAddress().getHostAddress())) {
+ com.google.common.io.ByteArrayDataInput in = com.google.common.io.ByteStreams.newDataInput(pcp.data);
+ String subTag = in.readUTF();
+ if (subTag.equals("Login")) {
@ -28,7 +28,7 @@ index a945892..7ef9a6f 100644
+ // Spigot end
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 305855b..e6e9295 100644
index b7e327b..30c6503 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -293,7 +293,7 @@ public abstract class PlayerList {
@ -41,7 +41,7 @@ index 305855b..e6e9295 100644
SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
index fcd4136..fb4ec7b 100644
index 1254e63..a4eae65 100644
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -45,11 +45,11 @@ class ThreadLoginVerifier extends Thread {
@ -58,31 +58,11 @@ index fcd4136..fb4ec7b 100644
if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index c434f14..dd92087 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -55,6 +55,7 @@ public class Spigot {
private static boolean filterIps;
public static boolean tabPing = false;
private static Metrics metrics;
+ public static List<String> bungeeIPs;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -91,6 +92,7 @@ public class Spigot {
}
tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
+ bungeeIPs = configuration.getStringList("settings.bungee-proxies");
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 8ec84e1..d70c110 100644
index 7cae665..21141f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1016,6 +1016,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -998,6 +998,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Spigot start
private final Spigot spigot = new Spigot()
{
@ -94,19 +74,33 @@ index 8ec84e1..d70c110 100644
};
public Spigot spigot()
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 28d13fb..2e3b242 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -37,6 +37,8 @@ settings:
timeout-time: 30
restart-on-crash: false
restart-script-location: /path/to/server/start.sh
+ bungee-proxies:
+ - 127.0.0.1
world-settings:
default:
growth-chunks-per-tick: 650
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 910d0de..b71d425 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -193,4 +194,14 @@ public class SpigotConfig
nettyThreads = getInt( "settings.netty-threads", 3 );
}
+ public static List<String> bungeeAddresses = Arrays.asList( new String[]
+ {
+ "127.0.0.1"
+ } );
+ public static boolean bungee = true;
+ private static void bungee()
+ {
+ bungeeAddresses = getList( "settings.bungeecord-addresses", bungee );
+ bungee = getBoolean( "settings.bungeecord", true );
+ }
}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From cdea9e85e90d8ad08e7391db9ef20b362a0d3965 Mon Sep 17 00:00:00 2001
From 2f81e3294321a9bfcb00956f75bb54ea5cdfecf5 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 19:08:41 +1100
Subject: [PATCH] Limit Custom Map Rendering

View File

@ -0,0 +1,51 @@
From 093c26055d78b7e52e6653e47dc73ae765decf5c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 24 Feb 2013 20:45:20 +1100
Subject: [PATCH] Enable Improved Ping Sending
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 7de5b48..35a579c 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -51,6 +51,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public int newLevel = 0;
public int newTotalExp = 0;
public boolean keepLevel = false;
+ public int lastPing = -1; // Spigot
// CraftBukkit end
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, PlayerInteractManager playerinteractmanager) {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 30c6503..1891308 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -717,6 +717,25 @@ public abstract class PlayerList {
this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.ping));
}
// CraftBukkit end */
+ // Spigot start
+ if ( !players.isEmpty() )
+ {
+ int index = MinecraftServer.currentTick % this.players.size();
+ EntityPlayer player = (EntityPlayer) this.players.get( index );
+ if ( player.lastPing == -1 || Math.abs( player.ping - player.lastPing ) > 20 )
+ {
+ Packet packet = new Packet201PlayerInfo( player.listName, true, player.ping );
+ for ( EntityPlayer splayer : (List<EntityPlayer>) this.players )
+ {
+ if ( splayer.getBukkitEntity().canSee( player.getBukkitEntity() ) )
+ {
+ splayer.playerConnection.sendPacket( packet );
+ }
+ }
+ player.lastPing = player.ping;
+ }
+ }
+ // Spigot end
}
public void sendAll(Packet packet) {
--
1.8.1.2

View File

@ -1,153 +0,0 @@
From be31d26856f8eec9b73d506af26ae2de32a87c85 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
This will let you configure how far to track entities in range from players, so that the entity does not render on the client if out of this range.
This has multiple benefits:
1) Less bandwidth. Not sending update packets for entities that are not even close to a player, or even close enough to clearly see.
2) Less lag by maps in item frames - Default range is 160 blocks... Many players can track that item frame and cause lag and not even see it.
3) Less lag in general - Less work for the server to do
4) Less client lag - Not trying to render distant item frames and paintings and entities will reduce entity count on the client, which is major for shop/town worlds which may use tons of item frames.
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
index d7efe3e..f6f1ab0 100644
--- a/src/main/java/net/minecraft/server/EntityTracker.java
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
@@ -90,6 +90,7 @@ public class EntityTracker {
public void addEntity(Entity entity, int i, int j, boolean flag) {
if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity track!"); // Spigot
+ i = org.bukkit.craftbukkit.Spigot.getEntityTrackingRange(entity, i); // Spigot
if (i > this.d) {
i = this.d;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ebf1a67..4439ebc 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -89,6 +89,12 @@ public class CraftWorld implements World {
public int miscEntityActivationRange = 16;
public int animalEntityActivationRange = 32;
public int monsterEntityActivationRange = 32;
+ // Tracking Ranges:
+ public int playerTrackingRange = 64;
+ public int miscTrackingRange = 32;
+ public int animalTrackingRange = 48;
+ public int monsterTrackingRange = 48;
+ public int maxTrackingRange = 64;
// Spigot end
// Spigot start
@@ -128,6 +134,11 @@ public class CraftWorld implements World {
miscEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-misc" );
animalEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-animals" );
monsterEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-monsters" );
+ playerTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-players" );
+ miscTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-misc" );
+ animalTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-animals" );
+ monsterTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-monsters" );
+ maxTrackingRange = configuration.getInt( "world-settings.default.entity-tracking-range-max" );
// Override defaults with world specific, if they exist
info = configuration.getBoolean( "world-settings." + name + ".info", info );
@@ -147,10 +158,19 @@ public class CraftWorld implements World {
miscEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-misc", miscEntityActivationRange );
animalEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-animals", animalEntityActivationRange );
monsterEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-monsters", monsterEntityActivationRange );
+ maxTrackingRange = configuration.getInt( "world-settings." + name + ".entity-tracking-range-max", maxTrackingRange );
+ playerTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-players", playerTrackingRange ) );
+ miscTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-misc", miscTrackingRange ) );
+ animalTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-animals", animalTrackingRange ) );
+ monsterTrackingRange = Math.min( maxTrackingRange, configuration.getInt( "world-settings." + name + ".entity-tracking-range-monsters", monsterTrackingRange ) );
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
obfuscated = world.getServer().orebfuscatorEnabled && !world.getServer().orebfuscatorDisabledWorlds.contains( name );
+ if ( maxTrackingRange == 0 )
+ {
+ System.err.println( "Error! Should not have 0 maxRange" );
+ }
if ( info )
{
@@ -172,6 +192,7 @@ public class CraftWorld implements World {
server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "Orebfuscator: " + obfuscated );
server.getLogger().info( "Entity Activation Range: An " + animalEntityActivationRange + " / Mo " + monsterEntityActivationRange + " / Mi " + miscEntityActivationRange );
+ server.getLogger().info( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Max " + maxTrackingRange );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 6a164ca..c434f14 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -16,11 +16,16 @@ import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.EntityCreature;
import net.minecraft.server.EntityEnderCrystal;
import net.minecraft.server.EntityEnderDragon;
+import net.minecraft.server.EntityExperienceOrb;
import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityFireworks;
+import net.minecraft.server.EntityGhast;
import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityItem;
+import net.minecraft.server.EntityItemFrame;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
+import net.minecraft.server.EntityPainting;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntitySheep;
@@ -374,6 +379,30 @@ public class Spigot {
}
}
+ /**
+ * Gets the range an entity should be 'tracked' by players and visible in the client.
+ * @param entity
+ * @param defaultRange Default range defined by Mojang
+ * @return
+ */
+ public static int getEntityTrackingRange(Entity entity, int defaultRange) {
+ CraftWorld world = entity.world.getWorld();
+ int range = defaultRange;
+ if (entity instanceof EntityPlayer) {
+ range = world.playerTrackingRange;
+ } else if (entity.defaultActivationState || entity instanceof EntityGhast) {
+ range = defaultRange;
+ } else if (entity.activationType == 1) {
+ range = world.monsterTrackingRange;
+ } else if (entity.activationType == 2) {
+ range = world.animalTrackingRange;
+ } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb) {
+ range = world.miscTrackingRange;
+ }
+
+ return Math.min(world.maxTrackingRange, range);
+ }
+
public static boolean filterIp(PendingConnection con) {
if (filterIps) {
try {
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 53db120..28d13fb 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -55,6 +55,11 @@ world-settings:
entity-activation-range-animals: 32
entity-activation-range-monsters: 32
entity-activation-range-misc: 16
+ entity-tracking-range-players: 48
+ entity-tracking-range-animals: 48
+ entity-tracking-range-monsters: 48
+ entity-tracking-range-misc: 32
+ entity-tracking-range-max: 64
info: true
world:
growth-chunks-per-tick: 1000
--
1.8.1.2

View File

@ -0,0 +1,27 @@
From 47e90e4e5c72a105ff5b9901ef6929ef7511d1fb Mon Sep 17 00:00:00 2001
From: Benjamin James Harrison-Sims <tehrainbowguy@gmail.com>
Date: Sun, 14 Apr 2013 21:19:57 +0500
Subject: [PATCH] Filter Invalid Names
diff --git a/src/main/java/net/minecraft/server/Packet2Handshake.java b/src/main/java/net/minecraft/server/Packet2Handshake.java
index 343af93..26de0b5 100644
--- a/src/main/java/net/minecraft/server/Packet2Handshake.java
+++ b/src/main/java/net/minecraft/server/Packet2Handshake.java
@@ -14,11 +14,13 @@ public class Packet2Handshake extends Packet {
public Packet2Handshake() {}
+ public static final java.util.regex.Pattern validName = java.util.regex.Pattern.compile("^[a-zA-Z0-9_-]{2,16}$");
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
this.a = datainputstream.readByte();
this.b = a(datainputstream, 16);
this.c = a(datainputstream, 255);
this.d = datainputstream.readInt();
+ if(!validName.matcher(this.b).matches()) throw new IOException("Invalid name!"); // Spigot
}
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 7ec562c76eba6f4ad566e41199e27c93d47d1399 Mon Sep 17 00:00:00 2001
From 3ffe256945a7df36f9b9fe08be2b44547d8e9c14 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:50:27 +1000
Subject: [PATCH] Thread Naming and Tweaks
@ -6,7 +6,7 @@ Subject: [PATCH] Thread Naming and Tweaks
Removes the sleep forever thread and adds useful names for debugging to all staged thread files.
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index e4f1cbe..048196e 100644
index b2a4229..2a6250d 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -34,7 +34,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@ -31,7 +31,7 @@ index 489e184..bfd219c 100644
}
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
index fb4ec7b..c15efc5 100644
index a4eae65..496cfe4 100644
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -21,6 +21,7 @@ class ThreadLoginVerifier extends Thread {
@ -43,10 +43,10 @@ index fb4ec7b..c15efc5 100644
// CraftBukkit end
this.pendingConnection = pendingconnection;
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 0a5c61a..35badf3 100644
index 84dcfcc..a30f217 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -70,7 +70,7 @@ public class CraftScheduler implements BukkitScheduler {
@@ -71,7 +71,7 @@ public class CraftScheduler implements BukkitScheduler {
*/
private final ConcurrentHashMap<Integer, CraftTask> runners = new ConcurrentHashMap<Integer, CraftTask>();
private volatile int currentTick = -1;

View File

@ -1,7 +1,7 @@
From 7c270c3974b72f4338387b224b1bc3683062e721 Mon Sep 17 00:00:00 2001
From 84f08c5d634c68048f6621cdd42344ce0bc8a9ea Mon Sep 17 00:00:00 2001
From: Antony Riley <antony@cyberiantiger.org>
Date: Wed, 27 Mar 2013 01:41:54 +0200
Subject: [PATCH] Close Unloaded World's Save Files
Subject: [PATCH] Close Unloaded Save Files
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
@ -18,7 +18,7 @@ index 900ed68..829f4a3 100644
public static synchronized RegionFile a(File file1, int i, int j) {
File file2 = new File(file1, "region");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2485ef9..b6fe332 100644
index 68694de..2cca80a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -37,6 +37,8 @@ import net.minecraft.server.MinecraftServer;
@ -30,7 +30,7 @@ index 2485ef9..b6fe332 100644
import net.minecraft.server.ServerNBTManager;
import net.minecraft.server.WorldLoaderServer;
import net.minecraft.server.WorldManager;
@@ -831,6 +833,30 @@ public final class CraftServer implements Server {
@@ -811,6 +813,30 @@ public final class CraftServer implements Server {
worlds.remove(world.getName().toLowerCase());
console.worlds.remove(console.worlds.indexOf(handle));

View File

@ -1,68 +0,0 @@
From 169434d1db9c1d520028cbe61fb5a386db115c72 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
Fix issues when specifiying a server texture pack URL with resolution != 16.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d197f06..e348ac5 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1076,7 +1076,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public int S() {
- return 16;
+ return org.bukkit.craftbukkit.Spigot.textureResolution; // Spigot
}
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 dd92087..99020e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -56,6 +56,7 @@ public class Spigot {
public static boolean tabPing = false;
private static Metrics metrics;
public static List<String> bungeeIPs;
+ public static int textureResolution = 16;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -93,6 +94,7 @@ public class Spigot {
tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
bungeeIPs = configuration.getStringList("settings.bungee-proxies");
+ textureResolution = configuration.getInt("settings.texture-resolution", textureResolution);
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 d70c110..3d39d07 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -830,7 +830,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setTexturePack(String url) {
Validate.notNull(url, "Texture pack URL cannot be null");
- byte[] message = (url + "\0" + "16").getBytes();
+ byte[] message = (url + "\0" + org.bukkit.craftbukkit.Spigot.textureResolution).getBytes(); // Spigot
Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long");
getHandle().playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", message));
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 2e3b242..4334b20 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -39,6 +39,7 @@ settings:
restart-script-location: /path/to/server/start.sh
bungee-proxies:
- 127.0.0.1
+ texture-resolution: 16
world-settings:
default:
growth-chunks-per-tick: 650
--
1.8.1.2

View File

@ -1,7 +1,7 @@
From 74f1a8847b7ddcd2384478a03bec9f0bced13808 Mon Sep 17 00:00:00 2001
From c4ca5d2c5867b36a6e203fbf55f741a644ba87c0 Mon Sep 17 00:00:00 2001
From: snowleo <schneeleo@gmail.com>
Date: Wed, 8 May 2013 12:09:45 +1000
Subject: [PATCH] Optimized version of LocaleLanguage
Subject: [PATCH] Cache Translation Storage
This patch reduces the memory footprint of each EntityPlayer by about 300 KB. The original class looks very unfinished and future versions might use the commented code.

View File

@ -1,9 +1,10 @@
From 6ea72294e723e6676db69b32f206f029b2833210 Mon Sep 17 00:00:00 2001
From 79812d32f7cfef51de310b72ed9eb59410395573 Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 24 Apr 2013 01:43:33 -0500
Subject: [PATCH] Improve next-tick-list performance on chunk unloads, large
queues
Subject: [PATCH] Improve NextTickList Performance
Improve next-tick-list performance on chunk unloads, large
queues
diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java
index 52a70a1..08a4240 100644
@ -19,7 +20,7 @@ index 52a70a1..08a4240 100644
public NextTickListEntry a(long i) {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 7b8e70c..93e7b9b 100644
index 69d955f..7cdb549 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -25,8 +25,8 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@ -41,9 +42,9 @@ index 7b8e70c..93e7b9b 100644
+ private ArrayList<NextTickListEntry> pendingTickEntries = new ArrayList<NextTickListEntry>(); // Spigot
+ private int nextPendingTickEntry; // Spigot
private IntHashMap entitiesById;
private int aggregateTicks = 1; // Spigot
@@ -54,13 +55,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit start
@@ -53,13 +54,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.entitiesById = new IntHashMap();
}
@ -63,7 +64,7 @@ index 7b8e70c..93e7b9b 100644
this.P = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit
this.scoreboard = new ScoreboardServer(minecraftserver);
@@ -446,9 +449,16 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -441,9 +444,16 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
}
public boolean a(int i, int j, int k, int l) {
@ -83,7 +84,7 @@ index 7b8e70c..93e7b9b 100644
}
public void a(int i, int j, int k, int l, int i1) {
@@ -481,10 +491,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -476,10 +486,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
nextticklistentry.a(j1);
}
@ -97,7 +98,7 @@ index 7b8e70c..93e7b9b 100644
}
}
@@ -496,10 +505,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -491,10 +500,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
nextticklistentry.a((long) i1 + this.worldData.getTime());
}
@ -111,7 +112,7 @@ index 7b8e70c..93e7b9b 100644
}
public void tickEntities() {
@@ -519,11 +527,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -514,11 +522,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
}
public boolean a(boolean flag) {
@ -128,7 +129,7 @@ index 7b8e70c..93e7b9b 100644
if (i > 1000) {
// CraftBukkit start - If the server has too much to process over time, try to alleviate that
if (i > 20 * 1000) {
@@ -539,23 +548,24 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -534,23 +543,24 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
NextTickListEntry nextticklistentry;
for (int j = 0; j < i; ++j) {
@ -162,7 +163,7 @@ index 7b8e70c..93e7b9b 100644
byte b0 = 0;
if (this.e(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) {
@@ -586,52 +596,18 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -581,52 +591,18 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
}
this.methodProfiler.b();
@ -224,7 +225,7 @@ index 7b8e70c..93e7b9b 100644
}
public void entityJoinedWorld(Entity entity, boolean flag) {
@@ -708,13 +684,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -703,13 +679,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.entitiesById = new IntHashMap();
}
@ -244,7 +245,7 @@ index 7b8e70c..93e7b9b 100644
this.b(worldsettings);
super.a(worldsettings);
@@ -1001,4 +979,62 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -996,4 +974,62 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
return this.setTypeIdAndData(x, y, z, typeId, data, 3);
}
// CraftBukkit end

View File

@ -1,33 +0,0 @@
From bc47d2f19f661d565fa5a5836ae12611ca919b41 Mon Sep 17 00:00:00 2001
From: Hudson <hudson@mydomain.com>
Date: Wed, 3 Apr 2013 02:16:56 -0500
Subject: [PATCH] Revert "Throw exception for disabled plugin tasks. Fixes
BUKKIT-3951"
This reverts commit 052e955ed71a30516a5e9cfd76649daaba4ae7d8.
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 84dcfcc..0a5c61a 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import org.apache.commons.lang.Validate;
-import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
@@ -390,9 +389,6 @@ public class CraftScheduler implements BukkitScheduler {
private static void validate(final Plugin plugin, final Object task) {
Validate.notNull(plugin, "Plugin cannot be null");
Validate.notNull(task, "Task cannot be null");
- if (!plugin.isEnabled()) {
- throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
- }
}
private int nextId() {
--
1.8.1.2

View File

@ -1,64 +0,0 @@
From ce0a432bfc7a8c6d84276172bb03c4641a4fdf1f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 24 Feb 2013 20:45:20 +1100
Subject: [PATCH] Enable Improved ping sending
3 files changed, 18 insertions(+)
3 files changed, 18 insertions(+)
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 9925d1b..5fa0b05 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -51,6 +51,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public int newLevel = 0;
public int newTotalExp = 0;
public boolean keepLevel = false;
+ public int lastPing = -1; // Spigot
// CraftBukkit end
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, PlayerInteractManager playerinteractmanager) {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index e6e9295..d5387f3 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -724,7 +724,23 @@ public abstract class PlayerList {
this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.ping));
}
// CraftBukkit end */
+ // Spigot start
+ if (this.players.size() == 0 || !org.bukkit.craftbukkit.Spigot.tabPing) {
+ return;
+ }
+ int index = MinecraftServer.currentTick % this.players.size();
+ EntityPlayer player = (EntityPlayer) this.players.get(index);
+ if (player.lastPing == -1 || Math.abs(player.ping - player.lastPing) > 20) {
+ Packet packet = new Packet201PlayerInfo(player.listName, true, player.ping);
+ for (EntityPlayer splayer : (List<EntityPlayer>) this.players) {
+ if (splayer.getBukkitEntity().canSee(player.getBukkitEntity())) {
+ splayer.playerConnection.sendPacket(packet);
+ }
+ }
+ player.lastPing = player.ping;
+ }
}
+ // Spigot end
public void sendAll(Packet packet) {
for (int i = 0; i < this.players.size(); ++i) {
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 4334b20..5d2ef1f 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -34,6 +34,7 @@ settings:
spam-exclusions:
- /skill
filter-unsafe-ips: false
+ tab-ping: false
timeout-time: 30
restart-on-crash: false
restart-script-location: /path/to/server/start.sh
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From cd7d8ce5ba9c942a20b7c740075824f042a4a5a2 Mon Sep 17 00:00:00 2001
From ae0e44f5154f07327ce85320d291f6d38d2b96b7 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 19 May 2013 18:29:48 +1000
Subject: [PATCH] Remove -o Option

View File

@ -1,60 +0,0 @@
From c1dcecdd3cca81c750580a70b1125012481fca7c Mon Sep 17 00:00:00 2001
From: Benjamin James Harrison-Sims <tehrainbowguy@gmail.com>
Date: Sun, 14 Apr 2013 21:19:57 +0500
Subject: [PATCH] Prevent handshake spam from invalid names.
diff --git a/src/main/java/net/minecraft/server/Packet2Handshake.java b/src/main/java/net/minecraft/server/Packet2Handshake.java
index 343af93..aa6609b 100644
--- a/src/main/java/net/minecraft/server/Packet2Handshake.java
+++ b/src/main/java/net/minecraft/server/Packet2Handshake.java
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.Spigot;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -19,6 +21,7 @@ public class Packet2Handshake extends Packet {
this.b = a(datainputstream, 16);
this.c = a(datainputstream, 255);
this.d = datainputstream.readInt();
+ if(!Spigot.validName.matcher(this.b).matches()) throw new IOException("Invalid name!"); // Spigot
}
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 99020e7..c7ef0e1 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -6,6 +6,7 @@ import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import java.util.regex.Pattern;
import net.minecraft.server.AxisAlignedBB;
import net.minecraft.server.Chunk;
import net.minecraft.server.Entity;
@@ -57,6 +58,7 @@ public class Spigot {
private static Metrics metrics;
public static List<String> bungeeIPs;
public static int textureResolution = 16;
+ public static final Pattern validName = Pattern.compile("^[a-zA-Z0-9_-]{2,16}$");
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -384,7 +386,9 @@ public class Spigot {
}
/**
- * Gets the range an entity should be 'tracked' by players and visible in the client.
+ * Gets the range an entity should be 'tracked' by players and visible in
+ * the client.
+ *
* @param entity
* @param defaultRange Default range defined by Mojang
* @return
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 447a2540b8e5a301acf27915d2423d9b2ff98a49 Mon Sep 17 00:00:00 2001
From 584fae45430e0fd52bcdb5742ca77f893a862264 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 1 Jun 2013 16:34:38 +1000
Subject: [PATCH] Recipe Deconstruction

View File

@ -1,4 +1,4 @@
From 56451612f8d3f8100ddecca4f72ed97c69b20be1 Mon Sep 17 00:00:00 2001
From 5537a2a1c5596e5df2f5f3d9c953f46ef7e3d372 Mon Sep 17 00:00:00 2001
From: Nick Minkler <sleaker@gmail.com>
Date: Sun, 2 Jun 2013 14:54:11 +1000
Subject: [PATCH] Fix Health Scaling

View File

@ -1,79 +0,0 @@
From 47715338fc2fd1041950cdcf86997d977d596b3d Mon Sep 17 00:00:00 2001
From: Ammar Askar <ammar@ammaraskar.com>
Date: Sat, 20 Apr 2013 12:26:20 +0500
Subject: [PATCH] Save entity counts for randomly spawned creatures to avoid
repeatedly traversing over the entity slices
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7416edc..958b5af 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Random;
import org.bukkit.Bukkit; // CraftBukkit
+import gnu.trove.map.hash.TObjectIntHashMap; // Spigot
public class Chunk {
@@ -33,6 +34,7 @@ public class Chunk {
public int p;
private int u;
boolean q;
+ protected TObjectIntHashMap<Class> entityCount = new TObjectIntHashMap<Class>(); // Spigot
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
@@ -560,6 +562,13 @@ public class Chunk {
entity.ak = k;
entity.al = this.z;
this.entitySlices[k].add(entity);
+ // Spigot start - increment creature type count
+ for (EnumCreatureType creatureType : EnumCreatureType.values()) {
+ if (creatureType.a().isAssignableFrom(entity.getClass())) {
+ this.entityCount.adjustOrPutValue(creatureType.a(), 1, 1);
+ }
+ }
+ // Spigot end
}
public void b(Entity entity) {
@@ -576,6 +585,13 @@ public class Chunk {
}
this.entitySlices[i].remove(entity);
+ // Spigot start - decrement creature type count
+ for (EnumCreatureType creatureType : EnumCreatureType.values()) {
+ if (creatureType.a().isAssignableFrom(entity.getClass())) {
+ this.entityCount.adjustValue(creatureType.a(), -1);
+ }
+ }
+ // Spigot end
}
public boolean d(int i, int j, int k) {
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 3529074..25b83f7 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -33,14 +33,8 @@ public final class SpawnerCreature {
for (Long coord : b.keySet()) {
int x = LongHash.msw(coord);
int z = LongHash.lsw(coord);
- if (!server.chunkProviderServer.unloadQueue.contains(x,z) && server.isChunkLoaded(x, z)) {
- for (List<Entity> entitySlice : server.getChunkAt(x, z).entitySlices) {
- for (Entity entity : entitySlice) {
- if (oClass.isAssignableFrom(entity.getClass())) {
- ++i;
- }
- }
- }
+ if (!server.chunkProviderServer.unloadQueue.contains(coord) && server.isChunkLoaded(x, z)) {
+ i += server.getChunkAt(x, z).entityCount.get(oClass);
}
}
return i;
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From b4cca3cf71f2fe61f71edfdacded8a751ccab99e Mon Sep 17 00:00:00 2001
From 88def699bf4f7a11ff3764f0ecd9831c162ad0e2 Mon Sep 17 00:00:00 2001
From: Nick Minkler <sleaker@gmail.com>
Date: Sun, 2 Jun 2013 15:04:37 +1000
Subject: [PATCH] Fix EntityShootBowEvent with Skeletons

View File

@ -1,4 +1,4 @@
From fd7a9cd07230c70af60b51327a2dc29657e3b64d Mon Sep 17 00:00:00 2001
From 9bcb4c341ee6908fa4a141583283d21283f26a55 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 2 Jun 2013 15:16:05 +1000
Subject: [PATCH] Implement Arrow API

View File

@ -1,4 +1,4 @@
From 4fde28828a4820deccf067f854ecae8e3eb8996b Mon Sep 17 00:00:00 2001
From d1725f257553f7abf4fa2f13734713972b756b06 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 2 Jun 2013 16:14:30 +1000
Subject: [PATCH] Particle API
@ -43,10 +43,10 @@ index 7de0de5..7eca388 100644
datavalue = 0;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4439ebc..56d3d32 100644
index edc59b1..0778a66 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -885,31 +885,21 @@ public class CraftWorld implements World {
@@ -766,31 +766,21 @@ public class CraftWorld implements World {
} else {
Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
}
@ -88,7 +88,7 @@ index 4439ebc..56d3d32 100644
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
return spawn(location, clazz, SpawnReason.CUSTOM);
}
@@ -1388,6 +1378,62 @@ public class CraftWorld implements World {
@@ -1269,6 +1259,62 @@ public class CraftWorld implements World {
// Spigot start
private final Spigot spigot = new Spigot()
{
@ -152,7 +152,7 @@ index 4439ebc..56d3d32 100644
public Spigot spigot()
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 3d39d07..8ee2c3b 100644
index 21141f2..feed78e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -266,13 +266,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -191,7 +191,7 @@ index 3d39d07..8ee2c3b 100644
}
public void sendBlockChange(Location loc, Material material, byte data) {
@@ -1021,6 +1024,43 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1003,6 +1006,43 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
{
return ( getHandle().playerConnection == null ) ? null : (InetSocketAddress) getHandle().playerConnection.networkManager.getSocket().getRemoteSocketAddress();
}
@ -236,5 +236,5 @@ index 3d39d07..8ee2c3b 100644
public Spigot spigot()
--
1.8.3
1.8.1.2

View File

@ -0,0 +1,86 @@
From 2a158ef53f85cf5004c22e680bfe80dcd1f4f573 Mon Sep 17 00:00:00 2001
From: DerFlash <bte@freenet.de>
Date: Sun, 2 Jun 2013 16:23:46 +1000
Subject: [PATCH] Hopper Cooldowns
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
index f6d269d..1f69c7b 100644
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
@@ -181,16 +181,19 @@ public class TileEntityHopper extends TileEntity implements IHopper {
boolean flag = this.u() | suckInItems(this);
if (flag) {
- this.c(8);
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
this.update();
return true;
}
}
-
- return false;
- } else {
- return false;
}
+ // Spigot start
+ if ( this.c == 0 )
+ {
+ this.c( world.spigotConfig.hopperCheck );
+ }
+ // Spigot end
+ return false;
}
private boolean u() {
@@ -217,7 +220,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
this.getWorld().getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.setItem(i, itemstack);
- this.c(8); // Delay hopper checks
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
return false;
}
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[BlockHopper.c(this.p())]);
@@ -298,9 +301,9 @@ public class TileEntityHopper extends TileEntity implements IHopper {
iinventory.setItem(i, itemstack1);
if (ihopper instanceof TileEntityHopper) {
- ((TileEntityHopper) ihopper).c(8); // Delay hopper checks
+ ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
} else if (ihopper instanceof EntityMinecartHopper) {
- ((EntityMinecartHopper) ihopper).n(4); // Delay hopper minecart checks
+ ((EntityMinecartHopper) ihopper).n(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
}
return false;
@@ -404,7 +407,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
if (flag) {
if (iinventory instanceof TileEntityHopper) {
- ((TileEntityHopper) iinventory).c(8);
+ ((TileEntityHopper) iinventory).c(((TileEntityHopper) iinventory).world.spigotConfig.hopperTransfer); // Spigot
}
iinventory.update();
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 89d716c..8f13fa9 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -178,4 +178,13 @@ public class SpigotWorldConfig
maxTrackingRange = getInt( "entity-tracking-range.other", maxTrackingRange );
log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + maxTrackingRange );
}
+
+ public int hopperTransfer = 8;
+ public int hopperCheck = 8;
+ private void hoppers()
+ {
+ hopperCheck = getInt( "ticks-per.hopper-check", hopperCheck );
+ hopperTransfer = getInt( "ticks-per.hopper-transfer", hopperTransfer );
+ log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck );
+ }
}
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 88c21014a866791f3be6e9b2c8778eb6dda3d506 Mon Sep 17 00:00:00 2001
From c18ceeae093ea461e065fbea7051ab0917bf29dd Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 11:54:32 +1000
Subject: [PATCH] Prevent Shutdown Hang
@ -6,10 +6,10 @@ Subject: [PATCH] Prevent Shutdown Hang
Prevents server hanging if players disconnect during the shutdown sequence.
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index d5387f3..e5d2710 100644
index 1891308..fe846af 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -1071,7 +1071,14 @@ public abstract class PlayerList {
@@ -1067,7 +1067,14 @@ public abstract class PlayerList {
public void r() {
while (!this.players.isEmpty()) {

View File

@ -1,4 +1,4 @@
From 7166f5c5d632bd3598ae824985e27a73a9befd2c Mon Sep 17 00:00:00 2001
From 6257069117c3870c0b8640386252867a3f4f5c0a Mon Sep 17 00:00:00 2001
From: Andy Shulman <andy.shulman@hotmail.com>
Date: Mon, 15 Apr 2013 20:06:37 -0500
Subject: [PATCH] Implement SpawnerSpawnEvent.

View File

@ -1,4 +1,4 @@
From 6eb432158c3fde080bddf7a8e643b5c355bd023e Mon Sep 17 00:00:00 2001
From 395165e77c0d165c30ffbba7eea45b98d81f4b93 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 15 Jun 2013 21:34:48 +1000
Subject: [PATCH] Firework Meta Crash Fix

View File

@ -1,4 +1,4 @@
From f0c3892e80dc22f3fb93e7ee8177da61c7c54204 Mon Sep 17 00:00:00 2001
From 4822e71bfb0e5730738fd2a06a4bf3ff33e75c28 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 16 Jun 2013 08:20:26 +1000
Subject: [PATCH] Do Not Search for Offline Players
@ -6,10 +6,10 @@ Subject: [PATCH] Do Not Search for Offline Players
By default we do not want to search as this leads to massive load times for plugins wanting to do mass data lookups.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b6fe332..76659bc 100644
index 2cca80a..1fcbd33 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1108,7 +1108,7 @@ public final class CraftServer implements Server {
@@ -1088,7 +1088,7 @@ public final class CraftServer implements Server {
}
public OfflinePlayer getOfflinePlayer(String name) {

View File

@ -0,0 +1,22 @@
From ba0018601961308c4c4213daaeef9c23e62ef37f Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:53:03 +1000
Subject: [PATCH] Enable Foreign Language Signs
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 8deba1b..998ac8d 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1559,7 +1559,7 @@ public class PlayerConnection extends Connection {
flag = false;
} else {
for (i = 0; i < packet130updatesign.lines[j].length(); ++i) {
- if (SharedConstants.allowedCharacters.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) {
+ if (!SharedConstants.isAllowedChatCharacter(packet130updatesign.lines[j].charAt(i))) { // Spigot
flag = false;
}
}
--
1.8.1.2

View File

@ -0,0 +1,41 @@
From ca4219456ce6b7f5ea1b18b4b7adce3fc08f9cf1 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:59:22 +1000
Subject: [PATCH] Spam Filter Exclusions
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 998ac8d..a292c1a 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -846,7 +846,8 @@ public class PlayerConnection extends Connection {
this.chat(s, packet3chat.a_());
// This section stays because it is only applicable to packets
- if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.name)) { // CraftBukkit use thread-safe spam
+ // Spigot - spam exclusions
+ if (!org.spigotmc.SpigotConfig.spamExclusions.contains(s) && chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.name)) { // CraftBukkit use thread-safe spam
if (packet3chat.a_()) {
Waitable waitable = new Waitable() {
@Override
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index b71d425..1685d9f 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -204,4 +204,13 @@ public class SpigotConfig
bungeeAddresses = getList( "settings.bungeecord-addresses", bungee );
bungee = getBoolean( "settings.bungeecord", true );
}
+
+ public static List<String> spamExclusions;
+ private static void spamExclusions()
+ {
+ spamExclusions = getList( "commands.spam-exclusions", Arrays.asList( new String[]
+ {
+ "/skill"
+ } ) );
+ }
}
--
1.8.1.2

View File

@ -0,0 +1,42 @@
From f78427a84375f14b3204f9891f62783c8c2840bb Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:01:29 +1000
Subject: [PATCH] Allow Disabling of Command Logging
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a292c1a..0e8d292 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -970,7 +970,12 @@ public class PlayerConnection extends Connection {
}
try {
- this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
+ // Spigot Start
+ if ( org.spigotmc.SpigotConfig.logCommands )
+ {
+ this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
+ }
+ // Spigot end
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 1685d9f..9214f16 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -213,4 +213,10 @@ public class SpigotConfig
"/skill"
} ) );
}
+
+ public static boolean logCommands;
+ private static void logCommands()
+ {
+ logCommands = getBoolean( "commands.log", true );
+ }
}
--
1.8.1.2

View File

@ -1,103 +0,0 @@
From eb047d75ceeb8a7efd65347ced86047bb40205e7 Mon Sep 17 00:00:00 2001
From: DerFlash <bte@freenet.de>
Date: Sun, 2 Jun 2013 16:23:46 +1000
Subject: [PATCH] Hopper Cooldowns
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
index f6d269d..88b2cb0 100644
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
@@ -181,16 +181,19 @@ public class TileEntityHopper extends TileEntity implements IHopper {
boolean flag = this.u() | suckInItems(this);
if (flag) {
- this.c(8);
+ this.c(org.bukkit.craftbukkit.Spigot.hopperTransferCooldown); // Spigot
this.update();
return true;
}
}
-
- return false;
- } else {
- return false;
}
+ // Spigot start
+ if ( this.c == 0 )
+ {
+ this.c( org.bukkit.craftbukkit.Spigot.hopperCheckCooldown );
+ }
+ // Spigot end
+ return false;
}
private boolean u() {
@@ -217,7 +220,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
this.getWorld().getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.setItem(i, itemstack);
- this.c(8); // Delay hopper checks
+ this.c(org.bukkit.craftbukkit.Spigot.hopperTransferCooldown); // Spigot
return false;
}
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[BlockHopper.c(this.p())]);
@@ -298,9 +301,9 @@ public class TileEntityHopper extends TileEntity implements IHopper {
iinventory.setItem(i, itemstack1);
if (ihopper instanceof TileEntityHopper) {
- ((TileEntityHopper) ihopper).c(8); // Delay hopper checks
+ ((TileEntityHopper) ihopper).c(org.bukkit.craftbukkit.Spigot.hopperTransferCooldown); // Spigot
} else if (ihopper instanceof EntityMinecartHopper) {
- ((EntityMinecartHopper) ihopper).n(4); // Delay hopper minecart checks
+ ((EntityMinecartHopper) ihopper).n(org.bukkit.craftbukkit.Spigot.hopperTransferCooldown / 2); // Spigot
}
return false;
@@ -404,7 +407,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
if (flag) {
if (iinventory instanceof TileEntityHopper) {
- ((TileEntityHopper) iinventory).c(8);
+ ((TileEntityHopper) iinventory).c(org.bukkit.craftbukkit.Spigot.hopperTransferCooldown); // Spigot
}
iinventory.update();
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index c7ef0e1..bbfcd97 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -59,6 +59,8 @@ public class Spigot {
public static List<String> bungeeIPs;
public static int textureResolution = 16;
public static final Pattern validName = Pattern.compile("^[a-zA-Z0-9_-]{2,16}$");
+ public static int hopperTransferCooldown = 8;
+ public static int hopperCheckCooldown = 8;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
@@ -97,6 +99,8 @@ public class Spigot {
tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
bungeeIPs = configuration.getStringList("settings.bungee-proxies");
textureResolution = configuration.getInt("settings.texture-resolution", textureResolution);
+ hopperTransferCooldown = configuration.getInt("ticks-per.hopper-transfer", hopperTransferCooldown);
+ hopperCheckCooldown = configuration.getInt("ticks-per.hopper-check", hopperCheckCooldown);
if (metrics == null) {
try {
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 5d2ef1f..c056762 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -83,6 +83,8 @@ ticks-per:
animal-spawns: 400
monster-spawns: 1
autosave: 0
+ hopper-transfer: 8
+ hopper-check: 8
auto-updater:
enabled: true
on-broken: [warn-console, warn-ops]
--
1.8.1.2

View File

@ -0,0 +1,37 @@
From ef86c38f34b99933811189b6710f79cdfe593557 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:05:54 +1000
Subject: [PATCH] Allow Disabling of Command TabComplete
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1fcbd33..42600a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1355,7 +1355,7 @@ public final class CraftServer implements Server {
public List<String> tabCompleteCommand(Player player, String message) {
List<String> completions = null;
try {
- completions = getCommandMap().tabComplete(player, message.substring(1));
+ completions = (org.spigotmc.SpigotConfig.tabComplete) ? getCommandMap().tabComplete(player, message.substring(1)) : null;
} catch (CommandException ex) {
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 9214f16..3cccb72 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -219,4 +219,10 @@ public class SpigotConfig
{
logCommands = getBoolean( "commands.log", true );
}
+
+ public static boolean tabComplete;
+ private static void tabComplete()
+ {
+ tabComplete = getBoolean( "commands.tab-complete", true );
+ }
}
--
1.8.1.2

View File

@ -0,0 +1,64 @@
From 866aee41f87d8a15b7181248f1f36076e818c67a Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 19:21:58 +1000
Subject: [PATCH] Configurable Messages
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index fe846af..edeefba 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -307,7 +307,7 @@ public abstract class PlayerList {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s1);
} else if (!this.isWhitelisted(s)) {
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot
} else {
String s2 = socketaddress.toString();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 42600a6..9d71ae3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -526,7 +526,7 @@ public final class CraftServer implements Server {
return true;
}
- sender.sendMessage("Unknown command. Type \"help\" for help.");
+ sender.sendMessage(org.spigotmc.SpigotConfig.unknownCommandMessage);
return false;
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 3cccb72..102c5fa 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -15,6 +15,7 @@ import java.util.Map;
import java.util.logging.Level;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.command.TicksPerSecondCommand;
@@ -225,4 +226,16 @@ public class SpigotConfig
{
tabComplete = getBoolean( "commands.tab-complete", true );
}
+
+ public static String whitelistMessage;
+ public static String unknownCommandMessage;
+ private static String transform(String s)
+ {
+ return ChatColor.translateAlternateColorCodes( '&', s ).replaceAll( "\\n", "\n" );
+ }
+ private static void messages()
+ {
+ whitelistMessage = transform( getString( "messages.whitelist", "You are not whitelisted on this server!" ) );
+ unknownCommandMessage = transform( getString( "messages.unknown-command", "Unknown command. Type \"help\" for help." ) );
+ }
}
--
1.8.1.2