betawawawawa release v1.0.0-BETA

This commit is contained in:
LunarAkai 2024-03-24 03:49:42 +01:00
commit e12642eb62
14 changed files with 190 additions and 142 deletions

View file

@ -156,16 +156,16 @@ public class MinecleanerArena {
double southGapFixZ = 0.0; double southGapFixZ = 0.0;
if(orientation == BlockFace.EAST) { if(orientation == BlockFace.EAST) {
rotation0 = 90; rotation0 = 90;
eastWestGapFixX = 0.55; eastWestGapFixX = 0.5;
eastWestGapFixZ = -0.46; eastWestGapFixZ = -0.55;
} else if(orientation == BlockFace.SOUTH) { } else if(orientation == BlockFace.SOUTH) {
rotation0 = 180; rotation0 = 180;
southGapFixX = 1.02; southGapFixX = 1.02;
southGapFixZ = 0.1; southGapFixZ = -0.05;
} else if(orientation == BlockFace.WEST) { } else if(orientation == BlockFace.WEST) {
rotation0 = 270; rotation0 = 270;
eastWestGapFixX = 0.5; eastWestGapFixX = 0.55;
eastWestGapFixZ = 0.5725; eastWestGapFixZ = 0.5;
} }
float rotation = rotation0; float rotation = rotation0;
@ -177,7 +177,6 @@ public class MinecleanerArena {
Location loc = location.clone(); Location loc = location.clone();
// todo: felder bisschen dichter an die wand
for(int fx = 0; fx < size; fx++) { for(int fx = 0; fx < size; fx++) {
final int fxf = fx; final int fxf = fx;
for(int fz = 0; fz < size; fz++) { for(int fz = 0; fz < size; fz++) {
@ -185,7 +184,7 @@ public class MinecleanerArena {
loc.set(location.getX() - 0.016 + eastWestGapFixX + southGapFixX - (d1x * fz) / 3.0 + d0x * 0.55 + d1x * 1.847, loc.set(location.getX() - 0.016 + eastWestGapFixX + southGapFixX - (d1x * fz) / 3.0 + d0x * 0.55 + d1x * 1.847,
location.getY() - 0.8225 + fxf / 3.0, location.getY() - 0.8225 + fxf / 3.0,
location.getZ() + 0.45 + eastWestGapFixZ + southGapFixZ - (d1z * fz) / 3.0 + d0z * 0.55 + d1z * 1.847); location.getZ() + 0.525 + eastWestGapFixZ + southGapFixZ - (d1z * fz) / 3.0 + d0z * 0.55 + d1z * 1.847);
Display blockDisplay = world.spawn(loc, ItemDisplay.class, blockdisplay -> { Display blockDisplay = world.spawn(loc, ItemDisplay.class, blockdisplay -> {
Transformation transformation = blockdisplay.getTransformation(); Transformation transformation = blockdisplay.getTransformation();
@ -270,6 +269,7 @@ public class MinecleanerArena {
currentMinecleanerGame.start(); currentMinecleanerGame.start();
flagsPlaced = 0; flagsPlaced = 0;
arenaStatus = ArenaStatus.PLAYING; arenaStatus = ArenaStatus.PLAYING;
currentGameStartTime = System.currentTimeMillis();
} }
public void addJoiningPlayer(Player player) { public void addJoiningPlayer(Player player) {
@ -468,7 +468,6 @@ public class MinecleanerArena {
} }
player.getLocation(tempLoc); player.getLocation(tempLoc);
double dist = tempLoc.distanceSquared(centerLocation); double dist = tempLoc.distanceSquared(centerLocation);
// todo: larger for bigger boards
switch (widthIndex) { switch (widthIndex) {
case 0: case 0:
return dist > 64.0; return dist > 64.0;
@ -512,9 +511,11 @@ public class MinecleanerArena {
return BoardSize.boardSizes[widthIndex]; return BoardSize.boardSizes[widthIndex];
} }
// Difficulty public long getCurrentGameStartTime() {
return currentGameStartTime;
}
public int getWidthIndex() { public int getWidthIndex() {
return widthIndex; return widthIndex;
} }
} }

View file

@ -31,7 +31,7 @@ public class MinecleanerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent e) { public void onPlayerInteract(PlayerInteractEvent e) {
// wenn (e.getHand != MainHand) return; if(e.getHand() != EquipmentSlot.HAND) return;
if((e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_BLOCK)) { if((e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
Block block = e.getClickedBlock(); Block block = e.getClickedBlock();
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(e.getPlayer()); MinecleanerArena arena = plugin.getArenaList().getPlayerArena(e.getPlayer());
@ -51,18 +51,14 @@ public class MinecleanerListener implements Listener {
if(r2 != null) { if(r2 != null) {
Vector hitPos = r2.getHitPosition(); Vector hitPos = r2.getHitPosition();
//Vector hitPos = rayTraceResult.getHitPosition();
Vector substract = new Vector(0.5, 0.5, 0.5); Vector substract = new Vector(0.5, 0.5, 0.5);
Location loc = hitPos.subtract(arena.getLocation().toVector()).subtract(substract).toLocation(player.getWorld()); //(0.5, 0.5, 0.5); // substract 0.5, 0.5, 0.5 Location loc = hitPos.subtract(arena.getLocation().toVector()).subtract(substract).toLocation(player.getWorld()); //(0.5, 0.5, 0.5); // substract 0.5, 0.5, 0.5
double lx = loc.getX(); double lx = loc.getX();
double ly = loc.getY(); double ly = loc.getY();
double lz = loc.getZ(); double lz = loc.getZ();
//player.sendMessage(ChatColor.GRAY + "lx: " + lx + " ,ly: " + ly + " ,lz: " + lz); double dy = ly + 1.5;
double dy = ly + 1.5; // 1.5 double dz = -d1x * lx - d1z * lz + 1.5;
//player.sendMessage(ChatColor.GRAY + "dy: " + dy);
double dz = -d1x * lx - d1z * lz + 1.5; // 1.5
//player.sendMessage(ChatColor.GRAY + "dz: " + dz);
double blockx = (dy / 3.0) * 9.0; double blockx = (dy / 3.0) * 9.0;
double blockz = (dz / 3.0) * 9.0; double blockz = (dz / 3.0) * 9.0;
@ -72,35 +68,13 @@ public class MinecleanerListener implements Listener {
blockx -= blockxInt; blockx -= blockxInt;
blockz -= blockzInt; blockz -= blockzInt;
/* boolean hasRightClicked = false;
if(lx < 0) { if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
blockxInt = blockxInt - (-blockxInt); hasRightClicked = true;
} else {
blockxInt = blockxInt - blockxInt;
}
if(lz < 0) {
blockzInt = blockzInt - (-blockzInt);
} else {
blockzInt = blockzInt - blockzInt;
}
*/
player.sendMessage(ChatColor.GRAY + "blockx: " + blockx + " ,blockz: " + blockz);
//player.sendMessage(ChatColor.GRAY + "blockxInt: " + blockxInt + " ,blockzInt: " + blockzInt);
if (blockx >= 0.1 && blockx <= 0.95 && blockz >= 0.0125 && blockz <= 0.98125) {
//if ((blockx >= 0.13 && blockx <= 0.9825 && blockx <= 0.12) && blockz >= 0.0125 && blockz <= 0.98125) {
boolean hasRightClicked = false;
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
hasRightClicked = true;
}
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked);
} }
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked);
} }
} }
} }
} else { } else {

View file

@ -26,6 +26,7 @@ import de.iani.cubesidestats.api.TimeFrame;
import de.iani.cubesideutils.bukkit.items.ItemStacks; import de.iani.cubesideutils.bukkit.items.ItemStacks;
import de.iani.playerUUIDCache.CachedPlayer; import de.iani.playerUUIDCache.CachedPlayer;
import de.lunarakai.minecleaner.game.BoardSize; import de.lunarakai.minecleaner.game.BoardSize;
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
public class MinecleanerManager { public class MinecleanerManager {
@ -34,14 +35,11 @@ public class MinecleanerManager {
private final HashMap<Integer, String> sizes; private final HashMap<Integer, String> sizes;
// Statistics // Statistics
private final StatisticKey statisticsGamesTotal; private final StatisticKey statisticsWonGamesTotal;
private final StatisticKey statisticsPointsAcquired; private final StatisticKey statisticsPointsAcquired;
// <BoardSize, StatisticKey>
private final HashMap<Integer, StatisticKey> statisticsGames; private final HashMap<Integer, StatisticKey> statisticsGames;
private final HashMap<Integer, StatisticKey> statisticsTimeRecord;
private int prevTick = 0; private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed;
public MinecleanerManager(MinecleanerPlugin plugin) { public MinecleanerManager(MinecleanerPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -51,29 +49,39 @@ public class MinecleanerManager {
this.sizes.put(1, "mittel"); this.sizes.put(1, "mittel");
this.sizes.put(2, "groß"); this.sizes.put(2, "groß");
// Deprecated
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?"); this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?");
this.confirmPlayingInventory.setItem(1, this.confirmPlayingInventory.setItem(1,
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen"))); ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
this.confirmPlayingInventory.setItem(3, this.confirmPlayingInventory.setItem(3,
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen"))); ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen")));
statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal");
statisticsWonGamesTotal.setIsMonthlyStats(true);
statisticsWonGamesTotal.setDisplayName("Runden gewonnen");
statisticsGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamesTotal"); statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointstotal");
statisticsGamesTotal.setIsMonthlyStats(true);
statisticsGamesTotal.setDisplayName("Runden gespielt");
statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointsTotal");
statisticsPointsAcquired.setIsMonthlyStats(true); statisticsPointsAcquired.setIsMonthlyStats(true);
statisticsPointsAcquired.setDisplayName("Punkte erspielt"); statisticsPointsAcquired.setDisplayName("Punkte erspielt");
statisticsGames = new HashMap<>(); statisticsGames = new HashMap<>();
statisticsTimeRecord = new HashMap<>();
statisticsTotalGamesPlayed = new HashMap<>();
for(Entry<Integer, String> e : this.sizes.entrySet()) { for(Entry<Integer, String> e : this.sizes.entrySet()) {
String sizeDisplay = e.getValue(); String sizeDisplay = e.getValue();
StatisticKey s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.games.boardsize." + e.getKey()); StatisticKey s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wongames.boardsize." + e.getKey());
s.setIsMonthlyStats(true); s.setIsMonthlyStats(true);
s.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay + " gespielt"); s.setDisplayName("Runden gewonnen auf Spielfeldgröße " + sizeDisplay);
statisticsGames.put(e.getKey(), s); statisticsGames.put(e.getKey(), s);
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamestotal.boardsize." + e.getKey());
s.setIsMonthlyStats(true);
s.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay );
statisticsTotalGamesPlayed.put(e.getKey(), s);
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.timerecord." + e.getKey());
s.setDisplayName("Bestzeit bei Größe " + sizeDisplay);
statisticsTimeRecord.put(e.getKey(), s);
} }
} }
@ -112,29 +120,44 @@ public class MinecleanerManager {
public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) { public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
World world = player.getWorld(); World world = player.getWorld();
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
StatisticKey sg;
if(!isSuccessfullyCleared) { if(!isSuccessfullyCleared) {
// angefangene Spiele zählen
world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f); world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Feld nicht erfolgreich lösen!"); player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Minecleaner-Feld nicht erfolgreich lösen!");
arena.showMines(); arena.showMines();
sg = statisticsTotalGamesPlayed.get(arena.getWidthIndex());
if(sg != null) {
ps.increaseScore(sg, 1);
}
Bukkit.getScheduler().runTaskLater(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () -> {
if(arena.getCurrentPlayer() == null) { if(arena.getCurrentPlayer() == null) {
arena.removePlayer(); arena.removePlayer();
} else { } else {
leaveArena(player, false); leaveArena(player, false);
} }
}, 100L); }, 100L);
return; return;
} }
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Feld erfolgreich lösen!"); int millis = (int) (System.currentTimeMillis() - arena.getCurrentGameStartTime());
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Minecleaner-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) + ChatColor.YELLOW + " erfolgreich lösen!");
world.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f); world.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId()); ps.increaseScore(statisticsWonGamesTotal, 1);
ps.increaseScore(statisticsGamesTotal, 1);
sg = statisticsGames.get(arena.getWidthIndex());
if(sg != null) {
ps.increaseScore(sg, 1);
}
sg = statisticsTimeRecord.get(arena.getWidthIndex());
if(sg != null) {
ps.minScore(sg, millis);
}
int wIndex = arena.getWidthIndex(); int wIndex = arena.getWidthIndex();
switch (wIndex) { switch (wIndex) {
@ -163,7 +186,6 @@ public class MinecleanerManager {
leaveArena(player, false); leaveArena(player, false);
} }
}, 100L); }, 100L);
} }
public void clearAllArenas() { public void clearAllArenas() {
@ -183,21 +205,11 @@ public class MinecleanerManager {
Preconditions.checkArgument(arena != null, "player is in no arena"); Preconditions.checkArgument(arena != null, "player is in no arena");
Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.PLAYING, "not running"); Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.PLAYING, "not running");
// Feels like a stupid solution for issue described in the next comment if(hasRightClicked) {
int currentTick = plugin.getServer().getCurrentTick(); arena.flagCell(x, y);
if(prevTick != currentTick) { } else {
// Fires Twice for Right Click on Same Tick, but only once for left click... stupid :< arena.revealCell(x, y);
if(hasRightClicked) {
// flag
//plugin.getLogger().log(Level.SEVERE, " Right Clicked @ Tick: " + plugin.getServer().getCurrentTick());
arena.flagCell(x, y);
} else {
// reveal
//plugin.getLogger().log(Level.SEVERE, " Left Clicked @ Tick: " + plugin.getServer().getCurrentTick());
arena.revealCell(x, y);
}
} }
prevTick = currentTick;
} }
public void getStatisticsForPlayer(OfflinePlayer player, Consumer<PlayerStatisticsData> callback) { public void getStatisticsForPlayer(OfflinePlayer player, Consumer<PlayerStatisticsData> callback) {
@ -205,28 +217,35 @@ public class MinecleanerManager {
PlayerStatistics pStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId()); PlayerStatistics pStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
PlayerStatisticsQueryKey kMatchesPlayed; PlayerStatisticsQueryKey kMatchesPlayed;
keys.add(kMatchesPlayed = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE)); keys.add(kMatchesPlayed = new PlayerStatisticsQueryKey(pStatistics, statisticsWonGamesTotal, QueryType.SCORE));
PlayerStatisticsQueryKey kMatchesPlayedMonth; PlayerStatisticsQueryKey kMatchesPlayedMonth;
keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE, TimeFrame.MONTH)); keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsWonGamesTotal, QueryType.SCORE, TimeFrame.MONTH));
HashMap<Integer, PlayerStatisticsQueryKey> kgamesPlayedSize = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kgamesPlayedSizeMonth = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kWonGamesPlayedSize = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kWonGamesPlayedSizeMonth = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kSizeTimeRecord = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayed = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayedMonth = new HashMap<>();
for (int i = 0; i < BoardSize.boardSizes.length; i++) { for (int i = 0; i < BoardSize.boardSizes.length; i++) {
PlayerStatisticsQueryKey qk; PlayerStatisticsQueryKey qk;
StatisticKey statisticKeyGames = statisticsGames.get(i); StatisticKey statisticKeyGames = statisticsGames.get(i);
keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE)); keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE));
kgamesPlayedSize.put(i, qk); kWonGamesPlayedSize.put(i, qk);
keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE, TimeFrame.MONTH)); keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE, TimeFrame.MONTH));
kgamesPlayedSizeMonth.put(i, qk); kWonGamesPlayedSizeMonth.put(i, qk);
// todo: StatisticKey statisticKeyTotalGames = statisticsTotalGamesPlayed.get(i);
// PlayerTime keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyTotalGames, QueryType.SCORE));
kSizeTotalGamesPlayed.put(i, qk);
keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyTotalGames, QueryType.SCORE, TimeFrame.MONTH));
kSizeTotalGamesPlayedMonth.put(i, qk);
StatisticKey statisticKeyTime = statisticsTimeRecord.get(i);
keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyTime, QueryType.SCORE));
kSizeTimeRecord.put(i, qk);
} }
PlayerStatisticsQueryKey kPointsAcquired; PlayerStatisticsQueryKey kPointsAcquired;
keys.add(kPointsAcquired = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE)); keys.add(kPointsAcquired = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE));
PlayerStatisticsQueryKey kPointsAcquiredMonth; PlayerStatisticsQueryKey kPointsAcquiredMonth;
@ -238,17 +257,30 @@ public class MinecleanerManager {
int pointsAcquiredTotal = c.getOrDefault(kPointsAcquired, 0); int pointsAcquiredTotal = c.getOrDefault(kPointsAcquired, 0);
int pointsAcquiredMonth = c.getOrDefault(kPointsAcquiredMonth, 0); int pointsAcquiredMonth = c.getOrDefault(kPointsAcquiredMonth, 0);
HashMap<Integer, Integer> sizeGames = new HashMap<>(); HashMap<Integer, Integer> sizeWonGames = new HashMap<>();
HashMap<Integer, Integer> sizeGamesMonth = new HashMap<>(); HashMap<Integer, Integer> sizeWonGamesMonth = new HashMap<>();
HashMap<Integer, Integer> sizeTimeRecord = new HashMap<>();
HashMap<Integer, Integer> sizeTotalGamesPlayed = new HashMap<>();
HashMap<Integer, Integer> sizeTotalGamesPlayedMonth = new HashMap<>();
for(int i = 0; i < BoardSize.boardSizes.length; i++) { for(int i = 0; i < BoardSize.boardSizes.length; i++) {
sizeGames.put(i, c.getOrDefault(kgamesPlayedSize.get(i), 0)); sizeWonGames.put(i, c.getOrDefault(kWonGamesPlayedSize.get(i), 0));
sizeGames.put(i, c.getOrDefault(kgamesPlayedSizeMonth.get(i), 0)); sizeWonGamesMonth.put(i, c.getOrDefault(kWonGamesPlayedSizeMonth.get(i), 0));
sizeTimeRecord.put(i, c.getOrDefault(kSizeTimeRecord.get(i), null));
sizeTotalGamesPlayed.put(i, c.getOrDefault(kSizeTotalGamesPlayed.get(i), 0));
sizeTotalGamesPlayedMonth.put(i, c.getOrDefault(kSizeTotalGamesPlayedMonth.get(i), 0));
} }
callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(), matchesPlayed, matchesPlayedMonth, callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(),
sizeGames, sizeGamesMonth, sizeTotalGamesPlayed,
pointsAcquiredTotal, pointsAcquiredMonth)); sizeTotalGamesPlayedMonth,
matchesPlayed,
matchesPlayedMonth,
sizeWonGames,
sizeWonGamesMonth,
pointsAcquiredTotal,
pointsAcquiredMonth,
sizeTimeRecord));
}); });
} }
@ -263,7 +295,7 @@ public class MinecleanerManager {
public void deleteScores(UUID playerId) { public void deleteScores(UUID playerId) {
PlayerStatistics statsPlayer = plugin.getCubesideStatistics().getStatistics(playerId); PlayerStatistics statsPlayer = plugin.getCubesideStatistics().getStatistics(playerId);
statsPlayer.deleteScore(statisticsGamesTotal); statsPlayer.deleteScore(statisticsWonGamesTotal);
statsPlayer.deleteScore(statisticsPointsAcquired); statsPlayer.deleteScore(statisticsPointsAcquired);
} }
} }

