Beacon serialization

This commit is contained in:
Esophose 2019-04-13 20:45:54 -06:00
parent f665b2653d
commit a435d8fa34
2 changed files with 14 additions and 22 deletions

View File

@ -56,8 +56,10 @@ public final class BlockUtil {
blockData.setStateType(BlockStateType.BANNER.toString());
} else if (blockState instanceof Beacon) {
Beacon beacon = (Beacon) blockState;
blockData.setPotionEffect(
beacon.getPrimaryEffect().toString() + ":" + beacon.getSecondaryEffect().toString());
String primaryEffectName = beacon.getPrimaryEffect() != null ? beacon.getPrimaryEffect().toString() : "null";
String secondaryEffectName = beacon.getSecondaryEffect() != null ? beacon.getSecondaryEffect().toString() : "null";
blockData.setPotionEffect(primaryEffectName + ":" + secondaryEffectName);
for (int i = 0; i < beacon.getInventory().getSize(); i++) {
ItemStack is = beacon.getInventory().getItem(i);
@ -300,8 +302,13 @@ public final class BlockUtil {
} else if (blockTypeState == BlockStateType.BEACON) {
Beacon beacon = (Beacon) block.getState();
String[] potionEffect = blockData.getPotionEffect().split(":");
if (!potionEffect[0].equals("null")) {
beacon.setPrimaryEffect(PotionEffectType.getByName(potionEffect[0].toUpperCase()));
}
if (!potionEffect[1].equals("null")) {
beacon.setSecondaryEffect(PotionEffectType.getByName(potionEffect[1].toUpperCase()));
}
for (Integer slotList : blockData.getInventory().keySet()) {
if (slotList < beacon.getInventory().getSize()) {

View File

@ -47,12 +47,7 @@ public class WorldManager {
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(World.Environment.NORMAL)
.generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
@Override
public void run() {
registerMultiverse(normalWorldName, World.Environment.NORMAL);
}
});
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, World.Environment.NORMAL));
}
if (netherWorld == null) {
@ -61,12 +56,7 @@ public class WorldManager {
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(World.Environment.NETHER)
.generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
@Override
public void run() {
registerMultiverse(netherWorldName, World.Environment.NETHER);
}
});
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, World.Environment.NETHER));
}
if (endWorld == null) {
@ -75,12 +65,7 @@ public class WorldManager {
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(World.Environment.THE_END)
.generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
@Override
public void run() {
registerMultiverse(endWorldName, World.Environment.THE_END);
}
});
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(endWorldName, World.Environment.THE_END));
}
}