betawawawawa release v1.0.0-BETA
This commit is contained in:
		
					parent
					
						
							
								a8cd7272f5
							
						
					
				
			
			
				commit
				
					
						e12642eb62
					
				
			
		
					 14 changed files with 190 additions and 142 deletions
				
			
		|  | @ -156,16 +156,16 @@ public class MinecleanerArena { | |||
|         double southGapFixZ = 0.0; | ||||
|         if(orientation == BlockFace.EAST) { | ||||
|             rotation0 = 90; | ||||
|             eastWestGapFixX = 0.55; | ||||
|             eastWestGapFixZ = -0.46; | ||||
|             eastWestGapFixX = 0.5; | ||||
|             eastWestGapFixZ = -0.55; | ||||
|         } else if(orientation == BlockFace.SOUTH) { | ||||
|             rotation0 = 180; | ||||
|             southGapFixX = 1.02; | ||||
|             southGapFixZ = 0.1; | ||||
|             southGapFixZ = -0.05; | ||||
|         } else if(orientation == BlockFace.WEST) { | ||||
|             rotation0 = 270; | ||||
|             eastWestGapFixX = 0.5; | ||||
|             eastWestGapFixZ = 0.5725; | ||||
|             eastWestGapFixX = 0.55; | ||||
|             eastWestGapFixZ = 0.5; | ||||
|         } | ||||
| 
 | ||||
|         float rotation = rotation0; | ||||
|  | @ -176,8 +176,7 @@ public class MinecleanerArena { | |||
|         int d1z = d0x; | ||||
| 
 | ||||
|         Location loc = location.clone(); | ||||
| 
 | ||||
|         // todo: felder bisschen dichter an die wand | ||||
|          | ||||
|         for(int fx = 0; fx < size; fx++) { | ||||
|             final int fxf = fx; | ||||
|             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,  | ||||
|                     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 -> { | ||||
|                     Transformation transformation = blockdisplay.getTransformation(); | ||||
|  | @ -270,6 +269,7 @@ public class MinecleanerArena { | |||
|         currentMinecleanerGame.start(); | ||||
|         flagsPlaced = 0; | ||||
|         arenaStatus = ArenaStatus.PLAYING; | ||||
|         currentGameStartTime = System.currentTimeMillis(); | ||||
|     } | ||||
| 
 | ||||
|     public void addJoiningPlayer(Player player) { | ||||
|  | @ -468,7 +468,6 @@ public class MinecleanerArena { | |||
|         } | ||||
|         player.getLocation(tempLoc); | ||||
|         double dist = tempLoc.distanceSquared(centerLocation); | ||||
|         // todo: larger for bigger boards | ||||
|         switch (widthIndex) { | ||||
|             case 0: | ||||
|                 return dist > 64.0; | ||||
|  | @ -512,9 +511,11 @@ public class MinecleanerArena { | |||
|         return BoardSize.boardSizes[widthIndex]; | ||||
|     } | ||||
| 
 | ||||
|     // Difficulty | ||||
|     public long getCurrentGameStartTime() { | ||||
|         return currentGameStartTime; | ||||
|     } | ||||
| 
 | ||||
|     public int getWidthIndex() { | ||||
|         return widthIndex; | ||||
|     } | ||||
|      | ||||
|     }  | ||||
| } | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ public class MinecleanerListener implements Listener { | |||
| 
 | ||||
|     @EventHandler(priority = EventPriority.LOWEST)  | ||||
|     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)) { | ||||
|             Block block = e.getClickedBlock(); | ||||
|             MinecleanerArena arena = plugin.getArenaList().getPlayerArena(e.getPlayer()); | ||||
|  | @ -51,18 +51,14 @@ public class MinecleanerListener implements Listener { | |||
| 
 | ||||
|                         if(r2 != null) { | ||||
|                             Vector hitPos = r2.getHitPosition(); | ||||
|                             //Vector hitPos = rayTraceResult.getHitPosition(); | ||||
|                             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 | ||||
|                             double lx = loc.getX(); | ||||
|                             double ly = loc.getY(); | ||||
|                             double lz = loc.getZ(); | ||||
|                             //player.sendMessage(ChatColor.GRAY + "lx: " + lx + " ,ly: " + ly + " ,lz: " + lz); | ||||
|                             double dy = ly + 1.5; // 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 dy = ly + 1.5;  | ||||
|                             double dz = -d1x * lx - d1z * lz + 1.5; | ||||
| 
 | ||||
|                             double blockx = (dy / 3.0) * 9.0; | ||||
|                             double blockz = (dz / 3.0) * 9.0; | ||||
|  | @ -72,35 +68,13 @@ public class MinecleanerListener implements Listener { | |||
|                             blockx -= blockxInt; | ||||
|                             blockz -= blockzInt; | ||||
| 
 | ||||
|                             /* | ||||
|                             if(lx < 0) { | ||||
|                                 blockxInt = blockxInt - (-blockxInt); | ||||
|                             } 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); | ||||
|                             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); | ||||
|                         } | ||||
|                          | ||||
|                          | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ import de.iani.cubesidestats.api.TimeFrame; | |||
| import de.iani.cubesideutils.bukkit.items.ItemStacks; | ||||
| import de.iani.playerUUIDCache.CachedPlayer; | ||||
| import de.lunarakai.minecleaner.game.BoardSize; | ||||
| import de.lunarakai.minecleaner.utils.MinecleanerStringUtil; | ||||
| import net.md_5.bungee.api.ChatColor; | ||||
| 
 | ||||
| public class MinecleanerManager { | ||||
|  | @ -34,14 +35,11 @@ public class MinecleanerManager { | |||
|     private final HashMap<Integer, String> sizes; | ||||
| 
 | ||||
|     // Statistics | ||||
|     private final StatisticKey statisticsGamesTotal; | ||||
|     private final StatisticKey statisticsWonGamesTotal; | ||||
|     private final StatisticKey statisticsPointsAcquired; | ||||
| 
 | ||||
|     // <BoardSize, StatisticKey> | ||||
|     private final HashMap<Integer, StatisticKey> statisticsGames; | ||||
| 
 | ||||
|     private int prevTick = 0; | ||||
| 
 | ||||
|     private final HashMap<Integer, StatisticKey> statisticsTimeRecord; | ||||
|     private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed; | ||||
| 
 | ||||
|     public MinecleanerManager(MinecleanerPlugin plugin) { | ||||
|         this.plugin = plugin; | ||||
|  | @ -51,29 +49,39 @@ public class MinecleanerManager { | |||
|         this.sizes.put(1, "mittel"); | ||||
|         this.sizes.put(2, "groß"); | ||||
| 
 | ||||
|         // Deprecated | ||||
|         this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?"); | ||||
|         this.confirmPlayingInventory.setItem(1,  | ||||
|             ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen"))); | ||||
|         this.confirmPlayingInventory.setItem(3, | ||||
|             ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen"))); | ||||
| 
 | ||||
| 
 | ||||
|         statisticsGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamesTotal"); | ||||
|         statisticsGamesTotal.setIsMonthlyStats(true); | ||||
|         statisticsGamesTotal.setDisplayName("Runden gespielt"); | ||||
|         statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal"); | ||||
|         statisticsWonGamesTotal.setIsMonthlyStats(true); | ||||
|         statisticsWonGamesTotal.setDisplayName("Runden gewonnen"); | ||||
|          | ||||
|         statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointsTotal"); | ||||
|         statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointstotal"); | ||||
|         statisticsPointsAcquired.setIsMonthlyStats(true); | ||||
|         statisticsPointsAcquired.setDisplayName("Punkte erspielt"); | ||||
| 
 | ||||
|         statisticsGames = new HashMap<>(); | ||||
|         statisticsTimeRecord = new HashMap<>(); | ||||
|         statisticsTotalGamesPlayed = new HashMap<>(); | ||||
| 
 | ||||
|         for(Entry<Integer, String> e : this.sizes.entrySet()) { | ||||
|             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.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay +  " gespielt"); | ||||
|             s.setDisplayName("Runden gewonnen auf Spielfeldgröße " + sizeDisplay); | ||||
|             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,11 +120,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; | ||||
| 
 | ||||
|         if(!isSuccessfullyCleared) { | ||||
|             // angefangene Spiele zählen | ||||
|             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(); | ||||
|              | ||||
|             sg = statisticsTotalGamesPlayed.get(arena.getWidthIndex()); | ||||
| 
 | ||||
|             if(sg != null) { | ||||
|                 ps.increaseScore(sg, 1); | ||||
|             } | ||||
| 
 | ||||
|             Bukkit.getScheduler().runTaskLater(plugin, () -> { | ||||
|                 if(arena.getCurrentPlayer() == null) { | ||||
|  | @ -124,17 +140,24 @@ public class MinecleanerManager { | |||
|                  } else { | ||||
|                     leaveArena(player, false); | ||||
|                  } | ||||
|                  | ||||
|             }, 100L); | ||||
|             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); | ||||
| 
 | ||||
|         PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId()); | ||||
|         ps.increaseScore(statisticsGamesTotal, 1); | ||||
|         ps.increaseScore(statisticsWonGamesTotal, 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(); | ||||
|         switch (wIndex) { | ||||
|  | @ -163,7 +186,6 @@ public class MinecleanerManager { | |||
|                 leaveArena(player, false); | ||||
|             } | ||||
|         }, 100L); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public void clearAllArenas() { | ||||
|  | @ -183,21 +205,11 @@ public class MinecleanerManager { | |||
|         Preconditions.checkArgument(arena != null, "player is in no arena"); | ||||
|         Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.PLAYING, "not running"); | ||||
| 
 | ||||
|         // Feels like a stupid solution for issue described in the next comment | ||||
|         int currentTick = plugin.getServer().getCurrentTick(); | ||||
|         if(prevTick != currentTick) { | ||||
|             // Fires Twice for Right Click on Same Tick, but only once for left click... stupid :<  | ||||
|             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;        | ||||
|         if(hasRightClicked) { | ||||
|             arena.flagCell(x, y); | ||||
|         } else { | ||||
|             arena.revealCell(x, y); | ||||
|         }      | ||||
|     } | ||||
| 
 | ||||
|     public void getStatisticsForPlayer(OfflinePlayer player, Consumer<PlayerStatisticsData> callback) { | ||||
|  | @ -205,28 +217,35 @@ public class MinecleanerManager { | |||
|         PlayerStatistics pStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId()); | ||||
| 
 | ||||
|         PlayerStatisticsQueryKey kMatchesPlayed; | ||||
|         keys.add(kMatchesPlayed = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE)); | ||||
|         keys.add(kMatchesPlayed = new PlayerStatisticsQueryKey(pStatistics, statisticsWonGamesTotal, QueryType.SCORE)); | ||||
|         PlayerStatisticsQueryKey kMatchesPlayedMonth; | ||||
|         keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE, TimeFrame.MONTH)); | ||||
| 
 | ||||
|         HashMap<Integer, PlayerStatisticsQueryKey> kgamesPlayedSize = new HashMap<>(); | ||||
|         HashMap<Integer, PlayerStatisticsQueryKey> kgamesPlayedSizeMonth = new HashMap<>(); | ||||
| 
 | ||||
|         keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsWonGamesTotal, QueryType.SCORE, TimeFrame.MONTH)); | ||||
| 
 | ||||
|         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++) { | ||||
|             PlayerStatisticsQueryKey qk; | ||||
|             StatisticKey statisticKeyGames = statisticsGames.get(i); | ||||
|             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)); | ||||
|             kgamesPlayedSizeMonth.put(i, qk); | ||||
|             kWonGamesPlayedSizeMonth.put(i, qk); | ||||
| 
 | ||||
|             // todo: | ||||
|             //  PlayerTime | ||||
|             StatisticKey statisticKeyTotalGames = statisticsTotalGamesPlayed.get(i); | ||||
|             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; | ||||
|         keys.add(kPointsAcquired = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE)); | ||||
|         PlayerStatisticsQueryKey kPointsAcquiredMonth; | ||||
|  | @ -238,17 +257,30 @@ public class MinecleanerManager { | |||
|             int pointsAcquiredTotal = c.getOrDefault(kPointsAcquired, 0); | ||||
|             int pointsAcquiredMonth = c.getOrDefault(kPointsAcquiredMonth, 0); | ||||
| 
 | ||||
|             HashMap<Integer, Integer> sizeGames = new HashMap<>(); | ||||
|             HashMap<Integer, Integer> sizeGamesMonth = new HashMap<>(); | ||||
|             HashMap<Integer, Integer> sizeWonGames = 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++) { | ||||
|                 sizeGames.put(i, c.getOrDefault(kgamesPlayedSize.get(i), 0)); | ||||
|                 sizeGames.put(i, c.getOrDefault(kgamesPlayedSizeMonth.get(i), 0)); | ||||
|                 sizeWonGames.put(i, c.getOrDefault(kWonGamesPlayedSize.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, | ||||
|                 sizeGames, sizeGamesMonth, | ||||
|                 pointsAcquiredTotal, pointsAcquiredMonth)); | ||||
|             callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(),  | ||||
|                 sizeTotalGamesPlayed,  | ||||
|                 sizeTotalGamesPlayedMonth,  | ||||
|                 matchesPlayed,  | ||||
|                 matchesPlayedMonth,   | ||||
|                 sizeWonGames,  | ||||
|                 sizeWonGamesMonth,  | ||||
|                 pointsAcquiredTotal,  | ||||
|                 pointsAcquiredMonth, | ||||
|                 sizeTimeRecord)); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | @ -263,7 +295,7 @@ public class MinecleanerManager { | |||
| 
 | ||||
|     public void deleteScores(UUID playerId) { | ||||
|         PlayerStatistics statsPlayer = plugin.getCubesideStatistics().getStatistics(playerId); | ||||
|         statsPlayer.deleteScore(statisticsGamesTotal); | ||||
|         statsPlayer.deleteScore(statisticsWonGamesTotal); | ||||
|         statsPlayer.deleteScore(statisticsPointsAcquired); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -6,19 +6,32 @@ import java.util.UUID; | |||
| public class PlayerStatisticsData { | ||||
|     private UUID playerUUID; | ||||
|     private String playerName; | ||||
|     private HashMap<Integer, Integer> totalGamesPlayedSize; | ||||
|     private HashMap<Integer, Integer> totalGamesPlayedSizeThisMonth; | ||||
|     private int gamesPlayed; | ||||
|     private int gamesPlayedThisMonth; | ||||
|     private HashMap<Integer, Integer> gamesPlayedSize; | ||||
|     private HashMap<Integer, Integer> gamesPlayedSizeThisMonth; | ||||
|     private int pointsAcquiredTotal; | ||||
|     private int pointsAcquiredMonth; | ||||
|     private HashMap<Integer, Integer> bestTime; | ||||
| 
 | ||||
|     public PlayerStatisticsData(UUID playerUUID, String playerName, int gamesPlayed, int gamesPlayedThisMonth, | ||||
|         HashMap<Integer, Integer> gamesPlayedSize, HashMap<Integer, Integer> gamesPlayedSizeThisMonth,  | ||||
|         int pointsAcquiredTotal, int pointsAcquiredMonth) { | ||||
|     public PlayerStatisticsData(UUID playerUUID, String playerName,  | ||||
|         HashMap<Integer, Integer> totalGamesPlayedSize,  | ||||
|         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.playerName = playerName; | ||||
| 
 | ||||
|         this.totalGamesPlayedSize = totalGamesPlayedSize; | ||||
|         this.totalGamesPlayedSizeThisMonth = totalGamesPlayedSizeThisMonth; | ||||
| 
 | ||||
|         this.gamesPlayed = gamesPlayed; | ||||
|         this.gamesPlayedThisMonth = gamesPlayedThisMonth; | ||||
|          | ||||
|  | @ -27,6 +40,8 @@ public class PlayerStatisticsData { | |||
|          | ||||
|         this.pointsAcquiredTotal = pointsAcquiredTotal; | ||||
|         this.pointsAcquiredMonth = pointsAcquiredMonth; | ||||
| 
 | ||||
|         this.bestTime = bestTime; | ||||
|     } | ||||
| 
 | ||||
|     public UUID getPlayerID() { | ||||
|  | @ -37,11 +52,21 @@ public class PlayerStatisticsData { | |||
|         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; | ||||
|     } | ||||
| 
 | ||||
|     public int getGamesPlayedThisMonth() { | ||||
|     public int getWonGamesPlayedThisMonth() { | ||||
|         return gamesPlayedThisMonth; | ||||
|     } | ||||
| 
 | ||||
|  | @ -62,5 +87,8 @@ public class PlayerStatisticsData { | |||
|     public int getPointsAquiredMonth() { | ||||
|         return pointsAcquiredMonth; | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     public Integer getBestTime(Integer widthIndex) { | ||||
|         return bestTime.get(widthIndex); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -31,7 +31,6 @@ public class CreateCommand extends SubCommand { | |||
|         this.plugin = plugin; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     @Override | ||||
|     public String getUsage() { | ||||
|         return "<name> [noblocks] [widthindex]"; | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ package de.lunarakai.minecleaner.commands; | |||
| 
 | ||||
| import java.util.Map.Entry; | ||||
| import java.util.function.Consumer; | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.command.Command; | ||||
| import org.bukkit.command.CommandSender; | ||||
| 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.lunarakai.minecleaner.MinecleanerPlugin; | ||||
| import de.lunarakai.minecleaner.PlayerStatisticsData; | ||||
| import de.lunarakai.minecleaner.utils.MinecleanerStringUtil; | ||||
| import net.md_5.bungee.api.ChatColor; | ||||
| 
 | ||||
| public class StatsCommand extends SubCommand { | ||||
|     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.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()) { | ||||
|                     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) { | ||||
|                         String sizeName = StringUtil.capitalizeFirstLetter(e.getValue(), false); | ||||
|                         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) { | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ public class BoardSize { | |||
|     public static int[] boardSizes = { | ||||
|             9, | ||||
|             12, | ||||
|             15, // nicht größer als 24 | ||||
|             15, | ||||
|     }; | ||||
| 
 | ||||
|     public static int[] mineCounter = { | ||||
|  |  | |||
|  | @ -10,7 +10,6 @@ public class Cell { | |||
|         Number, | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public Vector2i position; | ||||
|     public CellType type; | ||||
|     public int number; | ||||
|  | @ -47,6 +46,4 @@ public class Cell { | |||
|     public boolean isExploded() { | ||||
|         return exploded; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import de.lunarakai.minecleaner.MinecleanerPlugin; | |||
| public class Game { | ||||
|     public boolean gameover; | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     private MinecleanerPlugin plugin;  | ||||
|     private int width; | ||||
|     private int height; | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ public class Tilemap { | |||
|             throw new IllegalArgumentException("Invalid coordinates"); | ||||
|         } | ||||
|     } | ||||
|     // Set method | ||||
|      | ||||
|     public void setTile(Vector2i pos, Tile.TileType tileType) { | ||||
|         int x = pos.x(); | ||||
|         int y = pos.y(); | ||||
|  |  | |||
|  | @ -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; | ||||
|     } | ||||
| } | ||||
|  | @ -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)); | ||||
|     } | ||||
| } | ||||
|  | @ -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(); | ||||
|     } | ||||
|      | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue