plugin should now work without cubesidestatistics (if the server doesnt have the plugin)
This commit is contained in:
parent
0865e344f9
commit
bf13f7e2b9
4 changed files with 125 additions and 89 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>de.lunarakai</groupId>
|
||||
<artifactId>Minecleaner</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Minecleaner</name>
|
||||
|
|
|
|||
|
|
@ -240,10 +240,13 @@ public class MinecleanerArena {
|
|||
if(!currentMinecleanerGame.gameover) {
|
||||
ingameTime++;
|
||||
}
|
||||
if(plugin.isStatisticsEnabled()) {
|
||||
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0
|
||||
|| plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||
updateIngameInfoTexts();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
|
|
@ -382,9 +385,15 @@ public class MinecleanerArena {
|
|||
|
||||
public void updateIngameInfoTexts() {
|
||||
String timer = "";
|
||||
if(plugin.isStatisticsEnabled()) {
|
||||
if(plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||
timer = ChatColor.GOLD + " Zeit: " + MinecleanerStringUtil.timeToString((ingameTime/20)*1000, true) + " ";
|
||||
}
|
||||
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0 && plugin.isStatisticsEnabled()) {
|
||||
String componentActionBar = ChatColor.GREEN + "Flaggen gesetzt: " + flagsPlaced + ChatColor.RED + " Minen insgesamt: " + BoardSize.mineCounter[widthIndex];
|
||||
currentPlayer.sendActionBar(Component.text(componentActionBar + " " + timer));
|
||||
}
|
||||
}
|
||||
|
||||
if (textDisplay != null) {
|
||||
String component = ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --";
|
||||
|
|
@ -398,10 +407,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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeTextDisplay() {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class MinecleanerManager {
|
|||
|
||||
// Settings
|
||||
|
||||
|
||||
if(plugin.isStatisticsEnabled()) {
|
||||
minecleanerSettingTimerKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.timer");
|
||||
minecleanerSettingTimerKey.setDefault(0);
|
||||
minecleanerSettingTimerKey.setDisplayName("Timer");
|
||||
|
|
@ -111,8 +111,19 @@ public class MinecleanerManager {
|
|||
s.setDisplayName("Bestzeit bei Größe " + sizeDisplay);
|
||||
statisticsTimeRecord.put(e.getKey(), s);
|
||||
}
|
||||
} else {
|
||||
this.statisticsWonGamesTotal = null;
|
||||
this.statisticsPointsAcquired = null;
|
||||
this.statisticsGames = null;
|
||||
this.statisticsTimeRecord = null;
|
||||
this.statisticsTotalGamesPlayed = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void joinArena(Player player, MinecleanerArena arena) {
|
||||
if (!player.hasPermission(MinecleanerPlugin.PERMISSION_PLAY)) {
|
||||
return;
|
||||
|
|
@ -144,16 +155,19 @@ public class MinecleanerManager {
|
|||
|
||||
public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
|
||||
World world = player.getWorld();
|
||||
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||
StatisticKey sg;
|
||||
PlayerStatistics ps = null;
|
||||
StatisticKey sg = null;
|
||||
if(plugin.isStatisticsEnabled()) {
|
||||
ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||
sg = statisticsTotalGamesPlayed.get(arena.getWidthIndex());
|
||||
}
|
||||
|
||||
if(!isSuccessfullyCleared) {
|
||||
world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
||||
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das " + plugin.getDisplayedPluginName() + "-Feld nicht erfolgreich lösen!");
|
||||
arena.showMines();
|
||||
|
||||
if(sg != null) {
|
||||
if(sg != null && plugin.isStatisticsEnabled()) {
|
||||
ps.increaseScore(sg, 1);
|
||||
}
|
||||
|
||||
|
|
@ -170,10 +184,11 @@ public class MinecleanerManager {
|
|||
|
||||
world.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
|
||||
|
||||
if(sg != null) {
|
||||
if(sg != null && plugin.isStatisticsEnabled()) {
|
||||
ps.increaseScore(sg, 1);
|
||||
}
|
||||
|
||||
if(plugin.isStatisticsEnabled()) {
|
||||
ps.increaseScore(statisticsWonGamesTotal, 1);
|
||||
|
||||
sg = statisticsGames.get(arena.getWidthIndex());
|
||||
|
|
@ -213,6 +228,9 @@ public class MinecleanerManager {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis, false) + ChatColor.YELLOW + " erfolgreich lösen!");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if(arena.getCurrentPlayer() == null) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import de.lunarakai.minecleaner.commands.InfoCommand;
|
|||
import de.lunarakai.minecleaner.commands.ListCommand;
|
||||
import de.lunarakai.minecleaner.commands.StatsCommand;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class MinecleanerPlugin extends JavaPlugin {
|
||||
public static final String PERMISSION_PLAY = "minecleaner.play";
|
||||
public static final String PERMISSION_ADMIN = "minecleaner.admin";
|
||||
|
|
@ -29,7 +31,11 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
|||
|
||||
public void onLateEnable() {
|
||||
playerUUIDCache = (PlayerUUIDCache) getServer().getPluginManager().getPlugin("PlayerUUIDCache");
|
||||
if(getServer().getPluginManager().getPlugin("CubesideStatistics") != null) {
|
||||
cubesideStatistics = getServer().getServicesManager().load(CubesideStatisticsAPI.class);
|
||||
} else {
|
||||
this.getLogger().log(Level.WARNING, "Cubeside Statistics not found. No Statistics will be available");
|
||||
}
|
||||
|
||||
arenaList = new ArenaList(this);
|
||||
arenaList.load();
|
||||
|
|
@ -41,10 +47,13 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
|||
minecleanerCommand.addCommandMapping(new CreateCommand(this), "create");
|
||||
minecleanerCommand.addCommandMapping(new DeleteCommand(this), "delete");
|
||||
minecleanerCommand.addCommandMapping(new ListCommand(this), "list");
|
||||
minecleanerCommand.addCommandMapping(new InfoCommand(this), "info");
|
||||
|
||||
if(isStatisticsEnabled()) {
|
||||
minecleanerCommand.addCommandMapping(new SettingsCommand(this), "settings");
|
||||
minecleanerCommand.addCommandMapping(new StatsCommand(this), "stats");
|
||||
minecleanerCommand.addCommandMapping(new DeletePlayerScoreCommand(this), "deleteplayerscores");
|
||||
minecleanerCommand.addCommandMapping(new InfoCommand(this), "info");
|
||||
minecleanerCommand.addCommandMapping(new SettingsCommand(this), "settings");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,6 +71,9 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
|||
return minecleanerManager;
|
||||
}
|
||||
|
||||
public boolean isStatisticsEnabled() {
|
||||
return cubesideStatistics != null;
|
||||
}
|
||||
public CubesideStatisticsAPI getCubesideStatistics() {
|
||||
return cubesideStatistics;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue