Fixed NPE errors when loading chunk loaders after deleting player data

This commit is contained in:
OmerBenGera 2023-04-11 20:54:16 +03:00
parent 7da9f07005
commit ddb36f8d28
10 changed files with 30 additions and 18 deletions

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
@ -132,9 +133,9 @@ public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEn
}
private void updateName(EntityHologram hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class TileEntityChunkLoader extends TileEntity implements ITickable, ITileEntityChunkLoader {
@ -116,8 +117,9 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable
}
private void updateName(EntityHolograms hologram, String line) {
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -19,6 +19,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class TileEntityChunkLoader extends TileEntity implements ITickable, ITileEntityChunkLoader {
@ -130,9 +131,9 @@ public final class TileEntityChunkLoader extends TileEntity implements ITickable
}
private void updateName(EntityHolograms hologram, String line) {
assert chunkLoader.getWhoPlaced().getName() != null;
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public final class TileEntityChunkLoader extends TileEntity implements IUpdatePlayerListBox, ITileEntityChunkLoader {
@ -116,8 +117,9 @@ public final class TileEntityChunkLoader extends TileEntity implements IUpdatePl
}
private void updateName(EntityHolograms hologram, String line) {
String placerName = Optional.ofNullable(chunkLoader.getWhoPlaced().getName()).orElse("");
hologram.setHologramName(line
.replace("{0}", chunkLoader.getWhoPlaced().getName())
.replace("{0}", placerName)
.replace("{1}", daysAmount + "")
.replace("{2}", hoursAmount + "")
.replace("{3}", minutesAmount + "")