mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
Revert "Remove getCubes patch as under some circumstances it can loop around itself forever. For anyone wishing to reimplement this patch, the rationale behind it is quite simple, get all cubes within each chunk at the same time."
This reverts commit 06233ce472
.
This commit is contained in:
parent
78bc1384a7
commit
b47555dc7a
74 changed files with 68 additions and 7044 deletions
|
@ -1,96 +0,0 @@
|
|||
From 78f8199a2ecba8ffbbbc9e0028611713579eb8b6 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
|
||||
|
||||
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 bbcf674..08b9ac8 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -117,7 +117,10 @@ public class EntityItem extends Entity {
|
||||
}
|
||||
|
||||
private void k() {
|
||||
- Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
|
||||
+ // Spigot start
|
||||
+ double radius = world.spigotConfig.itemMerge;
|
||||
+ Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
|
||||
+ // Spigot end
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityItem entityitem = (EntityItem) iterator.next();
|
||||
@@ -148,11 +151,13 @@ public class EntityItem extends Entity {
|
||||
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
|
||||
return false;
|
||||
} else {
|
||||
- itemstack1.count += itemstack.count;
|
||||
- entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
|
||||
- entityitem.age = Math.min(entityitem.age, this.age);
|
||||
- entityitem.setItemStack(itemstack1);
|
||||
- this.die();
|
||||
+ // Spigot start
|
||||
+ itemstack.count += itemstack1.count;
|
||||
+ this.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
|
||||
+ this.age = Math.min(entityitem.age, this.age);
|
||||
+ this.setItemStack(itemstack);
|
||||
+ entityitem.die();
|
||||
+ // Spigot end
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 53ab411..d90d5a4 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -934,6 +934,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 = spigotConfig.expMerge;
|
||||
+ if (radius > 0) {
|
||||
+ List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
|
||||
+ for (Entity e : entities) {
|
||||
+ if (e instanceof EntityExperienceOrb) {
|
||||
+ EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
|
||||
+ if (!loopItem.dead) {
|
||||
+ xp.value += loopItem.value;
|
||||
+ loopItem.die();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } // Spigot end
|
||||
|
||||
if (event != null && (event.isCancelled() || entity.dead)) {
|
||||
entity.dead = true;
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index f38bb25..9f07e71 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -106,4 +106,18 @@ public class SpigotWorldConfig
|
||||
saplingModifier = getAndValidateGrowth( "Sapling" );
|
||||
wheatModifier = getAndValidateGrowth( "Wheat" );
|
||||
}
|
||||
+
|
||||
+ 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.3.2
|
||||
|
68
CraftBukkit-Patches/0008-More-Efficient-GetCubes.patch
Normal file
68
CraftBukkit-Patches/0008-More-Efficient-GetCubes.patch
Normal file
|
@ -0,0 +1,68 @@
|
|||
From 7c6711b2f0781e7837623f639eaede10f38952a7 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 53ab411..8b07d84 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1022,23 +1022,42 @@ public abstract class World implements IBlockAccess {
|
||||
int i1 = MathHelper.floor(axisalignedbb.c);
|
||||
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
||||
|
||||
- for (int k1 = i; k1 < j; ++k1) {
|
||||
- for (int l1 = i1; l1 < j1; ++l1) {
|
||||
- if (this.isLoaded(k1, 64, l1)) {
|
||||
- for (int i2 = k - 1; i2 < l; ++i2) {
|
||||
- Block block;
|
||||
-
|
||||
- if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) {
|
||||
- block = this.getType(k1, i2, l1);
|
||||
- } else {
|
||||
- block = Blocks.STONE;
|
||||
+ // Spigot start
|
||||
+ int ystart = ( ( k - 1 ) < 0 ) ? 0 : ( k - 1 );
|
||||
+ for ( int chunkx = ( i >> 4 ); chunkx <= ( ( j - 1 ) >> 4 ); chunkx++ )
|
||||
+ {
|
||||
+ int cx = chunkx << 4;
|
||||
+ for ( int chunkz = ( i1 >> 4 ); chunkz <= ( ( j1 - 1 ) >> 4 ); chunkz++ )
|
||||
+ {
|
||||
+ if ( !this.isChunkLoaded( chunkx, chunkz ) )
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ int cz = chunkz << 4;
|
||||
+ Chunk chunk = this.getChunkAt( chunkx, chunkz );
|
||||
+ // Compute ranges within chunk
|
||||
+ int xstart = ( i < cx ) ? cx : i;
|
||||
+ int xend = ( j < ( cx + 16 ) ) ? j : ( cx + 16 );
|
||||
+ int zstart = ( i1 < cz ) ? cz : i1;
|
||||
+ int zend = ( j1 < ( cz + 16 ) ) ? j1 : ( cz + 16 );
|
||||
+ // Loop through blocks within chunk
|
||||
+ for ( int x = xstart; x < xend; x++ )
|
||||
+ {
|
||||
+ for ( int z = zstart; z < zend; z++ )
|
||||
+ {
|
||||
+ for ( int y = ystart; y < l; y++ )
|
||||
+ {
|
||||
+ Block block = chunk.getType(x - cx, y, z - cz );
|
||||
+ if ( block != null )
|
||||
+ {
|
||||
+ block.a( this, x, y, z, axisalignedbb, this.M, entity );
|
||||
+ }
|
||||
}
|
||||
-
|
||||
- block.a(this, k1, i2, l1, axisalignedbb, this.M, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
double d0 = 0.25D;
|
||||
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,224 +0,0 @@
|
|||
From fbc1a6586e57c2ab2fdfc2c994ed1cd663cc7876 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Fri, 21 Jun 2013 17:13:47 +1000
|
||||
Subject: [PATCH] LongHash Tweaks
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHash.java b/src/main/java/org/bukkit/craftbukkit/util/LongHash.java
|
||||
index 691cafd..9d54472 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/LongHash.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/LongHash.java
|
||||
@@ -10,6 +10,6 @@ public class LongHash {
|
||||
}
|
||||
|
||||
public static int lsw(long l) {
|
||||
- return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE;
|
||||
+ return (int) (l) + Integer.MIN_VALUE; // Spigot - remove redundant &
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
|
||||
index 22c96c5..7f659b7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java
|
||||
@@ -31,6 +31,7 @@ public class LongHashSet {
|
||||
private int elements;
|
||||
private long[] values;
|
||||
private int modCount;
|
||||
+ private org.spigotmc.FlatMap<Boolean> flat = new org.spigotmc.FlatMap<Boolean>(); // Spigot
|
||||
|
||||
public LongHashSet() {
|
||||
this(INITIAL_SIZE);
|
||||
@@ -56,10 +57,30 @@ public class LongHashSet {
|
||||
}
|
||||
|
||||
public boolean contains(int msw, int lsw) {
|
||||
+ // Spigot start
|
||||
+ if ( elements == 0 )
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if ( flat.contains( msw, lsw ) )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
return contains(LongHash.toLong(msw, lsw));
|
||||
}
|
||||
|
||||
public boolean contains(long value) {
|
||||
+ // Spigot start
|
||||
+ if ( elements == 0 )
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if ( flat.contains( value ) )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
int hash = hash(value);
|
||||
int index = (hash & 0x7FFFFFFF) % values.length;
|
||||
int offset = 1;
|
||||
@@ -82,6 +103,7 @@ public class LongHashSet {
|
||||
}
|
||||
|
||||
public boolean add(long value) {
|
||||
+ flat.put( value, Boolean.TRUE ); // Spigot
|
||||
int hash = hash(value);
|
||||
int index = (hash & 0x7FFFFFFF) % values.length;
|
||||
int offset = 1;
|
||||
@@ -125,10 +147,18 @@ public class LongHashSet {
|
||||
}
|
||||
|
||||
public void remove(int msw, int lsw) {
|
||||
- remove(LongHash.toLong(msw, lsw));
|
||||
+ // Spigot start
|
||||
+ flat.remove(msw, lsw);
|
||||
+ remove0(LongHash.toLong(msw, lsw));
|
||||
}
|
||||
|
||||
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 +191,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..2e5b436 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 transient org.spigotmc.FlatMap<V> flat = new org.spigotmc.FlatMap<V>(); // Spigot
|
||||
|
||||
public LongObjectHashMap() {
|
||||
initialize();
|
||||
@@ -61,6 +62,17 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
|
||||
}
|
||||
|
||||
public V get(long key) {
|
||||
+ // Spigot start
|
||||
+ if ( size == 0 )
|
||||
+ {
|
||||
+ return null;
|
||||
+ }
|
||||
+ 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 +90,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
|
||||
}
|
||||
|
||||
public V put(long key, V value) {
|
||||
+ flat.put(key, value); // Spigot
|
||||
int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1));
|
||||
long[] innerKeys = keys[index];
|
||||
V[] innerValues = values[index];
|
||||
@@ -124,6 +137,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
|
||||
}
|
||||
|
||||
public V remove(long key) {
|
||||
+ flat.remove(key); // Spigot
|
||||
int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1));
|
||||
long[] inner = keys[index];
|
||||
if (inner == null) {
|
||||
@@ -174,6 +188,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.3.2
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
From 86a27eece85c36b5402a3032925beb1fb53e90a3 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
|
||||
|
||||
Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
||||
index ad4e3a2..c063ca1 100644
|
||||
--- a/src/main/java/net/minecraft/server/Block.java
|
||||
+++ b/src/main/java/net/minecraft/server/Block.java
|
||||
@@ -433,9 +433,13 @@ public class Block {
|
||||
return 10;
|
||||
}
|
||||
|
||||
- public void onPlace(World world, int i, int j, int k) {}
|
||||
+ public void onPlace(World world, int i, int j, int k) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous block onPlace!"); // Spigot
|
||||
+ }
|
||||
|
||||
- public void remove(World world, int i, int j, int k, Block block, int l) {}
|
||||
+ public void remove(World world, int i, int j, int k, Block block, int l) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous block remove!"); // Spigot
|
||||
+ }
|
||||
|
||||
public int a(Random random) {
|
||||
return 1;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
|
||||
index 7447e42..97d0bbb 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTracker.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
|
||||
@@ -91,6 +91,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
|
||||
if (i > this.e) {
|
||||
i = this.e;
|
||||
}
|
||||
@@ -125,6 +126,7 @@ public class EntityTracker {
|
||||
}
|
||||
|
||||
public void untrackEntity(Entity entity) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity untrack!"); // Spigot
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||
Iterator iterator = this.c.iterator();
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
||||
index 9f818cf..8052ea6 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
||||
@@ -299,6 +299,7 @@ public class EntityTrackerEntry {
|
||||
}
|
||||
|
||||
public void updatePlayer(EntityPlayer entityplayer) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous player tracker update!"); // Spigot
|
||||
if (entityplayer != this.tracker) {
|
||||
double d0 = entityplayer.locX - (double) (this.xLoc / 32);
|
||||
double d1 = entityplayer.locZ - (double) (this.zLoc / 32);
|
||||
@@ -515,6 +516,7 @@ public class EntityTrackerEntry {
|
||||
}
|
||||
|
||||
public void clear(EntityPlayer entityplayer) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous player tracker clear!"); // Spigot
|
||||
if (this.trackedPlayers.contains(entityplayer)) {
|
||||
this.trackedPlayers.remove(entityplayer);
|
||||
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.getId()));
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index d90d5a4..1381660 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -903,6 +903,7 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity add!"); // Spigot
|
||||
if (entity == null) return false;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -1009,6 +1010,7 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
public void removeEntity(Entity entity) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity remove!"); // Spigot
|
||||
entity.die();
|
||||
if (entity instanceof EntityHuman) {
|
||||
this.players.remove(entity);
|
||||
@@ -2378,6 +2380,7 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
public void a(List list) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity world add!"); // Spigot
|
||||
// CraftBukkit start
|
||||
// this.entityList.addAll(list);
|
||||
Entity entity = null;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index c16413a..468a4e1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -159,6 +159,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public boolean unloadChunkRequest(int x, int z, boolean safe) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk unload!"); // Spigot
|
||||
if (safe && isChunkInUse(x, z)) {
|
||||
return false;
|
||||
}
|
||||
@@ -169,6 +170,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public boolean unloadChunk(int x, int z, boolean save, boolean safe) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk unload!"); // Spigot
|
||||
if (safe && isChunkInUse(x, z)) {
|
||||
return false;
|
||||
}
|
||||
@@ -236,6 +238,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk load!"); // Spigot
|
||||
chunkLoadCount++;
|
||||
if (generate) {
|
||||
// Use the default variant of loadChunk when generate == true.
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 83f51ab..ef74879 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -230,6 +230,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void kickPlayer(String message) {
|
||||
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous player kick!"); // Spigot
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
From 656c027b527e27b97b7224c00e898248d1de9a09 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
|
||||
|
||||
This commit allows the user to select per world view distances, and view distances below 3. Be wary of the issues selecting a view distance of 1 or 2 may cause!
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index 4e0398c..ae4ca63 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -24,7 +24,7 @@ public class PlayerChunkMap {
|
||||
public PlayerChunkMap(WorldServer worldserver, int i) {
|
||||
if (i > 15) {
|
||||
throw new IllegalArgumentException("Too big view radius!");
|
||||
- } else if (i < 3) {
|
||||
+ } else if (i < 1) {
|
||||
throw new IllegalArgumentException("Too small view radius!");
|
||||
} else {
|
||||
this.f = i;
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 812e887..9f09a3d 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -54,7 +54,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, spigotConfig.viewDistance); // Spigot
|
||||
if (this.entitiesById == null) {
|
||||
this.entitiesById = new IntHashMap();
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 9f07e71..97d56bd 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -120,4 +120,11 @@ public class SpigotWorldConfig
|
||||
expMerge = getDouble("merge-radius.exp", 3.0 );
|
||||
log( "Experience Merge Radius: " + expMerge );
|
||||
}
|
||||
+
|
||||
+ public int viewDistance;
|
||||
+ private void viewDistance()
|
||||
+ {
|
||||
+ viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
|
||||
+ log( "View Distance: " + viewDistance );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,394 +0,0 @@
|
|||
From a021e9bebd7dbed4f37f2e768da562122bd873ce Mon Sep 17 00:00:00 2001
|
||||
From: Mike Primm <mike@primmhome.com>
|
||||
Date: Sun, 13 Jan 2013 03:49:07 -0800
|
||||
Subject: [PATCH] Compressed Nibble Arrays
|
||||
|
||||
Implement 'lightening' of NibbleArrays - only allocate
|
||||
buffers when non-trivial value Saving from 40-45% of memory use by chunk
|
||||
section data.
|
||||
|
||||
Finish up NibbleArray lightening work - use for Snapshots, reduce copies
|
||||
|
||||
Fix nibble handling with NBT - arrays aren't copied by NBTByteArray
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 1e1499e..76b081a 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -225,15 +225,15 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
nbttagcompound1.setByte("Y", (byte) (chunksection.getYPosition() >> 4 & 255));
|
||||
nbttagcompound1.setByteArray("Blocks", chunksection.getIdArray());
|
||||
if (chunksection.getExtendedIdArray() != null) {
|
||||
- nbttagcompound1.setByteArray("Add", chunksection.getExtendedIdArray().a);
|
||||
+ nbttagcompound1.setByteArray("Add", chunksection.getExtendedIdArray().getValueArray()); // Spigot
|
||||
}
|
||||
|
||||
- nbttagcompound1.setByteArray("Data", chunksection.getDataArray().a);
|
||||
- nbttagcompound1.setByteArray("BlockLight", chunksection.getEmittedLightArray().a);
|
||||
+ nbttagcompound1.setByteArray("Data", chunksection.getDataArray().getValueArray()); // Spigot
|
||||
+ nbttagcompound1.setByteArray("BlockLight", chunksection.getEmittedLightArray().getValueArray()); // Spigot
|
||||
if (flag) {
|
||||
- nbttagcompound1.setByteArray("SkyLight", chunksection.getSkyLightArray().a);
|
||||
+ nbttagcompound1.setByteArray("SkyLight", chunksection.getSkyLightArray().getValueArray()); // Spigot
|
||||
} else {
|
||||
- nbttagcompound1.setByteArray("SkyLight", new byte[chunksection.getEmittedLightArray().a.length]);
|
||||
+ nbttagcompound1.setByteArray("SkyLight", new byte[chunksection.getEmittedLightArray().getValueArray().length]); // Spigot
|
||||
}
|
||||
|
||||
nbttaglist.add(nbttagcompound1);
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
index a05efa0..360de1a 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
@@ -140,7 +140,8 @@ public class ChunkSection {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
- byte[] ext = this.extBlockIds.a;
|
||||
+ this.extBlockIds.forceToNonTrivialArray(); // Spigot
|
||||
+ byte[] ext = this.extBlockIds.getValueArray();
|
||||
for (int off = 0, off2 = 0; off < blkIds.length;) {
|
||||
byte extid = ext[off2];
|
||||
int l = (blkIds[off] & 0xFF) | ((extid & 0xF) << 8); // Even data
|
||||
@@ -171,6 +172,12 @@ public class ChunkSection {
|
||||
off++;
|
||||
off2++;
|
||||
}
|
||||
+ // Spigot start
|
||||
+ this.extBlockIds.detectAndProcessTrivialArray();
|
||||
+ if (this.extBlockIds.isTrivialArray() && (this.extBlockIds.getTrivialArrayValue() == 0)) {
|
||||
+ this.extBlockIds = null;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
this.nonEmptyBlockCount = cntNonEmpty;
|
||||
this.tickingBlockCount = cntTicking;
|
||||
@@ -224,12 +231,11 @@ public class ChunkSection {
|
||||
public void setExtendedIdArray(NibbleArray nibblearray) {
|
||||
// CraftBukkit start - Don't hang on to an empty nibble array
|
||||
boolean empty = true;
|
||||
- for (int i = 0; i < nibblearray.a.length; i++) {
|
||||
- if (nibblearray.a[i] != 0) {
|
||||
- empty = false;
|
||||
- break;
|
||||
- }
|
||||
+ // Spigot start
|
||||
+ if ((!nibblearray.isTrivialArray()) || (nibblearray.getTrivialArrayValue() != 0)) {
|
||||
+ empty = false;
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
if (empty) {
|
||||
return;
|
||||
@@ -253,11 +259,11 @@ public class ChunkSection {
|
||||
|
||||
// CraftBukkit start - Validate array lengths
|
||||
private NibbleArray validateNibbleArray(NibbleArray nibbleArray) {
|
||||
- if (nibbleArray != null && nibbleArray.a.length < 2048) {
|
||||
- byte[] newArray = new byte[2048];
|
||||
- System.arraycopy(nibbleArray.a, 0, newArray, 0, ((nibbleArray.a.length > 2048) ? 2048 : nibbleArray.a.length));
|
||||
- nibbleArray = new NibbleArray(newArray, 4);
|
||||
+ // Spigot start - fix for more awesome nibble arrays
|
||||
+ if (nibbleArray != null && nibbleArray.getByteLength() < 2048) {
|
||||
+ nibbleArray.resizeArray(2048);
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
return nibbleArray;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
|
||||
index 5d75a54..c9bc20c 100644
|
||||
--- a/src/main/java/net/minecraft/server/NibbleArray.java
|
||||
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
|
||||
@@ -1,13 +1,117 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import java.util.Arrays; // Spigot
|
||||
+
|
||||
public class NibbleArray {
|
||||
|
||||
- public final byte[] a;
|
||||
+ private byte[] a; // Spigot - remove final, make private (anyone directly accessing this is broken already)
|
||||
private final int b;
|
||||
private final int c;
|
||||
+ // Spigot start
|
||||
+ private byte trivialValue;
|
||||
+ private byte trivialByte;
|
||||
+ private int length;
|
||||
+ private static final int LEN2K = 2048; // Universal length used right now - optimize around this
|
||||
+ private static final byte[][] TrivLen2k;
|
||||
+
|
||||
+ static {
|
||||
+ TrivLen2k = new byte[16][];
|
||||
+ for (int i = 0; i < 16; i++) {
|
||||
+ TrivLen2k[i] = new byte[LEN2K];
|
||||
+ Arrays.fill(TrivLen2k[i], (byte) (i | (i << 4)));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Try to convert array to trivial array
|
||||
+ public void detectAndProcessTrivialArray() {
|
||||
+ trivialValue = (byte) (a[0] & 0xF);
|
||||
+ trivialByte = (byte) (trivialValue | (trivialValue << 4));
|
||||
+ for (int i = 0; i < a.length; i++) {
|
||||
+ if (a[i] != trivialByte) return;
|
||||
+ }
|
||||
+ // All values matches, so array is trivial
|
||||
+ this.length = a.length;
|
||||
+ this.a = null;
|
||||
+ }
|
||||
+
|
||||
+ // Force array to non-trivial state
|
||||
+ public void forceToNonTrivialArray() {
|
||||
+ if (this.a == null) {
|
||||
+ this.a = new byte[this.length];
|
||||
+ if (this.trivialByte != 0) {
|
||||
+ Arrays.fill(this.a, this.trivialByte);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Test if array is in trivial state
|
||||
+ public boolean isTrivialArray() {
|
||||
+ return (this.a == null);
|
||||
+ }
|
||||
+
|
||||
+ // Get value of all elements (only valid if array is in trivial state)
|
||||
+ public int getTrivialArrayValue() {
|
||||
+ return this.trivialValue;
|
||||
+ }
|
||||
+
|
||||
+ // Get logical length of byte array for nibble data (whether trivial or non-trivial)
|
||||
+ public int getByteLength() {
|
||||
+ if (this.a == null) {
|
||||
+ return this.length;
|
||||
+ } else {
|
||||
+ return this.a.length;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Return byte encoding of array (whether trivial or non-trivial) - returns read-only array if trivial (do not modify!)
|
||||
+ public byte[] getValueArray() {
|
||||
+ if (this.a != null) {
|
||||
+ return this.a;
|
||||
+ } else {
|
||||
+ byte[] rslt;
|
||||
+
|
||||
+ if (this.length == LEN2K) { // All current uses are 2k long, but be safe
|
||||
+ rslt = TrivLen2k[this.trivialValue];
|
||||
+ } else {
|
||||
+ rslt = new byte[this.length];
|
||||
+ if (this.trivialByte != 0) {
|
||||
+ Arrays.fill(rslt, this.trivialByte);
|
||||
+ }
|
||||
+ }
|
||||
+ return rslt;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Copy byte representation of array to given offset in given byte array
|
||||
+ public int copyToByteArray(byte[] dest, int off) {
|
||||
+ if (this.a == null) {
|
||||
+ Arrays.fill(dest, off, off + this.length, this.trivialByte);
|
||||
+ return off + this.length;
|
||||
+ } else {
|
||||
+ System.arraycopy(this.a, 0, dest, off, this.a.length);
|
||||
+ return off + this.a.length;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Resize array to given byte length
|
||||
+ public void resizeArray(int len) {
|
||||
+ if (this.a == null) {
|
||||
+ this.length = len;
|
||||
+ } else if (this.a.length != len) {
|
||||
+ byte[] newa = new byte[len];
|
||||
+ System.arraycopy(this.a, 0, newa, 0, ((this.a.length > len) ? len : this.a.length));
|
||||
+ this.a = newa;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
public NibbleArray(int i, int j) {
|
||||
- this.a = new byte[i >> 1];
|
||||
+ // Spigot start
|
||||
+ //this.a = new byte[i >> 1];
|
||||
+ this.a = null; // Start off as trivial value (all same zero value)
|
||||
+ this.length = i >> 1;
|
||||
+ this.trivialByte = this.trivialValue = 0;
|
||||
+ // Spigot end
|
||||
this.b = j;
|
||||
this.c = j + 4;
|
||||
}
|
||||
@@ -16,9 +120,11 @@ public class NibbleArray {
|
||||
this.a = abyte;
|
||||
this.b = i;
|
||||
this.c = i + 4;
|
||||
+ detectAndProcessTrivialArray(); // Spigot
|
||||
}
|
||||
|
||||
public int a(int i, int j, int k) {
|
||||
+ if (this.a == null) return this.trivialValue; // Spigot
|
||||
int l = j << this.c | k << this.b | i;
|
||||
int i1 = l >> 1;
|
||||
int j1 = l & 1;
|
||||
@@ -27,6 +133,18 @@ public class NibbleArray {
|
||||
}
|
||||
|
||||
public void a(int i, int j, int k, int l) {
|
||||
+ // Spigot start
|
||||
+ if (this.a == null) {
|
||||
+ if (l != this.trivialValue) { // Not same as trivial value, array no longer trivial
|
||||
+ this.a = new byte[this.length];
|
||||
+ if (this.trivialByte != 0) {
|
||||
+ Arrays.fill(this.a, this.trivialByte);
|
||||
+ }
|
||||
+ } else {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
int i1 = j << this.c | k << this.b | i;
|
||||
int j1 = i1 >> 1;
|
||||
int k1 = i1 & 1;
|
||||
diff --git a/src/main/java/net/minecraft/server/OldChunkLoader.java b/src/main/java/net/minecraft/server/OldChunkLoader.java
|
||||
index fcb9912..6ee28cc 100644
|
||||
--- a/src/main/java/net/minecraft/server/OldChunkLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/OldChunkLoader.java
|
||||
@@ -94,9 +94,11 @@ public class OldChunkLoader {
|
||||
|
||||
nbttagcompound1.setByte("Y", (byte) (k & 255));
|
||||
nbttagcompound1.setByteArray("Blocks", abyte);
|
||||
- nbttagcompound1.setByteArray("Data", nibblearray.a);
|
||||
- nbttagcompound1.setByteArray("SkyLight", nibblearray1.a);
|
||||
- nbttagcompound1.setByteArray("BlockLight", nibblearray2.a);
|
||||
+ // Spigot start - a -> getValueArray() accessor
|
||||
+ nbttagcompound1.setByteArray("Data", nibblearray.getValueArray());
|
||||
+ nbttagcompound1.setByteArray("SkyLight", nibblearray1.getValueArray());
|
||||
+ nbttagcompound1.setByteArray("BlockLight", nibblearray2.getValueArray());
|
||||
+ // Spigot end
|
||||
nbttaglist.add(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
index c7b799a..856e825 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
@@ -138,16 +138,16 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].isEmpty()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].getDataArray();
|
||||
- System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
- j += nibblearray.a.length;
|
||||
+ nibblearray.copyToByteArray(abyte, j);
|
||||
+ j += nibblearray.getByteLength();
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].isEmpty()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].getEmittedLightArray();
|
||||
- System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
- j += nibblearray.a.length;
|
||||
+ nibblearray.copyToByteArray(abyte, j);
|
||||
+ j += nibblearray.getByteLength();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].isEmpty()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].getSkyLightArray();
|
||||
- System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
- j += nibblearray.a.length;
|
||||
+ nibblearray.copyToByteArray(abyte, j);
|
||||
+ j += nibblearray.getByteLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,8 +165,8 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].isEmpty()) && achunksection[l].getExtendedIdArray() != null && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].getExtendedIdArray();
|
||||
- System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
- j += nibblearray.a.length;
|
||||
+ nibblearray.copyToByteArray(abyte, j);
|
||||
+ j += nibblearray.getByteLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
index b2c6ef4..55f5225 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
@@ -174,7 +174,18 @@ public class CraftChunk implements Chunk {
|
||||
}
|
||||
|
||||
if (cs[i].getExtendedIdArray() != null) { /* If we've got extended IDs */
|
||||
- byte[] extids = cs[i].getExtendedIdArray().a;
|
||||
+ // Spigot start
|
||||
+ if (cs[i].getExtendedIdArray().isTrivialArray()) {
|
||||
+ int tval = cs[i].getExtendedIdArray().getTrivialArrayValue();
|
||||
+ if (tval != 0) {
|
||||
+ tval = tval << 8;
|
||||
+ for (int j = 0; j < 4096; j++) {
|
||||
+ blockids[j] |= tval;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ byte[] extids = cs[i].getExtendedIdArray().getValueArray();
|
||||
+ // Spigot end
|
||||
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
short b = (short) (extids[j] & 0xFF);
|
||||
@@ -186,21 +197,42 @@ public class CraftChunk implements Chunk {
|
||||
blockids[j<<1] |= (b & 0x0F) << 8;
|
||||
blockids[(j<<1)+1] |= (b & 0xF0) << 4;
|
||||
}
|
||||
+ } // Spigot
|
||||
}
|
||||
|
||||
sectionBlockIDs[i] = blockids;
|
||||
|
||||
/* Get block data nibbles */
|
||||
- sectionBlockData[i] = new byte[2048];
|
||||
- System.arraycopy(cs[i].getDataArray().a, 0, sectionBlockData[i], 0, 2048);
|
||||
+ // Spigot start
|
||||
+ if (cs[i].getDataArray().isTrivialArray() && (cs[i].getDataArray().getTrivialArrayValue() == 0)) {
|
||||
+ sectionBlockData[i] = emptyData;
|
||||
+ } else {
|
||||
+ sectionBlockData[i] = new byte[2048];
|
||||
+ cs[i].getDataArray().copyToByteArray(sectionBlockData[i], 0);
|
||||
+ }
|
||||
if (cs[i].getSkyLightArray() == null) {
|
||||
sectionSkyLights[i] = emptyData;
|
||||
+ }
|
||||
+ else if (cs[i].getSkyLightArray().isTrivialArray()) {
|
||||
+ if (cs[i].getSkyLightArray().getTrivialArrayValue() == 0) {
|
||||
+ sectionSkyLights[i] = emptyData;
|
||||
+ } else if (cs[i].getSkyLightArray().getTrivialArrayValue() == 15) {
|
||||
+ sectionSkyLights[i] = emptySkyLight;
|
||||
+ } else {
|
||||
+ sectionSkyLights[i] = new byte[2048];
|
||||
+ cs[i].getSkyLightArray().copyToByteArray(sectionSkyLights[i], 0);
|
||||
+ }
|
||||
} else {
|
||||
sectionSkyLights[i] = new byte[2048];
|
||||
- System.arraycopy(cs[i].getSkyLightArray().a, 0, sectionSkyLights[i], 0, 2048);
|
||||
+ cs[i].getSkyLightArray().copyToByteArray(sectionSkyLights[i], 0);
|
||||
+ }
|
||||
+ if (cs[i].getEmittedLightArray().isTrivialArray() && (cs[i].getEmittedLightArray().getTrivialArrayValue() == 0)) {
|
||||
+ sectionEmitLights[i] = emptyData;
|
||||
+ } else {
|
||||
+ sectionEmitLights[i] = new byte[2048];
|
||||
+ cs[i].getEmittedLightArray().copyToByteArray(sectionEmitLights[i], 0);
|
||||
}
|
||||
- sectionEmitLights[i] = new byte[2048];
|
||||
- System.arraycopy(cs[i].getEmittedLightArray().a, 0, sectionEmitLights[i], 0, 2048);
|
||||
+ // Spigot end
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
From a7daf7006ead79d50ea30a02cc1e225f5a192d16 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 1381660..00c2a18 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -292,20 +292,18 @@ public abstract class World implements IBlockAccess {
|
||||
return this.getChunkAt(i >> 4, j >> 4);
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
public Chunk getChunkAt(int i, int j) {
|
||||
- // CraftBukkit start
|
||||
- Chunk result = null;
|
||||
- synchronized (this.chunkLock) {
|
||||
- if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
|
||||
- this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
|
||||
- this.lastXAccessed = i;
|
||||
- this.lastZAccessed = j;
|
||||
- }
|
||||
- result = this.lastChunkAccessed;
|
||||
+ //synchronized (this.chunkLock) {
|
||||
+ Chunk result = this.lastChunkAccessed; // Exploit fact that read is atomic
|
||||
+ if (result == null || result.locX != i || result.locZ != j) {
|
||||
+ result = this.chunkProvider.getOrCreateChunk(i, j);
|
||||
+ this.lastChunkAccessed = result; // Exploit fact that write is atomic
|
||||
}
|
||||
+ //}
|
||||
return result;
|
||||
- // CraftBukkit end
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
public boolean setTypeAndData(int i, int j, int k, Block block, int l, int i1) {
|
||||
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
From beba6be18355cdfc84769477a37548598224f007 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
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 6a01982..0966b4b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -101,6 +101,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
public int autosavePeriod;
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ private static final int TPS = 20;
|
||||
+ private static final int TICK_TIME = 1000000000 / TPS;
|
||||
+ public static double currentTPS = 0;
|
||||
+ private static long catchupTime = 0;
|
||||
+ // Spigot end
|
||||
|
||||
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
|
||||
i = this;
|
||||
@@ -422,45 +428,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public void run() {
|
||||
try {
|
||||
if (this.init()) {
|
||||
- long i = ap();
|
||||
- long j = 0L;
|
||||
-
|
||||
- this.p.setMOTD(new ChatComponentText(this.motd));
|
||||
- this.p.setServerInfo(new ServerPingServerData("1.7.2", 4));
|
||||
- this.a(this.p);
|
||||
-
|
||||
- while (this.isRunning) {
|
||||
- long k = ap();
|
||||
- long l = k - i;
|
||||
-
|
||||
- if (l > 2000L && i - this.O >= 15000L) {
|
||||
- if (this.server.getWarnOnOverload()) // CraftBukkit - Added option to suppress warning messages
|
||||
- h.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(l), Long.valueOf(l / 50L)});
|
||||
- l = 2000L;
|
||||
- this.O = i;
|
||||
- }
|
||||
-
|
||||
- if (l < 0L) {
|
||||
- h.warn("Time ran backwards! Did the system time change?");
|
||||
- l = 0L;
|
||||
- }
|
||||
-
|
||||
- j += l;
|
||||
- i = k;
|
||||
- if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
|
||||
- this.t();
|
||||
- j = 0L;
|
||||
+ // Spigot start
|
||||
+ for (long lastTick = 0L; this.isRunning;) {
|
||||
+ long curTime = System.nanoTime();
|
||||
+ long wait = TICK_TIME - (curTime - lastTick) - catchupTime;
|
||||
+ if (wait > 0) {
|
||||
+ Thread.sleep(wait / 1000000);
|
||||
+ catchupTime = 0;
|
||||
+ continue;
|
||||
} else {
|
||||
- while (j > 50L) {
|
||||
- MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
- j -= 50L;
|
||||
- this.t();
|
||||
- }
|
||||
+ catchupTime = Math.min(TICK_TIME * TPS, Math.abs(wait));
|
||||
}
|
||||
-
|
||||
- Thread.sleep(1L);
|
||||
- this.N = true;
|
||||
+ currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
|
||||
+ lastTick = curTime;
|
||||
+ MinecraftServer.currentTick++;
|
||||
+ this.t();
|
||||
}
|
||||
+ // Spigot end
|
||||
} else {
|
||||
this.a((CrashReport) null);
|
||||
}
|
||||
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
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package org.bukkit.craftbukkit.command;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+public class TicksPerSecondCommand extends Command {
|
||||
+
|
||||
+ public TicksPerSecondCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "Gets the current ticks per second for the server";
|
||||
+ this.usageMessage = "/tps";
|
||||
+ this.setPermission("bukkit.command.tps");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ double tps = Math.min(20, Math.round(MinecraftServer.currentTPS * 10) / 10.0);
|
||||
+ ChatColor color;
|
||||
+ if (tps > 19.2D) {
|
||||
+ color = ChatColor.GREEN;
|
||||
+ } else if (tps > 17.4D) {
|
||||
+ color = ChatColor.YELLOW;
|
||||
+ } else {
|
||||
+ color = ChatColor.RED;
|
||||
+ }
|
||||
+
|
||||
+ sender.sendMessage(ChatColor.GOLD + "[TPS] " + color + tps);
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index 3dfe4ed..1b0e1bf 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
|
||||
config.addDefault( path, def );
|
||||
return config.getString( path, config.getString( path ) );
|
||||
}
|
||||
+
|
||||
+ private static void tpsCommand()
|
||||
+ {
|
||||
+ commands.put( "tps", new TicksPerSecondCommand( "tps" ) );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,550 +0,0 @@
|
|||
From 602c7cc451f09e8bba0087970c2c9770f6e7037c 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
|
||||
|
||||
Tracks nearly every point of minecraft internals and plugin events to give a good quick overview on what is causing TPS loss.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 9c99177..b88f75c 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -106,6 +106,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
// CraftBukkit end
|
||||
|
||||
if (chunk == null) {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.syncChunkLoadTimer.startTiming(); // Spigot
|
||||
chunk = this.loadChunk(i, j);
|
||||
if (chunk == null) {
|
||||
if (this.chunkProvider == null) {
|
||||
@@ -141,6 +142,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
}
|
||||
// CraftBukkit end
|
||||
chunk.a(this, this, i, j);
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.syncChunkLoadTimer.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
// CraftBukkit start - If we didn't need to load the chunk run the callback now
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index dc0abc5..3d6aeff 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||
@@ -110,6 +111,8 @@ public abstract class Entity {
|
||||
public EnumEntitySize at;
|
||||
public boolean valid; // CraftBukkit
|
||||
|
||||
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
||||
+
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -423,6 +426,8 @@ public abstract class Entity {
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
|
||||
if (this.Y) {
|
||||
this.boundingBox.d(d0, d1, d2);
|
||||
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
|
||||
@@ -731,6 +736,7 @@ public abstract class Entity {
|
||||
|
||||
this.world.methodProfiler.b();
|
||||
}
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
protected String H() {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0966b4b..d740620 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
-import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@@ -36,6 +35,7 @@ import jline.console.ConsoleReader;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
@@ -442,7 +442,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
|
||||
lastTick = curTime;
|
||||
MinecraftServer.currentTick++;
|
||||
+ SpigotTimings.serverTickTimer.startTiming();
|
||||
this.t();
|
||||
+ SpigotTimings.serverTickTimer.stopTiming();
|
||||
+ org.spigotmc.CustomTimingsHandler.tick();
|
||||
}
|
||||
// Spigot end
|
||||
} else {
|
||||
@@ -567,6 +570,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public void u() {
|
||||
this.methodProfiler.a("levels");
|
||||
|
||||
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
|
||||
// CraftBukkit start
|
||||
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
|
||||
|
||||
@@ -575,7 +579,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
processQueue.remove().run();
|
||||
}
|
||||
|
||||
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
|
||||
+ SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot
|
||||
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
|
||||
+ SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot
|
||||
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
if (this.ticks % 20 == 0) {
|
||||
@@ -627,7 +634,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.a("tracker");
|
||||
+ worldserver.timings.tracker.startTiming(); // Spigot
|
||||
worldserver.getTracker().updatePlayers();
|
||||
+ worldserver.timings.tracker.stopTiming(); // Spigot
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.b();
|
||||
// } // CraftBukkit
|
||||
@@ -636,14 +645,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
|
||||
this.methodProfiler.c("connection");
|
||||
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
|
||||
this.ag().c();
|
||||
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("players");
|
||||
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
|
||||
this.t.tick();
|
||||
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("tickables");
|
||||
|
||||
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
|
||||
for (i = 0; i < this.m.size(); ++i) {
|
||||
((IUpdatePlayerListBox) this.m.get(i)).a();
|
||||
}
|
||||
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
|
||||
|
||||
this.methodProfiler.b();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 29335ea..d0ea17a 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -917,6 +917,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
// CraftBukkit end
|
||||
|
||||
private void handleCommand(String s) {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
|
||||
// CraftBukkit start
|
||||
CraftPlayer player = this.getPlayer();
|
||||
|
||||
@@ -924,19 +925,23 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.c.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;
|
||||
}
|
||||
} catch (org.bukkit.command.CommandException ex) {
|
||||
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
||||
return;
|
||||
}
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
||||
//this.minecraftServer.getCommandHandler().a(this.player, s);
|
||||
// CraftBukkit end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
index 811f1a4..3de32fe 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
@@ -7,10 +7,12 @@ import java.util.concurrent.Callable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
||||
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
||||
|
||||
public class TileEntity {
|
||||
|
||||
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
||||
private static final Logger a = LogManager.getLogger();
|
||||
private static Map i = new HashMap();
|
||||
private static Map j = new HashMap();
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 00c2a18..f1bf467 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.Callable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.LongHashSet;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
import org.bukkit.craftbukkit.util.UnsafeList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -133,6 +134,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;
|
||||
}
|
||||
@@ -212,6 +215,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.a();
|
||||
|
||||
this.getServer().addWorld(this.world); // CraftBukkit
|
||||
+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot
|
||||
}
|
||||
|
||||
protected abstract IChunkProvider j();
|
||||
@@ -1230,6 +1234,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.f.clear();
|
||||
this.methodProfiler.c("regular");
|
||||
|
||||
+ timings.entityTick.startTiming(); // Spigot
|
||||
for (i = 0; i < this.entityList.size(); ++i) {
|
||||
entity = (Entity) this.entityList.get(i);
|
||||
|
||||
@@ -1252,7 +1257,9 @@ public abstract class World implements IBlockAccess {
|
||||
this.methodProfiler.a("tick");
|
||||
if (!entity.dead) {
|
||||
try {
|
||||
+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot
|
||||
this.playerJoinedWorld(entity);
|
||||
+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
|
||||
} catch (Throwable throwable1) {
|
||||
crashreport = CrashReport.a(throwable1, "Ticking entity");
|
||||
crashreportsystemdetails = crashreport.a("Entity being ticked");
|
||||
@@ -1277,7 +1284,9 @@ public abstract class World implements IBlockAccess {
|
||||
this.methodProfiler.b();
|
||||
}
|
||||
|
||||
+ timings.entityTick.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("blockEntities");
|
||||
+ timings.tileEntityTick.startTiming(); // Spigot
|
||||
this.N = true;
|
||||
Iterator iterator = this.tileEntityList.iterator();
|
||||
|
||||
@@ -1292,8 +1301,11 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
|
||||
try {
|
||||
+ tileentity.tickTimer.startTiming(); // Spigot
|
||||
tileentity.h();
|
||||
+ tileentity.tickTimer.stopTiming(); // Spigot
|
||||
} catch (Throwable throwable2) {
|
||||
+ tileentity.tickTimer.stopTiming(); // Spigot
|
||||
crashreport = CrashReport.a(throwable2, "Ticking block entity");
|
||||
crashreportsystemdetails = crashreport.a("Block entity being ticked");
|
||||
tileentity.a(crashreportsystemdetails);
|
||||
@@ -1313,6 +1325,8 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
}
|
||||
|
||||
+ timings.tileEntityTick.stopTiming(); // Spigot
|
||||
+ timings.tileEntityPending.startTiming(); // Spigot
|
||||
this.N = false;
|
||||
if (!this.b.isEmpty()) {
|
||||
this.tileEntityList.removeAll(this.b);
|
||||
@@ -1351,6 +1365,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.a.clear();
|
||||
}
|
||||
|
||||
+ timings.tileEntityPending.stopTiming(); // Spigot
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.b();
|
||||
}
|
||||
@@ -1373,6 +1388,7 @@ public abstract class World implements IBlockAccess {
|
||||
byte b0 = 32;
|
||||
|
||||
if (!flag || this.b(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
|
||||
+ entity.tickTimer.startTiming(); // Spigot
|
||||
entity.T = entity.locX;
|
||||
entity.U = entity.locY;
|
||||
entity.V = entity.locZ;
|
||||
@@ -1434,6 +1450,7 @@ public abstract class World implements IBlockAccess {
|
||||
entity.passenger = null;
|
||||
}
|
||||
}
|
||||
+ entity.tickTimer.stopTiming(); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 9f09a3d..74a2d45 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -184,10 +184,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)) {
|
||||
+ timings.mobSpawn.startTiming(); // Spigot
|
||||
this.R.spawnEntities(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L);
|
||||
- // CraftBukkit end
|
||||
+ timings.mobSpawn.stopTiming(); // Spigot
|
||||
}
|
||||
-
|
||||
+ // CraftBukkit end
|
||||
+ timings.doChunkUnload.startTiming(); // Spigot
|
||||
this.methodProfiler.c("chunkSource");
|
||||
this.chunkProvider.unloadChunks();
|
||||
int j = this.a(1.0F);
|
||||
@@ -201,21 +203,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
||||
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);
|
||||
}
|
||||
|
||||
+ timings.doChunkUnload.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("tickPending");
|
||||
+ timings.doTickPending.startTiming(); // Spigot
|
||||
this.a(false);
|
||||
+ timings.doTickPending.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("tickBlocks");
|
||||
+ timings.doTickTiles.startTiming(); // Spigot
|
||||
this.g();
|
||||
+ timings.doTickTiles.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("chunkMap");
|
||||
+ timings.doChunkMap.startTiming(); // Spigot
|
||||
this.manager.flush();
|
||||
+ timings.doChunkMap.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("village");
|
||||
+ timings.doVillages.startTiming(); // Spigot
|
||||
this.villages.tick();
|
||||
this.siegeManager.a();
|
||||
+ timings.doVillages.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("portalForcer");
|
||||
+ timings.doPortalForcer.startTiming(); // Spigot
|
||||
this.Q.a(this.getTime());
|
||||
+ timings.doPortalForcer.stopTiming(); // Spigot
|
||||
this.methodProfiler.b();
|
||||
+ timings.doSounds.startTiming(); // Spigot
|
||||
this.Z();
|
||||
+ timings.doSounds.stopTiming(); // Spigot
|
||||
|
||||
+ timings.doChunkGC.startTiming(); // Spigot
|
||||
this.getWorld().processChunkGC(); // CraftBukkit
|
||||
+ timings.doChunkGC.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
new file mode 100644
|
||||
index 0000000..8340c13
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
@@ -0,0 +1,125 @@
|
||||
+package org.bukkit.craftbukkit;
|
||||
+
|
||||
+import net.minecraft.server.*;
|
||||
+import org.spigotmc.CustomTimingsHandler;
|
||||
+import org.bukkit.scheduler.BukkitTask;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import org.bukkit.craftbukkit.scheduler.CraftTask;
|
||||
+
|
||||
+public class SpigotTimings {
|
||||
+
|
||||
+ public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
|
||||
+ public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
|
||||
+ public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Player Tick");
|
||||
+ public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
|
||||
+ public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
|
||||
+ public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
|
||||
+ public static final CustomTimingsHandler syncChunkLoadTimer = new CustomTimingsHandler("syncChunkLoad");
|
||||
+
|
||||
+ public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove");
|
||||
+ public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity");
|
||||
+ public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity");
|
||||
+ public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity");
|
||||
+
|
||||
+ public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick");
|
||||
+ public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI");
|
||||
+ public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision");
|
||||
+ public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove");
|
||||
+ public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest");
|
||||
+
|
||||
+ public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
|
||||
+
|
||||
+ 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>();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a timer associated with a plugins tasks.
|
||||
+ * @param task
|
||||
+ * @param period
|
||||
+ * @return
|
||||
+ */
|
||||
+ public static CustomTimingsHandler getPluginTaskTimings(BukkitTask task, long period) {
|
||||
+ String plugin = task.getOwner().getDescription().getFullName();
|
||||
+ String name = "Task: " + plugin + " Runnable: " + ( (CraftTask) task ).getTaskClass().getSimpleName();
|
||||
+ if (period > 0) {
|
||||
+ name += "(interval:" + period +")";
|
||||
+ } else {
|
||||
+ name += "(Single)";
|
||||
+ }
|
||||
+ CustomTimingsHandler result = pluginTaskTimingMap.get(name);
|
||||
+ if (result == null) {
|
||||
+ result = new CustomTimingsHandler(name);
|
||||
+ pluginTaskTimingMap.put(name, result);
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get a named timer for the specified entity type to track type specific timings.
|
||||
+ * @param entity
|
||||
+ * @return
|
||||
+ */
|
||||
+ public static CustomTimingsHandler getEntityTimings(Entity entity) {
|
||||
+ String entityType = entity.getClass().getSimpleName();
|
||||
+ CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
|
||||
+ if (result == null) {
|
||||
+ result = new CustomTimingsHandler("** tickEntity - " + entityType, activatedEntityTimer);
|
||||
+ entityTypeTimingMap.put(entityType, result);
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get a named timer for the specified tile entity type to track type specific timings.
|
||||
+ * @param entity
|
||||
+ * @return
|
||||
+ */
|
||||
+ public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
|
||||
+ String entityType = entity.getClass().getSimpleName();
|
||||
+ CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
|
||||
+ if (result == null) {
|
||||
+ result = new CustomTimingsHandler("** tickTileEntity - " + entityType, tickTileEntityTimer);
|
||||
+ tileEntityTypeTimingMap.put(entityType, result);
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set of timers per world, to track world specific timings.
|
||||
+ */
|
||||
+ public static class WorldTimingsHandler {
|
||||
+ public final CustomTimingsHandler mobSpawn;
|
||||
+ public final CustomTimingsHandler doChunkUnload;
|
||||
+ public final CustomTimingsHandler doPortalForcer;
|
||||
+ public final CustomTimingsHandler doTickPending;
|
||||
+ public final CustomTimingsHandler doTickTiles;
|
||||
+ public final CustomTimingsHandler doVillages;
|
||||
+ public final CustomTimingsHandler doChunkMap;
|
||||
+ public final CustomTimingsHandler doChunkGC;
|
||||
+ public final CustomTimingsHandler doSounds;
|
||||
+ public final CustomTimingsHandler entityTick;
|
||||
+ public final CustomTimingsHandler tileEntityTick;
|
||||
+ public final CustomTimingsHandler tileEntityPending;
|
||||
+ public final CustomTimingsHandler tracker;
|
||||
+
|
||||
+ public WorldTimingsHandler(World server) {
|
||||
+ String name = server.worldData.getName() +" - ";
|
||||
+
|
||||
+ mobSpawn = new CustomTimingsHandler(name + "mobSpawn");
|
||||
+ doChunkUnload = new CustomTimingsHandler(name + "doChunkUnload");
|
||||
+ doTickPending = new CustomTimingsHandler(name + "doTickPending");
|
||||
+ doTickTiles = new CustomTimingsHandler(name + "doTickTiles");
|
||||
+ doVillages = new CustomTimingsHandler(name + "doVillages");
|
||||
+ doChunkMap = new CustomTimingsHandler(name + "doChunkMap");
|
||||
+ doSounds = new CustomTimingsHandler(name + "doSounds");
|
||||
+ doChunkGC = new CustomTimingsHandler(name + "doChunkGC");
|
||||
+ doPortalForcer = new CustomTimingsHandler(name + "doPortalForcer");
|
||||
+ entityTick = new CustomTimingsHandler(name + "entityTick");
|
||||
+ tileEntityTick = new CustomTimingsHandler(name + "tileEntityTick");
|
||||
+ tileEntityPending = new CustomTimingsHandler(name + "tileEntityPending");
|
||||
+ tracker = new CustomTimingsHandler(name + "tracker");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
||||
index 55db3ff..7d294c0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.bukkit.craftbukkit.scheduler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
-class CraftTask implements BukkitTask, Runnable {
|
||||
+public class CraftTask implements BukkitTask, Runnable { // Spigot
|
||||
|
||||
private volatile CraftTask next = null;
|
||||
/**
|
||||
@@ -22,6 +24,7 @@ class CraftTask implements BukkitTask, Runnable {
|
||||
private final Plugin plugin;
|
||||
private final int id;
|
||||
|
||||
+ CustomTimingsHandler timings = null; // Spigot
|
||||
CraftTask() {
|
||||
this(null, null, -1, -1);
|
||||
}
|
||||
@@ -50,7 +53,22 @@ class CraftTask implements BukkitTask, Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
+ // Spigot start - Wrap custom timings on Tasks
|
||||
+ if (!Bukkit.getServer().getPluginManager().useTimings()) {
|
||||
+ task.run();
|
||||
+ return;
|
||||
+ }
|
||||
+ if (timings == null && this.getOwner() != null && this.isSync()) {
|
||||
+ timings = SpigotTimings.getPluginTaskTimings(this, period);
|
||||
+ }
|
||||
+ if (timings != null) {
|
||||
+ timings.startTiming();
|
||||
+ }
|
||||
task.run();
|
||||
+ if (timings != null) {
|
||||
+ timings.stopTiming();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
|
||||
long getPeriod() {
|
||||
@@ -77,7 +95,7 @@ class CraftTask implements BukkitTask, Runnable {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
- Class<? extends Runnable> getTaskClass() {
|
||||
+ public Class<? extends Runnable> getTaskClass() { // Spigot
|
||||
return task.getClass();
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
From 935017e6a09fdcb8e00283acc9c76b7d0ca0da6d 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 95b4704..3bcca91 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -40,6 +40,7 @@ public class Chunk {
|
||||
public int r;
|
||||
public long s;
|
||||
private int x;
|
||||
+ 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];
|
||||
@@ -601,6 +602,22 @@ public class Chunk {
|
||||
entity.aj = k;
|
||||
entity.ak = this.locZ;
|
||||
this.entitySlices[k].add(entity);
|
||||
+ // Spigot start - increment creature type count
|
||||
+ // Keep this synced up with World.a(Class)
|
||||
+ if (entity instanceof EntityInsentient) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ 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) {
|
||||
@@ -617,6 +634,22 @@ public class Chunk {
|
||||
}
|
||||
|
||||
this.entitySlices[i].remove(entity);
|
||||
+ // Spigot start - decrement creature type count
|
||||
+ // Keep this synced up with World.a(Class)
|
||||
+ if (entity instanceof EntityInsentient) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ 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 f514b78..3f0dd70 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
@@ -27,6 +27,23 @@ public final class SpawnerCreature {
|
||||
return new ChunkPosition(k, i1, l);
|
||||
}
|
||||
|
||||
+ // Spigot start - get entity count only from chunks being processed in b
|
||||
+ private int getEntityCount(WorldServer server, Class oClass)
|
||||
+ {
|
||||
+ int i = 0;
|
||||
+ for ( Long coord : this.a.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 int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) {
|
||||
if (!flag && !flag1) {
|
||||
return 0;
|
||||
@@ -42,6 +59,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) {
|
||||
@@ -89,13 +111,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 * this.a.size() / 256) { // CraftBukkit - use per-world limits
|
||||
+ if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && (mobcnt = getEntityCount(worldserver, enumcreaturetype.a())) <= limit * this.a.size() / 256) { // Spigot - use per-world limits and use all loaded chunks
|
||||
Iterator iterator = this.a.keySet().iterator();
|
||||
|
||||
+ int moblimit = (limit * this.a.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();
|
||||
|
||||
@@ -160,6 +184,13 @@ public final class SpawnerCreature {
|
||||
groupdataentity = entityinsentient.a(groupdataentity);
|
||||
worldserver.addEntity(entityinsentient, SpawnReason.NATURAL);
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ if ( --moblimit <= 0 )
|
||||
+ {
|
||||
+ // If we're past limit, stop spawn
|
||||
+ continue label110;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
if (j2 >= entityinsentient.bz()) {
|
||||
continue label110;
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 97d56bd..47d8421 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -127,4 +127,11 @@ public class SpigotWorldConfig
|
||||
viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
|
||||
log( "View Distance: " + viewDistance );
|
||||
}
|
||||
+
|
||||
+ public byte mobSpawnRange;
|
||||
+ private void mobSpawnRange()
|
||||
+ {
|
||||
+ mobSpawnRange = (byte) getInt( "mob-spawn-range", 4 );
|
||||
+ log( "Mob Spawn Range: " + mobSpawnRange );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From eb1ccaae514228e6a8562824ee3ea0fbea940624 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 f1bf467..5a368a0 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1292,6 +1292,13 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
TileEntity tileentity = (TileEntity) iterator.next();
|
||||
+ // Spigot start
|
||||
+ if (tileentity == null) {
|
||||
+ getServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash");
|
||||
+ iterator.remove();
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
// CraftBukkit start - Don't tick entities in chunks queued for unload
|
||||
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
||||
if (chunkProviderServer.unloadQueue.contains(tileentity.x >> 4, tileentity.z >> 4)) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,481 +0,0 @@
|
|||
From 67e430e29c2bb71e86ffe9d3742e3c4827948cee 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
|
||||
|
||||
This feature gives 3 new configurable ranges that if an entity of the matching type is outside of this radius of any player, will tick at 5% of its normal rate.
|
||||
|
||||
This will drastically cut down on tick timings for entities that are not in range of a user to actually be "used".
|
||||
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 3d6aeff..3e3d935 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 {
|
||||
public int ticksLived;
|
||||
public int maxFireTicks;
|
||||
public int fireTicks; // CraftBukkit - private -> public
|
||||
- protected boolean inWater;
|
||||
+ public boolean inWater; // Spigot - protected -> public
|
||||
public int noDamageTicks;
|
||||
private boolean justCreated;
|
||||
protected boolean fireProof;
|
||||
@@ -111,7 +111,13 @@ public abstract class Entity {
|
||||
public EnumEntitySize at;
|
||||
public boolean valid; // CraftBukkit
|
||||
|
||||
+ // Spigot start
|
||||
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
||||
+ public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
||||
+ public final boolean defaultActivationState;
|
||||
+ public long activatedTick = 0;
|
||||
+ public void inactiveTick() { }
|
||||
+ // Spigot end
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
@@ -138,7 +144,12 @@ public abstract class Entity {
|
||||
this.setPosition(0.0D, 0.0D, 0.0D);
|
||||
if (world != null) {
|
||||
this.dimension = world.worldProvider.dimension;
|
||||
+ // Spigot start
|
||||
+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, world.spigotConfig);
|
||||
+ } else {
|
||||
+ this.defaultActivationState = false;
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
this.datawatcher = new DataWatcher(this);
|
||||
this.datawatcher.a(0, Byte.valueOf((byte) 0));
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityAgeable.java b/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||
index 36ed831..7ddca48 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||
@@ -6,6 +6,31 @@ public abstract class EntityAgeable extends EntityCreature {
|
||||
private float bq;
|
||||
public boolean ageLocked = false; // CraftBukkit
|
||||
|
||||
+ // Spigot start
|
||||
+ @Override
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ super.inactiveTick();
|
||||
+ if ( this.world.isStatic || this.ageLocked )
|
||||
+ { // CraftBukkit
|
||||
+ this.a( this.isBaby() );
|
||||
+ } else
|
||||
+ {
|
||||
+ int i = this.getAge();
|
||||
+
|
||||
+ if ( i < 0 )
|
||||
+ {
|
||||
+ ++i;
|
||||
+ this.setAge( i );
|
||||
+ } else if ( i > 0 )
|
||||
+ {
|
||||
+ --i;
|
||||
+ this.setAge( i );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
public EntityAgeable(World world) {
|
||||
super(world);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
index 4b3e5dd..3fd3de9 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
@@ -14,7 +14,7 @@ public class EntityArrow extends Entity implements IProjectile {
|
||||
private int f = -1;
|
||||
private Block g;
|
||||
private int h;
|
||||
- private boolean inGround;
|
||||
+ public boolean inGround = false; // Spigot - private -> public
|
||||
public int fromPlayer;
|
||||
public int shake;
|
||||
public Entity shooter;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 7211da8..d06ec7b 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -78,6 +78,13 @@ public abstract class EntityLiving extends Entity {
|
||||
public int expToDrop;
|
||||
public int maxAirTicks = 300;
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ super.inactiveTick();
|
||||
+ ++this.aV;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
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 5a368a0..2cc9005 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1234,6 +1234,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.f.clear();
|
||||
this.methodProfiler.c("regular");
|
||||
|
||||
+ org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||
timings.entityTick.startTiming(); // Spigot
|
||||
for (i = 0; i < this.entityList.size(); ++i) {
|
||||
entity = (Entity) this.entityList.get(i);
|
||||
@@ -1394,7 +1395,11 @@ public abstract class World implements IBlockAccess {
|
||||
int j = MathHelper.floor(entity.locZ);
|
||||
byte b0 = 32;
|
||||
|
||||
- if (!flag || this.b(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
|
||||
+ // Spigot start
|
||||
+ if (!org.spigotmc.ActivationRange.checkIfActive(entity)) {
|
||||
+ entity.ticksLived++;
|
||||
+ entity.inactiveTick();
|
||||
+ } else {
|
||||
entity.tickTimer.startTiming(); // Spigot
|
||||
entity.T = entity.locX;
|
||||
entity.U = entity.locY;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
index 8340c13..541dfe4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
@@ -30,6 +30,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/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
new file mode 100644
|
||||
index 0000000..db4c927
|
||||
--- /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;
|
||||
+import net.minecraft.server.Chunk;
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.EntityAmbient;
|
||||
+import net.minecraft.server.EntityAnimal;
|
||||
+import net.minecraft.server.EntityArrow;
|
||||
+import net.minecraft.server.EntityComplexPart;
|
||||
+import net.minecraft.server.EntityCreature;
|
||||
+import net.minecraft.server.EntityEnderCrystal;
|
||||
+import net.minecraft.server.EntityEnderDragon;
|
||||
+import net.minecraft.server.EntityFireball;
|
||||
+import net.minecraft.server.EntityFireworks;
|
||||
+import net.minecraft.server.EntityHuman;
|
||||
+import net.minecraft.server.EntityLiving;
|
||||
+import net.minecraft.server.EntityMonster;
|
||||
+import net.minecraft.server.EntityProjectile;
|
||||
+import net.minecraft.server.EntitySheep;
|
||||
+import net.minecraft.server.EntitySlime;
|
||||
+import net.minecraft.server.EntityTNTPrimed;
|
||||
+import net.minecraft.server.EntityVillager;
|
||||
+import net.minecraft.server.EntityWeather;
|
||||
+import net.minecraft.server.EntityWither;
|
||||
+import net.minecraft.server.MathHelper;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.World;
|
||||
+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
|
||||
+ * entity is in for activation ranges.
|
||||
+ *
|
||||
+ * @param entity
|
||||
+ * @return group id
|
||||
+ */
|
||||
+ public static byte initializeEntityActivationType(Entity entity)
|
||||
+ {
|
||||
+ if ( entity instanceof EntityMonster || entity instanceof EntitySlime )
|
||||
+ {
|
||||
+ return 1; // Monster
|
||||
+ } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbient )
|
||||
+ {
|
||||
+ return 2; // Animal
|
||||
+ } else
|
||||
+ {
|
||||
+ return 3; // Misc
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * These entities are excluded from Activation range checks.
|
||||
+ *
|
||||
+ * @param entity
|
||||
+ * @param world
|
||||
+ * @return boolean If it should always tick.
|
||||
+ */
|
||||
+ 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
|
||||
+ || entity instanceof EntityComplexPart
|
||||
+ || entity instanceof EntityWither
|
||||
+ || entity instanceof EntityFireball
|
||||
+ || entity instanceof EntityWeather
|
||||
+ || entity instanceof EntityTNTPrimed
|
||||
+ || entity instanceof EntityEnderCrystal
|
||||
+ || entity instanceof EntityFireworks )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Utility method to grow an AABB without creating a new AABB or touching
|
||||
+ * the pool, so we can re-use ones we have.
|
||||
+ *
|
||||
+ * @param target
|
||||
+ * @param source
|
||||
+ * @param x
|
||||
+ * @param y
|
||||
+ * @param 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;
|
||||
+ target.d = source.d + x;
|
||||
+ target.e = source.e + y;
|
||||
+ target.f = source.f + z;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Find what entities are in range of the players in the world and set
|
||||
+ * active if in range.
|
||||
+ *
|
||||
+ * @param world
|
||||
+ */
|
||||
+ public static void activateEntities(World world)
|
||||
+ {
|
||||
+ SpigotTimings.entityActivationCheckTimer.startTiming();
|
||||
+ 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.spigotConfig.viewDistance << 4 ) - 8, maxRange );
|
||||
+
|
||||
+ 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 );
|
||||
+
|
||||
+ 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 ) );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ SpigotTimings.entityActivationCheckTimer.stopTiming();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the activation state of all entities in this chunk.
|
||||
+ *
|
||||
+ * @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 )
|
||||
+ {
|
||||
+ entity.activatedTick = MinecraftServer.currentTick;
|
||||
+ continue;
|
||||
+ }
|
||||
+ switch ( entity.activationType )
|
||||
+ {
|
||||
+ case 1:
|
||||
+ if ( monsterBB.b( entity.boundingBox ) )
|
||||
+ {
|
||||
+ entity.activatedTick = MinecraftServer.currentTick;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if ( animalBB.b( entity.boundingBox ) )
|
||||
+ {
|
||||
+ entity.activatedTick = MinecraftServer.currentTick;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ default:
|
||||
+ if ( miscBB.b( entity.boundingBox ) )
|
||||
+ {
|
||||
+ entity.activatedTick = MinecraftServer.currentTick;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * If an entity is not in range, do some more checks to see if we should
|
||||
+ * give it a shot.
|
||||
+ *
|
||||
+ * @param entity
|
||||
+ * @return
|
||||
+ */
|
||||
+ public static boolean checkEntityImmunities(Entity entity)
|
||||
+ {
|
||||
+ // quick checks.
|
||||
+ if ( entity.inWater /* isInWater */ || entity.fireTicks > 0 )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( !( entity instanceof EntityArrow ) )
|
||||
+ {
|
||||
+ if ( !entity.onGround || entity.passenger != null
|
||||
+ || entity.vehicle != null )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ } else if ( !( (EntityArrow) entity ).inGround )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // special cases.
|
||||
+ if ( entity instanceof EntityLiving )
|
||||
+ {
|
||||
+ EntityLiving living = (EntityLiving) entity;
|
||||
+ if ( living.attackTicks > 0 || living.hurtTicks > 0 || living.effects.size() > 0 )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).target != null )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).bY() /* Getter for first boolean */ )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( entity instanceof EntityAnimal )
|
||||
+ {
|
||||
+ EntityAnimal animal = (EntityAnimal) entity;
|
||||
+ if ( animal.isBaby() || animal.cc() /*love*/ )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).isSheared() )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the entity is active for this tick.
|
||||
+ *
|
||||
+ * @param entity
|
||||
+ * @return
|
||||
+ */
|
||||
+ 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 )
|
||||
+ {
|
||||
+ // Check immunities every 20 ticks.
|
||||
+ 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 ) )
|
||||
+ {
|
||||
+ isActive = false;
|
||||
+ }
|
||||
+ 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 ) )
|
||||
+ {
|
||||
+ 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 47d8421..f7c6166 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -134,4 +134,15 @@ public class SpigotWorldConfig
|
||||
mobSpawnRange = (byte) getInt( "mob-spawn-range", 4 );
|
||||
log( "Mob Spawn Range: " + mobSpawnRange );
|
||||
}
|
||||
+
|
||||
+ 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.3.2
|
||||
|
|
@ -1,692 +0,0 @@
|
|||
From fa3bbb6c887e39eea85aa363f7fa96caaa88d59c 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/spigotmc/Metrics.java b/src/main/java/org/spigotmc/Metrics.java
|
||||
new file mode 100644
|
||||
index 0000000..f1690a2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/Metrics.java
|
||||
@@ -0,0 +1,645 @@
|
||||
+/*
|
||||
+ * Copyright 2011-2013 Tyler Blair. All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without modification, are
|
||||
+ * permitted provided that the following conditions are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
+ * conditions and the following disclaimer.
|
||||
+ *
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
+ * of conditions and the following disclaimer in the documentation and/or other materials
|
||||
+ * provided with the distribution.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ *
|
||||
+ * The views and conclusions contained in the software and documentation are those of the
|
||||
+ * authors and contributors and should not be interpreted as representing official policies,
|
||||
+ * either expressed or implied, of anybody else.
|
||||
+ */
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.PluginDescriptionFile;
|
||||
+import org.bukkit.scheduler.BukkitTask;
|
||||
+
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStreamReader;
|
||||
+import java.io.OutputStreamWriter;
|
||||
+import java.io.UnsupportedEncodingException;
|
||||
+import java.net.Proxy;
|
||||
+import java.net.URL;
|
||||
+import java.net.URLConnection;
|
||||
+import java.net.URLEncoder;
|
||||
+import java.util.Collections;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.LinkedHashSet;
|
||||
+import java.util.Set;
|
||||
+import java.util.Timer;
|
||||
+import java.util.TimerTask;
|
||||
+import java.util.UUID;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.logging.Level;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+
|
||||
+/**
|
||||
+ * <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
|
||||
+ * Public methods provided by this class: </p>
|
||||
+ * <code>
|
||||
+ * Graph createGraph(String name); <br/>
|
||||
+ * void addCustomData(BukkitMetrics.Plotter plotter); <br/>
|
||||
+ * void start(); <br/>
|
||||
+ * </code>
|
||||
+ */
|
||||
+public class Metrics {
|
||||
+
|
||||
+ /**
|
||||
+ * The current revision number
|
||||
+ */
|
||||
+ private final static int REVISION = 6;
|
||||
+ /**
|
||||
+ * The base url of the metrics domain
|
||||
+ */
|
||||
+ private static final String BASE_URL = "http://mcstats.org";
|
||||
+ /**
|
||||
+ * The url used to report a server's status
|
||||
+ */
|
||||
+ private static final String REPORT_URL = "/report/%s";
|
||||
+ /**
|
||||
+ * The separator to use for custom data. This MUST NOT change unless you are hosting your own version of metrics and
|
||||
+ * want to change it.
|
||||
+ */
|
||||
+ private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||
+ /**
|
||||
+ * Interval of time to ping (in minutes)
|
||||
+ */
|
||||
+ private static final int PING_INTERVAL = 10;
|
||||
+ /**
|
||||
+ * All of the custom graphs to submit to metrics
|
||||
+ */
|
||||
+ private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
+ /**
|
||||
+ * The default graph, used for addCustomData when you don't want a specific graph
|
||||
+ */
|
||||
+ private final Graph defaultGraph = new Graph("Default");
|
||||
+ /**
|
||||
+ * The plugin configuration file
|
||||
+ */
|
||||
+ private final YamlConfiguration configuration;
|
||||
+ /**
|
||||
+ * The plugin configuration file
|
||||
+ */
|
||||
+ private final File configurationFile;
|
||||
+ /**
|
||||
+ * Unique server id
|
||||
+ */
|
||||
+ private final String guid;
|
||||
+ /**
|
||||
+ * Debug mode
|
||||
+ */
|
||||
+ private final boolean debug;
|
||||
+ /**
|
||||
+ * Lock for synchronization
|
||||
+ */
|
||||
+ private final Object optOutLock = new Object();
|
||||
+ /**
|
||||
+ * The scheduled task
|
||||
+ */
|
||||
+ private volatile Timer task = null;
|
||||
+
|
||||
+ public Metrics() throws IOException {
|
||||
+ // load the config
|
||||
+ configurationFile = getConfigFile();
|
||||
+ configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
+
|
||||
+ // add some defaults
|
||||
+ configuration.addDefault("opt-out", false);
|
||||
+ configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
+ configuration.addDefault("debug", false);
|
||||
+
|
||||
+ // Do we need to create the file?
|
||||
+ if (configuration.get("guid", null) == null) {
|
||||
+ configuration.options().header("http://mcstats.org").copyDefaults(true);
|
||||
+ configuration.save(configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ // Load the guid then
|
||||
+ guid = configuration.getString("guid");
|
||||
+ debug = configuration.getBoolean("debug", false);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
+ * website. Plotters can be added to the graph object returned.
|
||||
+ *
|
||||
+ * @param name The name of the graph
|
||||
+ * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
+ */
|
||||
+ public Graph createGraph(final String name) {
|
||||
+ if (name == null) {
|
||||
+ throw new IllegalArgumentException("Graph name cannot be null");
|
||||
+ }
|
||||
+
|
||||
+ // Construct the graph object
|
||||
+ final Graph graph = new Graph(name);
|
||||
+
|
||||
+ // Now we can add our graph
|
||||
+ graphs.add(graph);
|
||||
+
|
||||
+ // and return back
|
||||
+ return graph;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
+ *
|
||||
+ * @param graph The name of the graph
|
||||
+ */
|
||||
+ public void addGraph(final Graph graph) {
|
||||
+ if (graph == null) {
|
||||
+ throw new IllegalArgumentException("Graph cannot be null");
|
||||
+ }
|
||||
+
|
||||
+ graphs.add(graph);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Adds a custom data plotter to the default graph
|
||||
+ *
|
||||
+ * @param plotter The plotter to use to plot custom data
|
||||
+ */
|
||||
+ public void addCustomData(final Plotter plotter) {
|
||||
+ if (plotter == null) {
|
||||
+ throw new IllegalArgumentException("Plotter cannot be null");
|
||||
+ }
|
||||
+
|
||||
+ // Add the plotter to the graph o/
|
||||
+ defaultGraph.addPlotter(plotter);
|
||||
+
|
||||
+ // Ensure the default graph is included in the submitted graphs
|
||||
+ graphs.add(defaultGraph);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
+ * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
+ * ticks.
|
||||
+ *
|
||||
+ * @return True if statistics measuring is running, otherwise false.
|
||||
+ */
|
||||
+ public boolean start() {
|
||||
+ synchronized (optOutLock) {
|
||||
+ // Did we opt out?
|
||||
+ if (isOptOut()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Is metrics already running?
|
||||
+ if (task != null) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // Begin hitting the server with glorious data
|
||||
+ task = new Timer("Spigot Metrics Thread", true);
|
||||
+
|
||||
+ task.scheduleAtFixedRate(new TimerTask() {
|
||||
+ private boolean firstPost = true;
|
||||
+
|
||||
+ public void run() {
|
||||
+ try {
|
||||
+ // This has to be synchronized or it can collide with the disable method.
|
||||
+ synchronized (optOutLock) {
|
||||
+ // Disable Task, if it is running and the server owner decided to opt-out
|
||||
+ if (isOptOut() && task != null) {
|
||||
+ task.cancel();
|
||||
+ task = null;
|
||||
+ // Tell all plotters to stop gathering information.
|
||||
+ for (Graph graph : graphs) {
|
||||
+ graph.onOptOut();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // We use the inverse of firstPost because if it is the first time we are posting,
|
||||
+ // it is not a interval ping, so it evaluates to FALSE
|
||||
+ // Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
+ postPlugin(!firstPost);
|
||||
+
|
||||
+ // After the first post we set firstPost to false
|
||||
+ // Each post thereafter will be a ping
|
||||
+ firstPost = false;
|
||||
+ } catch (IOException e) {
|
||||
+ if (debug) {
|
||||
+ Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }, 0, TimeUnit.MINUTES.toMillis(PING_INTERVAL));
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Has the server owner denied plugin metrics?
|
||||
+ *
|
||||
+ * @return true if metrics should be opted out of it
|
||||
+ */
|
||||
+ public boolean isOptOut() {
|
||||
+ synchronized (optOutLock) {
|
||||
+ try {
|
||||
+ // Reload the metrics file
|
||||
+ configuration.load(getConfigFile());
|
||||
+ } catch (IOException ex) {
|
||||
+ if (debug) {
|
||||
+ Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
+ }
|
||||
+ return true;
|
||||
+ } catch (InvalidConfigurationException ex) {
|
||||
+ if (debug) {
|
||||
+ Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ return configuration.getBoolean("opt-out", false);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
+ *
|
||||
+ * @throws java.io.IOException
|
||||
+ */
|
||||
+ public void enable() throws IOException {
|
||||
+ // This has to be synchronized or it can collide with the check in the task.
|
||||
+ synchronized (optOutLock) {
|
||||
+ // Check if the server owner has already set opt-out, if not, set it.
|
||||
+ if (isOptOut()) {
|
||||
+ configuration.set("opt-out", false);
|
||||
+ configuration.save(configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ // Enable Task, if it is not running
|
||||
+ if (task == null) {
|
||||
+ start();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
+ *
|
||||
+ * @throws java.io.IOException
|
||||
+ */
|
||||
+ public void disable() throws IOException {
|
||||
+ // This has to be synchronized or it can collide with the check in the task.
|
||||
+ synchronized (optOutLock) {
|
||||
+ // Check if the server owner has already set opt-out, if not, set it.
|
||||
+ if (!isOptOut()) {
|
||||
+ configuration.set("opt-out", true);
|
||||
+ configuration.save(configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ // Disable Task, if it is running
|
||||
+ if (task != null) {
|
||||
+ task.cancel();
|
||||
+ task = null;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
+ *
|
||||
+ * @return the File object for the config file
|
||||
+ */
|
||||
+ public File getConfigFile() {
|
||||
+ // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||
+ // is to abuse the plugin object we already have
|
||||
+ // plugin.getDataFolder() => base/plugins/PluginA/
|
||||
+ // pluginsFolder => base/plugins/
|
||||
+ // The base is not necessarily relative to the startup directory.
|
||||
+ // File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||
+
|
||||
+ // return => base/plugins/PluginMetrics/config.yml
|
||||
+ return new File(new File((File) MinecraftServer.getServer().options.valueOf("plugins"), "PluginMetrics"), "config.yml");
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Generic method that posts a plugin to the metrics website
|
||||
+ */
|
||||
+ private void postPlugin(final boolean isPing) throws IOException {
|
||||
+ // Server software specific section
|
||||
+ String pluginName = "Spigot";
|
||||
+ boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
+ String pluginVersion = (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown";
|
||||
+ String serverVersion = Bukkit.getVersion();
|
||||
+ int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
||||
+
|
||||
+ // END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
+
|
||||
+ // Construct the post data
|
||||
+ final StringBuilder data = new StringBuilder();
|
||||
+
|
||||
+ // The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
+ data.append(encode("guid")).append('=').append(encode(guid));
|
||||
+ encodeDataPair(data, "version", pluginVersion);
|
||||
+ encodeDataPair(data, "server", serverVersion);
|
||||
+ encodeDataPair(data, "players", Integer.toString(playersOnline));
|
||||
+ encodeDataPair(data, "revision", String.valueOf(REVISION));
|
||||
+
|
||||
+ // New data as of R6
|
||||
+ String osname = System.getProperty("os.name");
|
||||
+ String osarch = System.getProperty("os.arch");
|
||||
+ String osversion = System.getProperty("os.version");
|
||||
+ String java_version = System.getProperty("java.version");
|
||||
+ int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
+
|
||||
+ // normalize os arch .. amd64 -> x86_64
|
||||
+ if (osarch.equals("amd64")) {
|
||||
+ osarch = "x86_64";
|
||||
+ }
|
||||
+
|
||||
+ encodeDataPair(data, "osname", osname);
|
||||
+ encodeDataPair(data, "osarch", osarch);
|
||||
+ encodeDataPair(data, "osversion", osversion);
|
||||
+ encodeDataPair(data, "cores", Integer.toString(coreCount));
|
||||
+ encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
|
||||
+ encodeDataPair(data, "java_version", java_version);
|
||||
+
|
||||
+ // If we're pinging, append it
|
||||
+ if (isPing) {
|
||||
+ encodeDataPair(data, "ping", "true");
|
||||
+ }
|
||||
+
|
||||
+ // Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||
+ // inside of the graph (e.g plotters)
|
||||
+ synchronized (graphs) {
|
||||
+ final Iterator<Graph> iter = graphs.iterator();
|
||||
+
|
||||
+ while (iter.hasNext()) {
|
||||
+ final Graph graph = iter.next();
|
||||
+
|
||||
+ for (Plotter plotter : graph.getPlotters()) {
|
||||
+ // The key name to send to the metrics server
|
||||
+ // The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||
+ // Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||
+ final String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
||||
+
|
||||
+ // The value to send, which for the foreseeable future is just the string
|
||||
+ // value of plotter.getValue()
|
||||
+ final String value = Integer.toString(plotter.getValue());
|
||||
+
|
||||
+ // Add it to the http post data :)
|
||||
+ encodeDataPair(data, key, value);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Create the url
|
||||
+ URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(pluginName)));
|
||||
+
|
||||
+ // Connect to the website
|
||||
+ URLConnection connection;
|
||||
+
|
||||
+ // Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
+ // It does not reroute POST requests so we need to go around it
|
||||
+ if (isMineshafterPresent()) {
|
||||
+ connection = url.openConnection(Proxy.NO_PROXY);
|
||||
+ } else {
|
||||
+ connection = url.openConnection();
|
||||
+ }
|
||||
+
|
||||
+ connection.setDoOutput(true);
|
||||
+
|
||||
+ // Write the data
|
||||
+ final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
||||
+ writer.write(data.toString());
|
||||
+ writer.flush();
|
||||
+
|
||||
+ // Now read the response
|
||||
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
+ final String response = reader.readLine();
|
||||
+
|
||||
+ // close resources
|
||||
+ writer.close();
|
||||
+ reader.close();
|
||||
+
|
||||
+ if (response == null || response.startsWith("ERR")) {
|
||||
+ throw new IOException(response); //Throw the exception
|
||||
+ } else {
|
||||
+ // Is this the first update this hour?
|
||||
+ if (response.contains("OK This is your first update this hour")) {
|
||||
+ synchronized (graphs) {
|
||||
+ final Iterator<Graph> iter = graphs.iterator();
|
||||
+
|
||||
+ while (iter.hasNext()) {
|
||||
+ final Graph graph = iter.next();
|
||||
+
|
||||
+ for (Plotter plotter : graph.getPlotters()) {
|
||||
+ plotter.reset();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
+ *
|
||||
+ * @return true if mineshafter is installed on the server
|
||||
+ */
|
||||
+ private boolean isMineshafterPresent() {
|
||||
+ try {
|
||||
+ Class.forName("mineshafter.MineServer");
|
||||
+ return true;
|
||||
+ } catch (Exception e) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first key/value pair
|
||||
+ * MUST be included manually, e.g:</p>
|
||||
+ * <code>
|
||||
+ * StringBuffer data = new StringBuffer();
|
||||
+ * data.append(encode("guid")).append('=').append(encode(guid));
|
||||
+ * encodeDataPair(data, "version", description.getVersion());
|
||||
+ * </code>
|
||||
+ *
|
||||
+ * @param buffer the stringbuilder to append the data pair onto
|
||||
+ * @param key the key value
|
||||
+ * @param value the value
|
||||
+ */
|
||||
+ private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
|
||||
+ buffer.append('&').append(encode(key)).append('=').append(encode(value));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Encode text as UTF-8
|
||||
+ *
|
||||
+ * @param text the text to encode
|
||||
+ * @return the encoded text, as UTF-8
|
||||
+ */
|
||||
+ private static String encode(final String text) throws UnsupportedEncodingException {
|
||||
+ return URLEncoder.encode(text, "UTF-8");
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom graph on the website
|
||||
+ */
|
||||
+ public static class Graph {
|
||||
+
|
||||
+ /**
|
||||
+ * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
+ * rejected
|
||||
+ */
|
||||
+ private final String name;
|
||||
+ /**
|
||||
+ * The set of plotters that are contained within this graph
|
||||
+ */
|
||||
+ private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
+
|
||||
+ private Graph(final String name) {
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the graph's name
|
||||
+ *
|
||||
+ * @return the Graph's name
|
||||
+ */
|
||||
+ public String getName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Add a plotter to the graph, which will be used to plot entries
|
||||
+ *
|
||||
+ * @param plotter the plotter to add to the graph
|
||||
+ */
|
||||
+ public void addPlotter(final Plotter plotter) {
|
||||
+ plotters.add(plotter);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Remove a plotter from the graph
|
||||
+ *
|
||||
+ * @param plotter the plotter to remove from the graph
|
||||
+ */
|
||||
+ public void removePlotter(final Plotter plotter) {
|
||||
+ plotters.remove(plotter);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
+ *
|
||||
+ * @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
+ */
|
||||
+ public Set<Plotter> getPlotters() {
|
||||
+ return Collections.unmodifiableSet(plotters);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return name.hashCode();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(final Object object) {
|
||||
+ if (!(object instanceof Graph)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final Graph graph = (Graph) object;
|
||||
+ return graph.name.equals(name);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
+ */
|
||||
+ protected void onOptOut() {
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Interface used to collect custom data for a plugin
|
||||
+ */
|
||||
+ public static abstract class Plotter {
|
||||
+
|
||||
+ /**
|
||||
+ * The plot's name
|
||||
+ */
|
||||
+ private final String name;
|
||||
+
|
||||
+ /**
|
||||
+ * Construct a plotter with the default plot name
|
||||
+ */
|
||||
+ public Plotter() {
|
||||
+ this("Default");
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Construct a plotter with a specific plot name
|
||||
+ *
|
||||
+ * @param name the name of the plotter to use, which will show up on the website
|
||||
+ */
|
||||
+ public Plotter(final String name) {
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
+ * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
+ * from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
+ *
|
||||
+ * @return the current value for the point to be plotted.
|
||||
+ */
|
||||
+ public abstract int getValue();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the column name for the plotted point
|
||||
+ *
|
||||
+ * @return the plotted point's column name
|
||||
+ */
|
||||
+ public String getColumnName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called after the website graphs have been updated
|
||||
+ */
|
||||
+ public void reset() {
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return getColumnName().hashCode();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(final Object object) {
|
||||
+ if (!(object instanceof Plotter)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final Plotter plotter = (Plotter) object;
|
||||
+ return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
\ 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 1b0e1bf..0043690 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()
|
||||
{
|
||||
@@ -56,6 +57,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.3.2
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
From a8204e89bc4de656d43787e2d7596332ab77d681 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
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
index b308e03..f32322e 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -176,7 +176,13 @@ public final class ItemStack {
|
||||
return this.item.getMaxDurability();
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
public boolean isDamaged(int i, Random random) {
|
||||
+ return isDamaged(i, random, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isDamaged(int i, Random random, EntityLiving entityliving) {
|
||||
+ // Spigot end
|
||||
if (!this.g()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -191,7 +197,16 @@ public final class ItemStack {
|
||||
}
|
||||
|
||||
i -= k;
|
||||
- if (i <= 0) {
|
||||
+ // Spigot start
|
||||
+ if (entityliving instanceof EntityPlayer) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this);
|
||||
+ org.bukkit.event.player.PlayerItemDamageEvent event = new org.bukkit.event.player.PlayerItemDamageEvent((org.bukkit.entity.Player) entityliving.getBukkitEntity(), item, i);
|
||||
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) return false;
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+ if (i <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -204,7 +219,7 @@ public final class ItemStack {
|
||||
public void damage(int i, EntityLiving entityliving) {
|
||||
if (!(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.canInstantlyBuild) {
|
||||
if (this.g()) {
|
||||
- if (this.isDamaged(i, entityliving.aI())) {
|
||||
+ if (this.isDamaged(i, entityliving.aI(), entityliving)) {
|
||||
entityliving.a(this);
|
||||
--this.count;
|
||||
if (entityliving instanceof EntityHuman) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
From 856b0c4a784349869639493b3bbdbbe1d2bae9dc 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
|
||||
|
||||
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 3e3d935..a3a8750 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -138,7 +138,7 @@ public abstract class Entity {
|
||||
this.random = new Random();
|
||||
this.maxFireTicks = 1;
|
||||
this.justCreated = true;
|
||||
- this.uniqueID = UUID.randomUUID();
|
||||
+ this.uniqueID = new UUID(random.nextLong(), random.nextLong()); // Spigot
|
||||
this.at = EnumEntitySize.SIZE_2;
|
||||
this.world = world;
|
||||
this.setPosition(0.0D, 0.0D, 0.0D);
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
From b85faba904f9bb8b5fb40390b7d7728e28005143 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
|
||||
|
||||
This commit prevents the constructor of CraftSign throwing an NPE when it cannot get the sign tile entity. Instead it will fallback to a 4 empty lined sign, and not try to do anything to those lines on .update().
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
||||
index 1647100..43c4434 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
||||
@@ -14,6 +14,12 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
+ // Spigot start
|
||||
+ if (sign == null) {
|
||||
+ lines = new String[]{"", "", "", ""};
|
||||
+ return;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
lines = new String[sign.lines.length];
|
||||
System.arraycopy(sign.lines, 0, lines, 0, lines.length);
|
||||
}
|
||||
@@ -34,7 +40,7 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
- if (result) {
|
||||
+ if (result && sign != null) { // Spigot, add null check
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(lines[i] != null) {
|
||||
sign.lines[i] = lines[i];
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
From 9487afa3fd4b3f43d9a105f6313832a7556d304c 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 97d0bbb..fc679ae 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTracker.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
|
||||
@@ -92,6 +92,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.e) {
|
||||
i = this.e;
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index f7c6166..92497f5 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -145,4 +145,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.3.2
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
From 29a0d1e2daef5bf61844e7a8646839971613c2de 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
|
||||
|
||||
The default CraftBukkit render sequence for maps is ridiculously slow. By only using it when a custom renderer has been added (rarely in most cases), we can fallback to the Vanilla renderer for general usage. This leads to a much higher effiency overall, especially if no plugins are rendering such maps.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldMapHumanTracker.java b/src/main/java/net/minecraft/server/WorldMapHumanTracker.java
|
||||
index ec708d1..ef56386 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldMapHumanTracker.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldMapHumanTracker.java
|
||||
@@ -37,23 +37,29 @@ public class WorldMapHumanTracker {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
- org.bukkit.craftbukkit.map.RenderData render = this.worldMap.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) trackee.getBukkitEntity()); // CraftBukkit
|
||||
+ // Spigot start
|
||||
+ boolean custom = this.worldMap.mapView.renderers.size() > 1 || !(this.worldMap.mapView.renderers.get(0) instanceof org.bukkit.craftbukkit.map.CraftMapRenderer);
|
||||
+ org.bukkit.craftbukkit.map.RenderData render = (custom) ? this.worldMap.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) trackee.getBukkitEntity()) : null; // CraftBukkit
|
||||
|
||||
if (--this.g < 0) {
|
||||
this.g = 4;
|
||||
- abyte = new byte[render.cursors.size() * 3 + 1]; // CraftBukkit
|
||||
+ abyte = new byte[((custom) ? render.cursors.size() : this.worldMap.g.size()) * 3 + 1]; // CraftBukkit
|
||||
abyte[0] = 1;
|
||||
i = 0;
|
||||
|
||||
// CraftBukkit start
|
||||
- for (i = 0; i < render.cursors.size(); ++i) {
|
||||
- org.bukkit.map.MapCursor cursor = render.cursors.get(i);
|
||||
- if (!cursor.isVisible()) continue;
|
||||
|
||||
- abyte[i * 3 + 1] = (byte) (cursor.getRawType() << 4 | cursor.getDirection() & 15);
|
||||
- abyte[i * 3 + 2] = (byte) cursor.getX();
|
||||
- abyte[i * 3 + 3] = (byte) cursor.getY();
|
||||
+ // Spigot start
|
||||
+ for (Iterator iterator = ((custom) ? render.cursors.iterator() : this.worldMap.g.values().iterator()); iterator.hasNext(); ++i) {
|
||||
+ org.bukkit.map.MapCursor cursor = (custom) ? (org.bukkit.map.MapCursor) iterator.next() : null;
|
||||
+ if (cursor != null && !cursor.isVisible()) continue;
|
||||
+ WorldMapDecoration deco = (custom) ? null : (WorldMapDecoration) iterator.next();
|
||||
+
|
||||
+ abyte[i * 3 + 1] = (byte) (((custom) ? cursor.getRawType() : deco.type) << 4 | ((custom) ? cursor.getDirection() : deco.rotation) & 15);
|
||||
+ abyte[i * 3 + 2] = (byte) ((custom) ? cursor.getX() : deco.locX);
|
||||
+ abyte[i * 3 + 3] = (byte) ((custom) ? cursor.getY() : deco.locY);
|
||||
}
|
||||
+ // Spigot end
|
||||
// CraftBukkit end
|
||||
|
||||
boolean flag = !itemstack.A();
|
||||
@@ -88,7 +94,7 @@ public class WorldMapHumanTracker {
|
||||
abyte1[2] = (byte) j;
|
||||
|
||||
for (int i1 = 0; i1 < abyte1.length - 3; ++i1) {
|
||||
- abyte1[i1 + 3] = render.buffer[(i1 + j) * 128 + i]; // CraftBukkit
|
||||
+ abyte1[i1 + 3] = ((custom) ? render.buffer : this.worldMap.colors)[(i1 + j) * 128 + i];
|
||||
}
|
||||
|
||||
this.c[i] = -1;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
|
||||
index 1a150d9..c9f0027 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
|
||||
@@ -18,7 +18,7 @@ import org.bukkit.map.MapView;
|
||||
public final class CraftMapView implements MapView {
|
||||
|
||||
private final Map<CraftPlayer, RenderData> renderCache = new HashMap<CraftPlayer, RenderData>();
|
||||
- private final List<MapRenderer> renderers = new ArrayList<MapRenderer>();
|
||||
+ public final List<MapRenderer> renderers = new ArrayList<MapRenderer>(); // Spigot
|
||||
private final Map<MapRenderer, Map<CraftPlayer, CraftMapCanvas>> canvases = new HashMap<MapRenderer, Map<CraftPlayer, CraftMapCanvas>>();
|
||||
protected final WorldMap worldMap;
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
From 8cd0ac970c8190e504f4debf8b5e46a651462692 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 1dee8b2..4945955 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -62,6 +62,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public int newTotalExp = 0;
|
||||
public boolean keepLevel = false;
|
||||
public double maxHealthCache;
|
||||
+ public int lastPing = -1; // Spigot
|
||||
// CraftBukkit end
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 534073b..07cee4d 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -765,6 +765,25 @@ public abstract class PlayerList {
|
||||
this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), 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 PacketPlayOutPlayerInfo( 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.3.2
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
From fa3116e53197665d9ff2fe7f7acfc7b0e7530e1f 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
|
||||
|
||||
Removes the sleep forever thread and adds useful names for debugging to all staged thread files.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 84dcfcc..a30f217 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -71,7 +71,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
*/
|
||||
private final ConcurrentHashMap<Integer, CraftTask> runners = new ConcurrentHashMap<Integer, CraftTask>();
|
||||
private volatile int currentTick = -1;
|
||||
- private final Executor executor = Executors.newCachedThreadPool();
|
||||
+ private final Executor executor = Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").build()); // Spigot
|
||||
private CraftAsyncDebugger debugHead = new CraftAsyncDebugger(-1, null, null) {@Override StringBuilder debugTo(StringBuilder string) {return string;}};
|
||||
private CraftAsyncDebugger debugTail = debugHead;
|
||||
private static final int RECENT_TICKS;
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
From 485dd82c12359a08e0ae43f94c4242beba2a3389 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 Save Files
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
index 900ed68..829f4a3 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
|
||||
public class RegionFileCache {
|
||||
|
||||
- private static final Map a = new HashMap();
|
||||
+ public static final Map a = new HashMap(); // CraftBukkit - private -> public
|
||||
|
||||
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 244c727..0ab3255 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -41,6 +41,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.PropertyManager;
|
||||
import net.minecraft.server.ServerCommand;
|
||||
+import net.minecraft.server.RegionFile;
|
||||
+import net.minecraft.server.RegionFileCache;
|
||||
import net.minecraft.server.ServerNBTManager;
|
||||
import net.minecraft.server.WorldLoaderServer;
|
||||
import net.minecraft.server.WorldManager;
|
||||
@@ -849,6 +851,30 @@ public final class CraftServer implements Server {
|
||||
worlds.remove(world.getName().toLowerCase());
|
||||
console.worlds.remove(console.worlds.indexOf(handle));
|
||||
|
||||
+ File parentFolder = world.getWorldFolder().getAbsoluteFile();
|
||||
+
|
||||
+ // Synchronized because access to RegionFileCache.a is guarded by this lock.
|
||||
+ synchronized (RegionFileCache.class) {
|
||||
+ // RegionFileCache.a should be RegionFileCache.cache
|
||||
+ Iterator<Map.Entry<File, RegionFile>> i = RegionFileCache.a.entrySet().iterator();
|
||||
+ while(i.hasNext()) {
|
||||
+ Map.Entry<File, RegionFile> entry = i.next();
|
||||
+ File child = entry.getKey().getAbsoluteFile();
|
||||
+ while (child != null) {
|
||||
+ if (child.equals(parentFolder)) {
|
||||
+ i.remove();
|
||||
+ try {
|
||||
+ entry.getValue().c(); // Should be RegionFile.close();
|
||||
+ } catch (IOException ex) {
|
||||
+ getLogger().log(Level.SEVERE, null, ex);
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ child = child.getParentFile();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return true;
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
From 2bdbd423c60165cca9ba498200943e3b6a9680f6 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
|
||||
|
||||
Serves no purpose other than to confuse users.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PropertyManager.java b/src/main/java/net/minecraft/server/PropertyManager.java
|
||||
index bb535c2..93968bd 100644
|
||||
--- a/src/main/java/net/minecraft/server/PropertyManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/PropertyManager.java
|
||||
@@ -52,7 +52,7 @@ public class PropertyManager {
|
||||
}
|
||||
|
||||
private <T> T getOverride(String name, T value) {
|
||||
- if ((this.options != null) && (this.options.has(name))) {
|
||||
+ if ((this.options != null) && (this.options.has(name)) && !name.equals( "online-mode")) { // Spigot
|
||||
return (T) this.options.valueOf(name);
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
From fbb867e8d9fb21d2139ab3e3ee134a51236a42be 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
|
||||
|
||||
Some non API methods contributed by Asphodan to allow recipe deconstruction.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/IRecipe.java b/src/main/java/net/minecraft/server/IRecipe.java
|
||||
index bb28c12..c0836e4 100644
|
||||
--- a/src/main/java/net/minecraft/server/IRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/server/IRecipe.java
|
||||
@@ -11,4 +11,6 @@ public interface IRecipe {
|
||||
ItemStack b();
|
||||
|
||||
org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
|
||||
+
|
||||
+ java.util.List<ItemStack> getIngredients(); // Spigot
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ShapedRecipes.java b/src/main/java/net/minecraft/server/ShapedRecipes.java
|
||||
index cc444db..867dd07 100644
|
||||
--- a/src/main/java/net/minecraft/server/ShapedRecipes.java
|
||||
+++ b/src/main/java/net/minecraft/server/ShapedRecipes.java
|
||||
@@ -10,7 +10,7 @@ public class ShapedRecipes implements IRecipe {
|
||||
private int width;
|
||||
private int height;
|
||||
private ItemStack[] items;
|
||||
- private ItemStack result;
|
||||
+ public ItemStack result; // Spigot
|
||||
private boolean e;
|
||||
|
||||
public ShapedRecipes(int i, int j, ItemStack[] aitemstack, ItemStack itemstack) {
|
||||
@@ -156,4 +156,11 @@ public class ShapedRecipes implements IRecipe {
|
||||
this.e = true;
|
||||
return this;
|
||||
}
|
||||
+
|
||||
+ // Spigot start
|
||||
+ public java.util.List<ItemStack> getIngredients()
|
||||
+ {
|
||||
+ return java.util.Arrays.asList( items );
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||
index 0fab83c..21181fb 100644
|
||||
--- a/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||
+++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
||||
@@ -11,7 +11,7 @@ import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||
|
||||
public class ShapelessRecipes implements IRecipe {
|
||||
|
||||
- private final ItemStack result;
|
||||
+ public final ItemStack result; // Spigot
|
||||
private final List ingredients;
|
||||
|
||||
public ShapelessRecipes(ItemStack itemstack, List list) {
|
||||
@@ -75,4 +75,11 @@ public class ShapelessRecipes implements IRecipe {
|
||||
public int a() {
|
||||
return this.ingredients.size();
|
||||
}
|
||||
+
|
||||
+ // Spigot start
|
||||
+ public java.util.List<ItemStack> getIngredients()
|
||||
+ {
|
||||
+ return java.util.Collections.unmodifiableList( ingredients );
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
From 796d3b16c23bc87581229e24bf7d998d28feda6e 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
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
|
||||
index a386001..236384f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
|
||||
@@ -44,6 +44,17 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
|
||||
// Spigot start
|
||||
private final Arrow.Spigot spigot = new Arrow.Spigot()
|
||||
{
|
||||
+ @Override
|
||||
+ public double getDamage()
|
||||
+ {
|
||||
+ return getHandle().e();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setDamage(double damage)
|
||||
+ {
|
||||
+ getHandle().b( damage );
|
||||
+ }
|
||||
};
|
||||
|
||||
public Arrow.Spigot spigot()
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
From 415632cb3560ddbd8e890d347ad37377503c3226 Mon Sep 17 00:00:00 2001
|
||||
From: erocs <github@erocs.org>
|
||||
Date: Sun, 8 Sep 2013 12:06:15 -0700
|
||||
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 730eb78..a68b748 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
@@ -182,12 +182,17 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||
|
||||
flag = suckInItems(this) || flag;
|
||||
if (flag) {
|
||||
- this.c(8);
|
||||
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
|
||||
this.update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-
|
||||
+ // Spigot start
|
||||
+ if ( !this.j() )
|
||||
+ {
|
||||
+ this.c( world.spigotConfig.hopperCheck );
|
||||
+ }
|
||||
+ // Spigot end
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
@@ -218,7 +223,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.b(this.p())]);
|
||||
@@ -299,9 +304,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).l(4); // Delay hopper minecart checks
|
||||
+ ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -405,7 +410,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 92497f5..fc0aa4c 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -160,4 +160,17 @@ 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()
|
||||
+ {
|
||||
+ // Set the tick delay between hopper item movements
|
||||
+ hopperTransfer = getInt( "ticks-per.hopper-transfer", hopperTransfer );
|
||||
+ // Set the tick delay between checking for items after the associated
|
||||
+ // container is empty. Default to the hopperTransfer value to prevent
|
||||
+ // hopper sorting machines from becoming out of sync.
|
||||
+ hopperCheck = getInt( "ticks-per.hopper-check", hopperTransfer );
|
||||
+ log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
From 6242c8d23fe6aaf1ff834c24b2c24c8c5e8139c9 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
|
||||
|
||||
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 07cee4d..1725bba 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -1115,8 +1115,15 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void r() {
|
||||
- for (int i = 0; i < this.players.size(); ++i) {
|
||||
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
|
||||
+ while (!this.players.isEmpty()) {
|
||||
+ // Spigot start
|
||||
+ EntityPlayer p = (EntityPlayer) this.players.get( 0 );
|
||||
+ p.playerConnection.disconnect( this.server.server.getShutdownMessage() );
|
||||
+ if ( ( !this.players.isEmpty() ) && ( this.players.get( 0 ) == p ) )
|
||||
+ {
|
||||
+ this.players.remove( 0 ); // Prevent shutdown hang if already disconnected
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
From 0174c049ce2f9f1f89fcf692a611fd753dc3aad5 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.
|
||||
|
||||
Adds BUKKIT-267
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
index 67c3397..bb6b3d5 100644
|
||||
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
@@ -5,7 +5,11 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
-import org.bukkit.event.entity.CreatureSpawnEvent; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public abstract class MobSpawnerAbstract {
|
||||
|
||||
@@ -128,7 +132,12 @@ public abstract class MobSpawnerAbstract {
|
||||
|
||||
entity.f(nbttagcompound);
|
||||
if (entity.world != null) {
|
||||
- entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
||||
+ // CraftBukkit start - call SpawnerSpawnEvent, abort if cancelled
|
||||
+ SpawnerSpawnEvent event = CraftEventFactory.callSpawnerSpawnEvent(entity, this.b(), this.c(), this.d());
|
||||
+ if (!event.isCancelled()) {
|
||||
+ entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound1;
|
||||
@@ -152,6 +161,11 @@ public abstract class MobSpawnerAbstract {
|
||||
|
||||
entity2.f(nbttagcompound2);
|
||||
entity2.setPositionRotation(entity1.locX, entity1.locY, entity1.locZ, entity1.yaw, entity1.pitch);
|
||||
+ // CraftBukkit start - call SpawnerSpawnEvent, skip if cancelled
|
||||
+ SpawnerSpawnEvent event = CraftEventFactory.callSpawnerSpawnEvent(entity2, this.b(), this.c(), this.d());
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
if (entity.world != null) {
|
||||
entity.world.addEntity(entity2, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
||||
}
|
||||
@@ -163,7 +177,12 @@ public abstract class MobSpawnerAbstract {
|
||||
}
|
||||
} else if (entity instanceof EntityLiving && entity.world != null) {
|
||||
((EntityInsentient) entity).a((GroupDataEntity) null);
|
||||
- this.a().addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
||||
+ // CraftBukkit start - call SpawnerSpawnEvent, abort if cancelled
|
||||
+ SpawnerSpawnEvent event = CraftEventFactory.callSpawnerSpawnEvent(entity, this.b(), this.c(), this.d());
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.a().addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return entity;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index a654a3e..f100884 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -35,6 +35,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
@@ -116,6 +117,22 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Mob spawner event
|
||||
+ */
|
||||
+ public static SpawnerSpawnEvent callSpawnerSpawnEvent(Entity spawnee, int spawnerX, int spawnerY, int spawnerZ) {
|
||||
+ org.bukkit.craftbukkit.entity.CraftEntity entity = spawnee.getBukkitEntity();
|
||||
+ BlockState state = entity.getWorld().getBlockAt(spawnerX, spawnerY, spawnerZ).getState();
|
||||
+
|
||||
+ if (!(state instanceof CreatureSpawner)) {
|
||||
+ state = null;
|
||||
+ }
|
||||
+
|
||||
+ SpawnerSpawnEvent event = new SpawnerSpawnEvent(entity, (CreatureSpawner) state);
|
||||
+ entity.getServer().getPluginManager().callEvent(event);
|
||||
+ return event;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
* Bucket methods
|
||||
*/
|
||||
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
From 97e7e5740bb1654040c96ffb2a47ad91ea46bb76 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
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
|
||||
index 0f7da6b..5a409ae 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
|
||||
@@ -145,7 +145,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
||||
case BURST:
|
||||
return 4;
|
||||
default:
|
||||
- throw new AssertionError(type);
|
||||
+ throw new IllegalStateException(type.toString()); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
||||
case 4:
|
||||
return Type.BURST;
|
||||
default:
|
||||
- throw new AssertionError(nbt);
|
||||
+ throw new IllegalStateException(Integer.toString(nbt)); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
From 102fe64bd5e3b33bf921032d76d2276af060f99d 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
|
||||
|
||||
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 0ab3255..6a38465 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1133,7 +1133,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer(String name) {
|
||||
- return getOfflinePlayer(name, true);
|
||||
+ return getOfflinePlayer(name, false); // Spigot
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer(String name, boolean search) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
From 8c1bd0faa1dd0baa446f54ee643cfcd040374e6a 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 d0ea17a..31be464 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -930,7 +930,12 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
}
|
||||
|
||||
try {
|
||||
- this.c.info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
|
||||
+ // Spigot Start
|
||||
+ if ( org.spigotmc.SpigotConfig.logCommands )
|
||||
+ {
|
||||
+ this.c.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 0043690..26d5845 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -136,4 +136,10 @@ public class SpigotConfig
|
||||
{
|
||||
commands.put( "tps", new TicksPerSecondCommand( "tps" ) );
|
||||
}
|
||||
+
|
||||
+ public static boolean logCommands;
|
||||
+ private static void logCommands()
|
||||
+ {
|
||||
+ logCommands = getBoolean( "commands.log", true );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
From 21b964347e1db3ea0f70388d9b76cc282e9405fa 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 6a38465..4d77259 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1398,6 +1398,13 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
public List<String> tabCompleteCommand(Player player, String message) {
|
||||
+ // Spigot Start
|
||||
+ if ( !org.spigotmc.SpigotConfig.tabComplete )
|
||||
+ {
|
||||
+ return ImmutableList.of();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+
|
||||
List<String> completions = null;
|
||||
try {
|
||||
completions = getCommandMap().tabComplete(player, message.substring(1));
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index 26d5845..dd842c6 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -142,4 +142,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.3.2
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
From f209b72b6aa9f23b232d9b81a3bd3604db5b4b43 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/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
index b7f6775..b96e2ef 100644
|
||||
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
@@ -19,11 +19,11 @@ public class HandshakeListener implements PacketHandshakingInListener {
|
||||
ChatComponentText chatcomponenttext;
|
||||
|
||||
if (packethandshakinginsetprotocol.d() > 4) {
|
||||
- chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.7.2");
|
||||
+ chatcomponenttext = new ChatComponentText( org.spigotmc.SpigotConfig.outdatedServerMessage ); // Spigot
|
||||
this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]);
|
||||
this.b.a((IChatBaseComponent) chatcomponenttext);
|
||||
} else if (packethandshakinginsetprotocol.d() < 4) {
|
||||
- chatcomponenttext = new ChatComponentText("Outdated client! Please use 1.7.2");
|
||||
+ chatcomponenttext = new ChatComponentText( org.spigotmc.SpigotConfig.outdatedClientMessage ); // Spigot
|
||||
this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]);
|
||||
this.b.a((IChatBaseComponent) chatcomponenttext);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 1725bba..5174602 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -335,7 +335,7 @@ public abstract class PlayerList {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s);
|
||||
} else if (!this.isWhitelisted(gameprofile.getName())) {
|
||||
// return "You are not white-listed on this server!";
|
||||
- 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 s1 = socketaddress.toString();
|
||||
|
||||
@@ -354,7 +354,7 @@ public abstract class PlayerList {
|
||||
} else {
|
||||
// return this.players.size() >= this.maxPlayers ? "The server is full!" : null;
|
||||
if (this.players.size() >= this.maxPlayers) {
|
||||
- event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4d77259..5cd6f7d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -547,11 +547,7 @@ public final class CraftServer implements Server {
|
||||
return true;
|
||||
}
|
||||
|
||||
- if (sender instanceof Player) {
|
||||
- sender.sendMessage("Unknown command. Type \"/help\" for help.");
|
||||
- } else {
|
||||
- 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 dd842c6..6d0a08e 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -12,6 +12,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;
|
||||
@@ -148,4 +149,28 @@ public class SpigotConfig
|
||||
{
|
||||
tabComplete = getBoolean( "commands.tab-complete", true );
|
||||
}
|
||||
+
|
||||
+ public static String whitelistMessage;
|
||||
+ public static String unknownCommandMessage;
|
||||
+ public static String serverFullMessage;
|
||||
+ public static String outdatedClientMessage = "Outdated client! Please use {}";
|
||||
+ public static String outdatedServerMessage = "Outdated server! I\'m still on {0}";
|
||||
+ private static String transform(String s)
|
||||
+ {
|
||||
+ return ChatColor.translateAlternateColorCodes( '&', s ).replaceAll( "\\n", "\n" );
|
||||
+ }
|
||||
+ private static void messages()
|
||||
+ {
|
||||
+ if (version < 4)
|
||||
+ {
|
||||
+ set( "messages.outdated-client", outdatedClientMessage );
|
||||
+ set( "messages.outdated-server", outdatedServerMessage );
|
||||
+ }
|
||||
+
|
||||
+ whitelistMessage = transform( getString( "messages.whitelist", "You are not whitelisted on this server!" ) );
|
||||
+ unknownCommandMessage = transform( getString( "messages.unknown-command", "Unknown command. Type \"/help\" for help." ) );
|
||||
+ serverFullMessage = transform( getString( "messages.server-full", "The server is full!" ) );
|
||||
+ outdatedClientMessage = transform( getString( "messages.outdated-client", outdatedClientMessage ) );
|
||||
+ outdatedServerMessage = transform( getString( "messages.outdated-server", outdatedServerMessage ) );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
From 876194673d572714aaf436d71af49fe19aac1e81 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 22 Jun 2013 16:12:02 +1000
|
||||
Subject: [PATCH] Allow Disabling of Random Lighting Updates
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 3bcca91..efe7ca5 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -895,7 +895,7 @@ public class Chunk {
|
||||
}
|
||||
|
||||
this.m = true;
|
||||
- if (!this.lit && this.done) {
|
||||
+ if (!this.lit && this.done && this.world.spigotConfig.randomLightUpdates) { // Spigot - also use random light updates setting to determine if we should relight
|
||||
this.p();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 2cc9005..0b6b681 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -2024,7 +2024,7 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
this.methodProfiler.a("playerCheckLight");
|
||||
- if (!this.players.isEmpty()) {
|
||||
+ if (spigotConfig.randomLightUpdates && !this.players.isEmpty()) { // Spigot
|
||||
i = this.random.nextInt(this.players.size());
|
||||
entityhuman = (EntityHuman) this.players.get(i);
|
||||
j = MathHelper.floor(entityhuman.locX) + this.random.nextInt(11) - 5;
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index fc0aa4c..eb118c6 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -173,4 +173,11 @@ public class SpigotWorldConfig
|
||||
hopperCheck = getInt( "ticks-per.hopper-check", hopperTransfer );
|
||||
log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck );
|
||||
}
|
||||
+
|
||||
+ public boolean randomLightUpdates;
|
||||
+ private void lightUpdates()
|
||||
+ {
|
||||
+ randomLightUpdates = getBoolean( "random-light-updates", false );
|
||||
+ log( "Random Lighting Updates: " + randomLightUpdates );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
From 1eae10315669613319309cd9a9b6753acbda643a Mon Sep 17 00:00:00 2001
|
||||
From: Andre LeBlanc <andre@norcode.com>
|
||||
Date: Sat, 6 Apr 2013 12:00:31 -0400
|
||||
Subject: [PATCH] Make AnvilInventory.getItem() use both containers. Fixes
|
||||
BUKKIT-2788
|
||||
|
||||
The AnvilInventory reports its size as the sum of the ingredient and
|
||||
result inventories, but when trying to access the slots, only the ingredient
|
||||
inventory is used, leading to an ArrayIndexOutOfBounds exception.
|
||||
|
||||
This change overrides getItem(I) and setItem(I) to use both inventories,
|
||||
with the slot number adjusted based on their size.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
|
||||
index a91d81a..46a1d38 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.IInventory;
|
||||
+
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
|
||||
private final IInventory resultInventory;
|
||||
@@ -20,6 +22,26 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
+ public ItemStack getItem(int slot) {
|
||||
+ if (slot < getIngredientsInventory().getSize()) {
|
||||
+ net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot);
|
||||
+ return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
+ } else {
|
||||
+ net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize());
|
||||
+ return item == null ? null : CraftItemStack.asCraftMirror(item);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setItem(int index, ItemStack item) {
|
||||
+ if (index < getIngredientsInventory().getSize()) {
|
||||
+ getIngredientsInventory().setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
+ } else {
|
||||
+ getResultInventory().setItem((index - getIngredientsInventory().getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item)));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
public int getSize() {
|
||||
return getResultInventory().getSize() + getIngredientsInventory().getSize();
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
From 84f4948f7f5ddc99b8231e9c6aa4959af774c17c Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Thu, 27 Jun 2013 17:26:09 +1000
|
||||
Subject: [PATCH] Properly Close Inventories
|
||||
|
||||
Properly close inventories when unloading and switching worlds.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index efe7ca5..a4adc56 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -749,6 +749,15 @@ public class Chunk {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
TileEntity tileentity = (TileEntity) iterator.next();
|
||||
+ // Spigot Start
|
||||
+ if ( tileentity instanceof IInventory )
|
||||
+ {
|
||||
+ for ( org.bukkit.craftbukkit.entity.CraftHumanEntity h : new ArrayList<org.bukkit.craftbukkit.entity.CraftHumanEntity>( (List) ( (IInventory) tileentity ).getViewers() ) )
|
||||
+ {
|
||||
+ h.getHandle().closeInventory();
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
this.world.a(tileentity);
|
||||
}
|
||||
@@ -758,6 +767,15 @@ public class Chunk {
|
||||
java.util.Iterator<Object> iter = this.entitySlices[i].iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entity entity = (Entity) iter.next();
|
||||
+ // Spigot Start
|
||||
+ if ( entity instanceof IInventory )
|
||||
+ {
|
||||
+ for ( org.bukkit.craftbukkit.entity.CraftHumanEntity h : new ArrayList<org.bukkit.craftbukkit.entity.CraftHumanEntity>( (List) ( (IInventory) entity ).getViewers() ) )
|
||||
+ {
|
||||
+ h.getHandle().closeInventory();
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
// Do not pass along players, as doing so can get them stuck outside of time.
|
||||
// (which for example disables inventory icon updates and prevents block breaking)
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMinecartContainer.java b/src/main/java/net/minecraft/server/EntityMinecartContainer.java
|
||||
index 1d997e1..1c64d42 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMinecartContainer.java
|
||||
@@ -149,6 +149,12 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract imp
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
+ // Spigot Start
|
||||
+ for ( HumanEntity human : new java.util.ArrayList<HumanEntity>( transaction ) )
|
||||
+ {
|
||||
+ human.closeInventory();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
this.b = false;
|
||||
super.b(i);
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From c12b6f2d2cb6e070537ab39f6cffd1d842b74a2c Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Fri, 28 Jun 2013 19:52:54 +1000
|
||||
Subject: [PATCH] Disallow Interaction With Self
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 31be464..6e54ad1 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -1047,6 +1047,13 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
if (this.player.dead) return; // CraftBukkit
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
Entity entity = packetplayinuseentity.a((World) worldserver);
|
||||
+ // Spigot Start
|
||||
+ if ( entity == player )
|
||||
+ {
|
||||
+ disconnect( "Cannot interact with self!" );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
this.player.w();
|
||||
if (entity != null) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
From 0cff27a815bbfc67edb5f6c5de71dd9e53df7b11 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 2 Jul 2013 09:07:54 +1000
|
||||
Subject: [PATCH] Lower Chunk Compression
|
||||
|
||||
Use a chunk compression level of 4 - this provides an optimal balance between speed and compression.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
index 856e825..09b34e9 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
@@ -24,7 +24,7 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
this.b = chunk.locZ;
|
||||
this.inflatedBuffer = flag;
|
||||
ChunkMap chunkmap = a(chunk, flag, i);
|
||||
- Deflater deflater = new Deflater(-1);
|
||||
+ Deflater deflater = new Deflater(4); // Spigot
|
||||
|
||||
this.d = chunkmap.c;
|
||||
this.c = chunkmap.b;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
index 3eac231..bf3a139 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
@@ -22,7 +22,7 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
||||
@Override
|
||||
protected Deflater initialValue() {
|
||||
// Don't use higher compression level, slows things down too much
|
||||
- return new Deflater(6);
|
||||
+ return new Deflater(4); // Spigot 6 -> 4
|
||||
}
|
||||
};
|
||||
// CraftBukkit end
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
From 1e87b5fb1a881cb63372a7fc5b1bd83ecbf7b8f7 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 2 Jul 2013 20:32:49 +1000
|
||||
Subject: [PATCH] Entity Mount and Dismount Events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index a3a8750..9ef9f88 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1451,6 +1451,7 @@ public abstract class Entity {
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
|
||||
|
||||
this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
|
||||
this.vehicle.passenger = null;
|
||||
@@ -1486,6 +1487,17 @@ public abstract class Entity {
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Spigot Start
|
||||
+ if ( entity.world.isChunkLoaded( (int) entity.locX >> 4, (int) entity.locZ >> 4 ) )
|
||||
+ {
|
||||
+ org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent( this.getBukkitEntity(), entity.getBukkitEntity() );
|
||||
+ pluginManager.callEvent( event );
|
||||
+ if ( event.isCancelled() )
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.vehicle.passenger = null;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index c12a08f..7442943 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -323,6 +323,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
public void setPassengerOf(Entity entity) {
|
||||
// CraftBukkit end
|
||||
if (this.vehicle != null && entity == null) {
|
||||
+ world.getServer().getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
|
||||
// CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent
|
||||
Entity originalVehicle = this.vehicle;
|
||||
// First statement moved down, second statement handled in parent method.
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 118933c32405aeaa7bae6beea6870ce4400643e8 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ciuba <alexciuba@gmail.com>
|
||||
Date: Tue, 11 Jun 2013 15:23:03 -0400
|
||||
Subject: [PATCH] Prevent Ghost Players Caused by Plugins
|
||||
|
||||
Check if the player is still connected after firing event. Fixes BUKKIT-4327
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 5174602..9a6e997 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -467,6 +467,11 @@ public abstract class PlayerList {
|
||||
Player respawnPlayer = this.cserver.getPlayer(entityplayer1);
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
|
||||
this.cserver.getPluginManager().callEvent(respawnEvent);
|
||||
+ // Spigot Start
|
||||
+ if (entityplayer.playerConnection.isDisconnected()) {
|
||||
+ return entityplayer;
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
location = respawnEvent.getRespawnLocation();
|
||||
entityplayer.reset();
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
From 9c4b4c0ba7d0fd8a5a336458aff31231fed72a07 Mon Sep 17 00:00:00 2001
|
||||
From: Ammar Askar <ammar@ammaraskar.com>
|
||||
Date: Tue, 16 Jul 2013 03:32:32 +0500
|
||||
Subject: [PATCH] Entity ticking chunk caching
|
||||
|
||||
Cache known loaded chunks so we avoid making a potentially expensive contains call for every single entity in exchange for some simple arithmetic. Best case scenario, this cuts down contains call to once per chunk, worst case it adds on some simple arithmetic operations
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 0b6b681..13ca7fa 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1179,6 +1179,7 @@ public abstract class World implements IBlockAccess {
|
||||
CrashReport crashreport;
|
||||
CrashReportSystemDetails crashreportsystemdetails;
|
||||
|
||||
+ long lastChunk = Long.MIN_VALUE; // Spigot - cache chunk x, z cords for unload queue
|
||||
for (i = 0; i < this.i.size(); ++i) {
|
||||
entity = (Entity) this.i.get(i);
|
||||
// CraftBukkit start - Fixed an NPE, don't process entities in chunks queued for unload
|
||||
@@ -1187,10 +1188,15 @@ public abstract class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
||||
- if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
|
||||
- continue;
|
||||
+ // Spigot start - check last chunk to see if this loaded (fast cache)
|
||||
+ long chunk = org.bukkit.craftbukkit.util.LongHash.toLong(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4);
|
||||
+ if (lastChunk != chunk) {
|
||||
+ if (chunkProviderServer.unloadQueue.contains(chunk)) { // Spigot end
|
||||
+ continue;
|
||||
+ }
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ lastChunk = chunk; // Spigot
|
||||
|
||||
try {
|
||||
++entity.ticksLived;
|
||||
@@ -1211,6 +1217,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.i.remove(i--);
|
||||
}
|
||||
}
|
||||
+ lastChunk = Long.MIN_VALUE; // Spigot
|
||||
|
||||
this.methodProfiler.c("remove");
|
||||
this.entityList.removeAll(this.f);
|
||||
@@ -1241,10 +1248,15 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
// CraftBukkit start - Don't tick entities in chunks queued for unload
|
||||
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
||||
- if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
|
||||
- continue;
|
||||
+ // Spigot start - check last chunk to see if this loaded (fast cache)
|
||||
+ long chunk = org.bukkit.craftbukkit.util.LongHash.toLong(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4);
|
||||
+ if (lastChunk != chunk) {
|
||||
+ if (chunkProviderServer.unloadQueue.contains(chunk)) { // Spigot end
|
||||
+ continue;
|
||||
+ }
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ lastChunk = Long.MIN_VALUE; // Spigot
|
||||
|
||||
if (entity.vehicle != null) {
|
||||
if (!entity.vehicle.dead && entity.vehicle.passenger == entity) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
From 1d33e95fa3ebee342cd44a88bd8352fefa44e1e3 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 3 Aug 2013 19:02:59 +1000
|
||||
Subject: [PATCH] Plug World Unload Memory Leak
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
||||
index 8e01414..e0469bb 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
||||
@@ -11,7 +11,7 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
public class BlockRedstoneTorch extends BlockTorch {
|
||||
|
||||
private boolean isOn;
|
||||
- private static Map b = new HashMap();
|
||||
+ private static Map b = new java.util.WeakHashMap(); // Spigot
|
||||
|
||||
private boolean a(World world, int i, int j, int k, boolean flag) {
|
||||
if (!b.containsKey(world)) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
From 699949312eb888c254babefdd149459054f120b8 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 3 Aug 2013 19:27:07 +1000
|
||||
Subject: [PATCH] Player Collision API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index 7442943..f034d30 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -430,7 +430,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
|
||||
List list = this.world.getEntities(this, axisalignedbb);
|
||||
|
||||
- if (list != null) {
|
||||
+ if (list != null && this.R()) { // Spigot: Add this.R() condition
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index d06ec7b..35b2f75 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -1485,7 +1485,7 @@ public abstract class EntityLiving extends Entity {
|
||||
protected void bo() {
|
||||
List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
||||
|
||||
- if (list != null && !list.isEmpty()) {
|
||||
+ if (this.R() && list != null && !list.isEmpty()) { // Spigot: Add this.R() condition
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index 4945955..ab39926 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -64,6 +64,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public double maxHealthCache;
|
||||
public int lastPing = -1; // Spigot
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public boolean collidesWithEntities = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean R()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.R();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean S()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.S();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||
super(worldserver, gameprofile);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index ef74879..06b13c3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1133,6 +1133,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Spigot start
|
||||
private final Player.Spigot spigot = new Player.Spigot()
|
||||
{
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean getCollidesWithEntities()
|
||||
+ {
|
||||
+ return getHandle().collidesWithEntities;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCollidesWithEntities(boolean collides)
|
||||
+ {
|
||||
+ getHandle().collidesWithEntities = collides;
|
||||
+ getHandle().l = collides; // First boolean of Entity
|
||||
+ }
|
||||
};
|
||||
|
||||
public Player.Spigot spigot()
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 6335386dae494d6e976b53f77204a1f4a013de92 Mon Sep 17 00:00:00 2001
|
||||
From: agentk20 <agentkid20@gmail.com>
|
||||
Date: Sat, 3 Aug 2013 19:28:48 +1000
|
||||
Subject: [PATCH] Fully Disable Snooper When Not Required
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d740620..cfb7922 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -555,11 +555,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.f[this.ticks % 100] = System.nanoTime() - i;
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.a("snooper");
|
||||
- if (!this.k.d() && this.ticks > 100) {
|
||||
+ if (getSnooperEnabled() && !this.k.d() && this.ticks > 100) { // Spigot
|
||||
this.k.a();
|
||||
}
|
||||
|
||||
- if (this.ticks % 6000 == 0) {
|
||||
+ if (getSnooperEnabled() && this.ticks % 6000 == 0) { // Spigot
|
||||
this.k.b();
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
From e2aeed0e085150d58a9ac5e45567924a63f1c213 Mon Sep 17 00:00:00 2001
|
||||
From: DerFlash <bte@freenet.de>
|
||||
Date: Sat, 3 Aug 2013 19:53:48 +1000
|
||||
Subject: [PATCH] Add Getter for Entity Invulnerability
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index e026c1f..96d763b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -403,6 +403,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
// Spigot start
|
||||
private final Spigot spigot = new Spigot()
|
||||
{
|
||||
+ @Override
|
||||
+ public boolean isInvulnerable()
|
||||
+ {
|
||||
+ return getHandle().isInvulnerable();
|
||||
+ }
|
||||
};
|
||||
|
||||
public Spigot spigot()
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
From e582842f0f1a49d697b1003021f56cd4b50ea5bf Mon Sep 17 00:00:00 2001
|
||||
From: Ammar Askar <ammar@ammaraskar.com>
|
||||
Date: Sat, 3 Aug 2013 21:42:00 +0500
|
||||
Subject: [PATCH] Guard entity list
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 13ca7fa..5b0875d 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -30,7 +30,25 @@ import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
public abstract class World implements IBlockAccess {
|
||||
|
||||
public boolean d;
|
||||
- public List entityList = new ArrayList();
|
||||
+ public List entityList = new ArrayList() { // Spigot start - guard entity list from removals
|
||||
+ @Override
|
||||
+ public Object remove(int index) {
|
||||
+ guard();
|
||||
+ return super.remove(index);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean remove(Object o) {
|
||||
+ guard();
|
||||
+ return super.remove(o);
|
||||
+ }
|
||||
+
|
||||
+ private void guard() {
|
||||
+ if (guardEntityList) {
|
||||
+ throw new java.util.ConcurrentModificationException();
|
||||
+ }
|
||||
+ }
|
||||
+ }; // Spigot end
|
||||
protected List f = new ArrayList();
|
||||
public Set tileEntityList = new HashSet(); // CraftBukkit - ArrayList -> HashSet
|
||||
private List a = new ArrayList();
|
||||
@@ -78,6 +96,7 @@ public abstract class World implements IBlockAccess {
|
||||
int[] I;
|
||||
|
||||
// Spigot start
|
||||
+ private boolean guardEntityList = false;
|
||||
protected final gnu.trove.map.hash.TLongShortHashMap chunkTickList;
|
||||
protected float growthOdds = 100;
|
||||
protected float modifiedOdds = 100;
|
||||
@@ -1243,6 +1262,7 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||
timings.entityTick.startTiming(); // Spigot
|
||||
+ guardEntityList = true; // Spigot
|
||||
for (i = 0; i < this.entityList.size(); ++i) {
|
||||
entity = (Entity) this.entityList.get(i);
|
||||
|
||||
@@ -1290,12 +1310,15 @@ public abstract class World implements IBlockAccess {
|
||||
this.getChunkAt(j, k).b(entity);
|
||||
}
|
||||
|
||||
+ guardEntityList = false; // Spigot
|
||||
this.entityList.remove(i--);
|
||||
+ guardEntityList = true; // Spigot
|
||||
this.b(entity);
|
||||
}
|
||||
|
||||
this.methodProfiler.b();
|
||||
}
|
||||
+ guardEntityList = false; // Spigot
|
||||
|
||||
timings.entityTick.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("blockEntities");
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
From 467c83f45b0ba27ca30d3ed5b69f8ee57332a7a2 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Mon, 5 Aug 2013 20:17:20 +1000
|
||||
Subject: [PATCH] Cap Minimum Player Speed
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 06b13c3..3524bce 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1005,7 +1005,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void setFlySpeed(float value) {
|
||||
validateSpeed(value);
|
||||
EntityPlayer player = getHandle();
|
||||
- player.abilities.flySpeed = value / 2f;
|
||||
+ player.abilities.flySpeed = Math.max( value, 0.0001f ) / 2f; // Spigot
|
||||
player.updateAbilities();
|
||||
|
||||
}
|
||||
@@ -1013,7 +1013,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void setWalkSpeed(float value) {
|
||||
validateSpeed(value);
|
||||
EntityPlayer player = getHandle();
|
||||
- player.abilities.walkSpeed = value / 2f;
|
||||
+ player.abilities.walkSpeed = Math.max( value, 0.0001f ) / 2f; // Spigot
|
||||
player.updateAbilities();
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
From efc31e76d1f8fe34d120325da804375d6812d7ff Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 14 Sep 2013 10:16:38 +1000
|
||||
Subject: [PATCH] Update Inventory and Health for PlayerConsumeItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index f034d30..c58b21b 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -277,6 +277,10 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
// Update client
|
||||
if (this instanceof EntityPlayer) {
|
||||
((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
|
||||
+ // Spigot Start
|
||||
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
||||
+ ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
|
||||
+ // Spigot End
|
||||
}
|
||||
return;
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
From babb634a3beeb956104a516df20ce6e05260df63 Mon Sep 17 00:00:00 2001
|
||||
From: BlackHole <black-hole@live.com>
|
||||
Date: Tue, 16 Jul 2013 22:34:50 +0200
|
||||
Subject: [PATCH] Call EntityChangeBlockEvent for Fire Arrows hitting TNT
|
||||
|
||||
Adds BUKKIT-4355
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
|
||||
index 6d5090b..50e2fa0 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockTNT.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
|
||||
@@ -54,7 +54,7 @@ public class BlockTNT extends Block {
|
||||
|
||||
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
|
||||
if (entityhuman.bD() != null && entityhuman.bD().getItem() == Items.FLINT_AND_STEEL) {
|
||||
- this.a(world, i, j, k, 1, entityhuman);
|
||||
+ this.a(world, i, j, k, 1, (EntityLiving) entityhuman); // Spigot - Fix decompile error!
|
||||
world.setAir(i, j, k);
|
||||
entityhuman.bD().damage(1, entityhuman);
|
||||
return true;
|
||||
@@ -68,6 +68,11 @@ public class BlockTNT extends Block {
|
||||
EntityArrow entityarrow = (EntityArrow) entity;
|
||||
|
||||
if (entityarrow.isBurning()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, i, j, k, Blocks.AIR, 0).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.a(world, i, j, k, 1, entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
|
||||
world.setAir(i, j, k);
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
From d57a7e68ec206c95533c184c62de6f34a67b10e9 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 21 Sep 2013 12:33:09 +1000
|
||||
Subject: [PATCH] Allow Disabling of 1.6.3 Structure Saving
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
index 1eb87ae..b3c8101 100644
|
||||
--- a/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
@@ -178,7 +178,15 @@ public abstract class StructureGenerator extends WorldGenBase {
|
||||
|
||||
private void a(World world) {
|
||||
if (this.e == null) {
|
||||
+ // Spigot Start
|
||||
+ if ( world.spigotConfig.saveStructureInfo )
|
||||
+ {
|
||||
this.e = (PersistentStructure) world.a(PersistentStructure.class, this.a());
|
||||
+ } else
|
||||
+ {
|
||||
+ this.e = new PersistentStructure( this.a() );
|
||||
+ }
|
||||
+ // Spigot End
|
||||
if (this.e == null) {
|
||||
this.e = new PersistentStructure(this.a());
|
||||
world.a(this.a(), (PersistentBase) this.e);
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index eb118c6..a4cdc7a 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -180,4 +180,16 @@ public class SpigotWorldConfig
|
||||
randomLightUpdates = getBoolean( "random-light-updates", false );
|
||||
log( "Random Lighting Updates: " + randomLightUpdates );
|
||||
}
|
||||
+
|
||||
+ public boolean saveStructureInfo;
|
||||
+ private void structureInfo()
|
||||
+ {
|
||||
+ saveStructureInfo = getBoolean( "save-structure-info", true );
|
||||
+ log( "Structure Info Saving: " + saveStructureInfo );
|
||||
+ if ( !saveStructureInfo )
|
||||
+ {
|
||||
+ log( "*** WARNING *** You have selected to NOT save structure info. This may cause structures such as fortresses to not spawn mobs when updating to 1.7!" );
|
||||
+ log( "*** WARNING *** Please use this option with caution, SpigotMC is not responsible for any issues this option may cause in the future!" );
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
From d02e5412d2e420a29b09c55cf51b3d40d541454d Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 22 Sep 2013 19:10:53 +1000
|
||||
Subject: [PATCH] Item Despawn Rate
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
index 08b9ac8..8ea7abc 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -104,7 +104,7 @@ public class EntityItem extends Entity {
|
||||
}
|
||||
|
||||
// ++this.age; // CraftBukkit - Moved up
|
||||
- if (!this.world.isStatic && this.age >= 6000) {
|
||||
+ if (!this.world.isStatic && this.age >= world.spigotConfig.itemDespawnRate) { // Spigot
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
this.age = 0;
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index a4cdc7a..0b4e527 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -192,4 +192,11 @@ public class SpigotWorldConfig
|
||||
log( "*** WARNING *** Please use this option with caution, SpigotMC is not responsible for any issues this option may cause in the future!" );
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public int itemDespawnRate;
|
||||
+ private void itemDespawnRate()
|
||||
+ {
|
||||
+ itemDespawnRate = getInt( "item-despawn-rate", 6000 );
|
||||
+ log( "Item Despawn Rate: " + itemDespawnRate );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
From 7ed621bde6fe42a653b6b9469d9336ac66f9368c Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 6 Oct 2013 17:36:28 +1100
|
||||
Subject: [PATCH] Don't Special Case X Move Value
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 6e54ad1..e88adfa 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -105,6 +105,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
private float lastPitch = Float.MAX_VALUE;
|
||||
private float lastYaw = Float.MAX_VALUE;
|
||||
private boolean justTeleported = false;
|
||||
+ private boolean hasMoved; // Spigot
|
||||
|
||||
// For the PacketPlayOutBlockPlace hack :(
|
||||
Long lastPacket;
|
||||
@@ -222,7 +223,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
this.lastPitch = to.getPitch();
|
||||
|
||||
// Skip the first time we do this
|
||||
- if (from.getX() != Double.MAX_VALUE) {
|
||||
+ if (hasMoved) { // Spigot - Better Check!
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
||||
@@ -246,7 +247,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
this.justTeleported = false;
|
||||
return;
|
||||
}
|
||||
- }
|
||||
+ } else { hasMoved = true; } // Spigot - Better Check!
|
||||
}
|
||||
|
||||
if (Double.isNaN(packetplayinflying.x) || Double.isNaN(packetplayinflying.y) || Double.isNaN(packetplayinflying.z) || Double.isNaN(packetplayinflying.stance)) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From c95acb2e785e7d4c8caa919d2bb19f35fdb7d6ac Mon Sep 17 00:00:00 2001
|
||||
From: ninja- <xninja@openmailbox.org>
|
||||
Date: Tue, 8 Oct 2013 14:34:49 +0200
|
||||
Subject: [PATCH] Implement respawn API.
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 3524bce..52c75f0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1146,6 +1146,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().collidesWithEntities = collides;
|
||||
getHandle().l = collides; // First boolean of Entity
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void respawn()
|
||||
+ {
|
||||
+ if ( getHealth() <= 0 )
|
||||
+ {
|
||||
+ server.getServer().getPlayerList().moveToWorld( getHandle(), 0, false );
|
||||
+ }
|
||||
+ }
|
||||
};
|
||||
|
||||
public Player.Spigot spigot()
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From f0eef156f0c34254016b8d8cfc82fd49f476a00e Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Wed, 9 Oct 2013 18:20:05 +1100
|
||||
Subject: [PATCH] Fix BrewingStands Removing NBT / Potions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockBrewingStand.java b/src/main/java/net/minecraft/server/BlockBrewingStand.java
|
||||
index 3287d77..eabea5a 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockBrewingStand.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockBrewingStand.java
|
||||
@@ -86,7 +86,13 @@ public class BlockBrewingStand extends BlockContainer {
|
||||
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
|
||||
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
|
||||
- world.addEntity(entityitem);
|
||||
+ // Spigot Start
|
||||
+ if ( itemstack.hasTag() )
|
||||
+ {
|
||||
+ entityitem.getItemStack().setTag( (NBTTagCompound) itemstack.getTag().clone() );
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+ world.addEntity( entityitem );
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
From b047f7511032e0fca1e85314fca8cfc061f85da7 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Mon, 14 Oct 2013 19:20:10 +1100
|
||||
Subject: [PATCH] Arrow Despawn Rate
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
index 3fd3de9..a49519b 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||
@@ -141,7 +141,7 @@ public class EntityArrow extends Entity implements IProjectile {
|
||||
|
||||
if (block == this.g && i == this.h) {
|
||||
++this.j;
|
||||
- if (this.j == 1200) {
|
||||
+ if (this.j == world.spigotConfig.arrowDespawnRate) { // Spigot
|
||||
this.die();
|
||||
}
|
||||
} else {
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 0b4e527..447581d 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -199,4 +199,11 @@ public class SpigotWorldConfig
|
||||
itemDespawnRate = getInt( "item-despawn-rate", 6000 );
|
||||
log( "Item Despawn Rate: " + itemDespawnRate );
|
||||
}
|
||||
+
|
||||
+ public int arrowDespawnRate;
|
||||
+ private void arrowDespawnRate()
|
||||
+ {
|
||||
+ arrowDespawnRate = getInt( "arrow-despawn-rate", 1200 );
|
||||
+ log( "Arrow Despawn Rate: " + arrowDespawnRate );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
From 11ba77bdbffe1dc29e19bffe07d92a9aa0268a9a 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.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cfb7922..1f057b1 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -446,6 +446,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.t();
|
||||
SpigotTimings.serverTickTimer.stopTiming();
|
||||
org.spigotmc.CustomTimingsHandler.tick();
|
||||
+ org.spigotmc.WatchdogThread.tick();
|
||||
}
|
||||
// Spigot end
|
||||
} else {
|
||||
@@ -472,6 +473,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.a(crashreport);
|
||||
} finally {
|
||||
try {
|
||||
+ org.spigotmc.WatchdogThread.doStop();
|
||||
this.stop();
|
||||
this.isStopped = true;
|
||||
} catch (Throwable throwable1) {
|
||||
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
new file mode 100644
|
||||
index 0000000..a8840c9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
@@ -0,0 +1,113 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.List;
|
||||
+import net.minecraft.server.EntityPlayer;
|
||||
+import net.minecraft.server.IChatBaseComponent;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.PacketPlayOutKickDisconnect;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+
|
||||
+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();
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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.disconnect(SpigotConfig.restartMessage);
|
||||
+ p.playerConnection.networkManager.d();
|
||||
+ }
|
||||
+ // Give the socket a chance to send the packets
|
||||
+ try
|
||||
+ {
|
||||
+ Thread.sleep( 100 );
|
||||
+ } catch ( InterruptedException ex )
|
||||
+ {
|
||||
+ }
|
||||
+ // Close the socket so we can rebind with the new process
|
||||
+ MinecraftServer.getServer().ag().b();
|
||||
+
|
||||
+ // Give time for it to kick in
|
||||
+ try
|
||||
+ {
|
||||
+ Thread.sleep( 100 );
|
||||
+ } catch ( InterruptedException ex )
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ // Actually shutdown
|
||||
+ try
|
||||
+ {
|
||||
+ MinecraftServer.getServer().stop();
|
||||
+ } catch ( Throwable t )
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ // This will be done AFTER the server has completely halted
|
||||
+ 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()
|
||||
+ } );
|
||||
+ }
|
||||
+ } catch ( Exception e )
|
||||
+ {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ 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 )
|
||||
+ {
|
||||
+ ex.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index 6d0a08e..6e32691 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -173,4 +173,18 @@ public class SpigotConfig
|
||||
outdatedClientMessage = transform( getString( "messages.outdated-client", outdatedClientMessage ) );
|
||||
outdatedServerMessage = transform( getString( "messages.outdated-server", outdatedServerMessage ) );
|
||||
}
|
||||
+
|
||||
+ public static int timeoutTime = 60;
|
||||
+ public static boolean restartOnCrash = true;
|
||||
+ public static String restartScript = "./start.sh";
|
||||
+ public static String restartMessage;
|
||||
+ private static void watchdog()
|
||||
+ {
|
||||
+ timeoutTime = getInt( "settings.timeout-time", timeoutTime );
|
||||
+ restartOnCrash = getBoolean( "settings.restart-on-crash", restartOnCrash );
|
||||
+ restartScript = getString( "settings.restart-script", restartScript );
|
||||
+ restartMessage = transform( getString( "messages.restart", "Server is restarting" ) );
|
||||
+ 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..8d6e1b4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -0,0 +1,121 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import java.lang.management.ManagementFactory;
|
||||
+import java.lang.management.MonitorInfo;
|
||||
+import java.lang.management.ThreadInfo;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+public class WatchdogThread extends Thread
|
||||
+{
|
||||
+
|
||||
+ private static WatchdogThread instance;
|
||||
+ private final long timeoutTime;
|
||||
+ private final boolean restart;
|
||||
+ private volatile long lastTick;
|
||||
+ private volatile boolean stopping;
|
||||
+
|
||||
+ 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 );
|
||||
+ instance.start();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void tick()
|
||||
+ {
|
||||
+ instance.lastTick = System.currentTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ public static void doStop()
|
||||
+ {
|
||||
+ if ( instance != null )
|
||||
+ {
|
||||
+ instance.stopping = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run()
|
||||
+ {
|
||||
+ while ( !stopping )
|
||||
+ {
|
||||
+ //
|
||||
+ 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, "------------------------------" );
|
||||
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" );
|
||||
+ dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().primaryThread.getId(), Integer.MAX_VALUE ), log );
|
||||
+ log.log( Level.SEVERE, "------------------------------" );
|
||||
+ //
|
||||
+ log.log( Level.SEVERE, "Entire Thread Dump:" );
|
||||
+ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads( true, true );
|
||||
+ for ( ThreadInfo thread : threads )
|
||||
+ {
|
||||
+ dumpThread( thread, log );
|
||||
+ }
|
||||
+ log.log( Level.SEVERE, "------------------------------" );
|
||||
+
|
||||
+ if ( restart )
|
||||
+ {
|
||||
+ RestartCommand.restart();
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ try
|
||||
+ {
|
||||
+ sleep( 10000 );
|
||||
+ } catch ( InterruptedException ex )
|
||||
+ {
|
||||
+ interrupt();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void dumpThread(ThreadInfo thread, Logger log)
|
||||
+ {
|
||||
+ if ( thread.getThreadState() != State.WAITING )
|
||||
+ {
|
||||
+ log.log( Level.SEVERE, "------------------------------" );
|
||||
+ //
|
||||
+ 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() );
|
||||
+ }
|
||||
+ }
|
||||
+ 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() );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
From 46a3c62c8d5683f3385686cfd53a353711091fc0 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 1 Dec 2013 17:52:14 +1100
|
||||
Subject: [PATCH] Fix packed ice generation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldGenPackedIce2.java b/src/main/java/net/minecraft/server/WorldGenPackedIce2.java
|
||||
index c0db754..a830758 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldGenPackedIce2.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldGenPackedIce2.java
|
||||
@@ -41,13 +41,13 @@ public class WorldGenPackedIce2 extends WorldGenerator {
|
||||
Block block = world.getType(i + l1, j + j1, k + i2);
|
||||
|
||||
if (block.getMaterial() == Material.AIR || block == Blocks.DIRT || block == Blocks.SNOW_BLOCK || block == Blocks.ICE) {
|
||||
- this.setType(world, i + l1, j + j1, k + i2, Blocks.PACKED_ICE);
|
||||
+ world.setTypeUpdate(i + l1, j + j1, k + i2, Blocks.PACKED_ICE); // Spigot
|
||||
}
|
||||
|
||||
if (j1 != 0 && k1 > 1) {
|
||||
block = world.getType(i + l1, j - j1, k + i2);
|
||||
if (block.getMaterial() == Material.AIR || block == Blocks.DIRT || block == Blocks.SNOW_BLOCK || block == Blocks.ICE) {
|
||||
- this.setType(world, i + l1, j - j1, k + i2, Blocks.PACKED_ICE);
|
||||
+ world.setTypeUpdate(i + l1, j - j1, k + i2, Blocks.PACKED_ICE); // Spigot
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class WorldGenPackedIce2 extends WorldGenerator {
|
||||
Block block1 = world.getType(i + j2, l1, k + k1);
|
||||
|
||||
if (block1.getMaterial() == Material.AIR || block1 == Blocks.DIRT || block1 == Blocks.SNOW_BLOCK || block1 == Blocks.ICE || block1 == Blocks.PACKED_ICE) {
|
||||
- this.setType(world, i + j2, l1, k + k1, Blocks.PACKED_ICE);
|
||||
+ world.setTypeUpdate(i + j2, l1, k + k1, Blocks.PACKED_ICE); // Spigot
|
||||
--l1;
|
||||
--k2;
|
||||
if (k2 <= 0) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
From 7f3b7ea04d8325ce3dce283069f694038fc25bc3 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 1 Dec 2013 18:18:41 +1100
|
||||
Subject: [PATCH] BungeeCord Support
|
||||
|
||||
Provides support for IP forwarding via BungeeCord.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
index b96e2ef..fe2098e 100644
|
||||
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
|
||||
@@ -28,6 +28,19 @@ public class HandshakeListener implements PacketHandshakingInListener {
|
||||
this.b.a((IChatBaseComponent) chatcomponenttext);
|
||||
} else {
|
||||
this.b.a((PacketListener) (new LoginListener(this.a, this.b)));
|
||||
+ // Spigot Start
|
||||
+ if (org.spigotmc.SpigotConfig.bungee) {
|
||||
+ String[] split = packethandshakinginsetprotocol.b.split("\00");
|
||||
+ if (split.length == 2 || split.length == 3) {
|
||||
+ packethandshakinginsetprotocol.b = split[0];
|
||||
+ b.l = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) b.getSocketAddress()).getPort());
|
||||
+ }
|
||||
+ if ( split.length == 3 )
|
||||
+ {
|
||||
+ b.spoofedUUID = split[2];
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
((LoginListener) this.b.getPacketListener()).hostname = packethandshakinginsetprotocol.b + ":" + packethandshakinginsetprotocol.c; // CraftBukkit - set hostname
|
||||
}
|
||||
break;
|
||||
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
index 6beac82..aa06e92 100644
|
||||
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
@@ -61,9 +61,18 @@ public class LoginListener implements PacketLoginInListener {
|
||||
|
||||
public void c() {
|
||||
if (!this.i.isComplete()) {
|
||||
- UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.i.getName()).getBytes(Charsets.UTF_8));
|
||||
-
|
||||
- this.i = new GameProfile(uuid.toString().replaceAll("-", ""), this.i.getName());
|
||||
+ // Spigot Start
|
||||
+ String uuid;
|
||||
+ if ( networkManager.spoofedUUID != null )
|
||||
+ {
|
||||
+ uuid = networkManager.spoofedUUID;
|
||||
+ } else
|
||||
+ {
|
||||
+ uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.i.getName()).getBytes(Charsets.UTF_8)).toString().replaceAll("-", "");
|
||||
+ }
|
||||
+
|
||||
+ this.i = new GameProfile(uuid, this.i.getName());
|
||||
+ // Spigot End
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
index 8f829bb..4907a62 100644
|
||||
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
@@ -34,7 +34,8 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
||||
private final Queue i = Queues.newConcurrentLinkedQueue();
|
||||
private final Queue j = Queues.newConcurrentLinkedQueue();
|
||||
private Channel k;
|
||||
- private SocketAddress l;
|
||||
+ public SocketAddress l; // Spigot
|
||||
+ public String spoofedUUID; // Spigot
|
||||
private PacketListener m;
|
||||
private EnumProtocol n;
|
||||
private IChatBaseComponent o;
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index 6e32691..acd5567 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -187,4 +187,14 @@ public class SpigotConfig
|
||||
commands.put( "restart", new RestartCommand( "restart" ) );
|
||||
WatchdogThread.doStart( timeoutTime, restartOnCrash );
|
||||
}
|
||||
+
|
||||
+ public static boolean bungee;
|
||||
+ private static void bungee() {
|
||||
+ if ( version < 4 )
|
||||
+ {
|
||||
+ set( "settings.bungeecord", false );
|
||||
+ System.out.println( "Oudated config, disabling BungeeCord support!" );
|
||||
+ }
|
||||
+ bungee = getBoolean( "settings.bungeecord", false );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From c6c40530159eb432a779d4ab639de83e40f14793 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 3 Dec 2013 11:07:48 +1100
|
||||
Subject: [PATCH] Clear Flower Pot on Drop
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockFlowerPot.java b/src/main/java/net/minecraft/server/BlockFlowerPot.java
|
||||
index ef909f7..734dcb4 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockFlowerPot.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockFlowerPot.java
|
||||
@@ -91,6 +91,7 @@ public class BlockFlowerPot extends BlockContainer {
|
||||
|
||||
if (tileentityflowerpot != null && tileentityflowerpot.a() != null) {
|
||||
this.a(world, i, j, k, new ItemStack(tileentityflowerpot.a(), 1, tileentityflowerpot.b()));
|
||||
+ tileentityflowerpot.a( null, 0 ); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +100,7 @@ public class BlockFlowerPot extends BlockContainer {
|
||||
|
||||
if (tileentityflowerpot != null && tileentityflowerpot.a() != null) {
|
||||
this.a(world, i, j, k, new ItemStack(tileentityflowerpot.a(), 1, tileentityflowerpot.b()));
|
||||
+ tileentityflowerpot.a( null, 0 ); // Spigot
|
||||
}
|
||||
|
||||
super.remove(world, i, j, k, block, l);
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From d6156ddcd63eed19eb93ffbf8b48e4849a157000 Mon Sep 17 00:00:00 2001
|
||||
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
||||
Date: Mon, 2 Dec 2013 23:42:09 +0000
|
||||
Subject: [PATCH] Fix some chunks not being sent to the client
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index a4adc56..d458dbb 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -919,7 +919,15 @@ public class Chunk {
|
||||
}
|
||||
|
||||
public boolean k() {
|
||||
- return this.m && this.done && this.lit;
|
||||
+ // Spigot Start
|
||||
+ /*
|
||||
+ * As of 1.7, Mojang added a check to make sure that only chunks which have been lit are sent to the client.
|
||||
+ * Unfortunately this interferes with our modified chunk ticking algorithm, which will only tick chunks distant from the player on a very infrequent basis.
|
||||
+ * We cannot unfortunately do this lighting stage during chunk gen as it appears to put a lot more noticeable load on the server, than when it is done at play time.
|
||||
+ * For now at least we will simply send all chunks, in accordance with pre 1.7 behaviour.
|
||||
+ */
|
||||
+ return true;
|
||||
+ // Spigot End
|
||||
}
|
||||
|
||||
public ChunkCoordIntPair l() {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
From 48df5c0517af9e8d07a1cd55ed09257cf8121ca2 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Thu, 5 Dec 2013 13:55:53 +1100
|
||||
Subject: [PATCH] Fix Broken Async Chat
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayInChat.java b/src/main/java/net/minecraft/server/PacketPlayInChat.java
|
||||
index 604a7af..d419f0f 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayInChat.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayInChat.java
|
||||
@@ -43,7 +43,25 @@ public class PacketPlayInChat extends Packet {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
- public void handle(PacketListener packetlistener) {
|
||||
+ // Spigot Start
|
||||
+ private static final java.util.concurrent.ExecutorService executors = java.util.concurrent.Executors.newCachedThreadPool(
|
||||
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon( true ).setNameFormat( "Async Chat Thread - #%d" ).build() );
|
||||
+ public void handle(final PacketListener packetlistener)
|
||||
+ {
|
||||
+ if ( a() )
|
||||
+ {
|
||||
+ executors.submit( new Runnable()
|
||||
+ {
|
||||
+
|
||||
+ @Override
|
||||
+ public void run()
|
||||
+ {
|
||||
+ PacketPlayInChat.this.a( (PacketPlayInListener) packetlistener );
|
||||
+ }
|
||||
+ } );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Spigot End
|
||||
this.a((PacketPlayInListener) packetlistener);
|
||||
}
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
From 76d2d1ab833f74faf04268f41e2b7c1455b28e88 Mon Sep 17 00:00:00 2001
|
||||
From: ItsHarry <info@itsjerryandharry.com>
|
||||
Date: Thu, 5 Dec 2013 21:58:11 +0100
|
||||
Subject: [PATCH] Allow Teleportation of Vehicles and Passengers
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 52c75f0..c9454b5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -430,9 +430,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return false;
|
||||
}
|
||||
|
||||
- if (entity.vehicle != null || entity.passenger != null) {
|
||||
- return false;
|
||||
- }
|
||||
+ // Spigot Start
|
||||
+ // if (entity.vehicle != null || entity.passenger != null) {
|
||||
+ // return false;
|
||||
+ // }
|
||||
+ // Spigot End
|
||||
|
||||
// From = Players current Location
|
||||
Location from = this.getLocation();
|
||||
@@ -446,6 +448,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+ // Spigot Start
|
||||
+ eject();
|
||||
+ leaveVehicle();
|
||||
+ // Spigot End
|
||||
|
||||
// Update the From Location
|
||||
from = event.getFrom();
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
From 8b6acbfa2d391d9b7b22d2a4aa288df7b2d1d791 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 8 Dec 2013 16:52:42 +1100
|
||||
Subject: [PATCH] Remove OS X Special Chars from Signs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index e88adfa..1903362 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -1562,6 +1562,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
|
||||
for (j = 0; j < 4; ++j) {
|
||||
boolean flag = true;
|
||||
+ packetplayinupdatesign.f()[j] = packetplayinupdatesign.f()[j].replaceAll( "\uF700", "" ).replaceAll( "\uF701", "" ); // Spigot - Mac OSX sends weird chars
|
||||
|
||||
if (packetplayinupdatesign.f()[j].length() > 15) {
|
||||
flag = false;
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,385 +0,0 @@
|
|||
From 2c1492b68db6d19ffc07fc9546ac9ff402bd0d13 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 991a765..e15840b 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||
@@ -86,6 +86,7 @@ public class EntityFallingBlock extends Entity {
|
||||
}
|
||||
|
||||
this.world.setAir(i, j, k);
|
||||
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
||||
}
|
||||
|
||||
if (this.onGround) {
|
||||
@@ -101,6 +102,7 @@ public class EntityFallingBlock extends Entity {
|
||||
}
|
||||
this.world.setTypeAndData(i, j, k, this.id, this.data, 3);
|
||||
// CraftBukkit end
|
||||
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
||||
|
||||
if (this.id instanceof BlockFalling) {
|
||||
((BlockFalling) this.id).a(this.world, i, j, k, this.data);
|
||||
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
|
||||
index 39e5b5b..d2587c1 100644
|
||||
--- a/src/main/java/net/minecraft/server/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/server/Explosion.java
|
||||
@@ -239,6 +239,7 @@ public class Explosion {
|
||||
j = chunkposition.y;
|
||||
k = chunkposition.z;
|
||||
block = this.world.getType(i, j, k);
|
||||
+ 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/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
index 09b34e9..3006712 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
@@ -28,6 +28,7 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
|
||||
this.d = chunkmap.c;
|
||||
this.c = chunkmap.b;
|
||||
+ chunk.world.spigotConfig.antiXrayInstance.obfuscateSync(chunk.locX, chunk.locZ, i, chunkmap.a, chunk.world); // Spigot
|
||||
|
||||
try {
|
||||
this.buffer = chunkmap.a;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
index bf3a139..30bf8a7 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
||||
@@ -26,6 +26,7 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
||||
}
|
||||
};
|
||||
// CraftBukkit end
|
||||
+ private World world; // Spigot
|
||||
|
||||
public PacketPlayOutMapChunkBulk() {}
|
||||
|
||||
@@ -44,6 +45,9 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
||||
Chunk chunk = (Chunk) list.get(k);
|
||||
ChunkMap chunkmap = PacketPlayOutMapChunk.a(chunk, true, '\uffff');
|
||||
|
||||
+ // Spigot start
|
||||
+ world = chunk.world;
|
||||
+ /*
|
||||
if (buildBuffer.length < j + chunkmap.a.length) {
|
||||
byte[] abyte = new byte[j + chunkmap.a.length];
|
||||
|
||||
@@ -52,6 +56,8 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
||||
}
|
||||
|
||||
System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length);
|
||||
+ */
|
||||
+ // Spigot end
|
||||
j += chunkmap.a.length;
|
||||
this.a[k] = chunk.locX;
|
||||
this.b[k] = chunk.locZ;
|
||||
@@ -79,6 +85,22 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
||||
if (this.buffer != null) {
|
||||
return;
|
||||
}
|
||||
+ // Spigot start
|
||||
+ int finalBufferSize = 0;
|
||||
+ // Obfuscate all sections
|
||||
+ for (int i = 0; i < a.length; i++) {
|
||||
+ world.spigotConfig.antiXrayInstance.obfuscate(a[i], b[i], c[i], inflatedBuffers[i], world);
|
||||
+ finalBufferSize += inflatedBuffers[i].length;
|
||||
+ }
|
||||
+
|
||||
+ // Now it's time to efficiently copy the chunk to the build buffer
|
||||
+ buildBuffer = new byte[finalBufferSize];
|
||||
+ int bufferLocation = 0;
|
||||
+ for (int i = 0; i < a.length; i++) {
|
||||
+ System.arraycopy(inflatedBuffers[i], 0, buildBuffer, bufferLocation, inflatedBuffers[i].length);
|
||||
+ bufferLocation += inflatedBuffers[i].length;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
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 bceba7b..c963fac 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
@@ -173,6 +173,7 @@ public class PlayerInteractManager {
|
||||
this.o = i1;
|
||||
}
|
||||
}
|
||||
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 5b0875d..1aca7f6 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -490,6 +490,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.e(i, j + 1, k, block);
|
||||
this.e(i, j, k - 1, block);
|
||||
this.e(i, j, k + 1, block);
|
||||
+ spigotConfig.antiXrayInstance.updateNearbyBlocks(this, i, j, k); // Spigot
|
||||
}
|
||||
|
||||
public void b(int i, int j, int k, Block block, int l) {
|
||||
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
|
||||
new file mode 100644
|
||||
index 0000000..297fae8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/AntiXray.java
|
||||
@@ -0,0 +1,200 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import gnu.trove.set.TByteSet;
|
||||
+import gnu.trove.set.hash.TByteHashSet;
|
||||
+import net.minecraft.server.Block;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
+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 final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
|
||||
+ // Used to select a random replacement ore
|
||||
+ private final byte[] replacementOres;
|
||||
+
|
||||
+ public AntiXray(SpigotWorldConfig config)
|
||||
+ {
|
||||
+ // Set all listed blocks as true to be obfuscated
|
||||
+ for ( int id : ( config.engineMode == 1 ) ? config.hiddenBlocks : config.replaceBlocks )
|
||||
+ {
|
||||
+ obfuscateBlocks[id] = true;
|
||||
+ }
|
||||
+
|
||||
+ // For every block
|
||||
+ TByteSet blocks = new TByteHashSet();
|
||||
+ for ( Integer i : config.hiddenBlocks )
|
||||
+ {
|
||||
+ Block block = Block.e( i );
|
||||
+ // Check it exists and is not a tile entity
|
||||
+ if ( block != null && !block.isTileEntity() )
|
||||
+ {
|
||||
+ // Add it to the set of replacement blocks
|
||||
+ blocks.add( (byte) (int) i );
|
||||
+ }
|
||||
+ }
|
||||
+ // Bake it to a flat array of replacements
|
||||
+ replacementOres = blocks.toArray();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Starts the timings handler, then updates all blocks within the set radius
|
||||
+ * of the given coordinate, revealing them if they are hidden ores.
|
||||
+ */
|
||||
+ public void updateNearbyBlocks(World world, int x, int y, int z)
|
||||
+ {
|
||||
+ if ( world.spigotConfig.antiXray )
|
||||
+ {
|
||||
+ update.startTiming();
|
||||
+ updateNearbyBlocks( world, x, y, z, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
|
||||
+ update.stopTiming();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Starts the timings handler, and then removes all non exposed ores from
|
||||
+ * the chunk buffer.
|
||||
+ */
|
||||
+ public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
||||
+ {
|
||||
+ if ( world.spigotConfig.antiXray )
|
||||
+ {
|
||||
+ obfuscate.startTiming();
|
||||
+ obfuscate( chunkX, chunkY, bitmask, buffer, world );
|
||||
+ obfuscate.stopTiming();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Removes all non exposed ores from the chunk buffer.
|
||||
+ */
|
||||
+ public void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
||||
+ {
|
||||
+ // If the world is marked as obfuscated
|
||||
+ if ( world.spigotConfig.antiXray )
|
||||
+ {
|
||||
+ // Initial radius to search around for air
|
||||
+ int initialRadius = 1;
|
||||
+ // Which block in the buffer we are looking at, anywhere from 0 to 16^4
|
||||
+ int index = 0;
|
||||
+ // The iterator marking which random ore we should use next
|
||||
+ int randomOre = 0;
|
||||
+
|
||||
+ // Chunk corner X and Z blocks
|
||||
+ int startX = chunkX << 4;
|
||||
+ int startZ = chunkY << 4;
|
||||
+
|
||||
+ // Chunks can have up to 16 sections
|
||||
+ for ( int i = 0; i < 16; i++ )
|
||||
+ {
|
||||
+ // If the bitmask indicates this chunk is sent...
|
||||
+ if ( ( bitmask & 1 << i ) != 0 )
|
||||
+ {
|
||||
+ // Work through all blocks in the chunk, y,z,x
|
||||
+ for ( int y = 0; y < 16; y++ )
|
||||
+ {
|
||||
+ for ( int z = 0; z < 16; z++ )
|
||||
+ {
|
||||
+ for ( int x = 0; x < 16; x++ )
|
||||
+ {
|
||||
+ // For some reason we can get too far ahead of ourselves (concurrent modification on bulk chunks?) so if we do, just abort and move on
|
||||
+ if ( index >= buffer.length )
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Grab the block ID in the buffer.
|
||||
+ // TODO: extended IDs are not yet supported
|
||||
+ int blockId = buffer[index] & 0xFF;
|
||||
+ // Check if the block should be obfuscated
|
||||
+ if ( obfuscateBlocks[blockId] )
|
||||
+ {
|
||||
+ // TODO: Don't really understand this, but if radius is not 0 and the world isn't loaded, bail out
|
||||
+ if ( initialRadius != 0 && !isLoaded( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // 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.spigotConfig.engineMode )
|
||||
+ {
|
||||
+ case 1:
|
||||
+ // Replace with stone
|
||||
+ buffer[index] = 1;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ // Replace with random ore.
|
||||
+ if ( randomOre >= replacementOres.length )
|
||||
+ {
|
||||
+ randomOre = 0;
|
||||
+ }
|
||||
+ buffer[index] = replacementOres[randomOre++];
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ index++;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
|
||||
+ {
|
||||
+ // If the block in question is loaded
|
||||
+ if ( world.isLoaded( x, y, z ) )
|
||||
+ {
|
||||
+ // Get block id
|
||||
+ Block block = world.getType(x, y, z);
|
||||
+
|
||||
+ // See if it needs update
|
||||
+ if ( updateSelf && obfuscateBlocks[Block.b(block)] )
|
||||
+ {
|
||||
+ // Send the update
|
||||
+ world.notify( x, y, z );
|
||||
+ }
|
||||
+
|
||||
+ // Check other blocks for updates
|
||||
+ if ( radius > 0 )
|
||||
+ {
|
||||
+ updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
|
||||
+ updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
|
||||
+ updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
|
||||
+ updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
|
||||
+ updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
|
||||
+ updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isLoaded(World world, int x, int y, int z, int radius)
|
||||
+ {
|
||||
+ return world.isLoaded( x, y, z )
|
||||
+ || ( radius > 0
|
||||
+ && ( isLoaded( world, x + 1, y, z, radius - 1 )
|
||||
+ || isLoaded( world, x - 1, y, z, radius - 1 )
|
||||
+ || isLoaded( world, x, y + 1, z, radius - 1 )
|
||||
+ || isLoaded( world, x, y - 1, z, radius - 1 )
|
||||
+ || isLoaded( world, x, y, z + 1, radius - 1 )
|
||||
+ || isLoaded( world, x, y, z - 1, radius - 1 ) ) );
|
||||
+ }
|
||||
+
|
||||
+ private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius)
|
||||
+ {
|
||||
+ return !world.getType(x, y, z).r() /* isSolidBlock */
|
||||
+ || ( radius > 0
|
||||
+ && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 )
|
||||
+ || hasTransparentBlockAdjacent( world, x - 1, y, z, radius - 1 )
|
||||
+ || hasTransparentBlockAdjacent( world, x, y + 1, z, radius - 1 )
|
||||
+ || hasTransparentBlockAdjacent( world, x, y - 1, z, radius - 1 )
|
||||
+ || hasTransparentBlockAdjacent( world, x, y, z + 1, radius - 1 )
|
||||
+ || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 447581d..b207c02 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;
|
||||
@@ -206,4 +207,36 @@ public class SpigotWorldConfig
|
||||
arrowDespawnRate = getInt( "arrow-despawn-rate", 1200 );
|
||||
log( "Arrow Despawn Rate: " + arrowDespawnRate );
|
||||
}
|
||||
+
|
||||
+ public boolean antiXray;
|
||||
+ public int engineMode;
|
||||
+ public List<Integer> hiddenBlocks;
|
||||
+ public List<Integer> replaceBlocks;
|
||||
+ public AntiXray antiXrayInstance;
|
||||
+ private void antiXray()
|
||||
+ {
|
||||
+ antiXray = getBoolean( "anti-xray.enabled", true );
|
||||
+ log( "Anti X-Ray: " + antiXray );
|
||||
+
|
||||
+ engineMode = getInt( "anti-xray.engine-mode", 1 );
|
||||
+ log( "\tEngine Mode: " + engineMode );
|
||||
+
|
||||
+ if ( SpigotConfig.version < 5 )
|
||||
+ {
|
||||
+ set( "anti-xray.blocks", null );
|
||||
+ }
|
||||
+ hiddenBlocks = getList( "anti-xray.hide-blocks", Arrays.asList( new Integer[]
|
||||
+ {
|
||||
+ 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
|
||||
+ } ) );
|
||||
+ log( "\tHidden Blocks: " + hiddenBlocks );
|
||||
+
|
||||
+ replaceBlocks = getList( "anti-xray.replace-blocks", Arrays.asList( new Integer[]
|
||||
+ {
|
||||
+ 1, 5
|
||||
+ } ) );
|
||||
+ log( "\tReplace Blocks: " + hiddenBlocks );
|
||||
+
|
||||
+ antiXrayInstance = new AntiXray( this );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
From 387fba40bf4ace15665c03556f01272d752d366e Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Fri, 13 Dec 2013 11:45:47 +1100
|
||||
Subject: [PATCH] Optimize DataWatcher
|
||||
|
||||
Use primitive orientated collections, as well as more effective copies across collections.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java
|
||||
index 90a2a80..cca6bd9 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataWatcher.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataWatcher.java
|
||||
@@ -14,8 +14,13 @@ public class DataWatcher {
|
||||
|
||||
private final Entity a;
|
||||
private boolean b = true;
|
||||
- private static final HashMap c = new HashMap();
|
||||
- private final Map d = new HashMap();
|
||||
+ // Spigot Start
|
||||
+ private static final gnu.trove.map.TObjectIntMap classToId = new gnu.trove.map.hash.TObjectIntHashMap( 10, 0.5f, -1 );
|
||||
+ private final gnu.trove.map.TIntObjectMap dataValues = new gnu.trove.map.hash.TIntObjectHashMap( 10, 0.5f, -1 );
|
||||
+ // These exist as an attempt at backwards compatability for (broken) NMS plugins
|
||||
+ private static final Map c = gnu.trove.TDecorators.wrap( classToId );
|
||||
+ private final Map d = gnu.trove.TDecorators.wrap( dataValues );
|
||||
+ // Spigot End
|
||||
private boolean e;
|
||||
private ReadWriteLock f = new ReentrantReadWriteLock();
|
||||
|
||||
@@ -24,19 +29,19 @@ public class DataWatcher {
|
||||
}
|
||||
|
||||
public void a(int i, Object object) {
|
||||
- Integer integer = (Integer) c.get(object.getClass());
|
||||
+ int integer = classToId.get(object.getClass()); // Spigot
|
||||
|
||||
- if (integer == null) {
|
||||
+ if (integer == -1) { // Spigot
|
||||
throw new IllegalArgumentException("Unknown data type: " + object.getClass());
|
||||
} else if (i > 31) {
|
||||
throw new IllegalArgumentException("Data value id is too big with " + i + "! (Max is " + 31 + ")");
|
||||
- } else if (this.d.containsKey(Integer.valueOf(i))) {
|
||||
+ } else if (this.dataValues.containsKey(i)) { // Spigot
|
||||
throw new IllegalArgumentException("Duplicate id value for " + i + "!");
|
||||
} else {
|
||||
- WatchableObject watchableobject = new WatchableObject(integer.intValue(), i, object);
|
||||
+ WatchableObject watchableobject = new WatchableObject(integer, i, object); // Spigot
|
||||
|
||||
this.f.writeLock().lock();
|
||||
- this.d.put(Integer.valueOf(i), watchableobject);
|
||||
+ this.dataValues.put(i, watchableobject); // Spigot
|
||||
this.f.writeLock().unlock();
|
||||
this.b = false;
|
||||
}
|
||||
@@ -46,7 +51,7 @@ public class DataWatcher {
|
||||
WatchableObject watchableobject = new WatchableObject(j, i, null);
|
||||
|
||||
this.f.writeLock().lock();
|
||||
- this.d.put(Integer.valueOf(i), watchableobject);
|
||||
+ this.dataValues.put(i, watchableobject); // Spigot
|
||||
this.f.writeLock().unlock();
|
||||
this.b = false;
|
||||
}
|
||||
@@ -81,7 +86,7 @@ public class DataWatcher {
|
||||
WatchableObject watchableobject;
|
||||
|
||||
try {
|
||||
- watchableobject = (WatchableObject) this.d.get(Integer.valueOf(i));
|
||||
+ watchableobject = (WatchableObject) this.dataValues.get(i); // Spigot
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Getting synched entity data");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Synched entity data");
|
||||
@@ -133,7 +138,7 @@ public class DataWatcher {
|
||||
|
||||
if (this.e) {
|
||||
this.f.readLock().lock();
|
||||
- Iterator iterator = this.d.values().iterator();
|
||||
+ Iterator iterator = this.dataValues.valueCollection().iterator(); // Spigot
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
WatchableObject watchableobject = (WatchableObject) iterator.next();
|
||||
@@ -157,7 +162,7 @@ public class DataWatcher {
|
||||
|
||||
public void a(PacketDataSerializer packetdataserializer) {
|
||||
this.f.readLock().lock();
|
||||
- Iterator iterator = this.d.values().iterator();
|
||||
+ Iterator iterator = this.dataValues.valueCollection().iterator(); // Spigot
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
WatchableObject watchableobject = (WatchableObject) iterator.next();
|
||||
@@ -170,18 +175,11 @@ public class DataWatcher {
|
||||
}
|
||||
|
||||
public List c() {
|
||||
- ArrayList arraylist = null;
|
||||
+ ArrayList arraylist = new ArrayList(); // Spigot
|
||||
|
||||
this.f.readLock().lock();
|
||||
|
||||
- WatchableObject watchableobject;
|
||||
-
|
||||
- for (Iterator iterator = this.d.values().iterator(); iterator.hasNext(); arraylist.add(watchableobject)) {
|
||||
- watchableobject = (WatchableObject) iterator.next();
|
||||
- if (arraylist == null) {
|
||||
- arraylist = new ArrayList();
|
||||
- }
|
||||
- }
|
||||
+ arraylist.addAll(this.dataValues.valueCollection()); // Spigot
|
||||
|
||||
this.f.readLock().unlock();
|
||||
return arraylist;
|
||||
@@ -295,12 +293,14 @@ public class DataWatcher {
|
||||
}
|
||||
|
||||
static {
|
||||
- c.put(Byte.class, Integer.valueOf(0));
|
||||
- c.put(Short.class, Integer.valueOf(1));
|
||||
- c.put(Integer.class, Integer.valueOf(2));
|
||||
- c.put(Float.class, Integer.valueOf(3));
|
||||
- c.put(String.class, Integer.valueOf(4));
|
||||
- c.put(ItemStack.class, Integer.valueOf(5));
|
||||
- c.put(ChunkCoordinates.class, Integer.valueOf(6));
|
||||
+ // Spigot Start - remove valueOf
|
||||
+ classToId.put(Byte.class, 0);
|
||||
+ classToId.put(Short.class, 1);
|
||||
+ classToId.put(Integer.class, 2);
|
||||
+ classToId.put(Float.class, 3);
|
||||
+ classToId.put(String.class, 4);
|
||||
+ classToId.put(ItemStack.class, 5);
|
||||
+ classToId.put(ChunkCoordinates.class, 6);
|
||||
+ // Spigot End
|
||||
}
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
From c1e1312dd0160816ea0557941dc3336ee218c044 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Xaldin <Puremin0rez515@gmail.com>
|
||||
Date: Thu, 12 Dec 2013 18:05:03 -0600
|
||||
Subject: [PATCH] Allow Disabling Zombie Villager Aggression
|
||||
|
||||
Ability to configure if Zombies will be aggressive towards Villagers.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
index 6c6e03e..5c8b0a8 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
@@ -26,7 +26,7 @@ public class EntityZombie extends EntityMonster {
|
||||
this.getNavigation().b(true);
|
||||
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
||||
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false));
|
||||
- this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true));
|
||||
+ if ( world.spigotConfig.zombieAggressiveTowardsVillager ) { this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); } // Spigot
|
||||
this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
|
||||
this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false));
|
||||
this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
|
||||
@@ -34,7 +34,7 @@ public class EntityZombie extends EntityMonster {
|
||||
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
||||
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true));
|
||||
- this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false));
|
||||
+ if ( world.spigotConfig.zombieAggressiveTowardsVillager ) { this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false)); } // Spigot
|
||||
this.a(0.6F, 1.8F);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index b207c02..ea447f9 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -239,4 +239,11 @@ public class SpigotWorldConfig
|
||||
|
||||
antiXrayInstance = new AntiXray( this );
|
||||
}
|
||||
+
|
||||
+ public boolean zombieAggressiveTowardsVillager;
|
||||
+ private void zombieAggressiveTowardsVillager()
|
||||
+ {
|
||||
+ zombieAggressiveTowardsVillager = getBoolean( "zombie-aggressive-towards-villager", true );
|
||||
+ log( "Zombie Aggressive Towards Villager: " + zombieAggressiveTowardsVillager );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
From 28d8e9d734ccd0c04d564bafa44ac378cbe11fc9 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Fri, 13 Dec 2013 11:58:58 +1100
|
||||
Subject: [PATCH] Configurable Amount of Netty Threads
|
||||
|
||||
This brings back the option that the Spigot version of netty saw. By default Netty will try and use cores*2 threads, however if running multiple servers on the same machine, this can be too many threads. Additionally some people have 16 core servers. If 32 Netty threads are allowed in this setup, then the lock contention, and thus blocking between threads becomes much greater, leading to decreased performance.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 1f057b1..eee0119 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -51,7 +51,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
private final List m = new ArrayList();
|
||||
private final ICommandHandler n;
|
||||
public final MethodProfiler methodProfiler = new MethodProfiler();
|
||||
- private final ServerConnection o;
|
||||
+ private ServerConnection o; // Spigot
|
||||
private final ServerPing p = new ServerPing();
|
||||
private final Random q = new Random();
|
||||
private String serverIp;
|
||||
@@ -112,7 +112,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
i = this;
|
||||
this.c = proxy;
|
||||
// this.universe = file1; // CraftBukkit
|
||||
- this.o = new ServerConnection(this);
|
||||
+ // this.o = new ServerConnection(this); // Spigot
|
||||
this.n = new CommandDispatcher();
|
||||
// this.convertable = new WorldLoaderServer(file1); // CraftBukkit - moved to DedicatedServer.init
|
||||
this.S = (new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
|
||||
@@ -1211,7 +1211,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
|
||||
public ServerConnection ag() {
|
||||
- return this.o;
|
||||
+ return ( this.o ) == null ? this.o = new ServerConnection( this ) : this.o; // Spigot
|
||||
}
|
||||
|
||||
public boolean ai() {
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index acd5567..c4a5488 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -197,4 +197,11 @@ public class SpigotConfig
|
||||
}
|
||||
bungee = getBoolean( "settings.bungeecord", false );
|
||||
}
|
||||
+
|
||||
+ private static void nettyThreads()
|
||||
+ {
|
||||
+ int count = getInt( "settings.netty-threads", 4 );
|
||||
+ System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
|
||||
+ Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
From 0af066aa9c3e945fc52cb7309f3c94e1bd2ac5d1 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Fri, 13 Dec 2013 15:21:02 +1100
|
||||
Subject: [PATCH] Prevent Mineshaft Saving
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
index b3c8101..2a6a571 100644
|
||||
--- a/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
|
||||
@@ -179,7 +179,7 @@ public abstract class StructureGenerator extends WorldGenBase {
|
||||
private void a(World world) {
|
||||
if (this.e == null) {
|
||||
// Spigot Start
|
||||
- if ( world.spigotConfig.saveStructureInfo )
|
||||
+ if ( world.spigotConfig.saveStructureInfo && !this.a().equals( "Mineshaft" ) )
|
||||
{
|
||||
this.e = (PersistentStructure) world.a(PersistentStructure.class, this.a());
|
||||
} else
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,314 +0,0 @@
|
|||
From a066619c49f67a8590a2fd08e251642c1e504974 Mon Sep 17 00:00:00 2001
|
||||
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
||||
Date: Wed, 18 Dec 2013 10:32:15 +1100
|
||||
Subject: [PATCH] Add VanillaCommand Wrapper to Support New Commands
|
||||
|
||||
This implements testfor, setblock and summon, as well as the capacity to replace any command with its vanilla version.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
||||
index 5271272..f8d2ecb 100644
|
||||
--- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
||||
+++ b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
||||
@@ -96,7 +96,7 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener {
|
||||
|
||||
// Make sure this is a valid command
|
||||
if (commandMap.getCommand(args[0]) == null) {
|
||||
- this.b = 0;
|
||||
+ this.b = org.spigotmc.VanillaCommandWrapper.dispatch( sender, command ); // Spigot - Try vanilla commands
|
||||
return;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
|
||||
index e63f17c..e58be15 100644
|
||||
--- a/src/main/java/net/minecraft/server/CommandDispatcher.java
|
||||
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
|
||||
@@ -62,7 +62,7 @@ public class CommandDispatcher extends CommandHandler implements ICommandDispatc
|
||||
public void a(ICommandListener icommandlistener, int i, String s, Object... aobject) {
|
||||
boolean flag = true;
|
||||
|
||||
- if (icommandlistener instanceof CommandBlockListenerAbstract && !MinecraftServer.getServer().worldServer[0].getGameRules().getBoolean("commandBlockOutput")) {
|
||||
+ if (icommandlistener instanceof CommandBlockListenerAbstract && !MinecraftServer.getServer().worlds.get(0).getGameRules().getBoolean("commandBlockOutput")) { // Spigot - worldServer -> worlds
|
||||
flag = false;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 5cd6f7d..232a604 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -546,6 +546,12 @@ public final class CraftServer implements Server {
|
||||
if (commandMap.dispatch(sender, commandLine)) {
|
||||
return true;
|
||||
}
|
||||
+ // Spigot Start - Try vanilla commands
|
||||
+ if ( org.spigotmc.VanillaCommandWrapper.dispatch( sender, commandLine ) != -1 )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
sender.sendMessage(org.spigotmc.SpigotConfig.unknownCommandMessage);
|
||||
|
||||
@@ -1401,15 +1407,23 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
// Spigot End
|
||||
|
||||
- List<String> completions = null;
|
||||
+ // Spigot Start
|
||||
+ List<String> completions = new ArrayList<String>();
|
||||
try {
|
||||
- completions = getCommandMap().tabComplete(player, message.substring(1));
|
||||
+ message = message.substring( 1 );
|
||||
+ List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
|
||||
+ if ( bukkitCompletions != null )
|
||||
+ {
|
||||
+ completions.addAll( bukkitCompletions );
|
||||
+ }
|
||||
+ completions.addAll( org.spigotmc.VanillaCommandWrapper.complete( player, message ) );
|
||||
+ // Spigot End
|
||||
} 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);
|
||||
}
|
||||
|
||||
- return completions == null ? ImmutableList.<String>of() : completions;
|
||||
+ return completions; // Spigot
|
||||
}
|
||||
|
||||
public List<String> tabCompleteChat(Player player, String message) {
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index c4a5488..628533e 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
+import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -14,6 +15,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.craftbukkit.command.TicksPerSecondCommand;
|
||||
|
||||
@@ -204,4 +206,13 @@ public class SpigotConfig
|
||||
System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
|
||||
Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
|
||||
}
|
||||
+
|
||||
+ private static void replaceCommands()
|
||||
+ {
|
||||
+ for ( String command : (List<String>) getList( "replace-commands", Arrays.asList( "setblock", "summon", "testforblock" ) ) )
|
||||
+ {
|
||||
+ SimpleCommandMap.removeFallback( command );
|
||||
+ VanillaCommandWrapper.allowedCommands.add( command );
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/VanillaCommandWrapper.java b/src/main/java/org/spigotmc/VanillaCommandWrapper.java
|
||||
new file mode 100644
|
||||
index 0000000..a6c76cc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/VanillaCommandWrapper.java
|
||||
@@ -0,0 +1,194 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import net.minecraft.server.ChatComponentText;
|
||||
+import net.minecraft.server.ChunkCoordinates;
|
||||
+import net.minecraft.server.EntityMinecartCommandBlock;
|
||||
+import net.minecraft.server.IChatBaseComponent;
|
||||
+import net.minecraft.server.ICommandListener;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.TileEntityCommand;
|
||||
+import net.minecraft.server.World;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.command.CraftBlockCommandSender;
|
||||
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class VanillaCommandWrapper
|
||||
+{
|
||||
+
|
||||
+ public static final HashSet<String> allowedCommands = new HashSet<String>();
|
||||
+
|
||||
+ public static int dispatch(CommandSender sender, String commandLine)
|
||||
+ {
|
||||
+ int pos = commandLine.indexOf( ' ' );
|
||||
+ if ( pos == -1 )
|
||||
+ {
|
||||
+ pos = commandLine.length();
|
||||
+ }
|
||||
+ String name = commandLine.substring( 0, pos );
|
||||
+ if ( !allowedCommands.contains( name ) )
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if ( !sender.hasPermission( "bukkit.command." + name ) )
|
||||
+ {
|
||||
+ sender.sendMessage( ChatColor.RED + "You do not have permission for this command" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+ ICommandListener listener = getListener( sender );
|
||||
+ if ( listener == null )
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return MinecraftServer.getServer().getCommandHandler().a( listener, commandLine );
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> complete(CommandSender sender, String commandLine)
|
||||
+ {
|
||||
+ int pos = commandLine.indexOf( ' ' );
|
||||
+ if ( pos == -1 )
|
||||
+ {
|
||||
+ List<String> completions = new ArrayList<String>();
|
||||
+ commandLine = commandLine.toLowerCase();
|
||||
+ for ( String command : allowedCommands )
|
||||
+ {
|
||||
+ if ( command.startsWith( commandLine ) && sender.hasPermission( "bukkit.command." + command ) )
|
||||
+ {
|
||||
+ completions.add( "/" + command );
|
||||
+ }
|
||||
+ }
|
||||
+ return completions;
|
||||
+ }
|
||||
+ String name = commandLine.substring( 0, pos );
|
||||
+ if ( !allowedCommands.contains( name ) || !sender.hasPermission( "bukkit.command." + name ) )
|
||||
+ {
|
||||
+ return ImmutableList.<String>of();
|
||||
+ }
|
||||
+ ICommandListener listener = getListener( sender );
|
||||
+ if ( listener == null )
|
||||
+ {
|
||||
+ return ImmutableList.<String>of();
|
||||
+ }
|
||||
+ return MinecraftServer.getServer().getCommandHandler().b( listener, commandLine );
|
||||
+ }
|
||||
+
|
||||
+ private static ICommandListener getListener(CommandSender sender)
|
||||
+ {
|
||||
+ if ( sender instanceof CraftPlayer )
|
||||
+ {
|
||||
+ return new PlayerListener( ( (CraftPlayer) sender ).getHandle() );
|
||||
+ }
|
||||
+ if ( sender instanceof CraftBlockCommandSender )
|
||||
+ {
|
||||
+ CraftBlockCommandSender commandBlock = (CraftBlockCommandSender) sender;
|
||||
+ Block block = commandBlock.getBlock();
|
||||
+ return ( (TileEntityCommand) ( (CraftWorld) block.getWorld() ).getTileEntityAt( block.getX(), block.getY(), block.getZ() ) ).a();
|
||||
+ }
|
||||
+ if ( sender instanceof CraftMinecartCommand )
|
||||
+ {
|
||||
+ return ( (EntityMinecartCommandBlock) ( (CraftMinecartCommand) sender ).getHandle() ).e();
|
||||
+ }
|
||||
+ return new ConsoleListener(sender); // Assume console/rcon
|
||||
+ }
|
||||
+
|
||||
+ private static class PlayerListener implements ICommandListener
|
||||
+ {
|
||||
+
|
||||
+ private final ICommandListener handle;
|
||||
+
|
||||
+ public PlayerListener(ICommandListener handle)
|
||||
+ {
|
||||
+ this.handle = handle;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getName()
|
||||
+ {
|
||||
+ return handle.getName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public IChatBaseComponent getScoreboardDisplayName()
|
||||
+ {
|
||||
+ return handle.getScoreboardDisplayName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void sendMessage(IChatBaseComponent iChatBaseComponent)
|
||||
+ {
|
||||
+ handle.sendMessage( iChatBaseComponent );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean a(int i, String s)
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ChunkCoordinates getChunkCoordinates()
|
||||
+ {
|
||||
+ return handle.getChunkCoordinates();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public World getWorld()
|
||||
+ {
|
||||
+ return handle.getWorld();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static class ConsoleListener implements ICommandListener {
|
||||
+
|
||||
+ private final CommandSender sender;
|
||||
+
|
||||
+ public ConsoleListener( CommandSender sender )
|
||||
+ {
|
||||
+ this.sender = sender;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getName()
|
||||
+ {
|
||||
+ return sender.getName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public IChatBaseComponent getScoreboardDisplayName()
|
||||
+ {
|
||||
+ return new ChatComponentText( getName() );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void sendMessage( IChatBaseComponent iChatBaseComponent )
|
||||
+ {
|
||||
+ sender.sendMessage( iChatBaseComponent.e() );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean a( int i, String s )
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ChunkCoordinates getChunkCoordinates()
|
||||
+ {
|
||||
+ return new ChunkCoordinates( 0, 0, 0 );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public World getWorld()
|
||||
+ {
|
||||
+ return MinecraftServer.getServer().getWorld();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
From 0d18750f7e80f8d191ae52b339e013679f61bfa8 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Wed, 18 Dec 2013 13:32:10 +1100
|
||||
Subject: [PATCH] Fire PreLogin Events in Offline Mode
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
index aa06e92..fa80b74 100644
|
||||
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
@@ -108,7 +108,7 @@ public class LoginListener implements PacketLoginInListener {
|
||||
this.g = EnumProtocolState.KEY;
|
||||
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.I().getPublic(), this.e), new GenericFutureListener[0]);
|
||||
} else {
|
||||
- this.g = EnumProtocolState.READY_TO_ACCEPT;
|
||||
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start(); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
||||
index cc96775..ea8c269 100644
|
||||
--- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
||||
+++ b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
||||
@@ -22,47 +22,21 @@ class ThreadPlayerLookupUUID extends Thread {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
+ // Spigot Start
|
||||
+ if ( !LoginListener.b( this.a ).getOnlineMode() )
|
||||
+ {
|
||||
+ fireLoginEvents();
|
||||
+ LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Spigot End
|
||||
String s = (new BigInteger(MinecraftEncryption.a(LoginListener.a(this.a), LoginListener.b(this.a).I().getPublic(), LoginListener.c(this.a)))).toString(16);
|
||||
|
||||
LoginListener.a(this.a, LoginListener.b(this.a).as().hasJoinedServer(new GameProfile((String) null, LoginListener.d(this.a).getName()), s));
|
||||
if (LoginListener.d(this.a) != null) {
|
||||
- // CraftBukkit start
|
||||
- if (!this.a.networkManager.d()) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- String playerName = LoginListener.d(this.a).getName();
|
||||
- java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
||||
- final org.bukkit.craftbukkit.CraftServer server = LoginListener.b(this.a).server;
|
||||
-
|
||||
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address);
|
||||
- server.getPluginManager().callEvent(asyncEvent);
|
||||
-
|
||||
- if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
||||
- final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address);
|
||||
- if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
- event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
|
||||
- }
|
||||
- Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() {
|
||||
- @Override
|
||||
- protected PlayerPreLoginEvent.Result evaluate() {
|
||||
- server.getPluginManager().callEvent(event);
|
||||
- return event.getResult();
|
||||
- }};
|
||||
-
|
||||
- LoginListener.b(this.a).processQueue.add(waitable);
|
||||
- if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
- this.a.disconnect(event.getKickMessage());
|
||||
- return;
|
||||
- }
|
||||
- } else {
|
||||
- if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||
- this.a.disconnect(asyncEvent.getKickMessage());
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
-
|
||||
+ // Spigot Start
|
||||
+ fireLoginEvents();
|
||||
+ // Spigot End
|
||||
LoginListener.e().info("UUID of player " + LoginListener.d(this.a).getName() + " is " + LoginListener.d(this.a).getId());
|
||||
LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
||||
} else {
|
||||
@@ -79,4 +53,44 @@ class ThreadPlayerLookupUUID extends Thread {
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
+
|
||||
+ private void fireLoginEvents() throws Exception
|
||||
+ {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.a.networkManager.d()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ String playerName = LoginListener.d(this.a).getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
||||
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.b(this.a).server;
|
||||
+
|
||||
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address);
|
||||
+ server.getPluginManager().callEvent(asyncEvent);
|
||||
+
|
||||
+ if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
||||
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address);
|
||||
+ if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
|
||||
+ }
|
||||
+ Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() {
|
||||
+ @Override
|
||||
+ protected PlayerPreLoginEvent.Result evaluate() {
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ return event.getResult();
|
||||
+ }};
|
||||
+
|
||||
+ LoginListener.b(this.a).processQueue.add(waitable);
|
||||
+ if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ this.a.disconnect(event.getKickMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ this.a.disconnect(asyncEvent.getKickMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
}
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 3560afc28dba265c643dcbb594ce6306dd56005c Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Wed, 18 Dec 2013 13:39:14 +1100
|
||||
Subject: [PATCH] Log Cause of Unexpected Exceptions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index eee0119..868061b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -454,6 +454,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
h.error("Encountered an unexpected exception", throwable);
|
||||
+ // Spigot Start
|
||||
+ if ( throwable.getCause() != null )
|
||||
+ {
|
||||
+ h.error( "\tCause of unexpected exception was", throwable.getCause() );
|
||||
+ }
|
||||
+ // Spigot End
|
||||
CrashReport crashreport = null;
|
||||
|
||||
if (throwable instanceof ReportedException) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
From 053010b794cf421760be77790ee247a9040a46a1 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Wed, 18 Dec 2013 20:39:24 +1100
|
||||
Subject: [PATCH] Remove Bukkit URL Clicking
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index 66368f4..cc8e715 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -3,28 +3,23 @@ package org.bukkit.craftbukkit.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
-import java.util.regex.Matcher;
|
||||
-import java.util.regex.Pattern;
|
||||
|
||||
-import net.minecraft.server.ChatClickable;
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.ChatModifier;
|
||||
import net.minecraft.server.EnumChatFormat;
|
||||
-import net.minecraft.server.EnumClickAction;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
public final class CraftChatMessage {
|
||||
- private static class StringMessage {
|
||||
+ private static class FromString {
|
||||
private static final Map<Character, EnumChatFormat> formatMap;
|
||||
- private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|(?:(https?://[^ ][^ ]*?)(?=[\\.\\?!,;:]?(?:[ \\n]|$)))", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
static {
|
||||
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
|
||||
for (EnumChatFormat format : EnumChatFormat.values()) {
|
||||
- builder.put(Character.toLowerCase(format.getChar()), format);
|
||||
+ builder.put(format.getChar(), format);
|
||||
}
|
||||
formatMap = builder.build();
|
||||
}
|
||||
@@ -32,29 +27,25 @@ public final class CraftChatMessage {
|
||||
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
|
||||
private IChatBaseComponent currentChatComponent = new ChatComponentText("");
|
||||
private ChatModifier modifier = new ChatModifier();
|
||||
+ private StringBuilder builder = new StringBuilder();
|
||||
private final IChatBaseComponent[] output;
|
||||
- private int currentIndex;
|
||||
- private final String message;
|
||||
|
||||
- private StringMessage(String message) {
|
||||
- this.message = message;
|
||||
+ private FromString(String message) {
|
||||
if (message == null) {
|
||||
output = new IChatBaseComponent[] { currentChatComponent };
|
||||
return;
|
||||
}
|
||||
list.add(currentChatComponent);
|
||||
|
||||
- Matcher matcher = INCREMENTAL_PATTERN.matcher(message);
|
||||
- String match = null;
|
||||
- while (matcher.find()) {
|
||||
- int groupId = 0;
|
||||
- while ((match = matcher.group(++groupId)) == null) {
|
||||
- // NOOP
|
||||
- }
|
||||
- appendNewComponent(matcher.start(groupId));
|
||||
- switch (groupId) {
|
||||
- case 1:
|
||||
- EnumChatFormat format = formatMap.get(match.toLowerCase().charAt(1));
|
||||
+ EnumChatFormat format = null;
|
||||
+
|
||||
+ for (int i = 0; i < message.length(); i++) {
|
||||
+ char currentChar = message.charAt(i);
|
||||
+ if (currentChar == '\u00A7' && (i < (message.length() - 1)) && (format = formatMap.get(message.charAt(i + 1))) != null) {
|
||||
+ if (builder.length() > 0) {
|
||||
+ appendNewComponent();
|
||||
+ }
|
||||
+
|
||||
if (format == EnumChatFormat.RESET) {
|
||||
modifier = new ChatModifier();
|
||||
} else if (format.isFormat()) {
|
||||
@@ -80,31 +71,27 @@ public final class CraftChatMessage {
|
||||
} else { // Color resets formatting
|
||||
modifier = new ChatModifier().setColor(format);
|
||||
}
|
||||
- break;
|
||||
- case 2:
|
||||
+ i++;
|
||||
+ } else if (currentChar == '\n') {
|
||||
+ if (builder.length() > 0) {
|
||||
+ appendNewComponent();
|
||||
+ }
|
||||
currentChatComponent = null;
|
||||
- break;
|
||||
- case 3:
|
||||
- modifier.a(new ChatClickable(EnumClickAction.OPEN_URL, match)); // Should be setChatClickable
|
||||
- appendNewComponent(matcher.end(groupId));
|
||||
- modifier.a((ChatClickable) null);
|
||||
+ } else {
|
||||
+ builder.append(currentChar);
|
||||
}
|
||||
- currentIndex = matcher.end(groupId);
|
||||
}
|
||||
|
||||
- if (currentIndex < message.length()) {
|
||||
- appendNewComponent(message.length());
|
||||
+ if (builder.length() > 0) {
|
||||
+ appendNewComponent();
|
||||
}
|
||||
|
||||
output = list.toArray(new IChatBaseComponent[0]);
|
||||
}
|
||||
|
||||
- private void appendNewComponent(int index) {
|
||||
- if (index <= currentIndex) {
|
||||
- return;
|
||||
- }
|
||||
- IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setChatModifier(modifier);
|
||||
- currentIndex = index;
|
||||
+ private void appendNewComponent() {
|
||||
+ IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
|
||||
+ builder = new StringBuilder();
|
||||
modifier = modifier.clone();
|
||||
if (currentChatComponent == null) {
|
||||
currentChatComponent = new ChatComponentText("");
|
||||
@@ -119,7 +106,7 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
public static IChatBaseComponent[] fromString(String message) {
|
||||
- return new StringMessage(message).getOutput();
|
||||
+ return new FromString(message).getOutput();
|
||||
}
|
||||
|
||||
private CraftChatMessage() {
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
From e550640b2f560ef5af9f93c5d7002ac79d3ecbd6 Mon Sep 17 00:00:00 2001
|
||||
From: Thinkofdeath <purggames@gmail.com>
|
||||
Date: Sun, 1 Dec 2013 10:33:55 +0000
|
||||
Subject: [PATCH] Fix links in chat
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index cc8e715..5607df1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -3,11 +3,15 @@ package org.bukkit.craftbukkit.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import java.util.regex.Matcher;
|
||||
+import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.ChatModifier;
|
||||
import net.minecraft.server.EnumChatFormat;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
+import net.minecraft.server.ChatClickable;
|
||||
+import net.minecraft.server.EnumClickAction;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
@@ -29,6 +33,8 @@ public final class CraftChatMessage {
|
||||
private ChatModifier modifier = new ChatModifier();
|
||||
private StringBuilder builder = new StringBuilder();
|
||||
private final IChatBaseComponent[] output;
|
||||
+ private static final Pattern url = Pattern.compile("^(\u00A7.)*?((?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,4})(/\\S*?)?)(\u00A7.)*?$");
|
||||
+ private int lastWord = 0;
|
||||
|
||||
private FromString(String message) {
|
||||
if (message == null) {
|
||||
@@ -38,10 +44,14 @@ public final class CraftChatMessage {
|
||||
list.add(currentChatComponent);
|
||||
|
||||
EnumChatFormat format = null;
|
||||
+ Matcher matcher = url.matcher(message);
|
||||
+ lastWord = 0;
|
||||
|
||||
for (int i = 0; i < message.length(); i++) {
|
||||
char currentChar = message.charAt(i);
|
||||
if (currentChar == '\u00A7' && (i < (message.length() - 1)) && (format = formatMap.get(message.charAt(i + 1))) != null) {
|
||||
+ checkUrl(matcher, message, i);
|
||||
+ lastWord++;
|
||||
if (builder.length() > 0) {
|
||||
appendNewComponent();
|
||||
}
|
||||
@@ -73,11 +83,18 @@ public final class CraftChatMessage {
|
||||
}
|
||||
i++;
|
||||
} else if (currentChar == '\n') {
|
||||
+ checkUrl(matcher, message, i);
|
||||
+ lastWord = i + 1;
|
||||
if (builder.length() > 0) {
|
||||
appendNewComponent();
|
||||
}
|
||||
currentChatComponent = null;
|
||||
} else {
|
||||
+ if (currentChar == ' ' || i == message.length() - 1) {
|
||||
+ if (checkUrl(matcher, message, i)) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
builder.append(currentChar);
|
||||
}
|
||||
}
|
||||
@@ -89,6 +106,31 @@ public final class CraftChatMessage {
|
||||
output = list.toArray(new IChatBaseComponent[0]);
|
||||
}
|
||||
|
||||
+ private boolean checkUrl(Matcher matcher, String message, int i) {
|
||||
+ Matcher urlMatcher = matcher.region(lastWord, i == message.length() - 1 ? message.length() : i);
|
||||
+ lastWord = i + 1;
|
||||
+ if (urlMatcher.find()) {
|
||||
+ String fullUrl = urlMatcher.group(2);
|
||||
+ String protocol = urlMatcher.group(3);
|
||||
+ String url = urlMatcher.group(4);
|
||||
+ String path = urlMatcher.group(5);
|
||||
+ builder.delete(builder.length() - fullUrl.length() + (i == message.length() - 1 ? 1 : 0), builder.length());
|
||||
+ if (builder.length() > 0) {
|
||||
+ appendNewComponent();
|
||||
+ }
|
||||
+ builder.append(fullUrl);
|
||||
+ ChatClickable link = new ChatClickable(EnumClickAction.OPEN_URL,
|
||||
+ (protocol!=null?protocol:"http") + "://" + url + (path!=null?path:""));
|
||||
+ modifier.a(link);
|
||||
+ appendNewComponent();
|
||||
+ modifier.a((ChatClickable) null);
|
||||
+ if (i == message.length() - 1) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
private void appendNewComponent() {
|
||||
IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
|
||||
builder = new StringBuilder();
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
From 695b58dfaee4bba87a6189894d367f87f534aa2d Mon Sep 17 00:00:00 2001
|
||||
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
||||
Date: Fri, 20 Dec 2013 21:36:06 +0000
|
||||
Subject: [PATCH] Particle API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
|
||||
index 7de0de5..7eca388 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
|
||||
@@ -55,6 +55,8 @@ public class CraftEffect {
|
||||
Validate.isTrue(((Material) data).isBlock(), "Material is not a block!");
|
||||
datavalue = ((Material) data).getId();
|
||||
break;
|
||||
+ case ITEM_BREAK:
|
||||
+ datavalue = ((Material) data).getId();
|
||||
default:
|
||||
datavalue = 0;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 468a4e1..c90dd54 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -779,28 +779,18 @@ public class CraftWorld implements World {
|
||||
Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
|
||||
}
|
||||
|
||||
- int datavalue = data == null ? 0 : CraftEffect.getDataValue(effect, data);
|
||||
- playEffect(loc, effect, datavalue, radius);
|
||||
+ if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) {
|
||||
+ org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data;
|
||||
+ Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" );
|
||||
+ spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius );
|
||||
+ } else {
|
||||
+ int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data );
|
||||
+ playEffect( loc, effect, dataValue, radius );
|
||||
+ }
|
||||
}
|
||||
|
||||
public void playEffect(Location location, Effect effect, int data, int radius) {
|
||||
- Validate.notNull(location, "Location cannot be null");
|
||||
- Validate.notNull(effect, "Effect cannot be null");
|
||||
- Validate.notNull(location.getWorld(), "World cannot be null");
|
||||
- int packetData = effect.getId();
|
||||
- PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false);
|
||||
- int distance;
|
||||
- radius *= radius;
|
||||
-
|
||||
- for (Player player : getPlayers()) {
|
||||
- if (((CraftPlayer) player).getHandle().playerConnection == null) continue;
|
||||
- if (!location.getWorld().equals(player.getWorld())) continue;
|
||||
-
|
||||
- distance = (int) player.getLocation().distanceSquared(location);
|
||||
- if (distance <= radius) {
|
||||
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
- }
|
||||
- }
|
||||
+ spigot().playEffect( location, effect, data, 0, 0, 0, 0, 1, 1, radius );
|
||||
}
|
||||
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
|
||||
@@ -1286,6 +1276,56 @@ public class CraftWorld implements World {
|
||||
// Spigot start
|
||||
private final Spigot spigot = new Spigot()
|
||||
{
|
||||
+ @Override
|
||||
+ public void playEffect( Location location, Effect effect, int id, int data, float offsetX, float offsetY, float offsetZ, float speed, int particleCount, int radius )
|
||||
+ {
|
||||
+ Validate.notNull( location, "Location cannot be null" );
|
||||
+ Validate.notNull( effect, "Effect cannot be null" );
|
||||
+ Validate.notNull( location.getWorld(), "World cannot be null" );
|
||||
+ Packet packet;
|
||||
+ if ( effect.getType() != Effect.Type.PARTICLE )
|
||||
+ {
|
||||
+ int packetData = effect.getId();
|
||||
+ packet = new PacketPlayOutWorldEvent( packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), id, false );
|
||||
+ } else
|
||||
+ {
|
||||
+ StringBuilder particleFullName = new StringBuilder();
|
||||
+ particleFullName.append( effect.getName() );
|
||||
+ if ( effect.getData() != null && ( effect.getData().equals( Material.class ) || effect.getData().equals( org.bukkit.material.MaterialData.class ) ) )
|
||||
+ {
|
||||
+ particleFullName.append( '_' ).append( id );
|
||||
+ }
|
||||
+ if ( effect.getData() != null && effect.getData().equals( org.bukkit.material.MaterialData.class ) )
|
||||
+ {
|
||||
+ particleFullName.append( '_' ).append( data );
|
||||
+ }
|
||||
+ packet = new PacketPlayOutWorldParticles( particleFullName.toString(), (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount );
|
||||
+ }
|
||||
+ int distance;
|
||||
+ radius *= radius;
|
||||
+ for ( Player player : getPlayers() )
|
||||
+ {
|
||||
+ if ( ( (CraftPlayer) player ).getHandle().playerConnection == null )
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if ( !location.getWorld().equals( player.getWorld() ) )
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ distance = (int) player.getLocation().distanceSquared( location );
|
||||
+ if ( distance <= radius )
|
||||
+ {
|
||||
+ ( (CraftPlayer) player ).getHandle().playerConnection.sendPacket( packet );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void playEffect( Location location, Effect effect )
|
||||
+ {
|
||||
+ CraftWorld.this.playEffect( location, effect, 0 );
|
||||
+ }
|
||||
};
|
||||
|
||||
public Spigot spigot()
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
From af0f2a8858b0070326fe0ddc1db994c63af6a107 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Sat, 21 Dec 2013 20:08:26 +1100
|
||||
Subject: [PATCH] Force Load Chunks for Biome Decoration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BiomeDecorator.java b/src/main/java/net/minecraft/server/BiomeDecorator.java
|
||||
index b048d6c..a8bbe06 100644
|
||||
--- a/src/main/java/net/minecraft/server/BiomeDecorator.java
|
||||
+++ b/src/main/java/net/minecraft/server/BiomeDecorator.java
|
||||
@@ -147,10 +147,23 @@ public class BiomeDecorator {
|
||||
for (j = 0; j < this.z; ++j) {
|
||||
k = this.c + this.b.nextInt(16) + 8;
|
||||
l = this.d + this.b.nextInt(16) + 8;
|
||||
+ // Spigot Start
|
||||
+ boolean chunkWasLoaded = this.a.isChunkLoaded( i >> 4, j >> 4 );
|
||||
+ if ( !chunkWasLoaded )
|
||||
+ {
|
||||
+ this.a.getChunkAt( i, j );
|
||||
+ }
|
||||
+ // Spigot End
|
||||
i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
||||
WorldGenerator worldgenerator = biomebase.b(this.b);
|
||||
|
||||
worldgenerator.a(this.a, this.b, k, i1, l);
|
||||
+ // Spigot Start
|
||||
+ if ( !chunkWasLoaded )
|
||||
+ {
|
||||
+ this.a.getWorld().unloadChunk( i >> 4, j >> 4 );
|
||||
+ }
|
||||
+ // Spigot End
|
||||
}
|
||||
|
||||
for (j = 0; j < this.A; ++j) {
|
||||
--
|
||||
1.8.3.2
|
||||
|
Loading…
Reference in a new issue