many things
This commit is contained in:
parent
c164d1b6cd
commit
c25886d72d
10 changed files with 261 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
||||||
/target/
|
/target/
|
||||||
/.vscode
|
/.vscode
|
||||||
*.log
|
*.log
|
||||||
|
Minecleaner.iml
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
@ -23,6 +22,9 @@ import de.lunarakai.minecleaner.game.BoardSize;
|
||||||
import de.lunarakai.minecleaner.game.Cell;
|
import de.lunarakai.minecleaner.game.Cell;
|
||||||
import de.lunarakai.minecleaner.game.Game;
|
import de.lunarakai.minecleaner.game.Game;
|
||||||
import de.lunarakai.minecleaner.utils.MinecleanerHeads;
|
import de.lunarakai.minecleaner.utils.MinecleanerHeads;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class MinecleanerArena {
|
public class MinecleanerArena {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
@ -33,7 +35,10 @@ public class MinecleanerArena {
|
||||||
private final BlockFace orientation;
|
private final BlockFace orientation;
|
||||||
private ArenaStatus arenaStatus = ArenaStatus.INACTIVE;
|
private ArenaStatus arenaStatus = ArenaStatus.INACTIVE;
|
||||||
private UUID[] blockDisplays;
|
private UUID[] blockDisplays;
|
||||||
|
// private UUID[] textDisplays;
|
||||||
|
|
||||||
|
private int flagsPlaced = 0;
|
||||||
|
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
private long currentGameStartTime;
|
private long currentGameStartTime;
|
||||||
private Game currentMinecleanerGame;
|
private Game currentMinecleanerGame;
|
||||||
|
|
@ -60,6 +65,7 @@ public class MinecleanerArena {
|
||||||
this.location = Preconditions.checkNotNull(arenaSection.getLocation("location"));
|
this.location = Preconditions.checkNotNull(arenaSection.getLocation("location"));
|
||||||
this.widthIndex = Preconditions.checkNotNull(arenaSection.getInt("fieldwidth"));
|
this.widthIndex = Preconditions.checkNotNull(arenaSection.getInt("fieldwidth"));
|
||||||
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]];
|
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]];
|
||||||
|
// this.textDisplays = new UUID[1];
|
||||||
|
|
||||||
BlockFace orientation = BlockFace.NORTH;
|
BlockFace orientation = BlockFace.NORTH;
|
||||||
try {
|
try {
|
||||||
|
|
@ -78,6 +84,14 @@ public class MinecleanerArena {
|
||||||
blockDisplays[i] = UUID.fromString(blockDisplay);
|
blockDisplays[i] = UUID.fromString(blockDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List<String> textList = arenaSection.getStringList("textdisplay");
|
||||||
|
// for(int i = 0; i < textList.size(); i++) {
|
||||||
|
// String textString = list.get(i);
|
||||||
|
// if(textString != null) {
|
||||||
|
// textDisplays[0] = UUID.fromString(textString);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecleanerArena(MinecleanerPlugin plugin, String name, Location location, int widthIndex, BlockFace orientation) {
|
public MinecleanerArena(MinecleanerPlugin plugin, String name, Location location, int widthIndex, BlockFace orientation) {
|
||||||
|
|
@ -86,6 +100,7 @@ public class MinecleanerArena {
|
||||||
this.location = Preconditions.checkNotNull(location, "location");
|
this.location = Preconditions.checkNotNull(location, "location");
|
||||||
this.widthIndex = Preconditions.checkNotNull(widthIndex, ("fieldwidth"));
|
this.widthIndex = Preconditions.checkNotNull(widthIndex, ("fieldwidth"));
|
||||||
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]];
|
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]];
|
||||||
|
//this.textDisplays = new UUID[1];
|
||||||
|
|
||||||
Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction");
|
Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction");
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
|
@ -109,7 +124,7 @@ public class MinecleanerArena {
|
||||||
// todo: larger grids
|
// todo: larger grids
|
||||||
|
|
||||||
|
|
||||||
for (int fx = -1; fx < 2 + widthIndex; fx++) {
|
for (int fx = -1 - widthIndex; fx < 2 ; fx++) {
|
||||||
for (int fy = -1; fy < 2 + widthIndex; fy++) {
|
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);
|
||||||
boolean f = (fx + fy) % 2 == 0;
|
boolean f = (fx + fy) % 2 == 0;
|
||||||
|
|
@ -137,14 +152,27 @@ public class MinecleanerArena {
|
||||||
Arrays.fill(blockDisplays, null);
|
Arrays.fill(blockDisplays, null);
|
||||||
|
|
||||||
float rotation0 = 0;
|
float rotation0 = 0;
|
||||||
|
double eastWestGapFixX = 0.0;
|
||||||
|
double eastWestGapFixZ = 0.0;
|
||||||
|
|
||||||
|
double southGapFixX = 0.0;
|
||||||
|
double southGapFixZ = 0.0;
|
||||||
if(orientation == BlockFace.EAST) {
|
if(orientation == BlockFace.EAST) {
|
||||||
rotation0 = 90;
|
rotation0 = 90;
|
||||||
|
eastWestGapFixX = 0.55;
|
||||||
|
eastWestGapFixZ = -0.46;
|
||||||
} else if(orientation == BlockFace.SOUTH) {
|
} else if(orientation == BlockFace.SOUTH) {
|
||||||
rotation0 = 180;
|
rotation0 = 180;
|
||||||
|
southGapFixX = 1.02;
|
||||||
|
southGapFixZ = 0.1;
|
||||||
} else if(orientation == BlockFace.WEST) {
|
} else if(orientation == BlockFace.WEST) {
|
||||||
rotation0 = 270;
|
rotation0 = 270;
|
||||||
|
eastWestGapFixX = 0.5;
|
||||||
|
eastWestGapFixZ = 0.5725;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float rotation = rotation0;
|
float rotation = rotation0;
|
||||||
|
|
||||||
int d0x = orientation.getModX();
|
int d0x = orientation.getModX();
|
||||||
|
|
@ -160,16 +188,16 @@ public class MinecleanerArena {
|
||||||
// Todo not correctly alligned at different orientations (other than NORTH)
|
// 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.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() - (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.8 + fxf / 3.0,
|
location.getY() - 0.8225 + fxf / 3.0,
|
||||||
location.getZ() + 0.45 - (d1z * fz) / 3.0 + d0z * 0.55 + d1z * 1.847);
|
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 Unknown Tile Heads && Flags(Front)
|
||||||
// Todo: Z-Fighting on the Sides for all Tiles
|
// Todo: Z-Fighting on the Sides for all Tiles
|
||||||
Display blockDisplay = world.spawn(loc, ItemDisplay.class, blockdisplay -> {
|
Display blockDisplay = world.spawn(loc, ItemDisplay.class, blockdisplay -> {
|
||||||
Transformation transformation = blockdisplay.getTransformation();
|
Transformation transformation = blockdisplay.getTransformation();
|
||||||
Transformation newTransform;
|
Transformation newTransform;
|
||||||
Vector3f newTranslationScale = new Vector3f(0.65f, 0.65f, 0.65f);
|
Vector3f newTranslationScale = new Vector3f(0.60f, 0.60f, 0.60f);
|
||||||
newTransform = new Transformation(
|
newTransform = new Transformation(
|
||||||
transformation.getTranslation(),
|
transformation.getTranslation(),
|
||||||
transformation.getLeftRotation(),
|
transformation.getLeftRotation(),
|
||||||
|
|
@ -188,6 +216,29 @@ public class MinecleanerArena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Location textLocation = location.clone();
|
||||||
|
// TextDisplay textDisplay = world.spawn(textLocation.add(-1, 2 + widthIndex, -0.25), TextDisplay.class, textdisplay -> {
|
||||||
|
// Transformation transformation = textdisplay.getTransformation();
|
||||||
|
// Transformation newTransformation;
|
||||||
|
// newTransformation = new Transformation(
|
||||||
|
// transformation.getTranslation(),
|
||||||
|
// transformation.getLeftRotation(),
|
||||||
|
// transformation.getTranslation(),
|
||||||
|
// transformation.getRightRotation());
|
||||||
|
|
||||||
|
// textdisplay.setTransformation(newTransformation);
|
||||||
|
// textdisplay.setRotation(rotation, 0);
|
||||||
|
|
||||||
|
// textdisplay.setVisibleByDefault(true);
|
||||||
|
// textdisplay.setDisplayHeight(3);
|
||||||
|
// textdisplay.setDisplayWidth(9);
|
||||||
|
// textdisplay.setText("Minecleaner");
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if(textDisplay != null) {
|
||||||
|
// textDisplays[0] = textDisplay.getUniqueId();
|
||||||
|
// }
|
||||||
|
|
||||||
// show Displays
|
// show Displays
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +253,11 @@ public class MinecleanerArena {
|
||||||
blockDisplays.add(uuid == null ? null : uuid.toString());
|
blockDisplays.add(uuid == null ? null : uuid.toString());
|
||||||
}
|
}
|
||||||
arenaSection.set("blockdisplays", blockDisplays);
|
arenaSection.set("blockdisplays", blockDisplays);
|
||||||
|
// List<String> textd = new ArrayList<>();
|
||||||
|
// for(UUID uuid : this.textDisplays) {
|
||||||
|
// textd.add(uuid == null ? null : uuid.toString());
|
||||||
|
// }
|
||||||
|
// arenaSection.set("textdisplay", textd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDiplayBlock(int x, int y, MinecleanerHeads head) {
|
private void setDiplayBlock(int x, int y, MinecleanerHeads head) {
|
||||||
|
|
@ -218,6 +274,7 @@ public class MinecleanerArena {
|
||||||
public void startNewGame() {
|
public void startNewGame() {
|
||||||
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]);
|
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]);
|
||||||
currentMinecleanerGame.start();
|
currentMinecleanerGame.start();
|
||||||
|
flagsPlaced = 0;
|
||||||
arenaStatus = ArenaStatus.PLAYING;
|
arenaStatus = ArenaStatus.PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,7 +330,9 @@ public class MinecleanerArena {
|
||||||
//plugin.getLogger().log(Level.SEVERE, " Is Flagged (before first if): " + cell.isFlagged());
|
//plugin.getLogger().log(Level.SEVERE, " Is Flagged (before first if): " + cell.isFlagged());
|
||||||
|
|
||||||
if(cell.isFlagged() == true) {
|
if(cell.isFlagged() == true) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Flagged Cell: [" + cell.position.x + "," + cell.position.y + "]");
|
//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);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -281,7 +340,9 @@ public class MinecleanerArena {
|
||||||
//plugin.getLogger().log(Level.SEVERE, " Is Flagged (before second if): " + cell.isFlagged());
|
//plugin.getLogger().log(Level.SEVERE, " Is Flagged (before second if): " + cell.isFlagged());
|
||||||
|
|
||||||
if(cell.isFlagged() == false) {
|
if(cell.isFlagged() == false) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Unflagged Cell: [" + cell.position.x + "," + cell.position.y + "]");
|
//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);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -297,12 +358,13 @@ public class MinecleanerArena {
|
||||||
Player player = this.currentPlayer;
|
Player player = this.currentPlayer;
|
||||||
|
|
||||||
currentMinecleanerGame.reveal(x, y);
|
currentMinecleanerGame.reveal(x, y);
|
||||||
|
|
||||||
setBlockForCellType(x, y, cell);
|
setBlockForCellType(x, y, cell);
|
||||||
|
|
||||||
if(currentMinecleanerGame.gameover) {
|
if(currentMinecleanerGame.gameover) {
|
||||||
plugin.getManager().handleGameover(player, this, !(cell.isRevealed() && cell.isExploded()));
|
plugin.getManager().handleGameover(player, this, !(cell.isRevealed() && cell.isExploded()));
|
||||||
}
|
} else {
|
||||||
|
sendActionBarMessage(player);
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
||||||
if(floodedCells != null) {
|
if(floodedCells != null) {
|
||||||
|
|
@ -315,6 +377,12 @@ public class MinecleanerArena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendActionBarMessage(Player player) {
|
||||||
|
TextComponent textComponent = new TextComponent("Flaggen gesetzt: " + flagsPlaced + " Minen insgesamt: " + BoardSize.mineCounter[widthIndex]);
|
||||||
|
textComponent.setColor(ChatColor.GOLD);
|
||||||
|
player.sendMessage(ChatMessageType.ACTION_BAR, textComponent);
|
||||||
|
}
|
||||||
|
|
||||||
public void showMines() {
|
public void showMines() {
|
||||||
ArrayList<Cell> explodedCells = currentMinecleanerGame.getExplodedCells();
|
ArrayList<Cell> explodedCells = currentMinecleanerGame.getExplodedCells();
|
||||||
if(explodedCells != null) {
|
if(explodedCells != null) {
|
||||||
|
|
@ -452,5 +520,10 @@ public class MinecleanerArena {
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return BoardSize.boardSizes[widthIndex];
|
return BoardSize.boardSizes[widthIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Difficulty
|
||||||
|
public int getWidthIndex() {
|
||||||
|
return widthIndex;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,11 @@ public class MinecleanerListener implements Listener {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//player.sendMessage(ChatColor.GRAY + "blockx: " + blockx + " ,blockz: " + blockz);
|
player.sendMessage(ChatColor.GRAY + "blockx: " + blockx + " ,blockz: " + blockz);
|
||||||
// player.sendMessage(ChatColor.GRAY + "blockxInt: " + blockxInt + " ,blockzInt: " + blockzInt);
|
//player.sendMessage(ChatColor.GRAY + "blockxInt: " + blockxInt + " ,blockzInt: " + blockzInt);
|
||||||
|
|
||||||
if (blockx >= 0.1 && blockx <= 0.9 && blockz >= 0.1 && blockz <= 0.9) {
|
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;
|
boolean hasRightClicked = false;
|
||||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
hasRightClicked = true;
|
hasRightClicked = true;
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
@ -27,7 +28,10 @@ import net.md_5.bungee.api.ChatColor;
|
||||||
public class MinecleanerManager {
|
public class MinecleanerManager {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
private final Inventory confirmPlayingInventory;
|
private final Inventory confirmPlayingInventory;
|
||||||
|
|
||||||
|
// Statistics
|
||||||
private final StatisticKey statisticsGamesTotal;
|
private final StatisticKey statisticsGamesTotal;
|
||||||
|
private final StatisticKey statisticsPointsAcquired;
|
||||||
|
|
||||||
private int prevTick = 0;
|
private int prevTick = 0;
|
||||||
|
|
||||||
|
|
@ -45,6 +49,10 @@ public class MinecleanerManager {
|
||||||
statisticsGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamesTotal");
|
statisticsGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamesTotal");
|
||||||
statisticsGamesTotal.setIsMonthlyStats(true);
|
statisticsGamesTotal.setIsMonthlyStats(true);
|
||||||
statisticsGamesTotal.setDisplayName("Runden gespielt");
|
statisticsGamesTotal.setDisplayName("Runden gespielt");
|
||||||
|
|
||||||
|
statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointsTotal");
|
||||||
|
statisticsPointsAcquired.setIsMonthlyStats(true);
|
||||||
|
statisticsPointsAcquired.setDisplayName("Punkte erspielt");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,22 +86,56 @@ 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();
|
||||||
if(!isSuccessfullyCleared) {
|
if(!isSuccessfullyCleared) {
|
||||||
|
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 Feld nicht erfolgreich lösen!");
|
||||||
arena.showMines();
|
arena.showMines();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
leaveArena(player, false);
|
if(arena.getCurrentPlayer() == null) {
|
||||||
|
arena.removePlayer();
|
||||||
|
} else {
|
||||||
|
leaveArena(player, false);
|
||||||
|
}
|
||||||
|
|
||||||
}, 100L);
|
}, 100L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Feld erfolgreich lösen!");
|
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Feld erfolgreich lösen!");
|
||||||
|
|
||||||
|
|
||||||
|
world.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
|
||||||
|
|
||||||
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||||
ps.increaseScore(statisticsGamesTotal, 1);
|
ps.increaseScore(statisticsGamesTotal, 1);
|
||||||
|
|
||||||
|
int wIndex = arena.getWidthIndex();
|
||||||
|
switch (wIndex) {
|
||||||
|
case 0: {
|
||||||
|
ps.increaseScore(statisticsPointsAcquired, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
ps.increaseScore(statisticsPointsAcquired, 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
ps.increaseScore(statisticsPointsAcquired, 5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
ps.increaseScore(statisticsPointsAcquired, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
if(arena.getCurrentPlayer() == null) {
|
||||||
|
arena.removePlayer();
|
||||||
|
} else {
|
||||||
|
leaveArena(player, false);
|
||||||
|
}
|
||||||
leaveArena(player, false);
|
leaveArena(player, false);
|
||||||
}, 100L);
|
}, 100L);
|
||||||
|
|
||||||
|
|
@ -122,11 +164,11 @@ public class MinecleanerManager {
|
||||||
// Fires Twice for Right Click on Same Tick, but only once for left click... stupid :<
|
// Fires Twice for Right Click on Same Tick, but only once for left click... stupid :<
|
||||||
if(hasRightClicked) {
|
if(hasRightClicked) {
|
||||||
// flag
|
// flag
|
||||||
plugin.getLogger().log(Level.SEVERE, " Right Clicked @ Tick: " + plugin.getServer().getCurrentTick());
|
//plugin.getLogger().log(Level.SEVERE, " Right Clicked @ Tick: " + plugin.getServer().getCurrentTick());
|
||||||
arena.flagCell(x, y);
|
arena.flagCell(x, y);
|
||||||
} else {
|
} else {
|
||||||
// reveal
|
// reveal
|
||||||
plugin.getLogger().log(Level.SEVERE, " Left Clicked @ Tick: " + plugin.getServer().getCurrentTick());
|
//plugin.getLogger().log(Level.SEVERE, " Left Clicked @ Tick: " + plugin.getServer().getCurrentTick());
|
||||||
arena.revealCell(x, y);
|
arena.revealCell(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -142,11 +184,19 @@ public class MinecleanerManager {
|
||||||
PlayerStatisticsQueryKey kMatchesPlayedMonth;
|
PlayerStatisticsQueryKey kMatchesPlayedMonth;
|
||||||
keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE, TimeFrame.MONTH));
|
keys.add(kMatchesPlayedMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsGamesTotal, QueryType.SCORE, TimeFrame.MONTH));
|
||||||
|
|
||||||
|
PlayerStatisticsQueryKey kPointsAcquired;
|
||||||
|
keys.add(kPointsAcquired = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE));
|
||||||
|
PlayerStatisticsQueryKey kPointsAcquiredMonth;
|
||||||
|
keys.add(kPointsAcquiredMonth = new PlayerStatisticsQueryKey(pStatistics, statisticsPointsAcquired, QueryType.SCORE, TimeFrame.MONTH));
|
||||||
|
|
||||||
plugin.getCubesideStatistics().queryStats(keys, (c) -> {
|
plugin.getCubesideStatistics().queryStats(keys, (c) -> {
|
||||||
int matchesPlayed = c.getOrDefault(kMatchesPlayed, 0);
|
int matchesPlayed = c.getOrDefault(kMatchesPlayed, 0);
|
||||||
int matchesPlayedMonth = c.getOrDefault(kMatchesPlayedMonth, 0);
|
int matchesPlayedMonth = c.getOrDefault(kMatchesPlayedMonth, 0);
|
||||||
|
int pointsAcquiredTotal = c.getOrDefault(kPointsAcquired, 0);
|
||||||
|
int pointsAcquiredMonth = c.getOrDefault(kPointsAcquiredMonth, 0);
|
||||||
|
|
||||||
callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(), matchesPlayed, matchesPlayedMonth));
|
callback.accept(new PlayerStatisticsData(player.getUniqueId(), player.getName(), matchesPlayed, matchesPlayedMonth,
|
||||||
|
pointsAcquiredTotal, pointsAcquiredMonth));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,5 +212,6 @@ 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(statisticsGamesTotal);
|
||||||
|
statsPlayer.deleteScore(statisticsPointsAcquired);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,24 @@ public class PlayerStatisticsData {
|
||||||
private String playerName;
|
private String playerName;
|
||||||
private int gamesPlayed;
|
private int gamesPlayed;
|
||||||
private int gamesPlayedThisMonth;
|
private int gamesPlayedThisMonth;
|
||||||
|
// 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,
|
||||||
|
int pointsAcquiredTotal, int pointsAcquiredMonth) {
|
||||||
this.playerUUID = playerUUID;
|
this.playerUUID = playerUUID;
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
|
|
||||||
this.gamesPlayed = gamesPlayed;
|
this.gamesPlayed = gamesPlayed;
|
||||||
this.gamesPlayedThisMonth = gamesPlayedThisMonth;
|
this.gamesPlayedThisMonth = gamesPlayedThisMonth;
|
||||||
|
|
||||||
|
// this.gamesPlayedSize = gamesPlayedSize;
|
||||||
|
// this.gamesPlayedSizeThisMonth = gamesPlayedSizeThisMonth;
|
||||||
|
|
||||||
|
this.pointsAcquiredTotal = pointsAcquiredTotal;
|
||||||
|
this.pointsAcquiredMonth = pointsAcquiredMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPlayerID() {
|
public UUID getPlayerID() {
|
||||||
|
|
@ -30,5 +42,23 @@ public class PlayerStatisticsData {
|
||||||
public int getGamesPlayedThisMonth() {
|
public int getGamesPlayedThisMonth() {
|
||||||
return gamesPlayedThisMonth;
|
return gamesPlayedThisMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 getPointsAcquiredTotal() {
|
||||||
|
return pointsAcquiredTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPointsAquiredMonth() {
|
||||||
|
return pointsAcquiredMonth;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ public class CreateCommand extends SubCommand {
|
||||||
widthindex = Integer.parseInt(arg);
|
widthindex = Integer.parseInt(arg);
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Kein Valider Arena WidthIndex!");
|
sender.sendMessage(ChatColor.DARK_RED + "Kein Valider Arena WidthIndex!");
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 15*15, 2 = 24*24");
|
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 12*12, 2 = 15*15");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(widthindex > 2) {
|
if(widthindex > 2) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Arena WidthIndex darf nicht größer als 2 sein");
|
sender.sendMessage(ChatColor.DARK_RED + "Arena WidthIndex darf nicht größer als 2 sein");
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 15*15, 2 = 24*24");
|
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 12*12, 2 = 15*15");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.InternalCommandException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.NoPermissionException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
|
||||||
|
import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
|
import de.iani.playerUUIDCache.CachedPlayer;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class DeletePlayerScoreCommand extends SubCommand{
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public DeletePlayerScoreCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "<name> DELETE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String alias, String commandString,
|
||||||
|
ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException,
|
||||||
|
NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
String player = args.getNext(null);
|
||||||
|
String deleteConfirm = args.getNext(null);
|
||||||
|
if(player == null || deleteConfirm == null || !deleteConfirm.equals("DELETE") || args.remaining() > 0) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + commandString + getUsage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CachedPlayer cachedPlayer = plugin.getPlayerUUIDCache().getPlayer(player);
|
||||||
|
if(cachedPlayer == null) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + "Ein Spieler mit dem Namen '" + player + "' konnte nicht gefunden werden.");
|
||||||
|
}
|
||||||
|
plugin.getManager().deleteScores(cachedPlayer.getUUID());
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + "Alle Minecleaner-Statistiken von Spieler '" + cachedPlayer.getName() + "' wurden gelöscht.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -54,6 +54,8 @@ 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 + " Runden gespielt: " + ChatColor.GREEN + data.getGamesPlayed() + " (Dieser Monat: " + data.getGamesPlayedThisMonth() + ")");
|
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() + ")");
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(playerName == null) {
|
if(playerName == null) {
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,7 @@ public class Game {
|
||||||
floodedCells.add(cell);
|
floodedCells.add(cell);
|
||||||
state[cell.position.x][cell.position.y] = cell;
|
state[cell.position.x][cell.position.y] = cell;
|
||||||
|
|
||||||
|
// this looks bad, i should probably go to the doctor with it D:
|
||||||
if(cell.getType() == Cell.CellType.Empty) {
|
if(cell.getType() == Cell.CellType.Empty) {
|
||||||
if(isValid(cell.position.x -1, cell.position.y)) {
|
if(isValid(cell.position.x -1, cell.position.y)) {
|
||||||
flood(getCell(cell.position.x -1, cell.position.y));
|
flood(getCell(cell.position.x -1, cell.position.y));
|
||||||
|
|
@ -202,6 +203,21 @@ public class Game {
|
||||||
if(isValid(cell.position.x, cell.position.y +1)) {
|
if(isValid(cell.position.x, cell.position.y +1)) {
|
||||||
flood(getCell(cell.position.x, cell.position.y +1));
|
flood(getCell(cell.position.x, cell.position.y +1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Corners
|
||||||
|
// Todo: oben links geht nicht
|
||||||
|
if(isValid(cell.position.x + 1, cell.position.y +1)) {
|
||||||
|
flood(getCell(cell.position.x +1, cell.position.y +1));
|
||||||
|
}
|
||||||
|
if(isValid(cell.position.x + 1, cell.position.y -1)) {
|
||||||
|
flood(getCell(cell.position.x +1, cell.position.y -1));
|
||||||
|
}
|
||||||
|
if(isValid(cell.position.x - 1, cell.position.y +1)) {
|
||||||
|
flood(getCell(cell.position.x -1, cell.position.y +1));
|
||||||
|
}
|
||||||
|
if(isValid(cell.position.x - 1, cell.position.y - 1)) {
|
||||||
|
flood(getCell(cell.position.x -1, cell.position.y -1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,9 @@ api-version: '1.20'
|
||||||
commands:
|
commands:
|
||||||
minecleaner:
|
minecleaner:
|
||||||
description: main command
|
description: main command
|
||||||
aliases: "mcl"
|
aliases: "mcl"
|
||||||
|
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
minecleaner.admin: {}
|
||||||
|
minecleaner.play: {}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue