stats
This commit is contained in:
		
					parent
					
						
							
								c32314b787
							
						
					
				
			
			
				commit
				
					
						a8cd7272f5
					
				
			
		
					 6 changed files with 98 additions and 42 deletions
				
			
		|  | @ -121,8 +121,6 @@ public class MinecleanerArena { | |||
| 
 | ||||
|         BlockData block0 = Material.NETHER_BRICKS.createBlockData(); | ||||
|         BlockData block1 = Material.BRICKS.createBlockData(); | ||||
|         // todo: larger grids | ||||
| 
 | ||||
| 
 | ||||
|         for (int fx = -1 - widthIndex; fx < 2 ; fx++) { | ||||
|             for (int fy = -1; fy < 2 + widthIndex; fy++) { | ||||
|  | @ -133,7 +131,6 @@ public class MinecleanerArena { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* | ||||
|      *  Bei Größen WidthIndex 1 + 2 -> Mitte = ein Block nach Links unten versetzt  | ||||
|      */ | ||||
|  | @ -171,8 +168,6 @@ public class MinecleanerArena { | |||
|             eastWestGapFixZ = 0.5725; | ||||
|         } | ||||
| 
 | ||||
|          | ||||
| 
 | ||||
|         float rotation = rotation0; | ||||
|          | ||||
|         int d0x = orientation.getModX(); | ||||
|  | @ -181,19 +176,17 @@ 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++) { | ||||
|                 final int fzf = fz; | ||||
|                 // Todo not correctly alligned at different orientations (other than NORTH) | ||||
| 
 | ||||
|                 //loc.set(location.getX() + 0.11 - (d1x * fz) / 3.0 + d0x * 0.501 + d1x * 1.847, location.getY() - 0.9725 + fxf / 3.0, location.getZ() + 0.45 - (d1z * fz) / 3.0 + d0z * 0.501 + d1z * 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.getZ() + 0.45 + eastWestGapFixZ  + southGapFixZ - (d1z * fz) / 3.0 + d0z * 0.55 + d1z * 1.847); | ||||
| 
 | ||||
|                 // Todo: Z-Fighting on Unknown Tile Heads && Flags(Front)  | ||||
|                 // Todo: Z-Fighting on the Sides for all Tiles | ||||
|                 Display blockDisplay = world.spawn(loc, ItemDisplay.class, blockdisplay -> { | ||||
|                     Transformation transformation = blockdisplay.getTransformation(); | ||||
|                     Transformation newTransform; | ||||
|  | @ -230,6 +223,7 @@ public class MinecleanerArena { | |||
|         //     textdisplay.setTransformation(newTransformation); | ||||
|         //     textdisplay.setRotation(rotation, 0); | ||||
| 
 | ||||
|         //      billboardmode = fixed | ||||
|         //     textdisplay.setVisibleByDefault(true); | ||||
|         //     textdisplay.setDisplayHeight(3); | ||||
|         //     textdisplay.setDisplayWidth(9); | ||||
|  | @ -318,29 +312,20 @@ public class MinecleanerArena { | |||
|         if(currentMinecleanerGame != null && !currentMinecleanerGame.gameover) { | ||||
|             Cell cell = currentMinecleanerGame.getCell(x, y); | ||||
|             if(!cell.isRevealed()) { | ||||
|                  | ||||
|                 Player player = this.currentPlayer; | ||||
|              | ||||
| 
 | ||||
|                 currentMinecleanerGame.flag(x, y); | ||||
|                 if(currentMinecleanerGame.gameover) { | ||||
|                     plugin.getManager().handleGameover(player, this, true); | ||||
|                 } | ||||
|                  | ||||
|                 //plugin.getLogger().log(Level.SEVERE, "  Is Flagged (before first if): " + cell.isFlagged()); | ||||
|          | ||||
|                 if(cell.isFlagged() == true) { | ||||
|                     //plugin.getLogger().log(Level.SEVERE, "Flagged Cell: [" + cell.position.x + "," + cell.position.y + "]"); | ||||
|                     flagsPlaced = flagsPlaced + 1; | ||||
|                     sendActionBarMessage(player); | ||||
|                     setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG); | ||||
| 
 | ||||
|                 }  | ||||
|                  | ||||
|                 //plugin.getLogger().log(Level.SEVERE, "  Is Flagged (before second if): " + cell.isFlagged());  | ||||
| 
 | ||||
|                 if(cell.isFlagged() == false) { | ||||
|                     //plugin.getLogger().log(Level.SEVERE, "Unflagged Cell: [" + cell.position.x + "," + cell.position.y + "]"); | ||||
|                     flagsPlaced = flagsPlaced - 1; | ||||
|                     sendActionBarMessage(player); | ||||
|                     setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN); | ||||
|  | @ -353,8 +338,7 @@ public class MinecleanerArena { | |||
|     public void revealCell(int x, int y) { | ||||
|         if(currentMinecleanerGame != null && !currentMinecleanerGame.gameover) { | ||||
|             Cell cell = currentMinecleanerGame.getCell(x, y); | ||||
|             if(!cell.isFlagged()) { | ||||
|                  //int id = x + y * 9;             | ||||
|             if(!cell.isFlagged()) {            | ||||
|                 Player player = this.currentPlayer; | ||||
|                  | ||||
|                 currentMinecleanerGame.reveal(x, y); | ||||
|  | @ -450,7 +434,6 @@ public class MinecleanerArena { | |||
|                 } else { | ||||
|                     setDiplayBlock(x, y, MinecleanerHeads.TNT); | ||||
|                 } | ||||
| 
 | ||||
|                 break; | ||||
|             } | ||||
|             default: { | ||||
|  | @ -470,13 +453,12 @@ public class MinecleanerArena { | |||
| 
 | ||||
|         Location loc = location.clone(); | ||||
| 
 | ||||
|         for(int fx = -2 - widthIndex; fx < 1 ; fx++) { | ||||
|         for(int fx = -1 - widthIndex; fx < 2; fx++) { | ||||
|             for(int fy = -1; fy < 2 + widthIndex; fy++) { | ||||
|                 loc.set(location.getX() + d1x + fx, location.getY() + fy, location.getZ() + d1z * fx); | ||||
|                 loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx); | ||||
|                 blocks.add(loc.clone()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return blocks; | ||||
|     } | ||||
| 
 | ||||
|  | @ -486,6 +468,15 @@ public class MinecleanerArena { | |||
|         } | ||||
|         player.getLocation(tempLoc); | ||||
|         double dist = tempLoc.distanceSquared(centerLocation); | ||||
|         // todo: larger for bigger boards | ||||
|         switch (widthIndex) { | ||||
|             case 0: | ||||
|                 return dist > 64.0; | ||||
|             case 1: | ||||
|                 return dist > 96.0; | ||||
|             case 2: | ||||
|                 return dist > 128.0; | ||||
|         } | ||||
|         return dist > 64.0; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ public class MinecleanerListener implements Listener { | |||
| 
 | ||||
|     @EventHandler(priority = EventPriority.LOWEST)  | ||||
|     public void onPlayerInteract(PlayerInteractEvent e) { | ||||
|         // wenn (e.getHand != MainHand) 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()); | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| package de.lunarakai.minecleaner; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.UUID; | ||||
| import java.util.function.Consumer; | ||||
| import org.bukkit.Bukkit; | ||||
|  | @ -23,20 +25,31 @@ import de.iani.cubesidestats.api.StatisticsQueryKey; | |||
| 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 net.md_5.bungee.api.ChatColor; | ||||
| 
 | ||||
| public class MinecleanerManager { | ||||
|     private final MinecleanerPlugin plugin; | ||||
|     private final Inventory confirmPlayingInventory; | ||||
|     private final HashMap<Integer, String> sizes; | ||||
| 
 | ||||
|     // Statistics | ||||
|     private final StatisticKey statisticsGamesTotal; | ||||
|     private final StatisticKey statisticsPointsAcquired; | ||||
| 
 | ||||
|     // <BoardSize, StatisticKey> | ||||
|     private final HashMap<Integer, StatisticKey> statisticsGames; | ||||
| 
 | ||||
|     private int prevTick = 0; | ||||
| 
 | ||||
| 
 | ||||
|     public MinecleanerManager(MinecleanerPlugin plugin) { | ||||
|         this.plugin = plugin; | ||||
|          | ||||
|         this.sizes = new HashMap<>(); | ||||
|         this.sizes.put(0, "klein"); | ||||
|         this.sizes.put(1, "mittel"); | ||||
|         this.sizes.put(2, "groß"); | ||||
| 
 | ||||
|         // Deprecated | ||||
|         this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?"); | ||||
|  | @ -54,6 +67,18 @@ public class MinecleanerManager { | |||
|         statisticsPointsAcquired.setIsMonthlyStats(true); | ||||
|         statisticsPointsAcquired.setDisplayName("Punkte erspielt"); | ||||
| 
 | ||||
|         statisticsGames = new HashMap<>(); | ||||
|         for(Entry<Integer, String> e : this.sizes.entrySet()) { | ||||
|             String sizeDisplay = e.getValue(); | ||||
|             StatisticKey s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.games.boardsize." + e.getKey()); | ||||
|             s.setIsMonthlyStats(true); | ||||
|             s.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay +  " gespielt"); | ||||
|             statisticsGames.put(e.getKey(), s); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public HashMap<Integer, String> getSizes() { | ||||
|         return sizes; | ||||
|     } | ||||
|      | ||||
|     public void joinArena(Player player, MinecleanerArena arena) { | ||||
|  | @ -88,6 +113,7 @@ public class MinecleanerManager { | |||
|     public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) { | ||||
|         World world = player.getWorld(); | ||||
|         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!"); | ||||
|             arena.showMines(); | ||||
|  | @ -136,7 +162,6 @@ public class MinecleanerManager { | |||
|             } else { | ||||
|                 leaveArena(player, false); | ||||
|             } | ||||
|             leaveArena(player, false); | ||||
|         }, 100L); | ||||
| 
 | ||||
|     } | ||||
|  | @ -184,6 +209,24 @@ public class MinecleanerManager { | |||
|         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<>(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         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); | ||||
|             keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE, TimeFrame.MONTH)); | ||||
|             kgamesPlayedSizeMonth.put(i, qk); | ||||
| 
 | ||||
|             // todo: | ||||
|             //  PlayerTime | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         PlayerStatisticsQueryKey kPointsAcquired; | ||||
|         keys.add(kPointsAcquired = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE)); | ||||
|         PlayerStatisticsQueryKey kPointsAcquiredMonth; | ||||
|  | @ -195,7 +238,16 @@ 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<>(); | ||||
| 
 | ||||
|             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)); | ||||
|             } | ||||
| 
 | ||||
|             callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(), matchesPlayed, matchesPlayedMonth, | ||||
|                 sizeGames, sizeGamesMonth, | ||||
|                 pointsAcquiredTotal, pointsAcquiredMonth)); | ||||
|         }); | ||||
|     } | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package de.lunarakai.minecleaner; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.UUID; | ||||
| 
 | ||||
| public class PlayerStatisticsData { | ||||
|  | @ -7,12 +8,13 @@ public class PlayerStatisticsData { | |||
|     private String playerName; | ||||
|     private int gamesPlayed; | ||||
|     private int gamesPlayedThisMonth; | ||||
|     // private HashMap<Integer, Integer> gamesPlayedSize; | ||||
|     // private HashMap<Integer, Integer> gamesPlayedSizeThisMonth; | ||||
|     private HashMap<Integer, Integer> gamesPlayedSize; | ||||
|     private HashMap<Integer, Integer> gamesPlayedSizeThisMonth; | ||||
|     private int pointsAcquiredTotal; | ||||
|     private int pointsAcquiredMonth; | ||||
| 
 | ||||
|     public PlayerStatisticsData(UUID playerUUID, String playerName, int gamesPlayed, int gamesPlayedThisMonth,  | ||||
|     public PlayerStatisticsData(UUID playerUUID, String playerName, int gamesPlayed, int gamesPlayedThisMonth, | ||||
|         HashMap<Integer, Integer> gamesPlayedSize, HashMap<Integer, Integer> gamesPlayedSizeThisMonth,  | ||||
|         int pointsAcquiredTotal, int pointsAcquiredMonth) { | ||||
|         this.playerUUID = playerUUID; | ||||
|         this.playerName = playerName; | ||||
|  | @ -20,8 +22,8 @@ public class PlayerStatisticsData { | |||
|         this.gamesPlayed = gamesPlayed; | ||||
|         this.gamesPlayedThisMonth = gamesPlayedThisMonth; | ||||
|          | ||||
|         // this.gamesPlayedSize = gamesPlayedSize; | ||||
|         // this.gamesPlayedSizeThisMonth = gamesPlayedSizeThisMonth; | ||||
|         this.gamesPlayedSize = gamesPlayedSize; | ||||
|         this.gamesPlayedSizeThisMonth = gamesPlayedSizeThisMonth; | ||||
|          | ||||
|         this.pointsAcquiredTotal = pointsAcquiredTotal; | ||||
|         this.pointsAcquiredMonth = pointsAcquiredMonth; | ||||
|  | @ -43,15 +45,15 @@ public class PlayerStatisticsData { | |||
|         return gamesPlayedThisMonth; | ||||
|     } | ||||
| 
 | ||||
|     // public int getGamesPlayedSize(Integer widthIndex) { | ||||
|     //     Integer value = gamesPlayedSize.get(widthIndex); | ||||
|     //     return value == null ? 0 : value; | ||||
|     // } | ||||
|     public int getGamesPlayedSize(Integer widthIndex) { | ||||
|         Integer value = gamesPlayedSize.get(widthIndex); | ||||
|         return value == null ? 0 : value; | ||||
|     } | ||||
| 
 | ||||
|     // public int getGamesPlayedSizeThisMonth(Integer widthIndex) { | ||||
|     //     Integer value = gamesPlayedSizeThisMonth.get(widthIndex); | ||||
|     //     return value == null ? 0 : value; | ||||
|     // } | ||||
|     public int getGamesPlayedSizeThisMonth(Integer widthIndex) { | ||||
|         Integer value = gamesPlayedSizeThisMonth.get(widthIndex); | ||||
|         return value == null ? 0 : value; | ||||
|     } | ||||
| 
 | ||||
|     public int getPointsAcquiredTotal() { | ||||
|         return pointsAcquiredTotal; | ||||
|  |  | |||
|  | @ -111,9 +111,9 @@ public class CreateCommand extends SubCommand { | |||
|             sender.sendMessage(ChatColor.DARK_RED + "An dieser Stelle befindet sich bereits eine Arena."); | ||||
|             return true; | ||||
|         } | ||||
|         newArena.generateBlockDisplays(); // Todo | ||||
|         newArena.generateBlockDisplays(); | ||||
|         if(!noblocks) { | ||||
|             newArena.generateBackgroundBlocks(); // Todo; | ||||
|             newArena.generateBackgroundBlocks(); | ||||
|         } | ||||
|         plugin.getArenaList().addArena(newArena); | ||||
|         sender.sendMessage(ChatColor.GREEN + "Die Arena wurde erfolgreich angelegt."); | ||||
|  |  | |||
|  | @ -1,9 +1,12 @@ | |||
| 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; | ||||
| import de.iani.cubesideutils.StringUtil; | ||||
| import de.iani.cubesideutils.bukkit.commands.SubCommand; | ||||
| import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException; | ||||
| import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException; | ||||
|  | @ -13,7 +16,6 @@ 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 net.md_5.bungee.api.ChatColor; | ||||
| 
 | ||||
| public class StatsCommand extends SubCommand { | ||||
|     private final MinecleanerPlugin plugin; | ||||
|  | @ -53,8 +55,16 @@ public class StatsCommand extends SubCommand { | |||
|                 } else { | ||||
|                     sender.sendMessage(ChatColor.GREEN + "Minecleaner-Statitik von " + data.getPlayerName() + ":"); | ||||
|                 } | ||||
|                 sender.sendMessage(ChatColor.BLUE + "  Runden gespielt: " + ChatColor.GREEN + data.getGamesPlayed() + " (Dieser Monat: " + data.getGamesPlayedThisMonth() + ")"); | ||||
|                 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() + ")"); | ||||
|                 for(Entry<Integer, String> e : plugin.getManager().getSizes().entrySet()) { | ||||
|                     int totalSize = data.getGamesPlayedSize(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()) + ")"); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|             } | ||||
|         }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue