Initial implementation for handling fake/wrong chunk unloads events

This commit is contained in:
filoghost 2016-08-29 11:11:52 +02:00
parent 435d455134
commit 108e1bb995
11 changed files with 86 additions and 18 deletions

View File

@ -32,5 +32,7 @@ public interface NMSManager {
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
public FancyMessage newFancyMessage(String text);
public boolean isUnloadUnsure(org.bukkit.Chunk bukkitChunk);
}

View File

@ -2,14 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
import java.lang.reflect.Method;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityTypes;
import net.minecraft.server.v1_10_R1.MathHelper;
import net.minecraft.server.v1_10_R1.World;
import net.minecraft.server.v1_10_R1.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.inventory.ItemStack;
@ -29,6 +25,12 @@ import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
import com.gmail.filoghost.holographicdisplays.util.Validator;
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityTypes;
import net.minecraft.server.v1_10_R1.MathHelper;
import net.minecraft.server.v1_10_R1.World;
import net.minecraft.server.v1_10_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private Method validateEntityMethod;
@ -143,5 +145,10 @@ public class NmsManagerImpl implements NMSManager {
public FancyMessage newFancyMessage(String text) {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ()) || !((CraftChunk) bukkitChunk).getHandle().d; // Field probably representing if the chunk is scheduled to be unloaded in ChunkProviderServer
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R1.MathHelper;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -160,4 +161,10 @@ public class NmsManagerImpl implements NMSManager {
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
throw new NotImplementedException("Method can only be used on 1.8 or higher");
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R2.MathHelper;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -160,4 +161,10 @@ public class NmsManagerImpl implements NMSManager {
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
throw new NotImplementedException("Method can only be used on 1.8 or higher");
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R3.MathHelper;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -160,4 +161,10 @@ public class NmsManagerImpl implements NMSManager {
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
throw new NotImplementedException("Method can only be used on 1.8 or higher");
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R4.MathHelper;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -160,4 +161,10 @@ public class NmsManagerImpl implements NMSManager {
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
throw new NotImplementedException("Method can only be used on 1.8 or higher");
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_8_R1.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -153,5 +154,10 @@ public class NmsManagerImpl implements NMSManager {
public FancyMessage newFancyMessage(String text) {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_8_R2.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -153,4 +154,9 @@ public class NmsManagerImpl implements NMSManager {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -2,14 +2,9 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R3;
import java.lang.reflect.Method;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.World;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -30,6 +25,12 @@ import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
import com.gmail.filoghost.holographicdisplays.util.Validator;
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.World;
import net.minecraft.server.v1_8_R3.WorldServer;
public class NmsManagerImpl implements NMSManager {
private Method validateEntityMethod;
@ -153,4 +154,9 @@ public class NmsManagerImpl implements NMSManager {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.server.v1_9_R1.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
import org.bukkit.inventory.ItemStack;
@ -144,4 +145,9 @@ public class NmsManagerImpl implements NMSManager {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ());
}
}

View File

@ -2,14 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_9_R2;
import java.lang.reflect.Method;
import net.minecraft.server.v1_9_R2.Entity;
import net.minecraft.server.v1_9_R2.EntityTypes;
import net.minecraft.server.v1_9_R2.MathHelper;
import net.minecraft.server.v1_9_R2.World;
import net.minecraft.server.v1_9_R2.WorldServer;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.inventory.ItemStack;
@ -29,6 +25,12 @@ import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
import com.gmail.filoghost.holographicdisplays.util.Validator;
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
import net.minecraft.server.v1_9_R2.Entity;
import net.minecraft.server.v1_9_R2.EntityTypes;
import net.minecraft.server.v1_9_R2.MathHelper;
import net.minecraft.server.v1_9_R2.World;
import net.minecraft.server.v1_9_R2.WorldServer;
public class NmsManagerImpl implements NMSManager {
private Method validateEntityMethod;
@ -143,5 +145,10 @@ public class NmsManagerImpl implements NMSManager {
public FancyMessage newFancyMessage(String text) {
return new FancyMessageImpl(text);
}
@Override
public boolean isUnloadUnsure(Chunk bukkitChunk) {
return bukkitChunk.getWorld().isChunkInUse(bukkitChunk.getX(), bukkitChunk.getZ()) || !((CraftChunk) bukkitChunk).getHandle().d; // Field probably representing if the chunk is scheduled to be unloaded in ChunkProviderServer
}
}