Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrote clearTeamInventory #848

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

sh0inx
Copy link
Contributor

@sh0inx sh0inx commented May 13, 2024

  • should now correctly ignore visitors (since visitors are technically members?)
  • should now remove data for offline players

hopefully fixes #847

- should now correctly ignore visitors (since visitors are technically members?)
- should now remove data for offline players

for(User user : island.getMembers()) {

if (user.getUserRank() == -1) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this is needed, island.getMembers() only returns a list of the island members which doesnt include visitors

Comment on lines +761 to +766
try{
user.getPlayer();
onlinePlayers.add(user);
} catch (Exception e) {
offlinePlayers.add(user);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try{
user.getPlayer();
onlinePlayers.add(user);
} catch (Exception e) {
offlinePlayers.add(user);
}
Player player = user.getPlayer();
if (player == null){
offlinePlayers.add(player);
} else {
onlinePlayers.add(player);
}

Comment on lines +774 to +798
for(User user : offlinePlayers) {

try {
File file = new File(Bukkit.getWorlds().get(0).getWorldFolder().getPath() + File.pathSeparator + "playerdata" + File.pathSeparator + user.getUuid() + ".dat");
NBTFile playerFile = new NBTFile(file);

if (IridiumSkyblock.getInstance().getConfiguration().clearInventoryOnRegen) {
NBTCompound compound = playerFile.getCompound("").getCompound("Inventory");
compound.clearNBT();
playerFile.save();
}

if (IridiumSkyblock.getInstance().getConfiguration().clearEnderChestOnRegen) {
NBTCompound compound = playerFile.getCompound("").getCompound("EnderItems");
compound.clearNBT();
playerFile.save();
}

} catch (IOException e) {
IridiumSkyblock.getInstance().getLogger().warning("Cannot mutate user: " + user.getName() + ". See stacktrace for details.");
IridiumSkyblock.getInstance().getLogger().warning(e.getMessage());
} catch (NullPointerException e) {
IridiumSkyblock.getInstance().getLogger().warning("Cannot mutate user: " + user.getName() + ". Either player or compound doesn't exist (See stacktrace for details).");
IridiumSkyblock.getInstance().getLogger().warning(e.getMessage());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this... why cant you access an offline player's inventory (Talking to the physical embodiment of the Spigot API here, not you)

@dlsf dlsf added the bug Something isn't working label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting island can remove itens from visiting players
3 participants