flags placed & total mines are shown above the field now + a little bit of cleaning up
This commit is contained in:
parent
fbd5f81e13
commit
625af3dfcb
4 changed files with 307 additions and 203 deletions
117
.gitignore
vendored
117
.gitignore
vendored
|
|
@ -1,5 +1,116 @@
|
||||||
# Project exclude paths
|
# Project exclude paths
|
||||||
/target/
|
.vscode/
|
||||||
/.vscode
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
*.log
|
*.log
|
||||||
Minecleaner.iml
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
target/
|
||||||
|
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
.flattened-pom.xml
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@
|
||||||
<facet type="minecraft" name="Minecraft">
|
<facet type="minecraft" name="Minecraft">
|
||||||
<configuration>
|
<configuration>
|
||||||
<autoDetectTypes>
|
<autoDetectTypes>
|
||||||
<platformType>SPIGOT</platformType>
|
<platformType>PAPER</platformType>
|
||||||
|
<platformType>ADVENTURE</platformType>
|
||||||
</autoDetectTypes>
|
</autoDetectTypes>
|
||||||
|
<projectReimportVersion>1</projectReimportVersion>
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>de.lunarakai</groupId>
|
<groupId>de.lunarakai</groupId>
|
||||||
<artifactId>Minecleaner</artifactId>
|
<artifactId>Minecleaner</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Minecleaner</name>
|
<name>Minecleaner</name>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ 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 net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
@ -15,6 +16,7 @@ import org.bukkit.entity.Display.Brightness;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ItemDisplay;
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TextDisplay;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Transformation;
|
import org.bukkit.util.Transformation;
|
||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
|
|
@ -37,54 +39,25 @@ 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 TextDisplay textDisplay;
|
||||||
private boolean hasMadeFirstClick = false;
|
private boolean hasMadeFirstClick = false;
|
||||||
|
|
||||||
private int flagsPlaced = 0;
|
private int flagsPlaced = 0;
|
||||||
|
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
private long currentGameStartTime;
|
private long currentGameStartTime;
|
||||||
private Game currentMinecleanerGame;
|
private Game currentMinecleanerGame;
|
||||||
|
|
||||||
private final Location tempLoc = new Location(null, 0, 0, 0);
|
private final Location tempLoc = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
public static final MinecleanerHeads[] MINECLEANER_HEADS = {
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_0,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_1,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_2,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_3,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_4,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_5,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_6,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_7,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_8,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_FLAG,
|
|
||||||
MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN,
|
|
||||||
MinecleanerHeads.TNT,
|
|
||||||
MinecleanerHeads.EXPLODED,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_M,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_I,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_N,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_E,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_S,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_W,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_P,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_R,
|
|
||||||
MinecleanerHeads.MINESWEEPER_LETTER_MINUS,
|
|
||||||
};
|
|
||||||
|
|
||||||
public MinecleanerArena(MinecleanerPlugin plugin, ConfigurationSection arenaSection) {
|
public MinecleanerArena(MinecleanerPlugin plugin, ConfigurationSection arenaSection) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = Preconditions.checkNotNull(arenaSection.getString("name"));
|
this.name = Preconditions.checkNotNull(arenaSection.getString("name"));
|
||||||
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.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]];
|
this.blockDisplays = new UUID[BoardSize.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]];
|
||||||
// this.textDisplays = new UUID[1];
|
|
||||||
|
|
||||||
BlockFace orientation = BlockFace.NORTH;
|
BlockFace orientation = BlockFace.NORTH;
|
||||||
try {
|
try {
|
||||||
orientation = BlockFace.valueOf(arenaSection.getString("orientation"));
|
orientation = BlockFace.valueOf(arenaSection.getString("orientation"));
|
||||||
} catch(IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
|
@ -92,21 +65,13 @@ public class MinecleanerArena {
|
||||||
this.centerLocation = location.clone().add(0.5, 0, 0.5);
|
this.centerLocation = location.clone().add(0.5, 0, 0.5);
|
||||||
|
|
||||||
List<String> list = arenaSection.getStringList("blockdisplays");
|
List<String> list = arenaSection.getStringList("blockdisplays");
|
||||||
for(int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
String blockDisplay = list.get(i);
|
String blockDisplay = list.get(i);
|
||||||
if(blockDisplay != null) {
|
if (blockDisplay != null) {
|
||||||
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) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
@ -114,7 +79,6 @@ 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.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]];
|
this.blockDisplays = new UUID[BoardSize.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[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;
|
||||||
|
|
@ -136,8 +100,8 @@ public class MinecleanerArena {
|
||||||
BlockData block0 = Material.NETHER_BRICKS.createBlockData();
|
BlockData block0 = Material.NETHER_BRICKS.createBlockData();
|
||||||
BlockData block1 = Material.BRICKS.createBlockData();
|
BlockData block1 = Material.BRICKS.createBlockData();
|
||||||
|
|
||||||
for (int fx = -1 - (BoardSize.boardSizesWidth[widthIndex]/3 - 3); fx < 2; fx++) {
|
for (int fx = -1 - (BoardSize.boardSizesWidth[widthIndex] / 3 - 3); fx < 2; fx++) {
|
||||||
for (int fy = -1; fy < BoardSize.boardSizesHeight[widthIndex]/3 - 1; fy++) {
|
for (int fy = -1; fy < BoardSize.boardSizesHeight[widthIndex] / 3 - 1; 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;
|
||||||
world.setBlockData(loc, f ? block0 : block1);
|
world.setBlockData(loc, f ? block0 : block1);
|
||||||
|
|
@ -146,17 +110,17 @@ public class MinecleanerArena {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bei Größen WidthIndex 1 + 2 -> Mitte = ein Block nach Links unten versetzt
|
* "Mitte" = Block (1,1)
|
||||||
*/
|
*/
|
||||||
public void generateBlockDisplays() {
|
public void generateBlockDisplays() {
|
||||||
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
||||||
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
||||||
|
|
||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
for(UUID id : blockDisplays) {
|
for (UUID id : blockDisplays) {
|
||||||
if(id != null) {
|
if (id != null) {
|
||||||
Entity blockdisplay = world.getEntity(id);
|
Entity blockdisplay = world.getEntity(id);
|
||||||
if(blockdisplay instanceof Display) {
|
if (blockdisplay instanceof Display) {
|
||||||
blockdisplay.remove();
|
blockdisplay.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,88 +133,59 @@ public class MinecleanerArena {
|
||||||
|
|
||||||
double southGapFixX = 0.0;
|
double southGapFixX = 0.0;
|
||||||
double southGapFixZ = 0.0;
|
double southGapFixZ = 0.0;
|
||||||
if(orientation == BlockFace.EAST) {
|
|
||||||
rotation0 = 90;
|
if (orientation == BlockFace.EAST) {
|
||||||
eastWestGapFixX = 0.5;
|
eastWestGapFixX = 0.5;
|
||||||
eastWestGapFixZ = -0.55;
|
eastWestGapFixZ = -0.55;
|
||||||
} else if(orientation == BlockFace.SOUTH) {
|
} else if (orientation == BlockFace.SOUTH) {
|
||||||
rotation0 = 180;
|
|
||||||
southGapFixX = 1.02;
|
southGapFixX = 1.02;
|
||||||
southGapFixZ = -0.05;
|
southGapFixZ = -0.05;
|
||||||
} else if(orientation == BlockFace.WEST) {
|
} else if (orientation == BlockFace.WEST) {
|
||||||
rotation0 = 270;
|
|
||||||
eastWestGapFixX = 0.55;
|
eastWestGapFixX = 0.55;
|
||||||
eastWestGapFixZ = 0.5;
|
eastWestGapFixZ = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotation0 = getRotationYaw();
|
||||||
float rotation = rotation0;
|
float rotation = rotation0;
|
||||||
|
|
||||||
int d0x = orientation.getModX();
|
int d0x = orientation.getModX();
|
||||||
int d0z = orientation.getModZ();
|
int d0z = orientation.getModZ();
|
||||||
int d1x = -d0z;
|
int d1x = -d0z;
|
||||||
int d1z = d0x;
|
int d1z = d0x;
|
||||||
|
|
||||||
Location loc = location.clone();
|
Location loc = location.clone();
|
||||||
|
|
||||||
for(int fx = 0; fx < sizeHeight; fx++) {
|
for (int fx = 0; fx < sizeHeight; fx++) {
|
||||||
final int fxf = fx;
|
final int fxf = fx;
|
||||||
for(int fz = 0; fz < sizeWidth; fz++) {
|
for (int fz = 0; fz < sizeWidth; fz++) {
|
||||||
final int fzf = fz;
|
final int fzf = fz;
|
||||||
|
|
||||||
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.525 + 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();
|
||||||
Transformation newTransform;
|
Transformation newTransform;
|
||||||
Vector3f newTranslationScale = new Vector3f(0.60f, 0.60f, 0.60f);
|
Vector3f newTranslationScale = new Vector3f(0.60f, 0.60f, 0.60f);
|
||||||
newTransform = new Transformation(
|
newTransform = new Transformation(
|
||||||
transformation.getTranslation(),
|
transformation.getTranslation(),
|
||||||
transformation.getLeftRotation(),
|
transformation.getLeftRotation(),
|
||||||
newTranslationScale,
|
newTranslationScale,
|
||||||
transformation.getRightRotation());
|
transformation.getRightRotation());
|
||||||
|
|
||||||
blockdisplay.setTransformation(newTransform);
|
blockdisplay.setTransformation(newTransform);
|
||||||
blockdisplay.setRotation(rotation, -90);
|
blockdisplay.setRotation(rotation, -90);
|
||||||
blockdisplay.setBrightness(new Brightness(15, 15));
|
blockdisplay.setBrightness(new Brightness(15, 15));
|
||||||
|
|
||||||
blockdisplay.setItemStack(MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN.getHead());
|
blockdisplay.setItemStack(MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN.getHead());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (blockDisplay != null) {
|
||||||
if(blockDisplay != null) {
|
|
||||||
blockDisplays[fxf * sizeWidth + fzf] = blockDisplay.getUniqueId();
|
blockDisplays[fxf * sizeWidth + fzf] = blockDisplay.getUniqueId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// billboardmode = fixed
|
|
||||||
// textdisplay.setVisibleByDefault(true);
|
|
||||||
// textdisplay.setDisplayHeight(3);
|
|
||||||
// textdisplay.setDisplayWidth(9);
|
|
||||||
// textdisplay.setText("Minecleaner");
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if(textDisplay != null) {
|
|
||||||
// textDisplays[0] = textDisplay.getUniqueId();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// show Displays
|
|
||||||
|
|
||||||
showStartHeads();
|
showStartHeads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,15 +195,10 @@ public class MinecleanerArena {
|
||||||
arenaSection.set("fieldwidth", this.widthIndex);
|
arenaSection.set("fieldwidth", this.widthIndex);
|
||||||
arenaSection.set("orientation", this.orientation.name());
|
arenaSection.set("orientation", this.orientation.name());
|
||||||
List<String> blockDisplays = new ArrayList<>();
|
List<String> blockDisplays = new ArrayList<>();
|
||||||
for(UUID uuid : this.blockDisplays) {
|
for (UUID uuid : this.blockDisplays) {
|
||||||
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, boolean applyUsualRotation) {
|
private void setDiplayBlock(int x, int y, MinecleanerHeads head, boolean applyUsualRotation) {
|
||||||
|
|
@ -277,9 +207,9 @@ public class MinecleanerArena {
|
||||||
|
|
||||||
UUID blockDisplayId = blockDisplays[x + y * sizeWidth];
|
UUID blockDisplayId = blockDisplays[x + y * sizeWidth];
|
||||||
Entity blockDisplay = blockDisplayId != null ? location.getWorld().getEntity(blockDisplayId) : null;
|
Entity blockDisplay = blockDisplayId != null ? location.getWorld().getEntity(blockDisplayId) : null;
|
||||||
if(blockDisplay instanceof ItemDisplay) {
|
if (blockDisplay instanceof ItemDisplay) {
|
||||||
ItemDisplay display = (ItemDisplay) blockDisplay;
|
ItemDisplay display = (ItemDisplay) blockDisplay;
|
||||||
if(!applyUsualRotation) {
|
if (!applyUsualRotation) {
|
||||||
blockDisplay.setRotation(blockDisplay.getYaw(), 0);
|
blockDisplay.setRotation(blockDisplay.getYaw(), 0);
|
||||||
} else {
|
} else {
|
||||||
blockDisplay.setRotation(blockDisplay.getYaw(), -90);
|
blockDisplay.setRotation(blockDisplay.getYaw(), -90);
|
||||||
|
|
@ -291,20 +221,12 @@ public class MinecleanerArena {
|
||||||
public void startNewGame() {
|
public void startNewGame() {
|
||||||
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
|
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
|
||||||
currentMinecleanerGame.start();
|
currentMinecleanerGame.start();
|
||||||
|
showTextDisplay();
|
||||||
removeStartHeads();
|
removeStartHeads();
|
||||||
flagsPlaced = 0;
|
flagsPlaced = 0;
|
||||||
hasMadeFirstClick = false;
|
hasMadeFirstClick = false;
|
||||||
arenaStatus = ArenaStatus.PLAYING;
|
arenaStatus = ArenaStatus.PLAYING;
|
||||||
currentGameStartTime = System.currentTimeMillis();
|
currentGameStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
|
||||||
sendActionBarMessage(currentPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 20L, 20L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJoiningPlayer(Player player) {
|
public void addJoiningPlayer(Player player) {
|
||||||
|
|
@ -312,7 +234,7 @@ public class MinecleanerArena {
|
||||||
Preconditions.checkState(arenaStatus == ArenaStatus.INACTIVE);
|
Preconditions.checkState(arenaStatus == ArenaStatus.INACTIVE);
|
||||||
this.arenaStatus = ArenaStatus.CONFIRM_PLAYING;
|
this.arenaStatus = ArenaStatus.CONFIRM_PLAYING;
|
||||||
this.currentPlayer = player;
|
this.currentPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer() {
|
public void removePlayer() {
|
||||||
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
||||||
|
|
@ -321,13 +243,14 @@ public class MinecleanerArena {
|
||||||
this.arenaStatus = ArenaStatus.INACTIVE;
|
this.arenaStatus = ArenaStatus.INACTIVE;
|
||||||
this.currentPlayer = null;
|
this.currentPlayer = null;
|
||||||
this.currentMinecleanerGame = null;
|
this.currentMinecleanerGame = null;
|
||||||
|
|
||||||
for(int x = 0; x < sizeWidth; x++) {
|
for (int x = 0; x < sizeWidth; x++) {
|
||||||
for(int y = 0; y < sizeHeight; y++) {
|
for (int y = 0; y < sizeHeight; y++) {
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showStartHeads();
|
showStartHeads();
|
||||||
|
removeTextDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showStartHeads() {
|
public void showStartHeads() {
|
||||||
|
|
@ -335,20 +258,20 @@ public class MinecleanerArena {
|
||||||
int height = BoardSize.boardSizesHeight[widthIndex];
|
int height = BoardSize.boardSizesHeight[widthIndex];
|
||||||
|
|
||||||
// MINE -
|
// MINE -
|
||||||
setDiplayBlock(width/2-2 + 0, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_M, true);
|
setDiplayBlock(width / 2 - 2 + 0, height / 2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_M, true);
|
||||||
setDiplayBlock(width/2-2 + 1, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_I, true);
|
setDiplayBlock(width / 2 - 2 + 1, height / 2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_I, true);
|
||||||
setDiplayBlock(width/2-2 + 2, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_N, true);
|
setDiplayBlock(width / 2 - 2 + 2, height / 2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_N, true);
|
||||||
setDiplayBlock(width/2-2 + 3, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
setDiplayBlock(width / 2 - 2 + 3, height / 2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
||||||
setDiplayBlock(width/2-2 + 4, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_MINUS, true);
|
setDiplayBlock(width / 2 - 2 + 4, height / 2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_MINUS, true);
|
||||||
|
|
||||||
// SWEEPER
|
// SWEEPER
|
||||||
setDiplayBlock(width/2-3 + 0, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_S, true);
|
setDiplayBlock(width / 2 - 3 + 0, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_S, true);
|
||||||
setDiplayBlock(width/2-3 + 1, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_W, true);
|
setDiplayBlock(width / 2 - 3 + 1, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_W, true);
|
||||||
setDiplayBlock(width/2-3 + 2, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
setDiplayBlock(width / 2 - 3 + 2, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
||||||
setDiplayBlock(width/2-3 + 3, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
setDiplayBlock(width / 2 - 3 + 3, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
||||||
setDiplayBlock(width/2-3 + 4, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_P, true);
|
setDiplayBlock(width / 2 - 3 + 4, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_P, true);
|
||||||
setDiplayBlock(width/2-3 + 5, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
setDiplayBlock(width / 2 - 3 + 5, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
|
||||||
setDiplayBlock(width/2-3 + 6, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_R, true);
|
setDiplayBlock(width / 2 - 3 + 6, height / 2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_R, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,22 +279,93 @@ public class MinecleanerArena {
|
||||||
int width = BoardSize.boardSizesWidth[widthIndex];
|
int width = BoardSize.boardSizesWidth[widthIndex];
|
||||||
int height = BoardSize.boardSizesHeight[widthIndex];
|
int height = BoardSize.boardSizesHeight[widthIndex];
|
||||||
|
|
||||||
// MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN
|
|
||||||
// MINE -
|
// MINE -
|
||||||
setDiplayBlock(width/2-2 + 0, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 2 + 0, height / 2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-2 + 1, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 2 + 1, height / 2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-2 + 2, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 2 + 2, height / 2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-2 + 3, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 2 + 3, height / 2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-2 + 4, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 2 + 4, height / 2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
|
|
||||||
// SWEEPER
|
// SWEEPER
|
||||||
setDiplayBlock(width/2-3 + 0, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 0, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 1, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 1, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 2, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 2, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 3, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 3, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 4, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 4, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 5, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 5, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
setDiplayBlock(width/2-3 + 6, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(width / 2 - 3 + 6, height / 2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showTextDisplay() {
|
||||||
|
Player player = this.getCurrentPlayer();
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
double textCenterX = centerLocation.getX();
|
||||||
|
double textCenterY = centerLocation.getY() + ((double) BoardSize.boardSizesHeight[widthIndex] / 3 - 2.75 - widthIndex);
|
||||||
|
double textCenterZ = centerLocation.getZ();
|
||||||
|
|
||||||
|
int rotation = getRotationYaw() - 180;
|
||||||
|
|
||||||
|
switch (orientation) {
|
||||||
|
case NORTH: {
|
||||||
|
textCenterX = centerLocation.getX() - (((double) BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 2.51;
|
||||||
|
textCenterZ = textCenterZ - 0.30;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EAST: {
|
||||||
|
textCenterX = textCenterX + 1.55;
|
||||||
|
textCenterZ = centerLocation.getZ() - (((double) BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 1.775;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SOUTH: {
|
||||||
|
textCenterX = centerLocation.getX() + (((double) BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 0.5275;
|
||||||
|
textCenterZ = textCenterZ + 0.80;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEST: {
|
||||||
|
textCenterX = textCenterX + 0.45;
|
||||||
|
textCenterZ = centerLocation.getZ() + (((double) BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 1.275;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location textDisplayLocation = new Location(player.getWorld(), textCenterX, textCenterY, textCenterZ);
|
||||||
|
|
||||||
|
textDisplay = world.spawn(textDisplayLocation.add(-1, 2 + widthIndex, -0.25), TextDisplay.class, textdisplay -> {
|
||||||
|
Transformation transformation = textdisplay.getTransformation();
|
||||||
|
Vector3f newTranslationScale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||||
|
Transformation newTransformation;
|
||||||
|
newTransformation = new Transformation(
|
||||||
|
transformation.getTranslation(),
|
||||||
|
transformation.getLeftRotation(),
|
||||||
|
newTranslationScale,
|
||||||
|
transformation.getRightRotation());
|
||||||
|
|
||||||
|
textdisplay.setTransformation(newTransformation);
|
||||||
|
textdisplay.setRotation(rotation, 0);
|
||||||
|
|
||||||
|
textdisplay.setBillboard(Display.Billboard.FIXED);
|
||||||
|
textdisplay.setBrightness(new Brightness(15, 15));
|
||||||
|
textdisplay.setVisibleByDefault(true);
|
||||||
|
textdisplay.setDisplayHeight(3);
|
||||||
|
textdisplay.setDisplayWidth((float) BoardSize.boardSizesWidth[widthIndex] / 3);
|
||||||
|
textdisplay.text(Component.text(ChatColor.GOLD + "Minesweeper"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTextDisplay() {
|
||||||
|
if (textDisplay != null) {
|
||||||
|
textDisplay.text(Component.text(ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTextDisplay() {
|
||||||
|
if (textDisplay != null) {
|
||||||
|
textDisplay.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBlockDisplays() {
|
public void removeBlockDisplays() {
|
||||||
|
|
@ -379,67 +373,64 @@ public class MinecleanerArena {
|
||||||
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
||||||
|
|
||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
for(int fx = 0; fx < sizeWidth; fx++) {
|
for (int fx = 0; fx < sizeWidth; fx++) {
|
||||||
for(int fy = 0; fy < sizeHeight; fy++) {
|
for (int fy = 0; fy < sizeHeight; fy++) {
|
||||||
UUID blockDisplayUuid = blockDisplays[fx + fy * sizeWidth];
|
UUID blockDisplayUuid = blockDisplays[fx + fy * sizeWidth];
|
||||||
Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null;
|
Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null;
|
||||||
if(blockDisplayEntity instanceof Display blockdisplay) {
|
if (blockDisplayEntity instanceof Display blockdisplay) {
|
||||||
blockDisplayEntity.remove();
|
blockDisplayEntity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flagCell(int x, int y) {
|
public void flagCell(int x, int y) {
|
||||||
if(currentMinecleanerGame != null && !currentMinecleanerGame.gameover) {
|
if (currentMinecleanerGame != null && !currentMinecleanerGame.gameover) {
|
||||||
Cell cell = currentMinecleanerGame.getCell(x, y);
|
Cell cell = currentMinecleanerGame.getCell(x, y);
|
||||||
if(!cell.isRevealed()) {
|
if (!cell.isRevealed()) {
|
||||||
Player player = this.currentPlayer;
|
Player player = this.currentPlayer;
|
||||||
|
|
||||||
currentMinecleanerGame.flag(x, y);
|
currentMinecleanerGame.flag(x, y);
|
||||||
if(currentMinecleanerGame.gameover) {
|
if (currentMinecleanerGame.gameover) {
|
||||||
plugin.getManager().handleGameover(player, this, true);
|
plugin.getManager().handleGameover(player, this, true);
|
||||||
}
|
}
|
||||||
|
if (cell.isFlagged() == true) {
|
||||||
if(cell.isFlagged() == true) {
|
|
||||||
flagsPlaced = flagsPlaced + 1;
|
flagsPlaced = flagsPlaced + 1;
|
||||||
sendActionBarMessage(player);
|
updateTextDisplay();
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
||||||
}
|
}
|
||||||
|
if (cell.isFlagged() == false) {
|
||||||
if(cell.isFlagged() == false) {
|
|
||||||
flagsPlaced = flagsPlaced - 1;
|
flagsPlaced = flagsPlaced - 1;
|
||||||
sendActionBarMessage(player);
|
updateTextDisplay();
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revealCell(int x, int y) {
|
public void revealCell(int x, int y) {
|
||||||
if(currentMinecleanerGame != null && !currentMinecleanerGame.gameover) {
|
if (currentMinecleanerGame != null && !currentMinecleanerGame.gameover) {
|
||||||
Cell cell = currentMinecleanerGame.getCell(x, y);
|
Cell cell = currentMinecleanerGame.getCell(x, y);
|
||||||
if(!cell.isFlagged()) {
|
if (!cell.isFlagged()) {
|
||||||
Player player = this.currentPlayer;
|
Player player = this.currentPlayer;
|
||||||
|
|
||||||
if(!hasMadeFirstClick) {
|
if (!hasMadeFirstClick) {
|
||||||
currentMinecleanerGame.firstClick(x, y);
|
currentMinecleanerGame.firstClick(x, y);
|
||||||
hasMadeFirstClick = true;
|
hasMadeFirstClick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
sendActionBarMessage(player);
|
updateTextDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
||||||
if(floodedCells != null) {
|
if (floodedCells != null) {
|
||||||
for(int i = 0; i < floodedCells.size(); i++) {
|
for (int i = 0; i < floodedCells.size(); i++) {
|
||||||
Vector2i pos = floodedCells.get(i).position;
|
Vector2i pos = floodedCells.get(i).position;
|
||||||
setBlockForCellType(pos.x, pos.y, floodedCells.get(i));
|
setBlockForCellType(pos.x, pos.y, floodedCells.get(i));
|
||||||
}
|
}
|
||||||
|
|
@ -449,36 +440,29 @@ 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) {
|
||||||
for(int i = 0; i < explodedCells.size(); i++) {
|
for (int i = 0; i < explodedCells.size(); i++) {
|
||||||
Vector2i pos = explodedCells.get(i).position;
|
Vector2i pos = explodedCells.get(i).position;
|
||||||
setBlockForCellType(pos.x, pos.y, explodedCells.get(i));
|
setBlockForCellType(pos.x, pos.y, explodedCells.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBlockForCellType(int x, int y, Cell cell) {
|
private void setBlockForCellType(int x, int y, Cell cell) {
|
||||||
switch (cell.getType()) {
|
switch (cell.getType()) {
|
||||||
case Empty: {
|
case Empty: {
|
||||||
if(!cell.isRevealed() || !cell.isFlagged() || !cell.isExploded()) {
|
if (!cell.isRevealed() || !cell.isFlagged() || !cell.isExploded()) {
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_0, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_0, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Number: {
|
case Number: {
|
||||||
if(!cell.isRevealed() || !cell.isFlagged() || !cell.isExploded()) {
|
if (!cell.isRevealed() || !cell.isFlagged() || !cell.isExploded()) {
|
||||||
switch(cell.number) {
|
switch (cell.number) {
|
||||||
case 1: {
|
case 1: {
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_1, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_1, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
|
|
@ -517,7 +501,7 @@ public class MinecleanerArena {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Mine: {
|
case Mine: {
|
||||||
if(cell.isExploded()) {
|
if (cell.isExploded()) {
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.EXPLODED, true);
|
setDiplayBlock(x, y, MinecleanerHeads.EXPLODED, true);
|
||||||
} else {
|
} else {
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.TNT, true);
|
setDiplayBlock(x, y, MinecleanerHeads.TNT, true);
|
||||||
|
|
@ -540,9 +524,9 @@ public class MinecleanerArena {
|
||||||
int d1z = d0x;
|
int d1z = d0x;
|
||||||
|
|
||||||
Location loc = location.clone();
|
Location loc = location.clone();
|
||||||
|
|
||||||
for(int fx = -1 - (BoardSize.boardSizesWidth[widthIndex]/3 - 3); fx < 2; fx++) { // boardWith/3
|
for (int fx = -1 - (BoardSize.boardSizesWidth[widthIndex] / 3 - 3); fx < 2; fx++) { // boardWith/3
|
||||||
for(int fy = -1; fy < BoardSize.boardSizesHeight[widthIndex]/3 - 1; fy++) { // fy < boardHeight/3 - 1
|
for (int fy = -1; fy < BoardSize.boardSizesHeight[widthIndex] / 3 - 1; fy++) { // fy < boardHeight/3 - 1
|
||||||
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());
|
blocks.add(loc.clone());
|
||||||
}
|
}
|
||||||
|
|
@ -551,44 +535,42 @@ public class MinecleanerArena {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTooFarAway(Player player) {
|
public boolean isTooFarAway(Player player) {
|
||||||
if(currentMinecleanerGame != null && currentMinecleanerGame.gameover) return false;
|
if (currentMinecleanerGame != null && currentMinecleanerGame.gameover) return false;
|
||||||
if(player.getWorld() != location.getWorld()) {
|
if (player.getWorld() != location.getWorld()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
player.getLocation(tempLoc);
|
player.getLocation(tempLoc);
|
||||||
|
|
||||||
double centerX = centerLocation.getX();
|
double centerX = centerLocation.getX();
|
||||||
double centerY = centerLocation.getY() + (BoardSize.boardSizesHeight[widthIndex]/3)/2.0 - 1;
|
double centerY = centerLocation.getY() + (BoardSize.boardSizesHeight[widthIndex] / 3) / 2.0 - 1;
|
||||||
double centerZ = centerLocation.getZ();
|
double centerZ = centerLocation.getZ();
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case NORTH: {
|
case NORTH: {
|
||||||
centerX = centerLocation.getX() - ((BoardSize.boardSizesWidth[widthIndex]/3)/2.0) + 1;
|
centerX = centerLocation.getX() - ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EAST: {
|
case EAST: {
|
||||||
centerZ = centerLocation.getZ() - ((BoardSize.boardSizesWidth[widthIndex]/3)/2.0) + 1;
|
centerZ = centerLocation.getZ() - ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SOUTH: {
|
case SOUTH: {
|
||||||
centerX = centerLocation.getX() + ((BoardSize.boardSizesWidth[widthIndex]/3)/2.0) -1;
|
centerX = centerLocation.getX() + ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WEST: {
|
case WEST: {
|
||||||
centerZ = centerLocation.getZ() + ((BoardSize.boardSizesWidth[widthIndex]/3)/2.0) - 1;
|
centerZ = centerLocation.getZ() + ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location trueCenterLocation = new Location(player.getWorld(), centerX, centerY, centerZ);
|
Location trueCenterLocation = new Location(player.getWorld(), centerX, centerY, centerZ);
|
||||||
double dist = tempLoc.distanceSquared(trueCenterLocation);
|
double dist = tempLoc.distanceSquared(trueCenterLocation);
|
||||||
player.sendMessage(ChatColor.GOLD + "Dist: " + dist);
|
|
||||||
|
|
||||||
return dist > Math.pow((BoardSize.boardSizesWidth[widthIndex]/4.5) + 6, 2);
|
return dist > Math.pow((BoardSize.boardSizesWidth[widthIndex] / 4.5) + 6, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -629,5 +611,14 @@ public class MinecleanerArena {
|
||||||
|
|
||||||
public int getWidthIndex() {
|
public int getWidthIndex() {
|
||||||
return widthIndex;
|
return widthIndex;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private int getRotationYaw() {
|
||||||
|
return switch (orientation) {
|
||||||
|
case EAST -> 90;
|
||||||
|
case SOUTH -> 180;
|
||||||
|
case WEST -> 270;
|
||||||
|
default -> 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue