Patch a few null references
This commit is contained in:
parent
bd3e570097
commit
46142e36aa
8 changed files with 54 additions and 16 deletions
|
@ -6,6 +6,7 @@ import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
|||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.StarterKitDoesNotExistException;
|
||||
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -32,6 +33,7 @@ public class StarterContainer
|
|||
public UUID owner;
|
||||
private MinecraftServer server;
|
||||
public final UUID VaultID;
|
||||
private boolean invalid = false;
|
||||
public Starter main_accessor;
|
||||
public StarterContainer(ServerPlayer player) throws NoMoreVaultException {
|
||||
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
||||
|
@ -68,6 +70,7 @@ public class StarterContainer
|
|||
|
||||
public void commit()
|
||||
{
|
||||
if(invalid)return;
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the starter kit's contents..."), server);
|
||||
|
@ -98,8 +101,13 @@ public class StarterContainer
|
|||
main_accessor.delete();
|
||||
|
||||
|
||||
VaultModifiedEvent vme = new VaultModifiedEvent(-2, profile, VaultProvider.getInUse(profile), myInventory, startingInventory);
|
||||
OTEMod.bus.post(vme);
|
||||
//VaultModifiedEvent vme = new VaultModifiedEvent(-2, profile, 0, myInventory, startingInventory);
|
||||
//OTEMod.bus.post(vme);
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
invalid=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,4 +53,10 @@ public class StarterProvider extends OTEDatastore
|
|||
return v;
|
||||
}else return null;
|
||||
}
|
||||
|
||||
public static boolean exists()
|
||||
{
|
||||
Path v = FILE_TREE_PATH.resolve("starter.nbt");
|
||||
return v.toFile().exists();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class VaultContainer
|
|||
public final int VAULT_NUMBER;
|
||||
public final UUID VaultID;
|
||||
public Vault main_accessor;
|
||||
private boolean invalid;
|
||||
public VaultContainer(ServerPlayer player, int vaultNum) throws NoMoreVaultException {
|
||||
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
||||
startingInventory = new ItemStackHandler(64);
|
||||
|
@ -73,6 +74,7 @@ public class VaultContainer
|
|||
|
||||
public void commit()
|
||||
{
|
||||
if(invalid)return;
|
||||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
|
@ -106,4 +108,9 @@ public class VaultContainer
|
|||
OTEMod.bus.post(vme);
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
invalid=true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class VaultWatcher {
|
|||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
} else if(ev.getContainer() instanceof StarterMenu)
|
||||
|
@ -36,6 +37,7 @@ public class VaultWatcher {
|
|||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue