Skip to content

Commit

Permalink
Show amount of levels player can receive from accepting xp offers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trophonix committed Jun 6, 2020
1 parent e8b232a commit 27bd791
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
17 changes: 14 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<groupId>com.trophonix</groupId>
<artifactId>TradePlus</artifactId>
<version>3.70</version>
<version>3.71</version>

<properties>
<res>${project.basedir}/res/</res>
<revision>3.70</revision>
<revision>3.71</revision>
</properties>

<repositories>
Expand Down Expand Up @@ -105,7 +105,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -204,6 +204,17 @@
</resources>

<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.12.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/trophonix/tradeplus/TradePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void loadConfig() {
config.set(
"extras.experience.material", Sounds.version < 113 ? "exp_bottle" : "experience_bottle");
config.set("extras.experience.display", "&aYour current XP offer is &2%AMOUNT%");
config.set("extras.experience.theirdisplay", "&aTheir current XP offer is &2%AMOUNT%");
config.set("extras.experience.theirdisplay", "&aTheir current XP offer is &2%AMOUNT% &a(+%LEVELS% levels)");
config.set(
"extras.experience.lore",
Arrays.asList("&fClick to edit your offer!", "&fYou have %BALANCE% XP."));
Expand Down Expand Up @@ -1038,6 +1038,12 @@ private void loadConfig() {
config.set("extras.votingplugin.taxpercent", 0);
}

if (configVersion < 3.71) {
if (!config.getString("extras.experience.theirdisplay").contains("%LEVELS%")) {
config.set("extras.experience.theirdisplay", config.getString("extras.experience.theirdisplay", "&aTheir current XP offer is &2%AMOUNT%") + " &a(+%LEVELS% levels)");
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ public ItemStack _getIcon(Player player) {
@Override
public ItemStack _getTheirIcon(Player player) {
return ItemFactory.replaceInMeta(
theirIcon, "%AMOUNT%", decimalFormat.format(player.equals(player1) ? value1 : value2));
theirIcon, "%AMOUNT%", decimalFormat.format(player.equals(player1) ? value1 : value2),
"%LEVELS%", Integer.toString(player.equals(player1) ? getLevelsFromXp(player2, value1) : getLevelsFromXp(player1, value2)));
}

private int getLevelsFromXp(Player receiver, double amount) {
int currentXp = XP.getExp(receiver);
double currentLevel = XP.getLevelFromExp(currentXp);
return (int)(XP.getLevelFromExp(currentXp + (int)amount) - currentLevel);
}

private void changeXp(Player player, Number amount) {
Expand Down

0 comments on commit 27bd791

Please sign in to comment.