Skip to content

Commit

Permalink
Version 1.2.1 - Dupe bug
Browse files Browse the repository at this point in the history
- implemented a check so the player exp can never be < 0.0 || > 1.0 because it can cause a duplication Bug
- version Bump

Took 25 minutes
  • Loading branch information
TubYoub committed Nov 21, 2024
1 parent 4b2227b commit 974dec8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.pluginz</groupId>
<artifactId>GravePlugin</artifactId>
<version>1.2</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>BT Graves</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/pluginz/graveplugin/GravePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Random;

public class GravePlugin extends JavaPlugin {
private final String version = "1.2";
private final String version = "1.2.1";
private final String project = "WGgaXko0";
private final int pluginId = 22622;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public void onPlayerDeath(PlayerDeathEvent event) {
ItemStack offHand = player.getInventory().getItemInOffHand();
int lvl = (int) (player.getLevel() * ((double) plugin.getConfigManager().getExpPercentage() / 100));
float xp = player.getExp();
// When the Grave saves a faulty xp it will cause a duplication bug
if (xp < 0 || xp > 1){
xp = 0;
}

if (!hasItems) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ public void run() {

Grave grave = graveManager.getGrave(graveId);
player.setLevel(player.getLevel() + grave.getLvl());
player.setExp(player.getExp() + grave.getExp());

float exp = player.getExp() + grave.getExp();
if (exp < 0 || exp > 1) {
exp = 0;
}
player.setExp(exp);

graveManager.removeGrave(graveId);
inventoryGraveMap.remove(inventory);
Expand Down

0 comments on commit 974dec8

Please sign in to comment.