From 6bf12d5e20333da728db43d986d9cde01262dd50 Mon Sep 17 00:00:00 2001 From: BONNe Date: Wed, 31 Jan 2024 05:32:13 +0200 Subject: [PATCH] Fixes EXP reset for players onJoin and onLeave (#2286) The total experience does not reset player collected exp. This fixes that, as it will set level to 0 and progress in towards next level to 0 --- .../bentobox/api/commands/admin/AdminDeleteCommand.java | 4 ++++ .../commands/island/team/IslandTeamInviteAcceptCommand.java | 4 ++++ .../java/world/bentobox/bentobox/managers/IslandsManager.java | 4 ++++ .../java/world/bentobox/bentobox/managers/PlayersManager.java | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java index f5988210c..117785ac8 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java @@ -109,6 +109,10 @@ private void cleanUp(User target) { // Reset the XP if (getIWM().isOnLeaveResetXP(getWorld())) { + // Player collected XP (displayed) + target.getPlayer().setLevel(0); + target.getPlayer().setExp(0); + // Player total XP (not displayed) target.getPlayer().setTotalExperience(0); } diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java index 576956b63..0d86ec37f 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java @@ -218,6 +218,10 @@ private void cleanPlayer(User user) { // Reset the XP if (getIWM().isOnJoinResetXP(getWorld())) { + // Player collected XP (displayed) + user.getPlayer().setLevel(0); + user.getPlayer().setExp(0); + // Player total XP (not displayed) user.getPlayer().setTotalExperience(0); } diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 3627912f6..b86cb3ac8 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -1177,6 +1177,10 @@ private void teleported(World world, User user, String name, boolean newIsland, // Reset the XP if (plugin.getIWM().isOnJoinResetXP(world)) { + // Player collected XP (displayed) + user.getPlayer().setLevel(0); + user.getPlayer().setExp(0); + // Player total XP (not displayed) user.getPlayer().setTotalExperience(0); } diff --git a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java index a39595825..007d67ba1 100644 --- a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java @@ -489,6 +489,10 @@ public void cleanLeavingPlayer(World world, User target, boolean kicked, Island // Reset the XP if (plugin.getIWM().isOnLeaveResetXP(world) && target.isPlayer()) { + // Player collected XP (displayed) + target.getPlayer().setLevel(0); + target.getPlayer().setExp(0); + // Player total XP (not displayed) target.getPlayer().setTotalExperience(0); } // Save player