View file

@ -6,19 +6,32 @@ import java.util.UUID;
public class PlayerStatisticsData { public class PlayerStatisticsData {
private UUID playerUUID; private UUID playerUUID;
private String playerName; private String playerName;
private HashMap<Integer, Integer> totalGamesPlayedSize;
private HashMap<Integer, Integer> totalGamesPlayedSizeThisMonth;
private int gamesPlayed; private int gamesPlayed;
private int gamesPlayedThisMonth; private int gamesPlayedThisMonth;
private HashMap<Integer, Integer> gamesPlayedSize; private HashMap<Integer, Integer> gamesPlayedSize;
private HashMap<Integer, Integer> gamesPlayedSizeThisMonth; private HashMap<Integer, Integer> gamesPlayedSizeThisMonth;
private int pointsAcquiredTotal; private int pointsAcquiredTotal;
private int pointsAcquiredMonth; private int pointsAcquiredMonth;
private HashMap<Integer, Integer> bestTime;
public PlayerStatisticsData(UUID playerUUID, String playerName, int gamesPlayed, int gamesPlayedThisMonth, public PlayerStatisticsData(UUID playerUUID, String playerName,
HashMap<Integer, Integer> gamesPlayedSize, HashMap<Integer, Integer> gamesPlayedSizeThisMonth, HashMap<Integer, Integer> totalGamesPlayedSize,
int pointsAcquiredTotal, int pointsAcquiredMonth) { HashMap<Integer, Integer> totalGamesPlayedSizeThisMonth,
int gamesPlayed,
int gamesPlayedThisMonth,
HashMap<Integer, Integer> gamesPlayedSize,
HashMap<Integer, Integer> gamesPlayedSizeThisMonth,
int pointsAcquiredTotal,
int pointsAcquiredMonth,
HashMap<Integer, Integer> bestTime) {
this.playerUUID = playerUUID; this.playerUUID = playerUUID;
this.playerName = playerName; this.playerName = playerName;
this.totalGamesPlayedSize = totalGamesPlayedSize;
this.totalGamesPlayedSizeThisMonth = totalGamesPlayedSizeThisMonth;
this.gamesPlayed = gamesPlayed; this.gamesPlayed = gamesPlayed;
this.gamesPlayedThisMonth = gamesPlayedThisMonth; this.gamesPlayedThisMonth = gamesPlayedThisMonth;
@ -27,6 +40,8 @@ public class PlayerStatisticsData {
this.pointsAcquiredTotal = pointsAcquiredTotal; this.pointsAcquiredTotal = pointsAcquiredTotal;
this.pointsAcquiredMonth = pointsAcquiredMonth; this.pointsAcquiredMonth = pointsAcquiredMonth;
this.bestTime = bestTime;
} }
public UUID getPlayerID() { public UUID getPlayerID() {
@ -37,11 +52,21 @@ public class PlayerStatisticsData {
return playerName; return playerName;
} }
public int getGamesPlayed() { public int getTotalGamesPlayedSize(Integer widthIndex) {
Integer value = totalGamesPlayedSize.get(widthIndex);
return value == null ? 0 : value;
}
public int getTotalGamesPlayedSizeThisMonth(Integer widthIndex) {
Integer value = totalGamesPlayedSizeThisMonth.get(widthIndex);
return value == null ? 0 : value;
}
public int getWonGamesPlayed() {
return gamesPlayed; return gamesPlayed;
} }
public int getGamesPlayedThisMonth() { public int getWonGamesPlayedThisMonth() {
return gamesPlayedThisMonth; return gamesPlayedThisMonth;
} }
@ -63,4 +88,7 @@ public class PlayerStatisticsData {
return pointsAcquiredMonth; return pointsAcquiredMonth;
} }
public Integer getBestTime(Integer widthIndex) {
return bestTime.get(widthIndex);
}
} }

View file

@ -31,7 +31,6 @@ public class CreateCommand extends SubCommand {
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public String getUsage() { public String getUsage() {
return "<name> [noblocks] [widthindex]"; return "<name> [noblocks] [widthindex]";

View file

@ -2,7 +2,6 @@ package de.lunarakai.minecleaner.commands;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,6 +15,8 @@ import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
import de.iani.cubesideutils.commands.ArgsParser; import de.iani.cubesideutils.commands.ArgsParser;
import de.lunarakai.minecleaner.MinecleanerPlugin; import de.lunarakai.minecleaner.MinecleanerPlugin;
import de.lunarakai.minecleaner.PlayerStatisticsData; import de.lunarakai.minecleaner.PlayerStatisticsData;
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
import net.md_5.bungee.api.ChatColor;
public class StatsCommand extends SubCommand { public class StatsCommand extends SubCommand {
private final MinecleanerPlugin plugin; private final MinecleanerPlugin plugin;
@ -56,16 +57,22 @@ public class StatsCommand extends SubCommand {
sender.sendMessage(ChatColor.GREEN + "Minecleaner-Statitik von " + data.getPlayerName() + ":"); sender.sendMessage(ChatColor.GREEN + "Minecleaner-Statitik von " + data.getPlayerName() + ":");
} }
sender.sendMessage(ChatColor.BLUE + " Punkte erspielt: " + ChatColor.GREEN + data.getPointsAcquiredTotal() + " (Dieser Monat: " + data.getPointsAquiredMonth() + ")"); sender.sendMessage(ChatColor.BLUE + " Punkte erspielt: " + ChatColor.GREEN + data.getPointsAcquiredTotal() + " (Dieser Monat: " + data.getPointsAquiredMonth() + ")");
sender.sendMessage(ChatColor.BLUE + " Runden gespielt: " + ChatColor.GREEN + data.getGamesPlayed() + " (Dieser Monat: " + data.getGamesPlayedThisMonth() + ")"); sender.sendMessage(ChatColor.BLUE + " Runden gewonnen: " + ChatColor.GREEN + data.getWonGamesPlayed() + " (Dieser Monat: " + data.getWonGamesPlayedThisMonth() + ")");
for(Entry<Integer, String> e : plugin.getManager().getSizes().entrySet()) { for(Entry<Integer, String> e : plugin.getManager().getSizes().entrySet()) {
int totalSize = data.getGamesPlayedSize(e.getKey()); int totalWonSize = data.getGamesPlayedSize(e.getKey());
int totalWonMonth = data.getGamesPlayedSizeThisMonth(e.getKey());
int totalSize = data.getTotalGamesPlayedSize(e.getKey());
int totalSizeMonth = data.getTotalGamesPlayedSizeThisMonth(e.getKey());
if(totalSize > 0) { if(totalSize > 0) {
String sizeName = StringUtil.capitalizeFirstLetter(e.getValue(), false); String sizeName = StringUtil.capitalizeFirstLetter(e.getValue(), false);
sender.sendMessage(ChatColor.GREEN + " " + sizeName + ":"); sender.sendMessage(ChatColor.GREEN + " " + sizeName + ":");
sender.sendMessage(ChatColor.BLUE + " Runden gespielt: " + ChatColor.GREEN + totalSize + " (Dieser Monat: " + data.getGamesPlayedSizeThisMonth(e.getKey()) + ")"); sender.sendMessage(ChatColor.BLUE + " Runden gewonnen: " + ChatColor.GREEN + totalWonSize + " von " + totalSize + " (Dieser Monat: " + totalWonMonth + " von " + totalSizeMonth + ")");
Integer time = data.getBestTime(e.getKey());
sender.sendMessage(ChatColor.BLUE + " Bestzeit: " + ChatColor.GREEN + (time == null ? "-": MinecleanerStringUtil.timeToString(time)));
} }
}
}
} }
}; };
if(playerName == null) { if(playerName == null) {

View file

@ -4,7 +4,7 @@ public class BoardSize {
public static int[] boardSizes = { public static int[] boardSizes = {
9, 9,
12, 12,
15, // nicht größer als 24 15,
}; };
public static int[] mineCounter = { public static int[] mineCounter = {

View file

@ -10,7 +10,6 @@ public class Cell {
Number, Number,
} }
public Vector2i position; public Vector2i position;
public CellType type; public CellType type;
public int number; public int number;
@ -47,6 +46,4 @@ public class Cell {
public boolean isExploded() { public boolean isExploded() {
return exploded; return exploded;
} }
} }

View file

@ -7,7 +7,6 @@ import de.lunarakai.minecleaner.MinecleanerPlugin;
public class Game { public class Game {
public boolean gameover; public boolean gameover;
@SuppressWarnings("unused")
private MinecleanerPlugin plugin; private MinecleanerPlugin plugin;
private int width; private int width;
private int height; private int height;

View file

@ -25,7 +25,7 @@ public class Tilemap {
throw new IllegalArgumentException("Invalid coordinates"); throw new IllegalArgumentException("Invalid coordinates");
} }
} }
// Set method
public void setTile(Vector2i pos, Tile.TileType tileType) { public void setTile(Vector2i pos, Tile.TileType tileType) {
int x = pos.x(); int x = pos.x();
int y = pos.y(); int y = pos.y();

View file

@ -1,14 +0,0 @@
package de.lunarakai.minecleaner.utils;
import org.bukkit.entity.Display;
import de.lunarakai.minecleaner.game.Tile;
public class BoardUtils {
public static Display matchTileToBlockDisplay(Tile tile) {
switch (tile.getTileType()) {
case TileEmpty:
}
return null;
}
}

View file

@ -1,7 +0,0 @@
package de.lunarakai.minecleaner.utils;
public class MathUtils {
public static int clamp(int value, int min, int max) {
return Math.max(min, Math.min(max, value));
}
}

View file

@ -0,0 +1,32 @@
package de.lunarakai.minecleaner.utils;
public class MinecleanerStringUtil {
private MinecleanerStringUtil() {
}
public static String timeToString(long millis) {
int sec = (int) (millis / 1000);
int min = sec / 60;
int hours = min / 60;
sec = sec % 60;
min = min % 60;
StringBuilder timeString = new StringBuilder();
if (hours > 0) {
timeString.append(hours).append(" Stunden");
}
if (min > 0 || !timeString.isEmpty()) {
if (!timeString.isEmpty()) {
timeString.append(", ");
}
timeString.append(min).append(" Minuten");
}
if (sec > 0 || !timeString.isEmpty()) {
if (!timeString.isEmpty()) {
timeString.append(" und ");
}
timeString.append(sec).append(" Sekunden");
}
return timeString.toString();
}
}

View file

@ -5,7 +5,7 @@ api-version: '1.20'
commands: commands:
minecleaner: minecleaner:
description: main command description: main command
aliases: "mcl" aliases: ["mcl", "minesweeper"]
permissions: permissions: