Rough Spigot Changes

This commit is contained in:
md_5 2013-06-20 18:21:31 +10:00
parent ba7c6ef6b0
commit df45aed819
2 changed files with 125 additions and 175 deletions

View File

@ -1,4 +1,4 @@
From fe7535a22ad65e997e3bec6529f4a9ec49e51cfb Mon Sep 17 00:00:00 2001
From 1abb83644de1706b96b50f0497854ecc1f228a12 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
@ -148,10 +148,10 @@ index 49360c1..6c3fcf1 100644
}
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index b954278..7d4cf91 100644
index 7d3ec55..4e1bdcf 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -47,4 +47,11 @@ public class SpigotWorldConfig
@@ -54,4 +54,11 @@ public class SpigotWorldConfig
config.addDefault( "world-settings.default." + path, def );
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
}

View File

@ -1,20 +1,9 @@
From 41fa2773f2174d13e06dc8696b97c5c95e9fa69c Mon Sep 17 00:00:00 2001
From c2d9713c3da77a4e39cbbea17070b2d41699a913 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 13:55:57 +1000
Date: Thu, 20 Jun 2013 18:21:09 +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
@ -37,7 +26,7 @@ index 4392cb2..8e041c2 100644
+ // 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
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 {
@ -45,12 +34,12 @@ index 83cc09d..eed8ded 100644
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
+ 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..0aee7af 100644
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 {
@ -58,7 +47,7 @@ index 14a1c3b..0aee7af 100644
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
+ 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
}
}
@ -77,7 +66,7 @@ index 6f9301d..2ccc0b8 100644
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
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 {
@ -85,7 +74,7 @@ index 872ad00..6e135a4 100644
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
+ if (random.nextInt(Math.max(1, (int) world.growthOdds / world.spigotConfig.mushroomModifier * 25)) == 0) { // Spigot
byte b0 = 4;
int l = 5;
@ -104,7 +93,7 @@ index 1de8c83..fa11d1c 100644
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
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 {
@ -112,12 +101,12 @@ index 8657860..50c5200 100644
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
+ 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..4ab0fb9 100644
index 3b00939..d48677a 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 {
@ -125,12 +114,12 @@ index 3b00939..4ab0fb9 100644
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
+ if (world.getLightLevel(i, j + 1, k) >= 9 && (random.nextInt(Math.max(2, (int) ((world.growthOdds / world.spigotConfig.tickAggregate / 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..c17ce36 100644
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 {
@ -138,12 +127,12 @@ index 8339a35..c17ce36 100644
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
+ 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/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 018c314..f6885d6 100644
index 018c314..52fa75a 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 {
@ -173,7 +162,7 @@ index 018c314..f6885d6 100644
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 (org.spigotmc.SpigotConfig.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;
}
@ -188,70 +177,11 @@ index 018c314..f6885d6 100644
}
}
}
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 6cb50b7..c78bc0f 100644
index 6cb50b7..2567bde 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 {
@@ -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"));
@ -260,20 +190,7 @@ index 6cb50b7..c78bc0f 100644
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 {
@@ -535,6 +535,7 @@ public final class CraftServer implements Server {
((DedicatedServer) console).propertyManager = config;
@ -281,48 +198,15 @@ index 6cb50b7..c78bc0f 100644
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 {
@@ -1326,7 +1327,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
+ completions = (org.spigotmc.SpigotConfig.tabComplete) ? 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/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
@ -336,41 +220,107 @@ index c896ba2..e99cb22 100644
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
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index bf297bc..38bd7ba 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -6,7 +6,6 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -84,15 +83,21 @@ public class SpigotConfig
return config.getInt( path, config.getInt( path ) );
}
- private <T> List<T> getList(String path, T def)
+ private static String getString(String path, String def)
{
config.addDefault( path, def );
- return (List<T>) config.getList( path, config.getList( path ) );
+ return config.getString( path, config.getString( path ) );
}
- private static String getString(String path, String def)
+ public static boolean tabComplete = true;
+ private static void tabComplete()
{
- config.addDefault( path, def );
- return config.getString( path, config.getString( path ) );
+ tabComplete = getBoolean( "commands.tab-complete", tabComplete );
+ }
+
+ public static boolean logCommands = true;
+ private static void logCommands()
+ {
+ logCommands = getBoolean( "commands.log", logCommands );
}
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 4e1bdcf..18278c6 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -61,4 +61,57 @@ public class SpigotWorldConfig
chunksPerTick = getInt( "chunks-per-tick", chunksPerTick );
log( "Chunks to Grow per Tick: " + chunksPerTick );
}
+
+ public boolean randomLightUpdates = false;
+ private void randomLightUpdates()
+ {
+ randomLightUpdates = getBoolean( "random-light-updates", randomLightUpdates );
+ log( "Random Lighting Updates: " + randomLightUpdates );
+ }
+
+ public int mobSpawnRange = 4;
+ private void mobSpawnRange()
+ {
+ mobSpawnRange = getInt( "mob-spawn-range", mobSpawnRange );
+ log( "Mob Spawn Range: " + mobSpawnRange );
+ }
+
+ public int tickAggregate = 4;
+ private void tickAggregate()
+ {
+ tickAggregate = getInt( "tick-aggregate", tickAggregate );
+ log( "Ticks to Aggregate: " + tickAggregate );
+ }
+
+ // Crop growth rates
+ public int cactusModifier = 100;
+ public int caneModifier = 100;
+ public int melonModifier = 100;
+ public int mushroomModifier = 100;
+ public int pumpkinModifier = 100;
+ public int saplingModifier = 100;
+ public int wheatModifier = 100;
+ private void growthModifiers()
+ {
+ cactusModifier = getInt( "growth.cactus-modifier", cactusModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ caneModifier = getInt( "growth.cane-modifier", caneModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ melonModifier = getInt( "growth.melon-modifier", melonModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ mushroomModifier = getInt( "growth.mushroom-modifier", mushroomModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ pumpkinModifier = getInt( "growth.pumpkin-modifier", pumpkinModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ saplingModifier = getInt( "growth.sapling-modifier", saplingModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+
+ wheatModifier = getInt( "growth.wheat-modifier", wheatModifier );
+ log( "Cactus Growth Modifier: " + cactusModifier + "%" );
+ }
}
--
1.8.1.2