change to (hopefully) prevent index out of bounds exception + return "-" when fromPercentage == 0
This commit is contained in:
parent
335b4cfab1
commit
c8978e2625
4 changed files with 12 additions and 3 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>de.lunarakai</groupId>
|
<groupId>de.lunarakai</groupId>
|
||||||
<artifactId>Minecleaner</artifactId>
|
<artifactId>Minecleaner</artifactId>
|
||||||
<version>1.0.3c</version>
|
<version>1.0.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Minecleaner</name>
|
<name>Minecleaner</name>
|
||||||
|
|
|
||||||
|
|
@ -600,10 +600,12 @@ public class MinecleanerArena {
|
||||||
return blockDisplays;
|
return blockDisplays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getArenaWidth() {
|
||||||
return BoardSize.boardSizesWidth[widthIndex];
|
return BoardSize.boardSizesWidth[widthIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getArenaHeight() { return BoardSize.boardSizesHeight[widthIndex]; }
|
||||||
|
|
||||||
public long getCurrentGameStartTime() {
|
public long getCurrentGameStartTime() {
|
||||||
return currentGameStartTime;
|
return currentGameStartTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,12 @@ public class MinecleanerListener implements Listener {
|
||||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
hasRightClicked = true;
|
hasRightClicked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(blockzInt < arena.getArenaWidth() && blockxInt < arenaClicked.getArenaHeight()) {
|
||||||
|
plugin.getManager().handleFieldClick(e.getPlayer(), blockzInt, blockxInt, hasRightClicked);
|
||||||
|
}
|
||||||
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
||||||
plugin.getManager().handleFieldClick(e.getPlayer(), blockzInt, blockxInt, hasRightClicked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ public class MinecleanerStringUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String percentageString(int whatPercentage, int fromPercentage) {
|
public static String percentageString(int whatPercentage, int fromPercentage) {
|
||||||
|
if(fromPercentage == 0) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
float percent = (float) whatPercentage/fromPercentage;
|
float percent = (float) whatPercentage/fromPercentage;
|
||||||
percent = percent * 100;
|
percent = percent * 100;
|
||||||
String percentageString = String.format("%.1f", percent);
|
String percentageString = String.format("%.1f", percent);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue