Attempt to fix the Profiles unloading immediately on first join
This commit is contained in:
parent
5ad671cc73
commit
e1c522e7a1
4 changed files with 31 additions and 5 deletions
|
@ -17,6 +17,7 @@ base {
|
|||
java {
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -236,6 +237,7 @@ publishing {
|
|||
mavenJava(MavenPublication) {
|
||||
artifact jar
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
|
|
|
@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.10.010224.1940
|
||||
mod_version=1.10.010824.1717
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ForgeEventHandlers {
|
|||
@Override
|
||||
public void run() {
|
||||
// Check player wallet, then send wallet to client
|
||||
ModMessages.sendToPlayer(new S2CWalletInitialSyncPacket(player.getUUID()), player);
|
||||
//ModMessages.sendToPlayer(new S2CWalletInitialSyncPacket(player.getUUID()), player);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ public class ForgeEventHandlers {
|
|||
Profile px=null;
|
||||
try {
|
||||
px = Profile.get_profile_of(ev.getEntity().getStringUUID());
|
||||
Profile.unload(px);
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Profile.unload(px);
|
||||
}
|
||||
} catch (InvalidSideException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -16,6 +16,11 @@ import net.minecraft.nbt.NbtIo;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* A libZontreck user profile
|
||||
*<p></p>
|
||||
* This is used to contain common player data, as well as be capable of serializing the player's data and sending to/from the client.
|
||||
*/
|
||||
public class Profile {
|
||||
public String username;
|
||||
public String user_id;
|
||||
|
@ -78,6 +83,12 @@ public class Profile {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets, or loads from persistent data, the user's LibZ profile
|
||||
* @param UUID Player ID
|
||||
* @return Profile
|
||||
* @throws UserProfileNotYetExistsException When the profile has not yet been created
|
||||
*/
|
||||
public static Profile get_profile_of(String UUID) throws UserProfileNotYetExistsException
|
||||
{
|
||||
if(LibZontreck.PROFILES.containsKey(UUID)){
|
||||
|
@ -122,6 +133,11 @@ public class Profile {
|
|||
return new Profile(tag.getString("user"), tag.getString("prefix"), tag.getString("nick"), tag.getString("nickc"), tag.getString("id"), tag.getString("prefixc"), tag.getString("chatc"), tag.getBoolean("flying"), tag.getInt("vaults"), accessor, tag.getInt("deaths"), player, tag.getCompound("misc"), tag.getCompound("data"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new user profile.
|
||||
*
|
||||
* @param player The player to generate the profile for
|
||||
*/
|
||||
private static void generateNewProfile(ServerPlayer player)
|
||||
{
|
||||
|
||||
|
@ -133,10 +149,10 @@ public class Profile {
|
|||
Profile template = new Profile(player.getName().getString(), "Member", player.getDisplayName().getString(), ChatColor.GREEN, player.getStringUUID(), ChatColor.AQUA, ChatColor.WHITE, false, 0, ace, 0, player, new CompoundTag(), new CompoundTag());
|
||||
template.commit();
|
||||
|
||||
LibZontreck.PROFILES.put(player.getStringUUID(), template);
|
||||
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ProfileCreatedEvent(template));
|
||||
|
||||
template=null;
|
||||
return;
|
||||
}else {
|
||||
try {
|
||||
|
@ -166,6 +182,11 @@ public class Profile {
|
|||
prof=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a profile if it does not yet exist
|
||||
* @param play Player
|
||||
* @return The existing, or new, profile instance.
|
||||
*/
|
||||
public static Profile factory(ServerPlayer play)
|
||||
{
|
||||
try {
|
||||
|
@ -176,6 +197,9 @@ public class Profile {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the profile to disk
|
||||
*/
|
||||
public void commit()
|
||||
{
|
||||
// Save data to FileTree
|
||||
|
|
Reference in a new issue