fixed time :3
This commit is contained in:
parent
b25e68ca14
commit
72f53f8aad
5 changed files with 38 additions and 32 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>de.lunarakai</groupId>
|
||||
<artifactId>Minecleaner</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.1.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Minecleaner</name>
|
||||
|
|
|
|||
|
|
@ -225,27 +225,6 @@ public class MinecleanerArena {
|
|||
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
|
||||
currentMinecleanerGame.start();
|
||||
showTextDisplay();
|
||||
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
||||
updateIngameInfoTexts();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 20L, 20L);
|
||||
}
|
||||
|
||||
if(plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
||||
updateIngameInfoTexts();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
|
||||
removeStartHeads();
|
||||
ingameTime = 0;
|
||||
|
|
@ -253,6 +232,21 @@ public class MinecleanerArena {
|
|||
hasMadeFirstClick = false;
|
||||
arenaStatus = ArenaStatus.PLAYING;
|
||||
currentGameStartTime = System.currentTimeMillis();
|
||||
|
||||
if((plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0
|
||||
|| plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) && arenaStatus == ArenaStatus.PLAYING) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
||||
ingameTime++;
|
||||
updateIngameInfoTexts();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
public void addJoiningPlayer(Player player) {
|
||||
|
|
@ -386,8 +380,7 @@ public class MinecleanerArena {
|
|||
private void updateIngameInfoTexts() {
|
||||
String timer = "";
|
||||
if(plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||
ingameTime += 1;
|
||||
timer = ChatColor.GOLD + " Zeit: " + MinecleanerStringUtil.timeToString((ingameTime/20)*1000) + " ";
|
||||
timer = ChatColor.GOLD + " Zeit: " + MinecleanerStringUtil.timeToString((ingameTime/20)*1000, true) + " ";
|
||||
}
|
||||
|
||||
if (textDisplay != null) {
|
||||
|
|
@ -401,6 +394,7 @@ public class MinecleanerArena {
|
|||
}
|
||||
textDisplay.text(Component.text(component + newLine + timer + filler));
|
||||
}
|
||||
|
||||
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0) {
|
||||
String componentActionBar = ChatColor.GREEN + "Flaggen gesetzt: " + flagsPlaced + ChatColor.RED + " Minen insgesamt: " + BoardSize.mineCounter[widthIndex];
|
||||
currentPlayer.sendActionBar(Component.text(componentActionBar + " " + timer));
|
||||
|
|
|
|||
|
|
@ -184,9 +184,9 @@ public class MinecleanerManager {
|
|||
if(sg != null) {
|
||||
ps.minScore(sg, millis, isUpdated -> {
|
||||
if(isUpdated != null && isUpdated) {
|
||||
player.sendMessage(ChatColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) );
|
||||
player.sendMessage(ChatColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis, false) );
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) + ChatColor.YELLOW + " erfolgreich lösen!");
|
||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis, false) + ChatColor.YELLOW + " erfolgreich lösen!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ public class StatsCommand extends SubCommand {
|
|||
sender.sendMessage(ChatColor.BLUE + " Dieser Monat: " + ChatColor.GREEN + totalWonMonth + " von " + totalSizeMonth + " (" + MinecleanerStringUtil.percentageString(totalWonMonth, totalSizeMonth)+ ")");
|
||||
Integer time = data.getBestTime(e.getKey());
|
||||
Integer timeThisMonth = data.getBestTimeThisMonth(e.getKey());
|
||||
sender.sendMessage(ChatColor.BLUE + " Bestzeit: " + ChatColor.GREEN + (time == null ? "-" : MinecleanerStringUtil.timeToString(time)));
|
||||
sender.sendMessage(ChatColor.BLUE + " Dieser Monat: " + ChatColor.GREEN + (timeThisMonth == null ? "-" : MinecleanerStringUtil.timeToString(timeThisMonth)));
|
||||
sender.sendMessage(ChatColor.BLUE + " Bestzeit: " + ChatColor.GREEN + (time == null ? "-" : MinecleanerStringUtil.timeToString(time, false)));
|
||||
sender.sendMessage(ChatColor.BLUE + " Dieser Monat: " + ChatColor.GREEN + (timeThisMonth == null ? "-" : MinecleanerStringUtil.timeToString(timeThisMonth, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ public class MinecleanerStringUtil {
|
|||
private MinecleanerStringUtil() {
|
||||
}
|
||||
|
||||
public static String timeToString(long millis) {
|
||||
public static String timeToString(long millis, boolean shorten) {
|
||||
int sec = (int) (millis / 1000);
|
||||
int min = sec / 60;
|
||||
int hours = min / 60;
|
||||
|
|
@ -12,19 +12,31 @@ public class MinecleanerStringUtil {
|
|||
min = min % 60;
|
||||
StringBuilder timeString = new StringBuilder();
|
||||
if (hours > 0) {
|
||||
timeString.append(hours).append(" Stunden");
|
||||
String hoursString = " Stunden";
|
||||
if(shorten) {
|
||||
hoursString = " h";
|
||||
}
|
||||
timeString.append(hours).append(hoursString);
|
||||
}
|
||||
if (min > 0 || !timeString.isEmpty()) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(", ");
|
||||
}
|
||||
timeString.append(min).append(" Minuten");
|
||||
String minString = " Minuten";
|
||||
if(shorten) {
|
||||
minString = " min";
|
||||
}
|
||||
timeString.append(min).append(minString);
|
||||
}
|
||||
if (sec > 0 || !timeString.isEmpty()) {
|
||||
if (!timeString.isEmpty()) {
|
||||
timeString.append(" und ");
|
||||
}
|
||||
timeString.append(sec).append(" Sekunden");
|
||||
String secondsString = " Sekunden";
|
||||
if(shorten) {
|
||||
secondsString = " s";
|
||||
}
|
||||
timeString.append(sec).append(secondsString);
|
||||
}
|
||||
return timeString.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue