Added a check to make sure the loader still exists when it's ticking (#9)

This commit is contained in:
OmerBenGera 2021-03-27 01:15:18 +03:00
parent 2ea46bcb15
commit d4c790c3a9
17 changed files with 79 additions and 23 deletions

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_10_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount = 0, minutesAmount = 0, secondsAmount = 0;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter {
setPosition(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_11_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter {
setPosition(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -207,6 +207,7 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_12_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -218,6 +219,8 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter {
setPosition(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -254,7 +257,7 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -177,6 +177,7 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_13_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -190,6 +191,8 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter {
setPosition(blockPosition);
setWorld(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -226,7 +229,7 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -177,6 +177,7 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter {
private final List<EntityHolograms_v1_13_R2> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -190,6 +191,8 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter {
setPosition(blockPosition);
setWorld(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -226,7 +229,7 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -185,6 +185,7 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_14_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -198,6 +199,8 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter {
setPosition(blockPosition);
setWorld(world);
loaderBlock = world.getType(blockPosition).getBlock();
try {
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
@ -244,7 +247,8 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
assert world != null;
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -185,6 +185,7 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_15_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -197,6 +198,8 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
setLocation(world, blockPosition);
loaderBlock = world.getType(blockPosition).getBlock();
try {
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
@ -243,7 +246,8 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
assert world != null;
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_16_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter {
setLocation(world, blockPosition);
loaderBlock = world.getType(blockPosition).getBlock();
try {
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
assert world != null;
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter {
private final List<EntityHolograms_v1_16_R2> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter {
setLocation(world, blockPosition);
loaderBlock = world.getType(blockPosition).getBlock();
try {
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
assert world != null;
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -187,6 +187,7 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter {
private final List<EntityHolograms_v1_16_R3> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -199,6 +200,8 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter {
setLocation(world, blockPosition);
loaderBlock = world.getType(blockPosition).getBlock();
try {
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
@ -245,7 +248,8 @@ public final class NMSAdapter_v1_16_R3 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
assert world != null;
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -183,19 +183,22 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter {
private static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
private final ChunkLoader chunkLoader;
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private boolean removed = false;
TileEntityChunkLoader(ChunkLoader chunkLoader, World world, int x, int y, int z){
this.chunkLoader = chunkLoader;
this.chunkLoader = (WChunkLoader) chunkLoader;
this.x = x;
this.y = y;
this.z = z;
a(world);
loaderBlock = world.getType(x, y, z);
tileEntityChunkLoaderMap.put(LongHash.toLong(x >> 4, z >> 4), this);
}
@ -206,12 +209,12 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter {
currentTick = 0;
if(((WChunkLoader) chunkLoader).isNotActive()){
if(chunkLoader.isNotActive() || world.getType(x, y, z) != loaderBlock){
chunkLoader.remove();
return;
}
((WChunkLoader) chunkLoader).tick();
chunkLoader.tick();
}
@Override

View File

@ -183,19 +183,22 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter {
private static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
private final ChunkLoader chunkLoader;
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private boolean removed = false;
TileEntityChunkLoader(ChunkLoader chunkLoader, World world, int x, int y, int z){
this.chunkLoader = chunkLoader;
this.chunkLoader = (WChunkLoader) chunkLoader;
this.x = x;
this.y = y;
this.z = z;
a(world);
loaderBlock = world.getType(x, y, z);
tileEntityChunkLoaderMap.put(LongHash.toLong(x >> 4, z >> 4), this);
}
@ -206,12 +209,12 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter {
currentTick = 0;
if(((WChunkLoader) chunkLoader).isNotActive()){
if(chunkLoader.isNotActive() || world.getType(x, y, z) != loaderBlock){
chunkLoader.remove();
return;
}
((WChunkLoader) chunkLoader).tick();
chunkLoader.tick();
}
@Override

View File

@ -187,6 +187,7 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_8_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -198,6 +199,8 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter {
a(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -234,7 +237,7 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter {
private final List<EntityHolograms_v1_8_R2> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter {
a(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter {
private final List<EntityHolograms_v1_8_R3> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter {
a(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter {
private final List<EntityHolograms_v1_9_R1> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter {
a(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}

View File

@ -184,6 +184,7 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter {
private final List<EntityHolograms_v1_9_R2> holograms = new ArrayList<>();
private final WChunkLoader chunkLoader;
private final Block loaderBlock;
private short currentTick = 20;
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
@ -195,6 +196,8 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter {
a(blockPosition);
a(world);
loaderBlock = world.getType(blockPosition).getBlock();
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -231,7 +234,7 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter {
currentTick = 0;
if(chunkLoader.isNotActive()){
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
chunkLoader.remove();
return;
}