getBlockMetadata() { // KigPaper - change type
return blockMetadata;
}
@@ -1457,22 +1459,16 @@ public class CraftWorld implements World {
{
net.minecraft.server.EnumParticle particle = null;
int[] extra = null;
- for ( net.minecraft.server.EnumParticle p : net.minecraft.server.EnumParticle.values() )
- {
- if ( effect.getName().startsWith( p.b().replace("_", "") ) )
+ if ((particle = Dictionary.EFFECT_TO_PARTICLE.get(effect)) != null) {
+ if ( effect.getData() != null )
{
- particle = p;
- if ( effect.getData() != null )
+ if ( effect.getData().equals( Material.class ) )
{
- if ( effect.getData().equals( org.bukkit.Material.class ) )
- {
- extra = new int[]{ id };
- } else
- {
- extra = new int[]{ (data << 12) | (id & 0xFFF) };
- }
+ extra = new int[]{ id };
+ } else
+ {
+ extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
- break;
}
}
if ( extra == null )
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandSender.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandSender.java
index b339cf3..72f99df 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandSender.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandSender.java
@@ -12,18 +12,19 @@ import org.bukkit.plugin.Plugin;
import java.util.Set;
public abstract class ServerCommandSender implements CommandSender {
- private static PermissibleBase blockPermInst;
+ //private static PermissibleBase blockPermInst; // KigPaper - fix memory leak
private final PermissibleBase perm;
public ServerCommandSender() {
- if (this instanceof CraftBlockCommandSender) {
+ /* if (this instanceof CraftBlockCommandSender) {
if (blockPermInst == null) {
blockPermInst = new PermissibleBase(this);
}
this.perm = blockPermInst;
} else {
this.perm = new PermissibleBase(this);
- }
+ } */ // KigPaper
+ this.perm = new PermissibleBase(this);
}
public boolean isPermissionSet(String name) {
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 0be2129..998cdef 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -43,7 +43,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
protected final CraftServer server;
protected Entity entity;
- private EntityDamageEvent lastDamageEvent;
+ //private EntityDamageEvent lastDamageEvent; // KigPaper - this is almost never used and only leads to memory leaks
public CraftEntity(final CraftServer server, final Entity entity) {
this.server = server;
@@ -259,6 +259,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// entity.world = ((CraftWorld) location.getWorld()).getHandle();
// Spigot end
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ entity.f(location.getYaw()); // KigPaper - update head yaw to keep consistency with /tp
entity.world.entityJoinedWorld(entity, false); // PaperSpigot - Fix issues with entities not being switched to their new chunk
// entity.setLocation() throws no event, and so cannot be cancelled
return true;
@@ -358,11 +359,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public void setLastDamageCause(EntityDamageEvent event) {
- lastDamageEvent = event;
+ // lastDamageEvent = event;
}
public EntityDamageEvent getLastDamageCause() {
- return lastDamageEvent;
+ return null;
}
public UUID getUniqueId() {
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 3f1b541..07ad9a8 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import com.elevatemc.spigot.event.PlayerHealthChangeEvent;
+import com.elevatemc.spigot.util.Dictionary;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.mojang.authlib.GameProfile;
@@ -289,6 +290,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
+ @Override
+ public void sendActionbarMessage(BaseComponent... message) {
+ if(getHandle().playerConnection == null) return;
+ PacketPlayOutChat packet = new PacketPlayOutChat(null, (byte) 2);
+ packet.components = message;
+ getHandle().playerConnection.sendPacket(packet);
+ }
+ // KigPaper end
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OfflinePlayer)) {
@@ -532,7 +542,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
if (entity.passenger != null) {
- return false;
+ // KigPaper - only cancel if not unknown
+ // if a PlayerMoveEvent is cancelled using setTo and the player has a passenger, the event won't set the user back.
+ if (cause != PlayerTeleportEvent.TeleportCause.UNKNOWN) {
+ return false;
+ }
}
// From = Players current Location
@@ -1244,7 +1258,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void setFlying(boolean value) {
- boolean needsUpdate = getHandle().abilities.canFly != value; // PaperSpigot - Only refresh abilities if needed
+ boolean needsUpdate = getHandle().abilities.isFlying != value; // PaperSpigot - Only refresh abilities if needed
if (!getAllowFlight() && value) {
throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false");
}
@@ -1508,22 +1522,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
{
net.minecraft.server.EnumParticle particle = null;
int[] extra = null;
- for ( net.minecraft.server.EnumParticle p : net.minecraft.server.EnumParticle.values() )
- {
- if ( effect.getName().startsWith( p.b().replace("_", "") ) )
+ if ((particle = Dictionary.EFFECT_TO_PARTICLE.get(effect)) != null) {
+ if ( effect.getData() != null )
{
- particle = p;
- if ( effect.getData() != null )
+ if ( effect.getData().equals( org.bukkit.Material.class ) )
{
- if ( effect.getData().equals( org.bukkit.Material.class ) )
- {
- extra = new int[]{ id };
- } else
- {
- extra = new int[]{ (data << 12) | (id & 0xFFF) };
- }
+ extra = new int[]{ id };
+ } else
+ {
+ extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
- break;
}
}
if ( extra == null )
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index db91503..6adc8f6 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -188,7 +188,7 @@ public class CraftEventFactory {
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
throw new IllegalArgumentException(String.format("%s performing %s with %s", who, action, itemstack)); // Spigot
}
- return callPlayerInteractEvent(who, action, new BlockPosition(0, 256, 0), EnumDirection.SOUTH, itemstack);
+ return callPlayerInteractEvent(who, action, /*new BlockPosition(0, 256, 0) KigPaper */ null, EnumDirection.SOUTH, itemstack);
}
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack) {
@@ -202,11 +202,11 @@ public class CraftEventFactory {
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
- Block blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ());
- BlockFace blockFace = CraftBlock.notchToBlockFace(direction);
-
- if (position.getY() > 255) {
- blockClicked = null;
+ // Block blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ()); // KigPaper
+ Block blockClicked = null;
+ if (position != null) {
+ blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ());
+ } else {
switch (action) {
case LEFT_CLICK_BLOCK:
action = Action.LEFT_CLICK_AIR;
@@ -217,6 +217,8 @@ public class CraftEventFactory {
}
}
+ BlockFace blockFace = CraftBlock.notchToBlockFace(direction); // KigPaper - moved down
+
if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
itemInHand = null;
}
@@ -532,7 +534,8 @@ public class CraftEventFactory {
} else if (source == DamageSource.FALL) {
cause = DamageCause.FALL;
} else if (source == DamageSource.GENERIC) {
- return new EntityDamageEvent(entity.getBukkitEntity(), null, modifiers, modifierFunctions);
+ //return new EntityDamageEvent(entity.getBukkitEntity(), null, modifiers, modifierFunctions);
+ cause = DamageCause.CUSTOM; // KigPaper
}
if (cause != null) {
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
index 0b5ada0..2463640 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -33,8 +33,10 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
static final ItemMetaKey BOOK_PAGES = new ItemMetaKey("pages");
static final ItemMetaKey RESOLVED = new ItemMetaKey("resolved");
static final ItemMetaKey GENERATION = new ItemMetaKey("generation");
- static final int MAX_PAGE_LENGTH = Short.MAX_VALUE; // TODO: Check me
- static final int MAX_TITLE_LENGTH = 0xffff;
+ static final int MAX_PAGES = 50;
+ static final int MAX_PAGE_LENGTH = 256;
+ static final int MAX_TITLE_LENGTH = 16;
+
protected String title;
protected String author;
@@ -61,11 +63,11 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
super(tag);
if (tag.hasKey(BOOK_TITLE.NBT)) {
- this.title = limit( tag.getString(BOOK_TITLE.NBT), 1024 ); // Spigot
+ this.title = limit( tag.getString(BOOK_TITLE.NBT), 32 ); // Spigot // KigPaper - tighter limits
}
if (tag.hasKey(BOOK_AUTHOR.NBT)) {
- this.author = limit( tag.getString(BOOK_AUTHOR.NBT), 1024 ); // Spigot
+ this.author = limit( tag.getString(BOOK_AUTHOR.NBT), 16 ); // Spigot // KigPaper - tighter limits
}
boolean resolved = false;
@@ -80,6 +82,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
if (tag.hasKey(BOOK_PAGES.NBT) && handlePages) {
NBTTagList pages = tag.getList(BOOK_PAGES.NBT, 8);
+ if (pages.size() > MAX_PAGES) return; // KigPaper - limit pages
for (int i = 0; i < pages.size(); i++) {
String page = pages.getString(i);
if (resolved) {
@@ -90,7 +93,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
// Ignore and treat as an old book
}
}
- addPage( limit( page, 2048 ) ); // Spigot
+ addPage( limit( page, MAX_PAGE_LENGTH ) ); // Spigot // KigPaper - tighter limits
}
}
}
@@ -103,13 +106,17 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
setTitle(SerializableMeta.getString(map, BOOK_TITLE.BUKKIT, true));
Iterable> pages = SerializableMeta.getObject(Iterable.class, map, BOOK_PAGES.BUKKIT, true);
+ // KigPaper start - limit pages
if(pages != null) {
+ int count = 0;
for (Object page : pages) {
+ if (count++ > MAX_PAGES) break;
if (page instanceof String) {
addPage((String) page);
}
}
}
+ // KigPaper end
generation = SerializableMeta.getObject(Integer.class, map, GENERATION.BUKKIT, true);
}
@@ -225,10 +232,14 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
public void addPage(final String... pages) {
for (String page : pages) {
+ if (this.pages.size() >= MAX_PAGES) {
+ return;
+ }
if (page == null) {
page = "";
} else if (page.length() > MAX_PAGE_LENGTH) {
- page = page.substring(0, MAX_PAGE_LENGTH);
+ //page = page.substring(0, MAX_PAGE_LENGTH);
+ return; // KigPaper
}
this.pages.add(CraftChatMessage.fromString(page, true)[0]);
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
index ad47bdd..7e43bdb 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
@@ -35,15 +35,17 @@ public class CraftMapRenderer extends MapRenderer {
cursors.removeCursor(cursors.getCursor(0));
}
- for (UUID key : worldMap.decorations.keySet()) { // Spigot string -> uuid.
- // If this cursor is for a player check visibility with vanish system
- Player other = Bukkit.getPlayer(key); // Spigot
- if (other != null && !player.canSee(other)) {
- continue;
+ if (getDrawCursors()) {
+ for (UUID key : worldMap.decorations.keySet()) { // Spigot string -> uuid.
+ // If this cursor is for a player check visibility with vanish system
+ Player other = Bukkit.getPlayer(key); // Spigot
+ if (other != null && !player.canSee(other)) {
+ continue;
+ }
+
+ MapIcon decoration = (MapIcon) worldMap.decorations.get(key);
+ cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType());
}
-
- MapIcon decoration = (MapIcon) worldMap.decorations.get(key);
- cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType());
}
}
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/SpecializedBlockMetadataStore.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/SpecializedBlockMetadataStore.java
new file mode 100644
index 0000000..920d968
--- /dev/null
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/SpecializedBlockMetadataStore.java
@@ -0,0 +1,175 @@
+package org.bukkit.craftbukkit.metadata;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.metadata.MetadataStore;
+import org.bukkit.metadata.MetadataValue;
+import org.bukkit.plugin.Plugin;
+
+import java.util.*;
+
+/**
+ * An alternative to {@link BlockMetadataStore} that uses specialized collections and bit-packing for faster
+ * operations and a lower memory footprint.
+ *
+ * This can be a drop-in replacement, though keep in mind methods will throw an {@link IllegalArgumentException}
+ * if invalid block coordinates are provided.
+ */
+public class SpecializedBlockMetadataStore implements MetadataStore {
+ // Allows storing 25 bits (up to 33,554,432 - MC supports up to 30,000,000) sign
+ private static final int MASK_26_BITS = 0b111_111_111_111_111_111_111_111_11;
+
+ private final Map> metadata = new HashMap<>();
+ private final World owningWorld;
+
+ // Cached key used for (synchronized) lookups, saves allocations.
+ // The key stored inside is usually cleared after use, so that the reference doesn't live too long.
+ private final StoreKey cachedKey = new StoreKey(null, 0);
+
+ public SpecializedBlockMetadataStore(World owningWorld) {
+ this.owningWorld = owningWorld;
+ }
+
+ @Override
+ public synchronized List getMetadata(Block block, String metadataKey) {
+ Preconditions.checkArgument(block.getWorld() == owningWorld, "block is from another world");
+
+ List list = Collections.emptyList();
+ Map pluginMetadata = getEntry(metadataKey, block);
+ if (pluginMetadata == null) {
+ return list;
+ }
+ list = ImmutableList.copyOf(pluginMetadata.values());
+
+ return list;
+ }
+
+ @Override
+ public synchronized boolean hasMetadata(Block block, String metadataKey) {
+ Preconditions.checkArgument(block.getWorld() == owningWorld, "block is from another world");
+ Map pluginMetadata = getEntry(metadataKey, block);
+ return pluginMetadata != null && !pluginMetadata.isEmpty();
+ }
+
+ @Override
+ public synchronized void removeMetadata(Block block, String metadataKey, Plugin owningPlugin) {
+ Preconditions.checkArgument(block.getWorld() == owningWorld, "block is from another world");
+ Preconditions.checkNotNull(owningPlugin, "plugin is null");
+
+ long id = getBlockId(block);
+ Map pluginMetadata = getEntry(metadataKey, id);
+ if (pluginMetadata == null) {
+ return;
+ }
+ // Clear empty entries
+ if (pluginMetadata.remove(owningPlugin) != null && pluginMetadata.isEmpty()) {
+ StoreKey key = getCachedKey(metadataKey, id);
+ this.metadata.remove(key);
+ key.metadataKey = null;
+ }
+ }
+
+ @Override
+ public synchronized void setMetadata(Block block, String metadataKey, MetadataValue newMetadataValue) {
+ Preconditions.checkArgument(block.getWorld() == owningWorld, "block is from another world");
+ Preconditions.checkNotNull(newMetadataValue, "value is null");
+ Plugin owningPlugin = newMetadataValue.getOwningPlugin();
+ Preconditions.checkNotNull(owningPlugin, "plugin is null");
+
+ Map entry = metadata.computeIfAbsent(new StoreKey(metadataKey, getBlockId(block)),
+ k -> new WeakHashMap<>(1));
+ entry.put(owningPlugin, newMetadataValue);
+ }
+
+ @Override
+ public synchronized void invalidateAll(Plugin owningPlugin) {
+ Preconditions.checkNotNull(owningPlugin, "plugin is null");
+ for (Map values : metadata.values()) {
+ MetadataValue value = values.get(owningPlugin);
+ if (value != null) {
+ value.invalidate();
+ }
+ }
+ }
+
+ private Map getEntry(String key, Block block) {
+ return getEntry(key, getBlockId(block));
+ }
+
+ private Map getEntry(String key, long id) {
+ StoreKey storeKey = getCachedKey(key, id);
+ Map ret = metadata.get(storeKey);
+ storeKey.metadataKey = null;
+ return ret;
+ }
+
+ private StoreKey getCachedKey(String metadataKey, long id) {
+ cachedKey.block = id;
+ cachedKey.metadataKey = metadataKey;
+ return cachedKey;
+ }
+
+ static long getBlockId(Block block) {
+ int x = block.getX();
+ int y = block.getY();
+ int z = block.getZ();
+ Preconditions.checkArgument(x >= -30_000_000 && x <= 30_000_000,
+ "block X out of range");
+ Preconditions.checkArgument(y >= 0 && y <= 255, "block Y out of range");
+ Preconditions.checkArgument(z >= -30_000_000 && z <= 30_000_000,
+ "block Z out of range");
+ // X (26 bits) + Y (8 bits) + Z (26 bits)
+ return ((long) (x & MASK_26_BITS) << 34) | ((long) (y & 0xFF) << 26) | (z & MASK_26_BITS);
+ }
+
+ /**
+ * Used for tests.
+ */
+ static Location toLocation(World world, long id) {
+ int x = (int) (id >> 34);
+ int y = (int) ((id >> 26) & 0xFF);
+ int z = (int) id;
+
+ // Restore sign
+ if ((x & (1 << 25)) > 0) {
+ x |= ~MASK_26_BITS;
+ } else {
+ x &= MASK_26_BITS;
+ }
+
+ if ((z & (1 << 25)) > 0) {
+ z |= ~MASK_26_BITS;
+ } else {
+ z &= MASK_26_BITS;
+ }
+
+ return new Location(world, x, y, z);
+ }
+
+ private static class StoreKey {
+ private String metadataKey;
+ private long block;
+
+ private StoreKey(String metadataKey, long block) {
+ this.metadataKey = metadataKey;
+ this.block = block;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ StoreKey storeKey = (StoreKey) o;
+ return block == storeKey.block && Objects.equal(metadataKey, storeKey.metadataKey);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(metadataKey, block);
+ }
+ }
+}
\ No newline at end of file
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/WorldMetadataStore.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/WorldMetadataStore.java
index dd37ed2..1077fab 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/WorldMetadataStore.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/metadata/WorldMetadataStore.java
@@ -10,7 +10,7 @@ import org.bukkit.metadata.MetadataStoreBase;
public class WorldMetadataStore extends MetadataStoreBase implements MetadataStore {
/**
* Generates a unique metadata key for a {@link World} object based on the world UID.
- * @see WorldMetadataStore#disambiguate(Object, String)
+ * @see WorldMetadataStore#disambiguate(World, String)
* @param world the world
* @param metadataKey The name identifying the metadata value
* @return a unique metadata key
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index d76ec40..1b0899b 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -32,7 +32,7 @@ import org.bukkit.scheduler.BukkitWorker;
* Changing the period on a task is delicate.
* Any future task needs to notify waiting threads.
* Async tasks must be synchronized to make sure that any thread that's finishing will remove itself from {@link #runners}.
- * Another utility method is provided for this, {@link #cancelTask(CraftTask)}
+ * Another utility method is provided for this, {@link #cancelTask(int)}
* {@link #runners} provides a moderately up-to-date view of active tasks.
* If the linked head to tail set is read, all remaining tasks that were active at the time execution started will be located in runners.
* Async tasks are responsible for removing themselves from runners
@@ -47,7 +47,7 @@ public class CraftScheduler implements BukkitScheduler {
*/
private final AtomicInteger ids = new AtomicInteger(1);
/**
- * Current head of linked-list. This reference is always stale, {@link CraftTask#next} is the live reference.
+ * Current head of linked-list. This reference is always stale, {@code CraftTask#next} is the live reference.
*/
private volatile CraftTask head = new CraftTask();
/**
diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index 38ef821..74f9799 100644
--- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -22,7 +22,8 @@ public final class CraftChatMessage {
private static final Pattern LINK_PATTERN = Pattern.compile("((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))");
private static class StringMessage {
private static final Map formatMap;
- private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))", Pattern.CASE_INSENSITIVE);
+ //private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))", Pattern.CASE_INSENSITIVE);
+ private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(§[0-9a-fk-or])|(\\n)|(https?://[^\\s/$.?#].[^\\s§]*)", Pattern.CASE_INSENSITIVE); // KigPaper - better regex
static {
Builder builder = ImmutableMap.builder();
diff --git a/TacoSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/TacoSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
index 6e9bec7..d4fe328 100644
--- a/TacoSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
+++ b/TacoSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
@@ -13,6 +13,7 @@ import java.util.logging.Level;
import net.minecraft.server.Item;
import net.minecraft.server.Items;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.RegionFile;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -227,4 +228,41 @@ public class PaperSpigotConfig
private static void saveEmptyScoreboardTeams() {
saveEmptyScoreboardTeams = getBoolean("save-empty-scoreboard-teams", false);
}
+
+ // KigPaper start
+ public static boolean betterVehicleHitboxes;
+ private static void betterVehicleHitboxes() {
+ betterVehicleHitboxes = getBoolean("better-vehicle-hitboxes", true);
+ }
+
+ public static boolean nettyReadTimeout;
+ private static void nettyReadTimeout() {
+ nettyReadTimeout = getBoolean("netty-read-timeout", true);
+ }
+
+ public static boolean savePlayerFiles;
+ private static void savePlayerFiles() {
+ savePlayerFiles = getBoolean("save-player-files", true);
+ }
+
+ public static boolean enableBookDeserialization;
+ private static void enableBookDeserialization() {
+ enableBookDeserialization = getBoolean("enable-book-deserialization", false);
+ }
+
+ public static boolean accurateBlockCollisions;
+ private static void accurateBlockCollisions() {
+ accurateBlockCollisions = getBoolean("accurate-block-collisions", true);
+ }
+
+ public static RegionFile.CompressionAlgorithm regionCompressionAlgorithm;
+ private static void regionCompressionAlgorithm() {
+ regionCompressionAlgorithm = RegionFile.CompressionAlgorithm.valueOf(getString("region-compression-algo", "ZLIB").toUpperCase(Locale.ROOT));
+ }
+
+ public static boolean kickChatMessageLength;
+ private static void kickChatMessageLength() {
+ kickChatMessageLength = getBoolean("kick-chat-message-length", false);
+ }
+ // KigPaper end
}
diff --git a/TacoSpigot-Server/src/main/java/org/spigotmc/ActivationRange.java b/TacoSpigot-Server/src/main/java/org/spigotmc/ActivationRange.java
index d3767d2..4b5f87d 100644
--- a/TacoSpigot-Server/src/main/java/org/spigotmc/ActivationRange.java
+++ b/TacoSpigot-Server/src/main/java/org/spigotmc/ActivationRange.java
@@ -67,7 +67,7 @@ public class ActivationRange
* These entities are excluded from Activation range checks.
*
* @param entity
- * @param world
+ * @param config
* @return boolean If it should always tick.
*/
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
diff --git a/TacoSpigot-Server/src/main/java/org/spigotmc/Metrics.java b/TacoSpigot-Server/src/main/java/org/spigotmc/Metrics.java
index f653050..bdecae2 100644
--- a/TacoSpigot-Server/src/main/java/org/spigotmc/Metrics.java
+++ b/TacoSpigot-Server/src/main/java/org/spigotmc/Metrics.java
@@ -344,7 +344,7 @@ public class Metrics {
*/
private void postPlugin(final boolean isPing) throws IOException {
// Server software specific section
- String pluginName = "TacoSpigot"; // PaperSpigot - We need some usage data // TacoSpigot - its *my* usage data
+ String pluginName = "eSpigot"; // PaperSpigot - We need some usage data // TacoSpigot - its *my* usage data // eSpigot
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();
diff --git a/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java b/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 8e86212..471d1aa 100644
--- a/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -191,10 +191,15 @@ public class SpigotWorldConfig
}
public boolean saveStructureInfo;
+ public boolean saveMineshaftStructureInfo; // Migot
private void structureInfo()
{
saveStructureInfo = getBoolean( "save-structure-info", true );
log( "Structure Info Saving: " + saveStructureInfo );
+ // Migot start
+ saveMineshaftStructureInfo = getBoolean( "save-mineshaft-structure-info", false);
+ log( "Mineshaft Structure Info Saving: " + saveMineshaftStructureInfo );
+ // Migot end
if ( !saveStructureInfo )
{
log( "*** WARNING *** You have selected to NOT save structure info. This may cause structures such as fortresses to not spawn mobs!" );
diff --git a/TacoSpigot-Server/src/main/java/org/spigotmc/WatchdogThread.java b/TacoSpigot-Server/src/main/java/org/spigotmc/WatchdogThread.java
index c8f619a..9fba1c7 100644
--- a/TacoSpigot-Server/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/TacoSpigot-Server/src/main/java/org/spigotmc/WatchdogThread.java
@@ -56,9 +56,8 @@ public class WatchdogThread extends Thread
{
Logger log = Bukkit.getServer().getLogger();
log.log( Level.SEVERE, "The server has stopped responding!" );
- log.log( Level.SEVERE, "Please report this to PaperSpigot directly!" );
- log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
- log.log( Level.SEVERE, "PaperSpigot version: " + Bukkit.getServer().getVersion() );
+ log.log( Level.SEVERE, "This is all alf's fault." );
+ log.log( Level.SEVERE, "Version: " + Bukkit.getServer().getVersion() );
//
if(net.minecraft.server.World.haveWeSilencedAPhysicsCrash)
{
diff --git a/TacoSpigot-Server/src/test/java/org/bukkit/craftbukkit/metadata/BlockMetadataTest.java b/TacoSpigot-Server/src/test/java/org/bukkit/craftbukkit/metadata/BlockMetadataTest.java
new file mode 100644
index 0000000..2427c90
--- /dev/null
+++ b/TacoSpigot-Server/src/test/java/org/bukkit/craftbukkit/metadata/BlockMetadataTest.java
@@ -0,0 +1,62 @@
+package org.bukkit.craftbukkit.metadata;
+
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.metadata.FixedMetadataValue;
+import org.bukkit.metadata.MetadataStore;
+import org.bukkit.metadata.MetadataValue;
+import org.bukkit.plugin.Plugin;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.util.List;
+
+public class BlockMetadataTest {
+ @Test
+ public void oldNewComparison() {
+ MetadataStore oldStore = new BlockMetadataStore(null);
+ MetadataStore newStore = new SpecializedBlockMetadataStore(null);
+ Plugin plugin = Mockito.mock(Plugin.class);
+
+ for (int x = 2, y = 0, z = 2, i = 0; i < 20; i++, x += 300, z += 200, y += 10) {
+ Block block = makeBlock(i % 2 == 0 ? x : -x, y, i % 2 == 0 ? z : -z);
+ MetadataValue value = new FixedMetadataValue(plugin, i);
+
+ oldStore.setMetadata(block, "test", value);
+ oldStore.setMetadata(block, "test" + i, value);
+ newStore.setMetadata(block, "test", value);
+ newStore.setMetadata(block, "test" + i, value);
+
+ Assert.assertTrue(newStore.hasMetadata(block, "test"));
+ Assert.assertTrue(newStore.hasMetadata(block, "test" + i));
+
+ List test = newStore.getMetadata(block, "test");
+ Assert.assertEquals(test, oldStore.getMetadata(block, "test"));
+ Assert.assertTrue("value in newStore[\"test\"]", test.contains(value));
+
+ List indexTest = newStore.getMetadata(block, "test" + i);
+ Assert.assertEquals(indexTest, oldStore.getMetadata(block, "test" + i));
+ Assert.assertTrue("value in newStore[\"test\" + i]", indexTest.contains(value));
+ }
+ }
+
+ @Test
+ public void compareIds() {
+ for (int x = 3, y = 1, z = 2, i = 0; i < 20; i++, x += 300, z += 200, y += 10) {
+ Block block = makeBlock(i % 2 == 0 ? x : -x, y, i % 2 == 0 ? z : -z);
+ Location location = new Location(null, block.getX(), block.getY(), block.getZ());
+
+ Assert.assertEquals(location, SpecializedBlockMetadataStore.toLocation(null,
+ SpecializedBlockMetadataStore.getBlockId(block)));
+ }
+ }
+
+ private static Block makeBlock(int x, int y, int z) {
+ Block block = Mockito.mock(Block.class);
+ Mockito.when(block.getX()).thenReturn(x);
+ Mockito.when(block.getY()).thenReturn(y);
+ Mockito.when(block.getZ()).thenReturn(z);
+ return block;
+ }
+}
\ No newline at end of file