Compare commits
56 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a89930a73a | |||
| 8c105bba58 | |||
| 017a02a0c0 | |||
| 854fdd1c1d | |||
| 9f65250771 | |||
| 31b18a98c9 | |||
| 63674eb9ef | |||
| a308cc9546 | |||
| d5536db37f | |||
| e17b7fcc1e | |||
| 7e171194ce | |||
| e4e973449b | |||
| 37ebd2a743 | |||
| 558f113f9d | |||
| 12c58e86a2 | |||
| 5df021e3dd | |||
| 50f51126bb | |||
| 70605461ef | |||
| 45ad276699 | |||
| b57e9ff410 | |||
| b7e97212ac | |||
| 583f8a1257 | |||
| 2bc7a3979e | |||
| f09c9772b2 | |||
| 75768ea587 | |||
| b1193d4687 | |||
| 0f349c3ea0 | |||
| d0c27ae733 | |||
| 94d796e09b | |||
| e2c84ec436 | |||
| b773d0e490 | |||
| 36e96a50e8 | |||
| 4e283a77b1 | |||
| d4a6b64ae5 | |||
| 482fc1e22d | |||
| 4ab4a1bec4 | |||
| bf13f7e2b9 | |||
| 0865e344f9 | |||
| b5fdf5bfec | |||
| 9ad56fe06c | |||
| 3cd55fa3fa | |||
| 72f53f8aad | |||
| b25e68ca14 | |||
| 82a4920899 | |||
| c8978e2625 | |||
| 335b4cfab1 | |||
| 42696fb612 | |||
| 50c72615bd | |||
| 8e3590db00 | |||
| 1fd325cebb | |||
| 625af3dfcb | |||
| fbd5f81e13 | |||
| 02c19075d7 | |||
|
|
6e62c7d172 |
||
| 496c0c06bd | |||
| 14e6d0b5e8 |
39 changed files with 2523 additions and 473 deletions
123
.gitignore
vendored
123
.gitignore
vendored
|
|
@ -1,5 +1,122 @@
|
||||||
# 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/
|
||||||
|
|
||||||
|
# eclipse
|
||||||
|
/.classpath
|
||||||
|
/.project
|
||||||
|
/.settings
|
||||||
|
/target
|
||||||
4
LICENSE
4
LICENSE
|
|
@ -208,7 +208,7 @@ If you develop a new program, and you want it to be of the greatest possible use
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
NewMinecleaner
|
Minecleaner
|
||||||
Copyright (C) 2024 LunarAkai
|
Copyright (C) 2024 LunarAkai
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
@ -221,7 +221,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
NewMinecleaner Copyright (C) 2024 LunarAkai
|
Minecleaner Copyright (C) 2024 LunarAkai
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
6
README.md
Normal file
6
README.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Minecleaner
|
||||||
|
|
||||||
|
Minecleaner is a Minecraft Implementation of the classic game "Minesweeper". Made using [Paper](https://papermc.io/).
|
||||||
|
|
||||||
|
## Important
|
||||||
|
Before opening an issue on the [GitHub Repo](https://github.com/LunarAkai/Minecleaner) of this Project, please check the issues page on my personal git server [here](https://git.lunarakai.de/LunarAkai/NewMinecleaner/issues) to see if this Bug / Issue is already on my list.
|
||||||
19
pom.xml
19
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>de.lunarakai</groupId>
|
<groupId>de.lunarakai</groupId>
|
||||||
<artifactId>Minecleaner</artifactId>
|
<artifactId>Minecleaner</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.2.0-dev</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Minecleaner</name>
|
<name>Minecleaner</name>
|
||||||
|
|
@ -17,7 +17,22 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${project.name}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.github.git-commit-id</groupId>
|
||||||
|
<artifactId>git-commit-id-maven-plugin</artifactId>
|
||||||
|
<version>8.0.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>get-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>revision</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
|
@ -71,7 +86,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
<version>1.21.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,14 @@ package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import de.lunarakai.minecleaner.utils.MinecleanerUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
@ -97,6 +101,13 @@ public class ArenaList {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checks for any other arena that might be at the same location as the new MinecleanerArena
|
||||||
|
*
|
||||||
|
* @param newArena the new Arena that is set to be created
|
||||||
|
* @return true if another MinecleanerArena (or at least one Block of another arena) is at the same location as newArena otherwise false
|
||||||
|
* @see MinecleanerArena
|
||||||
|
*/
|
||||||
public boolean collidesWithArena(MinecleanerArena newArena) {
|
public boolean collidesWithArena(MinecleanerArena newArena) {
|
||||||
for(Location location : newArena.getBlocks()) {
|
for(Location location : newArena.getBlocks()) {
|
||||||
if(arenaBlocks.get(location) != null) {
|
if(arenaBlocks.get(location) != null) {
|
||||||
|
|
@ -106,16 +117,74 @@ public class ArenaList {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArenaForPlayer(Player player, MinecleanerArena arena) {
|
public void setArenaForPlayers(Player[] players, MinecleanerArena arena) {
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
playersInArena.put(player.getUniqueId(), arena);
|
for(int i = 0; i < players.length; i++) {
|
||||||
|
playersInArena.put(players[i].getUniqueId(), arena);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
playersInArena.remove(player.getUniqueId());
|
for(int i = 0; i < players.length; i++) {
|
||||||
|
playersInArena.remove(players[i].getUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecleanerArena getPlayerArena(Player player) {
|
public MinecleanerArena getPlayerArena(Player player) {
|
||||||
return playersInArena.get(player.getUniqueId());
|
if(playersInArena.get(player.getUniqueId()) == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int arraySize = MinecleanerUtils.isPlayerInGroup(plugin, player) ? plugin.getGroupManager().getGroupSize(player) : 1;
|
||||||
|
Player[] players = new Player[arraySize];
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(player) != null) {
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
players[i] = iteratorPlayer;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Arrays.fill(players, player);
|
||||||
|
}
|
||||||
|
return getPlayerArena(players);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecleanerArena getPlayerArena(Player[] players) {
|
||||||
|
return playersInArena.get(players[0].getUniqueId());
|
||||||
|
// if(plugin.getGroupManager().getGroup(players[0]) != null) {
|
||||||
|
// if(players.length == 1) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// MinecleanerArena[] arenas = new MinecleanerArena[players.length];
|
||||||
|
// for(int i = 0; i < players.length; i++) {
|
||||||
|
// if(playersInArena.get(players[i].getUniqueId()) != null) {
|
||||||
|
// if(playersInArena.get(Bukkit.getPlayer(plugin.getGroupManager().getGroup(players[0]).getOwner()).getUniqueId()) != null) {
|
||||||
|
// arenas[i] = playersInArena.get(players[i].getUniqueId());
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// arenas[i] = null;
|
||||||
|
// } else {
|
||||||
|
// arenas = null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(playersInArena.get(players[0].getUniqueId()) == null) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(arenas != null && arenas[0] != null) {
|
||||||
|
// MinecleanerArena[] finalArenas = arenas;
|
||||||
|
// boolean match = Arrays.stream(arenas).allMatch(s -> s.equals(finalArenas[0]));
|
||||||
|
// if(match) {
|
||||||
|
// return arenas[0];
|
||||||
|
// } else {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// return playersInArena.get(players[0].getUniqueId());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecleanerArena getArenaAtBlock(Block block) {
|
public MinecleanerArena getArenaAtBlock(Block block) {
|
||||||
|
|
@ -127,21 +196,30 @@ public class ArenaList {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeArena(MinecleanerArena arena) {
|
public void removeArena(MinecleanerArena arena) {
|
||||||
if(arena.hasPlayer()) {
|
if(arena.hasPlayers()) {
|
||||||
plugin.getManager().leaveArena(arena.getCurrentPlayer(), true);
|
plugin.getManager().leaveArena(arena.getCurrentPlayers(), true, true);
|
||||||
}
|
|
||||||
|
|
||||||
for(UUID id : arena.getBlockDisplays()) {
|
|
||||||
if(id != null) {
|
|
||||||
arenaBlockDisplays.remove(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(Location block : arena.getBlocks()) {
|
|
||||||
arenaBlocks.remove(block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeArenaBlockDisplayIDs(arena);
|
||||||
|
removeArenaBlocks(arena);
|
||||||
|
|
||||||
arena.removeBlockDisplays();
|
arena.removeBlockDisplays();
|
||||||
|
|
||||||
arenas.remove(arena.getName());
|
arenas.remove(arena.getName());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeArenaBlocks(MinecleanerArena arena) {
|
||||||
|
for(Location block : arena.getBlocks()) {
|
||||||
|
arenaBlocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeArenaBlockDisplayIDs(MinecleanerArena arena) {
|
||||||
|
for(UUID id : arena.getBlockDisplays()) {
|
||||||
|
if(id != null) {
|
||||||
|
arenaBlockDisplays.remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,35 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possible Status of a MinecleanerArena
|
||||||
|
* <li>{@link #INACTIVE}</li>
|
||||||
|
* <li>{@link #CONFIRM_PLAYING}</li>
|
||||||
|
* <li>{@link #PLAYING}</li>
|
||||||
|
* <li>{@link #COMPLETED}</li>
|
||||||
|
*
|
||||||
|
* @see MinecleanerArena
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum ArenaStatus {
|
public enum ArenaStatus {
|
||||||
|
/**
|
||||||
|
* default state
|
||||||
|
*/
|
||||||
INACTIVE,
|
INACTIVE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active when the player (or group leader) has interacted with an {@link #INACTIVE} arena and
|
||||||
|
* sees the confirmPlayingInventory to decide if they start a Game or not
|
||||||
|
* @see MinecleanerManager#getConfirmPlayingInventory()
|
||||||
|
*/
|
||||||
CONFIRM_PLAYING,
|
CONFIRM_PLAYING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active when a Player (or Group) has confirmed to start a Minecleaner Game (and while playing)
|
||||||
|
*/
|
||||||
PLAYING,
|
PLAYING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active when a Player (or Group) has either won or lost a Mineclenaer Game and the Arena the scheduled for a reset -> {@link #INACTIVE}
|
||||||
|
*/
|
||||||
COMPLETED
|
COMPLETED
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import de.lunarakai.minecleaner.game.BoardSize;
|
||||||
|
import de.lunarakai.minecleaner.game.Cell;
|
||||||
|
import de.lunarakai.minecleaner.game.Game;
|
||||||
|
import de.lunarakai.minecleaner.utils.MinecleanerHeads;
|
||||||
|
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
||||||
import java.util.ArrayList;
|
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 net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
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,18 +25,11 @@ 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;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import de.lunarakai.minecleaner.game.BoardSize;
|
|
||||||
import de.lunarakai.minecleaner.game.Cell;
|
|
||||||
import de.lunarakai.minecleaner.game.Game;
|
|
||||||
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;
|
||||||
|
|
@ -37,54 +40,26 @@ 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[] currentPlayers;
|
||||||
private Player currentPlayer;
|
|
||||||
private long currentGameStartTime;
|
private long currentGameStartTime;
|
||||||
|
private long ingameTime;
|
||||||
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 +67,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 +81,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 +102,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 +112,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 +135,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 +197,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 +209,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,7 +223,10 @@ 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();
|
||||||
|
ingameTime = 0;
|
||||||
flagsPlaced = 0;
|
flagsPlaced = 0;
|
||||||
hasMadeFirstClick = false;
|
hasMadeFirstClick = false;
|
||||||
arenaStatus = ArenaStatus.PLAYING;
|
arenaStatus = ArenaStatus.PLAYING;
|
||||||
|
|
@ -299,56 +234,129 @@ public class MinecleanerArena {
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
if(arenaStatus == ArenaStatus.PLAYING && currentPlayers != null) {
|
||||||
sendActionBarMessage(currentPlayer);
|
if(!currentMinecleanerGame.gameover) {
|
||||||
}
|
ingameTime++;
|
||||||
|
}
|
||||||
|
if(plugin.isStatisticsEnabled()) {
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayers[0]) != 0
|
||||||
|
|| plugin.getManager().getSettingsValue("timer", currentPlayers[0]) != 0) {
|
||||||
|
updateIngameInfoTexts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 20L, 20L);
|
}.runTaskTimer(plugin, 1L, 1L);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJoiningPlayer(Player player) {
|
public void addJoiningPlayers(Player[] players) {
|
||||||
Preconditions.checkNotNull(player);
|
Preconditions.checkNotNull(players);
|
||||||
Preconditions.checkState(arenaStatus == ArenaStatus.INACTIVE);
|
Preconditions.checkState(arenaStatus == ArenaStatus.INACTIVE);
|
||||||
this.arenaStatus = ArenaStatus.CONFIRM_PLAYING;
|
this.arenaStatus = ArenaStatus.CONFIRM_PLAYING;
|
||||||
this.currentPlayer = player;
|
this.currentPlayers = players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer() {
|
public void removePlayers() {
|
||||||
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
|
||||||
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
|
||||||
|
|
||||||
this.arenaStatus = ArenaStatus.INACTIVE;
|
this.arenaStatus = ArenaStatus.INACTIVE;
|
||||||
this.currentPlayer = null;
|
this.currentPlayers = null;
|
||||||
this.currentMinecleanerGame = null;
|
this.currentMinecleanerGame = null;
|
||||||
|
|
||||||
for(int x = 0; x < sizeWidth; x++) {
|
// load chunk of block -1 and x+1
|
||||||
for(int y = 0; y < sizeHeight; y++) {
|
// loadBlockChunk();
|
||||||
|
|
||||||
|
for (int x = 0; x < sizeWidth; x++) {
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void loadBlockChunk() {
|
||||||
|
//
|
||||||
|
// BlockFace orientation = getOrientation();
|
||||||
|
// Location loc1 = this.getLocation();
|
||||||
|
// Location loc2 = this.getLocation();
|
||||||
|
// double x;
|
||||||
|
// double z;
|
||||||
|
//
|
||||||
|
// switch (orientation) {
|
||||||
|
// case NORTH:
|
||||||
|
// // Block -1:
|
||||||
|
// // x: +1
|
||||||
|
// x = loc1.x() + 3.0;
|
||||||
|
// loc1 = new Location(loc1.getWorld(), x, loc1.y(), loc1.z());
|
||||||
|
// // Block width+1:
|
||||||
|
// // x: -1;
|
||||||
|
// x = loc2.x() - (double) getArenaWidth()/4 - 1;
|
||||||
|
// loc2 = new Location(loc2.getWorld(), x, loc2.y(), loc2.z());
|
||||||
|
// break;
|
||||||
|
// case EAST:
|
||||||
|
// // Block -1:
|
||||||
|
// // z: +1
|
||||||
|
// z = loc1.z() + 3.0;
|
||||||
|
// loc1 = new Location(loc2.getWorld(), loc2.x(), loc2.y(), z);
|
||||||
|
// // Block width+1:
|
||||||
|
// // z: -1;
|
||||||
|
// z = loc2.z() - (double) getArenaWidth()/4 - 1;
|
||||||
|
// loc2 = new Location(loc2.getWorld(), loc2.x(), loc2.y(), z);
|
||||||
|
// break;
|
||||||
|
// case SOUTH:
|
||||||
|
// // Block -1:
|
||||||
|
// // x: -1
|
||||||
|
// x = loc1.x() - 3.0;
|
||||||
|
// loc1 = new Location(loc1.getWorld(), x, loc1.y(), loc1.z());
|
||||||
|
// // Block width+1:
|
||||||
|
// // x: +1;
|
||||||
|
// x = loc2.x() + (double) getArenaWidth()/4 + 1;
|
||||||
|
// loc2 = new Location(loc2.getWorld(), x, loc2.y(), loc2.z());
|
||||||
|
// break;
|
||||||
|
// case WEST:
|
||||||
|
// // Block -1:
|
||||||
|
// // z: -1
|
||||||
|
// z = loc1.z() - 3.0 ;
|
||||||
|
// loc1 = new Location(loc2.getWorld(), loc2.x(), loc2.y(), z);
|
||||||
|
// // Block width+1:
|
||||||
|
// // z: +1;
|
||||||
|
// z = loc2.z() + (double) getArenaWidth()/4 - 1;
|
||||||
|
// loc2 = new Location(loc2.getWorld(), loc2.x(), loc2.y(), z);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// plugin.getLogger().log(Level.WARNING, "Loc1: " + loc1);
|
||||||
|
// plugin.getLogger().log(Level.WARNING, "Loc2: " + loc2);
|
||||||
|
// loc1.getWorld().getChunkAt(loc1).load();
|
||||||
|
// loc2.getWorld().getChunkAt(loc2).load();
|
||||||
|
// }
|
||||||
|
|
||||||
public void showStartHeads() {
|
public void showStartHeads() {
|
||||||
int width = BoardSize.boardSizesWidth[widthIndex];
|
int width = BoardSize.boardSizesWidth[widthIndex];
|
||||||
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 +364,117 @@ 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[] players = this.getCurrentPlayers();
|
||||||
|
World world = players[0].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(players[0].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.setPersistent(false);
|
||||||
|
textdisplay.text(Component.text(ChatColor.GOLD + plugin.getDisplayedPluginName()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateIngameInfoTexts() {
|
||||||
|
String timer = "";
|
||||||
|
if(plugin.isStatisticsEnabled()) {
|
||||||
|
if(plugin.getManager().getSettingsValue("timer", currentPlayers[0]) != 0) {
|
||||||
|
timer = ChatColor.GOLD + " Zeit: " + MinecleanerStringUtil.timeToString((ingameTime/20)*1000, true) + " ";
|
||||||
|
}
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayers[0]) != 0 && plugin.isStatisticsEnabled()) {
|
||||||
|
String componentActionBar = ChatColor.GREEN + "Flaggen gesetzt: " + flagsPlaced + ChatColor.RED + " Minen insgesamt: " + BoardSize.mineCounter[widthIndex];
|
||||||
|
for(int i = 0; i < currentPlayers.length; i++) {
|
||||||
|
currentPlayers[i].sendActionBar(Component.text(componentActionBar + " " + timer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textDisplay != null) {
|
||||||
|
String component = ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --";
|
||||||
|
//textDisplay.text(Component.text(ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --"));
|
||||||
|
String newLine = "";
|
||||||
|
String filler = "";
|
||||||
|
if(!timer.equals("")) {
|
||||||
|
newLine = "\n" + ChatColor.GOLD + "-- ";
|
||||||
|
filler = " --";
|
||||||
|
}
|
||||||
|
textDisplay.text(Component.text(component + newLine + timer + filler));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTextDisplay() {
|
||||||
|
if (textDisplay != null) {
|
||||||
|
textDisplay.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBlockDisplays() {
|
public void removeBlockDisplays() {
|
||||||
|
|
@ -379,67 +482,71 @@ 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[] players = this.currentPlayers;
|
||||||
|
|
||||||
currentMinecleanerGame.flag(x, y);
|
|
||||||
if(currentMinecleanerGame.gameover) {
|
|
||||||
plugin.getManager().handleGameover(player, this, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cell.isFlagged() == true) {
|
|
||||||
flagsPlaced = flagsPlaced + 1;
|
|
||||||
sendActionBarMessage(player);
|
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cell.isFlagged() == false) {
|
currentMinecleanerGame.flag(x, y);
|
||||||
|
if (currentMinecleanerGame.gameover) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
arenaStatus = ArenaStatus.COMPLETED;
|
||||||
|
}, 5L);
|
||||||
|
|
||||||
|
plugin.getManager().handleGameover(players, this, true);
|
||||||
|
}
|
||||||
|
if (cell.isFlagged() == true) {
|
||||||
|
flagsPlaced = flagsPlaced + 1;
|
||||||
|
updateIngameInfoTexts();
|
||||||
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
||||||
|
}
|
||||||
|
if (cell.isFlagged() == false) {
|
||||||
flagsPlaced = flagsPlaced - 1;
|
flagsPlaced = flagsPlaced - 1;
|
||||||
sendActionBarMessage(player);
|
updateIngameInfoTexts();
|
||||||
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[] players = this.currentPlayers;
|
||||||
|
|
||||||
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()));
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
arenaStatus = ArenaStatus.COMPLETED;
|
||||||
|
}, 5L);
|
||||||
|
plugin.getManager().handleGameover(players, this, !(cell.isRevealed() && cell.isExploded()));
|
||||||
} else {
|
} else {
|
||||||
sendActionBarMessage(player);
|
updateIngameInfoTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +556,30 @@ 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) {
|
||||||
|
if(cell.getType() == null) return;
|
||||||
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 +618,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 +641,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,35 +652,54 @@ 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 dist = tempLoc.distanceSquared(centerLocation);
|
|
||||||
switch (widthIndex) {
|
double centerX = centerLocation.getX();
|
||||||
case 0:
|
double centerY = centerLocation.getY() + (BoardSize.boardSizesHeight[widthIndex] / 3) / 2.0 - 1;
|
||||||
return dist > 64.0;
|
double centerZ = centerLocation.getZ();
|
||||||
case 1:
|
|
||||||
return dist > 96.0;
|
switch (orientation) {
|
||||||
case 2:
|
case NORTH: {
|
||||||
return dist > 128.0;
|
centerX = centerLocation.getX() - ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 1;
|
||||||
case 3:
|
break;
|
||||||
return dist > 256.0;
|
}
|
||||||
|
case EAST: {
|
||||||
|
centerZ = centerLocation.getZ() - ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SOUTH: {
|
||||||
|
centerX = centerLocation.getX() + ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEST: {
|
||||||
|
centerZ = centerLocation.getZ() + ((BoardSize.boardSizesWidth[widthIndex] / 3) / 2.0) - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dist > 64.0;
|
|
||||||
|
Location trueCenterLocation = new Location(player.getWorld(), centerX, centerY, centerZ);
|
||||||
|
double dist = tempLoc.distanceSquared(trueCenterLocation);
|
||||||
|
|
||||||
|
return dist > Math.pow((BoardSize.boardSizesWidth[widthIndex] / 4.5) + 6, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayer() {
|
public boolean hasPlayers() {
|
||||||
return currentPlayer != null;
|
return currentPlayers != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getCurrentPlayer() {
|
public Player[] getCurrentPlayers() {
|
||||||
return currentPlayer;
|
return currentPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
|
|
@ -598,15 +718,33 @@ public class MinecleanerArena {
|
||||||
return blockDisplays;
|
return blockDisplays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getArenaWidth() {
|
||||||
return BoardSize.boardSizesWidth[widthIndex];
|
return BoardSize.boardSizesWidth[widthIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getArenaHeight() { return BoardSize.boardSizesHeight[widthIndex]; }
|
||||||
|
|
||||||
public long getCurrentGameStartTime() {
|
public long getCurrentGameStartTime() {
|
||||||
return currentGameStartTime;
|
return currentGameStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Game getCurrentMinecleanerGame() { return currentMinecleanerGame; }
|
||||||
|
|
||||||
public int getWidthIndex() {
|
public int getWidthIndex() {
|
||||||
return widthIndex;
|
return widthIndex;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void setArenaStaus(ArenaStatus status) {
|
||||||
|
this.arenaStatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRotationYaw() {
|
||||||
|
return switch (orientation) {
|
||||||
|
case EAST -> 90;
|
||||||
|
case SOUTH -> 180;
|
||||||
|
case WEST -> 270;
|
||||||
|
default -> 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,155 @@
|
||||||
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MinecleanerGroupManager {
|
||||||
|
|
||||||
|
public class MinecleanerGroup {
|
||||||
|
|
||||||
|
public UUID owner;
|
||||||
|
public HashSet<UUID> players;
|
||||||
|
public Set<UUID> invitedPlayers;
|
||||||
|
|
||||||
|
public MinecleanerGroup(UUID owner){
|
||||||
|
this.owner = owner;
|
||||||
|
this.players = new HashSet<>();
|
||||||
|
this.invitedPlayers = new HashSet<>();
|
||||||
|
|
||||||
|
players.add(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<UUID> getInvitedPlayers() {
|
||||||
|
return invitedPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<UUID> getPlayers() {
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayerToGroup(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
|
||||||
|
if(!isPlayerInvited(playerUUID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
invitedPlayers.remove(playerUUID);
|
||||||
|
players.add(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayerFromGroup(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
if(getOwner() == playerUUID) {
|
||||||
|
for(Iterator<UUID> iterator = getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
if(getOwner() == iterator.next()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "group.creator.removed");
|
||||||
|
}
|
||||||
|
deleteGroup(getGroup(Bukkit.getPlayer(owner)));
|
||||||
|
}
|
||||||
|
players.remove(playerUUID);
|
||||||
|
if(players.size() < 2) {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(Bukkit.getPlayer(owner), "group.dismantled.alone");
|
||||||
|
deleteGroup(getGroup(Bukkit.getPlayer(owner)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayerInvited(UUID playerUUID) {
|
||||||
|
return invitedPlayers.contains(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInGroup(UUID playerUUID) {
|
||||||
|
return players.contains(playerUUID) || owner.equals(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean invitePlayerToGroup(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
if(isPlayerInvited(playerUUID) || isInGroup(playerUUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
invitedPlayers.add(player.getUniqueId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayerFromInvitedList(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
if(!isPlayerInvited(playerUUID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
invitedPlayers.remove(playerUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Set<MinecleanerGroup> groups;
|
||||||
|
|
||||||
|
public MinecleanerGroupManager() {
|
||||||
|
this.groups = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createGroup(Player player) {
|
||||||
|
|
||||||
|
if (getGroup(player) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
groups.add(new MinecleanerGroup(player.getUniqueId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecleanerGroup getGroup(Player player){
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
for (MinecleanerGroup group : groups) {
|
||||||
|
if (group.isInGroup(playerUUID)) {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loops through all MinecleanerGroups to check if the player is invited to any group
|
||||||
|
*
|
||||||
|
* @param player Minecraft Player
|
||||||
|
* @return the MinecleanerGroup the Player is invited to or null
|
||||||
|
*/
|
||||||
|
public MinecleanerGroup getInvitedGroup(Player player){
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
for (MinecleanerGroup group : groups) {
|
||||||
|
if (group.isPlayerInvited(playerUUID)) {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteGroup(MinecleanerGroup minecleanerGroup) {
|
||||||
|
groups.remove(minecleanerGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes all MinecleanerGroups
|
||||||
|
*/
|
||||||
|
public void deleteAllGroups() {
|
||||||
|
groups.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the MinecleanerGroup the player is in
|
||||||
|
*
|
||||||
|
* @param player the Minecraft Player
|
||||||
|
* @return the size of the group the player is in
|
||||||
|
*/
|
||||||
|
public int getGroupSize(Player player) {
|
||||||
|
return getGroup(player).getPlayers().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -20,7 +25,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
public class MinecleanerListener implements Listener {
|
public class MinecleanerListener implements Listener {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
@ -38,44 +42,58 @@ public class MinecleanerListener implements Listener {
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
MinecleanerArena arenaClicked = plugin.getArenaList().getArenaAtBlock(block);
|
MinecleanerArena arenaClicked = plugin.getArenaList().getArenaAtBlock(block);
|
||||||
if(arenaClicked == arena && arena.getArenaStatus() == ArenaStatus.PLAYING) {
|
|
||||||
int d0x = arena.getOrientation().getModX();
|
|
||||||
int d0z = arena.getOrientation().getModZ();
|
|
||||||
int d1x = -d0z;
|
|
||||||
int d1z = d0x;
|
|
||||||
|
|
||||||
if (e.getBlockFace() == arena.getOrientation()) {
|
if(arenaClicked != arena) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = e.getPlayer();
|
boolean hasRightClicked = false;
|
||||||
RayTraceResult r2 = player.rayTraceBlocks(36.0);
|
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
hasRightClicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(r2 != null) {
|
if(arena.getCurrentMinecleanerGame() != null && !arena.getCurrentMinecleanerGame().gameover && (arena.getArenaStatus() == ArenaStatus.PLAYING || arena.getArenaStatus() == ArenaStatus.COMPLETED)) {
|
||||||
Vector hitPos = r2.getHitPosition();
|
if(arena.getArenaStatus() == ArenaStatus.PLAYING) {
|
||||||
Vector substract = new Vector(0.5, 0.5, 0.5);
|
int d0x = arena.getOrientation().getModX();
|
||||||
|
int d0z = arena.getOrientation().getModZ();
|
||||||
|
int d1x = -d0z;
|
||||||
|
int d1z = d0x;
|
||||||
|
|
||||||
Location loc = hitPos.subtract(arena.getLocation().toVector()).subtract(substract).toLocation(player.getWorld()); //(0.5, 0.5, 0.5); // substract 0.5, 0.5, 0.5
|
if (e.getBlockFace() == arena.getOrientation()) {
|
||||||
double lx = loc.getX();
|
|
||||||
double ly = loc.getY();
|
|
||||||
double lz = loc.getZ();
|
|
||||||
double dy = ly + 1.5;
|
|
||||||
double dz = -d1x * lx - d1z * lz + 1.5;
|
|
||||||
|
|
||||||
double blockx = (dy / 3.0) * 9.0;
|
Player player = e.getPlayer();
|
||||||
double blockz = (dz / 3.0) * 9.0;
|
RayTraceResult r2 = player.rayTraceBlocks(36.0);
|
||||||
|
|
||||||
int blockxInt = (int) blockx;
|
if(r2 != null) {
|
||||||
int blockzInt = (int) blockz;
|
Vector hitPos = r2.getHitPosition();
|
||||||
blockx -= blockxInt;
|
Vector substract = new Vector(0.5, 0.5, 0.5);
|
||||||
blockz -= blockzInt;
|
|
||||||
|
|
||||||
boolean hasRightClicked = false;
|
Location loc = hitPos.subtract(arena.getLocation().toVector()).subtract(substract).toLocation(player.getWorld()); //(0.5, 0.5, 0.5); // substract 0.5, 0.5, 0.5
|
||||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
double lx = loc.getX();
|
||||||
hasRightClicked = true;
|
double ly = loc.getY();
|
||||||
|
double lz = loc.getZ();
|
||||||
|
double dy = ly + 1.5;
|
||||||
|
double dz = -d1x * lx - d1z * lz + 1.5;
|
||||||
|
|
||||||
|
double blockx = (dy / 3.0) * 9.0;
|
||||||
|
double blockz = (dz / 3.0) * 9.0;
|
||||||
|
|
||||||
|
int blockxInt = (int) blockx;
|
||||||
|
int blockzInt = (int) blockz;
|
||||||
|
blockx -= blockxInt;
|
||||||
|
blockz -= blockzInt;
|
||||||
|
|
||||||
|
if(blockzInt < arena.getArenaWidth() && blockxInt < arena.getArenaHeight()) {
|
||||||
|
plugin.getManager().handleFieldClick(e.getPlayer(), blockzInt, blockxInt, hasRightClicked);
|
||||||
|
}
|
||||||
|
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
||||||
}
|
}
|
||||||
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
|
||||||
plugin.getManager().handleFieldClick(e.getPlayer(), blockzInt, blockxInt, hasRightClicked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(arena.hasPlayers() && arena.getArenaStatus() == ArenaStatus.COMPLETED && !hasRightClicked && (plugin.getManager().getSettingsValue("allowmanualreset", e.getPlayer()) == 1)) {
|
||||||
|
plugin.getManager().getSchedulerGameOver().cancel();
|
||||||
|
plugin.getLogger().log(Level.INFO, "canceled reset for arena " + arena.getName() + " loc: " + arena.getLocation());
|
||||||
|
plugin.getManager().leaveArena(arenaClicked.getCurrentPlayers(), false, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arena = plugin.getArenaList().getArenaAtBlock(block);
|
arena = plugin.getArenaList().getArenaAtBlock(block);
|
||||||
|
|
@ -83,9 +101,30 @@ public class MinecleanerListener implements Listener {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if(e.getHand() == EquipmentSlot.HAND) {
|
if(e.getHand() == EquipmentSlot.HAND) {
|
||||||
if(arena.getArenaStatus() == ArenaStatus.INACTIVE) {
|
if(arena.getArenaStatus() == ArenaStatus.INACTIVE) {
|
||||||
plugin.getManager().joinArena(e.getPlayer(), arena);
|
int arraySize = 1;
|
||||||
|
if(plugin.getGroupManager().getGroup(e.getPlayer()) != null) {
|
||||||
|
arraySize = plugin.getGroupManager().getGroup(e.getPlayer()).getPlayers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(e.getPlayer()) != null && plugin.getGroupManager().getGroup(e.getPlayer()).getOwner() != e.getPlayer().getUniqueId()) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(e.getPlayer(), "group.game.nopermission");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player[] players = new Player[arraySize];
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(e.getPlayer()) != null) {
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(e.getPlayer()).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
players[i] = iteratorPlayer;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Arrays.fill(players, e.getPlayer());
|
||||||
|
}
|
||||||
|
plugin.getManager().joinArena(players, arena);
|
||||||
} else {
|
} else {
|
||||||
e.getPlayer().sendMessage(ChatColor.YELLOW + "Hier spielt schon jemand anderes");
|
ChatUtils.sendSimpleInfoMessage(e.getPlayer(), "Hier spielt schon jemand anderes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -110,10 +149,20 @@ public class MinecleanerListener implements Listener {
|
||||||
if(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING) {
|
if(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING) {
|
||||||
int slot = e.getRawSlot();
|
int slot = e.getRawSlot();
|
||||||
boolean hasConfirmed = slot == 1 ? true : false;
|
boolean hasConfirmed = slot == 1 ? true : false;
|
||||||
if(hasConfirmed) {
|
if(hasConfirmed) {
|
||||||
plugin.getManager().startGame(player);
|
Player[] players;
|
||||||
player.closeInventory();
|
if(plugin.getGroupManager().getGroup(player) != null) {
|
||||||
|
players = new Player[plugin.getGroupManager().getGroupSize(player)];
|
||||||
|
players[0] = player;
|
||||||
|
} else {
|
||||||
|
players = new Player[1];
|
||||||
|
players[0] = player;
|
||||||
|
}
|
||||||
|
plugin.getManager().startGame(players);
|
||||||
|
|
||||||
|
//player.closeInventory();
|
||||||
}
|
}
|
||||||
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +175,18 @@ public class MinecleanerListener implements Listener {
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
if(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING && e.getInventory().equals(plugin.getManager().getConfirmPlayingInventory())) {
|
if(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING && e.getInventory().equals(plugin.getManager().getConfirmPlayingInventory())) {
|
||||||
plugin.getManager().leaveArena(player, false);
|
int arraySize = plugin.getGroupManager().getGroup(player) != null ? plugin.getGroupManager().getGroupSize(player) : 1;
|
||||||
|
Player[] players = new Player[arraySize];
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(player) != null) {
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
Arrays.fill(players, iteratorPlayer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Arrays.fill(players, player);
|
||||||
|
}
|
||||||
|
plugin.getManager().leaveArena(players, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -137,21 +197,106 @@ public class MinecleanerListener implements Listener {
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
if(arena.isTooFarAway(player)) {
|
if(plugin.getGroupManager().getGroup(player) == null) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Du hast dich zu weit von der Arena entfernt. Das Spiel wurde abgebrochen.");
|
if((arena.isTooFarAway(player))) {
|
||||||
plugin.getManager().leaveArena(player, false);
|
ChatUtils.sendSimpleInfoMessage(player, "arena.common.toofaraway");
|
||||||
|
Player[] players = new Player[] {
|
||||||
|
player
|
||||||
|
};
|
||||||
|
plugin.getManager().leaveArena(players, false, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Player ownerPlayer = Bukkit.getPlayer(plugin.getGroupManager().getGroup(player).getOwner());
|
||||||
|
if(ownerPlayer.equals(player)) {
|
||||||
|
if(arena.isTooFarAway(ownerPlayer)) {
|
||||||
|
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
if(iteratorPlayer == ownerPlayer) {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "arena.common.toofaraway");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert iteratorPlayer != null;
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "arena.common.groupleadertoofaraway");
|
||||||
|
}
|
||||||
|
Player[] players = new Player[] {
|
||||||
|
ownerPlayer
|
||||||
|
};
|
||||||
|
plugin.getManager().leaveArena(players, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(e.getPlayer());
|
Player player = e.getPlayer();
|
||||||
|
MinecleanerGroupManager groupManager = plugin.getGroupManager();
|
||||||
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
|
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
plugin.getManager().leaveArena(e.getPlayer(), false);
|
if(groupManager.getGroup(player) != null) {
|
||||||
|
MinecleanerGroupManager.MinecleanerGroup group = groupManager.getGroup(player);
|
||||||
|
Player ownerPlayer = Bukkit.getPlayer(group.getOwner());
|
||||||
|
if(player == ownerPlayer) {
|
||||||
|
Player[] players = iterateOverGroupMembersOnCreatorPlayerQuit(player, groupManager, group);
|
||||||
|
plugin.getManager().leaveArena(players, false, true);
|
||||||
|
} else {
|
||||||
|
iterateOverGroupMembersOnPlayerQuit(player, group);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Player[] players = new Player[] {
|
||||||
|
e.getPlayer()
|
||||||
|
};
|
||||||
|
plugin.getManager().leaveArena(players, false, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(groupManager.getGroup(player) != null) {
|
||||||
|
MinecleanerGroupManager.MinecleanerGroup group = groupManager.getGroup(player);
|
||||||
|
Player ownerPlayer = Bukkit.getPlayer(group.getOwner());
|
||||||
|
if(player == ownerPlayer) {
|
||||||
|
iterateOverGroupMembersOnCreatorPlayerQuit(player, groupManager, group);
|
||||||
|
} else {
|
||||||
|
iterateOverGroupMembersOnPlayerQuit(player, group);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void iterateOverGroupMembersOnPlayerQuit(Player player, MinecleanerGroupManager.MinecleanerGroup group) {
|
||||||
|
Player[] players = new Player[group.players.size()];
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<UUID> iterator = group.getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
if(iteratorPlayer == player) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
players[i] = iteratorPlayer;
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, player.getName() + " hat den Server verlassen und wurde aus der Gruppe entfernt.");
|
||||||
|
}
|
||||||
|
group.removePlayerFromGroup(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Player[] iterateOverGroupMembersOnCreatorPlayerQuit(Player player, MinecleanerGroupManager groupManager, MinecleanerGroupManager.MinecleanerGroup group) {
|
||||||
|
Player[] players = new Player[group.players.size()];
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<UUID> iterator = group.getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
if(iteratorPlayer == player) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
players[i] = iteratorPlayer;
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "Die " + plugin.getDisplayedPluginName() + "gruppe in der du dich befindest wurde aufgelöst. Die Person, welche die Gruppe erstellt hat, hat den Server verlassen");
|
||||||
|
}
|
||||||
|
groupManager.deleteGroup(group);
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBurn(BlockBurnEvent e) {
|
public void onBlockBurn(BlockBurnEvent e) {
|
||||||
if(plugin.getArenaList().getArenaAtBlock(e.getBlock()) != null) {
|
if(plugin.getArenaList().getArenaAtBlock(e.getBlock()) != null) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.iani.cubesidestats.api.SettingKey;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
@ -15,6 +23,7 @@ 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;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import de.iani.cubesidestats.api.PlayerStatistics;
|
import de.iani.cubesidestats.api.PlayerStatistics;
|
||||||
|
|
@ -27,12 +36,13 @@ import de.iani.cubesideutils.bukkit.items.ItemStacks;
|
||||||
import de.iani.playerUUIDCache.CachedPlayer;
|
import de.iani.playerUUIDCache.CachedPlayer;
|
||||||
import de.lunarakai.minecleaner.game.BoardSize;
|
import de.lunarakai.minecleaner.game.BoardSize;
|
||||||
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
|
// Todo: translatable components verwenden
|
||||||
public class MinecleanerManager {
|
public class MinecleanerManager {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
private final Inventory confirmPlayingInventory;
|
private final Inventory confirmPlayingInventory;
|
||||||
private final HashMap<Integer, String> sizes;
|
private final HashMap<Integer, String> sizes;
|
||||||
|
public BukkitTask schedulerGameOver;
|
||||||
|
|
||||||
// Statistics
|
// Statistics
|
||||||
private final StatisticKey statisticsWonGamesTotal;
|
private final StatisticKey statisticsWonGamesTotal;
|
||||||
|
|
@ -41,6 +51,14 @@ public class MinecleanerManager {
|
||||||
private final HashMap<Integer, StatisticKey> statisticsTimeRecord;
|
private final HashMap<Integer, StatisticKey> statisticsTimeRecord;
|
||||||
private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed;
|
private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed;
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
|
||||||
|
private Inventory settingsInventory;
|
||||||
|
private SettingKey minecleanerSettingTimerKey;
|
||||||
|
private SettingKey minecleanerAdditionalDisplaySettingKey;
|
||||||
|
private SettingKey minecleanerResetTimerSettingKey;
|
||||||
|
private SettingKey minecleanerAllowManualResetSettingKey;
|
||||||
|
|
||||||
public MinecleanerManager(MinecleanerPlugin plugin) {
|
public MinecleanerManager(MinecleanerPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
|
@ -50,169 +68,331 @@ public class MinecleanerManager {
|
||||||
this.sizes.put(2, "groß");
|
this.sizes.put(2, "groß");
|
||||||
this.sizes.put(3, "experte");
|
this.sizes.put(3, "experte");
|
||||||
|
|
||||||
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?");
|
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, plugin.getDisplayedPluginName() + " starten?");
|
||||||
this.confirmPlayingInventory.setItem(1,
|
this.confirmPlayingInventory.setItem(1, ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), NamedTextColor.GREEN + "Bestätigen"));
|
||||||
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
|
this.confirmPlayingInventory.setItem(3, ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), NamedTextColor.RED + "Abbrechen"));
|
||||||
this.confirmPlayingInventory.setItem(3,
|
|
||||||
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen")));
|
|
||||||
|
|
||||||
statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal");
|
// Settings
|
||||||
statisticsWonGamesTotal.setIsMonthlyStats(true);
|
|
||||||
statisticsWonGamesTotal.setDisplayName("Runden gewonnen");
|
|
||||||
|
|
||||||
statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointstotal");
|
|
||||||
statisticsPointsAcquired.setIsMonthlyStats(true);
|
|
||||||
statisticsPointsAcquired.setDisplayName("Punkte erspielt");
|
|
||||||
|
|
||||||
statisticsGames = new HashMap<>();
|
if(plugin.isStatisticsEnabled()) {
|
||||||
statisticsTimeRecord = new HashMap<>();
|
minecleanerSettingTimerKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.timer");
|
||||||
statisticsTotalGamesPlayed = new HashMap<>();
|
minecleanerSettingTimerKey.setDefault(0);
|
||||||
|
minecleanerSettingTimerKey.setDisplayName("Timer");
|
||||||
|
|
||||||
for(Entry<Integer, String> e : this.sizes.entrySet()) {
|
minecleanerAdditionalDisplaySettingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.additionaldisplay");
|
||||||
String sizeDisplay = e.getValue();
|
minecleanerAdditionalDisplaySettingKey.setDefault(0);
|
||||||
StatisticKey s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wongames.boardsize." + e.getKey());
|
minecleanerAdditionalDisplaySettingKey.setDisplayName("Zusätzliche Anzeige in der Action Bar");
|
||||||
s.setIsMonthlyStats(true);
|
|
||||||
s.setDisplayName("Runden gewonnen auf Spielfeldgröße " + sizeDisplay);
|
|
||||||
statisticsGames.put(e.getKey(), s);
|
|
||||||
|
|
||||||
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamestotal.boardsize." + e.getKey());
|
minecleanerResetTimerSettingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.resettime");
|
||||||
s.setIsMonthlyStats(true);
|
minecleanerResetTimerSettingKey.setDefault(5);
|
||||||
s.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay );
|
minecleanerResetTimerSettingKey.setDisplayName("Dauer die das Spielfeld für das Zurücksetzen brauchen soll");
|
||||||
statisticsTotalGamesPlayed.put(e.getKey(), s);
|
|
||||||
|
|
||||||
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.timerecord." + e.getKey());
|
minecleanerAllowManualResetSettingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.allowmanualreset");
|
||||||
s.setIsMonthlyStats(true);
|
minecleanerAllowManualResetSettingKey.setDefault(0);
|
||||||
s.setDisplayName("Bestzeit bei Größe " + sizeDisplay);
|
minecleanerAllowManualResetSettingKey.setDisplayName("Erlaube das manuelle Zurücksetzen des Spielfeldes");
|
||||||
statisticsTimeRecord.put(e.getKey(), s);
|
|
||||||
|
this.settingsInventory = plugin.getServer().createInventory(null, InventoryType.CHEST,
|
||||||
|
plugin.getDisplayedPluginName() + " Einstellungen");
|
||||||
|
|
||||||
|
|
||||||
|
// Statistics
|
||||||
|
|
||||||
|
statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal");
|
||||||
|
statisticsWonGamesTotal.setIsMonthlyStats(true);
|
||||||
|
statisticsWonGamesTotal.setDisplayName("Runden gewonnen");
|
||||||
|
|
||||||
|
statisticsPointsAcquired = plugin.getCubesideStatistics().getStatisticKey("minecleaner.pointstotal");
|
||||||
|
statisticsPointsAcquired.setIsMonthlyStats(true);
|
||||||
|
statisticsPointsAcquired.setDisplayName("Punkte erspielt");
|
||||||
|
|
||||||
|
statisticsGames = new HashMap<>();
|
||||||
|
statisticsTimeRecord = new HashMap<>();
|
||||||
|
statisticsTotalGamesPlayed = new HashMap<>();
|
||||||
|
|
||||||
|
for(Entry<Integer, String> e : this.sizes.entrySet()) {
|
||||||
|
String sizeDisplay = e.getValue();
|
||||||
|
StatisticKey s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wongames.boardsize." + e.getKey());
|
||||||
|
s.setIsMonthlyStats(true);
|
||||||
|
s.setDisplayName("Runden gewonnen auf Spielfeldgröße " + sizeDisplay);
|
||||||
|
statisticsGames.put(e.getKey(), s);
|
||||||
|
|
||||||
|
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.gamestotal.boardsize." + e.getKey());
|
||||||
|
s.setIsMonthlyStats(true);
|
||||||
|
s.setDisplayName("Runden gespielt auf Spielfeldgröße " + sizeDisplay );
|
||||||
|
statisticsTotalGamesPlayed.put(e.getKey(), s);
|
||||||
|
|
||||||
|
s = plugin.getCubesideStatistics().getStatisticKey("minecleaner.timerecord." + e.getKey());
|
||||||
|
s.setIsMonthlyStats(true);
|
||||||
|
s.setDisplayName("Bestzeit bei Größe " + sizeDisplay);
|
||||||
|
statisticsTimeRecord.put(e.getKey(), s);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.statisticsWonGamesTotal = null;
|
||||||
|
this.statisticsPointsAcquired = null;
|
||||||
|
this.statisticsGames = null;
|
||||||
|
this.statisticsTimeRecord = null;
|
||||||
|
this.statisticsTotalGamesPlayed = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, String> getSizes() {
|
|
||||||
return sizes;
|
public void joinArena(Player[] players, MinecleanerArena arena) {
|
||||||
}
|
if ((plugin.getGroupManager().getGroup(players[0]) == null && !players[0].hasPermission(MinecleanerPlugin.PERMISSION_PLAY)) || (plugin.getGroupManager().getGroup(players[0]) != null && !Bukkit.getPlayer(plugin.getGroupManager().getGroup(players[0]).getOwner()).hasPermission(MinecleanerPlugin.PERMISSION_PLAY))) {
|
||||||
|
|
||||||
public void joinArena(Player player, MinecleanerArena arena) {
|
|
||||||
if (!player.hasPermission(MinecleanerPlugin.PERMISSION_PLAY)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Preconditions.checkArgument(plugin.getArenaList().getPlayerArena(player) == null, "player is in an arena");
|
|
||||||
Preconditions.checkArgument(arena.getArenaStatus() == ArenaStatus.INACTIVE, "arena is in use");
|
|
||||||
arena.addJoiningPlayer(player);
|
|
||||||
plugin.getArenaList().setArenaForPlayer(player, arena);
|
|
||||||
player.openInventory(confirmPlayingInventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void leaveArena(Player player, boolean message) {
|
Preconditions.checkArgument(plugin.getArenaList().getPlayerArena(players) == null, "player is in an arena");
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
Preconditions.checkArgument(arena.getArenaStatus() == ArenaStatus.INACTIVE, "arena is in use");
|
||||||
Preconditions.checkArgument(arena != null, "player is in no arena");
|
|
||||||
arena.removePlayer();
|
arena.addJoiningPlayers(players);
|
||||||
plugin.getArenaList().setArenaForPlayer(player, null);
|
plugin.getArenaList().setArenaForPlayers(players, arena);
|
||||||
if(message) {
|
for(int i = 0; i < players.length; i++) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Das Minecleanerspiel wurde abgebrochen.");
|
if(plugin.getGroupManager().getGroup(players[i]) == null) {
|
||||||
|
players[i].openInventory(confirmPlayingInventory);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(players[i] == Bukkit.getPlayer(plugin.getGroupManager().getGroup(players[i]).getOwner())) {
|
||||||
|
players[i].openInventory(confirmPlayingInventory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startGame(Player player) {
|
public void leaveArena(Player[] players, boolean message, boolean reset) {
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
getGroupLeaderOrPlayer player = getGetGroupLeaderOrPlayer(players);
|
||||||
|
Player[] players1 = player.group() != null ? new Player[player.group().getPlayers().size()] : new Player[1];
|
||||||
|
if(plugin.getGroupManager().getGroup(players[0]) != null) {
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<UUID> iterator = player.group().getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
players1[i] = iteratorPlayer;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
players1 = players;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preconditions.checkArgument(player.arena() != null, "player is in no arena");
|
||||||
|
|
||||||
|
if(reset) {
|
||||||
|
player.arena().setArenaStaus(ArenaStatus.INACTIVE);
|
||||||
|
for(int i = 0; i < players1.length; i++) {
|
||||||
|
players1[i].closeInventory();
|
||||||
|
}
|
||||||
|
player.arena().removePlayers();
|
||||||
|
if(message) {
|
||||||
|
for(int i = 0; i < players.length; i++) {
|
||||||
|
players1[i].sendMessage(NamedTextColor.YELLOW + "Das " + plugin.getDisplayedPluginName() + "spiel wurde abgebrochen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getArenaList().setArenaForPlayers(players1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull getGroupLeaderOrPlayer getGetGroupLeaderOrPlayer(Player[] players) {
|
||||||
|
MinecleanerGroupManager.MinecleanerGroup group = null;
|
||||||
|
MinecleanerArena arena;
|
||||||
|
if(plugin.getGroupManager().getGroup(players[0]) != null) {
|
||||||
|
group = plugin.getGroupManager().getGroup(players[0]);
|
||||||
|
arena = plugin.getArenaList().getPlayerArena(Objects.requireNonNull(Bukkit.getPlayer(group.getOwner())));
|
||||||
|
} else {
|
||||||
|
arena = plugin.getArenaList().getPlayerArena(players);
|
||||||
|
}
|
||||||
|
return new getGroupLeaderOrPlayer(group, arena);
|
||||||
|
}
|
||||||
|
|
||||||
|
private record getGroupLeaderOrPlayer(MinecleanerGroupManager.MinecleanerGroup group, MinecleanerArena arena) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void startGame(Player[] players) {
|
||||||
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(players);
|
||||||
Preconditions.checkArgument(arena != null, "player is in no arena");
|
Preconditions.checkArgument(arena != null, "player is in no arena");
|
||||||
Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING, "not confirming playing status");
|
Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING, "not confirming playing status");
|
||||||
arena.startNewGame();
|
arena.startNewGame();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Du hast eine neue Runde Minecleaner gestartet.");
|
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(players[0]) != null) {
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(players[0]).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
assert iteratorPlayer != null;
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "Du hast eine neue Runde " + plugin.getDisplayedPluginName() + " gestartet.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(players[0], "Du hast eine neue Runde " + plugin.getDisplayedPluginName() + " gestartet.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
|
public void handleGameover(Player[] player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
|
||||||
World world = player.getWorld();
|
|
||||||
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
if(plugin.getGroupManager().getGroup(player[0]) != null) {
|
||||||
StatisticKey sg;
|
World world = player[0].getWorld();
|
||||||
sg = statisticsTotalGamesPlayed.get(arena.getWidthIndex());
|
MinecleanerGroupManager.MinecleanerGroup group = plugin.getGroupManager().getGroup(player[0]);
|
||||||
|
|
||||||
|
if(!isSuccessfullyCleared) {
|
||||||
|
world.playSound(Bukkit.getPlayer(group.getOwner()).getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player[0]).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
assert iteratorPlayer != null;
|
||||||
|
ChatUtils.sendSimpleInfoMessage(iteratorPlayer, "Game Over! Ihr konntest das " + plugin.getDisplayedPluginName() + "-Feld nicht erfolgreich lösen!");
|
||||||
|
if(plugin.isStatisticsEnabled()) {
|
||||||
|
|
||||||
|
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(iteratorPlayer.getUniqueId());
|
||||||
|
ps.increaseScore(statisticsTotalGamesPlayed.get(arena.getWidthIndex()), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arena.showMines();
|
||||||
|
scheduleArenaReset(Bukkit.getPlayer(plugin.getGroupManager().getGroup(player[0]).getOwner()), arena);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int millis = (int) (System.currentTimeMillis() - arena.getCurrentGameStartTime());
|
||||||
|
|
||||||
|
|
||||||
|
world.playSound(Bukkit.getPlayer(group.getOwner()).getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
|
||||||
|
for(UUID currentPlayer : group.getPlayers()) {
|
||||||
|
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(currentPlayer);
|
||||||
|
if(iteratorPlayer != null) {
|
||||||
|
iteratorPlayer.sendMessage(Component.text(
|
||||||
|
"Glückwunsch, ihr konntet das " + plugin.getDisplayedPluginName() + "-Feld in ", NamedTextColor.YELLOW)
|
||||||
|
.append(Component.text(MinecleanerStringUtil.timeToString(millis, false), NamedTextColor.RED))
|
||||||
|
.append(Component.text(" erfolgreich lösen!", NamedTextColor.YELLOW)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!plugin.isStatisticsEnabled())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PlayerStatistics ps = plugin.getCubesideStatistics().getStatistics(currentPlayer);
|
||||||
|
ps.increaseScore(statisticsTotalGamesPlayed.get(arena.getWidthIndex()), 1);
|
||||||
|
ps.increaseScore(statisticsWonGamesTotal, 1);
|
||||||
|
ps.increaseScore(statisticsGames.get(arena.getWidthIndex()), 1);
|
||||||
|
|
||||||
|
int wIndex = arena.getWidthIndex();
|
||||||
|
increaseScore(wIndex, ps, group.getPlayers().size());
|
||||||
|
}
|
||||||
|
scheduleArenaReset(Bukkit.getPlayer(group.getOwner()), arena);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = player[0].getWorld();
|
||||||
|
PlayerStatistics ps = null;
|
||||||
|
StatisticKey sg = null;
|
||||||
|
if(plugin.isStatisticsEnabled()) {
|
||||||
|
ps = plugin.getCubesideStatistics().getStatistics(player[0].getUniqueId());
|
||||||
|
sg = statisticsTotalGamesPlayed.get(arena.getWidthIndex());
|
||||||
|
}
|
||||||
|
|
||||||
if(!isSuccessfullyCleared) {
|
if(!isSuccessfullyCleared) {
|
||||||
world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
world.playSound(player[0].getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
||||||
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Minecleaner-Feld nicht erfolgreich lösen!");
|
ChatUtils.sendSimpleInfoMessage(player[0], "Game Over! Du konntest das " + plugin.getDisplayedPluginName() + "-Feld nicht erfolgreich lösen!");
|
||||||
arena.showMines();
|
arena.showMines();
|
||||||
|
|
||||||
if(sg != null) {
|
if(sg != null && plugin.isStatisticsEnabled()) {
|
||||||
ps.increaseScore(sg, 1);
|
ps.increaseScore(sg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
scheduleArenaReset(player[0], arena);
|
||||||
if(arena.getCurrentPlayer() == null) {
|
|
||||||
arena.removePlayer();
|
|
||||||
} else {
|
|
||||||
leaveArena(player, false);
|
|
||||||
}
|
|
||||||
}, 100L);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int millis = (int) (System.currentTimeMillis() - arena.getCurrentGameStartTime());
|
int millis = (int) (System.currentTimeMillis() - arena.getCurrentGameStartTime());
|
||||||
|
|
||||||
world.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
|
world.playSound(player[0].getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.5f, 0.5f);
|
||||||
|
|
||||||
if(sg != null) {
|
if(sg != null && plugin.isStatisticsEnabled()) {
|
||||||
ps.increaseScore(sg, 1);
|
ps.increaseScore(sg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.increaseScore(statisticsWonGamesTotal, 1);
|
if(plugin.isStatisticsEnabled()) {
|
||||||
|
ps.increaseScore(statisticsWonGamesTotal, 1);
|
||||||
|
|
||||||
sg = statisticsGames.get(arena.getWidthIndex());
|
sg = statisticsGames.get(arena.getWidthIndex());
|
||||||
if(sg != null) {
|
if(sg != null) {
|
||||||
ps.increaseScore(sg, 1);
|
ps.increaseScore(sg, 1);
|
||||||
}
|
}
|
||||||
sg = statisticsTimeRecord.get(arena.getWidthIndex());
|
sg = statisticsTimeRecord.get(arena.getWidthIndex());
|
||||||
if(sg != null) {
|
if(sg != null) {
|
||||||
ps.minScore(sg, millis, isUpdated -> {
|
ps.minScore(sg, millis, isUpdated -> {
|
||||||
if(isUpdated != null && isUpdated) {
|
if(isUpdated != null && isUpdated) {
|
||||||
player.sendMessage(ChatColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) );
|
player[0].sendMessage(NamedTextColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + NamedTextColor.RED + MinecleanerStringUtil.timeToString(millis, false) );
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Minecleaner-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) + ChatColor.YELLOW + " erfolgreich lösen!");
|
player[0].sendMessage(NamedTextColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + NamedTextColor.RED + MinecleanerStringUtil.timeToString(millis, false) + NamedTextColor.YELLOW + " erfolgreich lösen!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
int wIndex = arena.getWidthIndex();
|
||||||
|
increaseScore(wIndex, ps, 1);
|
||||||
|
} else {
|
||||||
|
player[0].sendMessage(NamedTextColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + NamedTextColor.RED + MinecleanerStringUtil.timeToString(millis, false) + NamedTextColor.YELLOW + " erfolgreich lösen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
int wIndex = arena.getWidthIndex();
|
scheduleArenaReset(player[0], arena);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void increaseScore(int wIndex, PlayerStatistics ps, int groupSize) {
|
||||||
switch (wIndex) {
|
switch (wIndex) {
|
||||||
case 0: {
|
case 0: {
|
||||||
ps.increaseScore(statisticsPointsAcquired, plugin.getConfig().getInt("winpoints.size.small"));
|
ps.increaseScore(statisticsPointsAcquired, (int) Math.floor((double) plugin.getConfig().getInt("winpoints.size.small") /groupSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
ps.increaseScore(statisticsPointsAcquired, plugin.getConfig().getInt("winpoints.size.medium"));
|
ps.increaseScore(statisticsPointsAcquired, (int) Math.floor((double) plugin.getConfig().getInt("winpoints.size.medium") /groupSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
ps.increaseScore(statisticsPointsAcquired, plugin.getConfig().getInt("winpoints.size.large"));
|
ps.increaseScore(statisticsPointsAcquired, (int) Math.floor((double) plugin.getConfig().getInt("winpoints.size.large") /groupSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
ps.increaseScore(statisticsPointsAcquired, plugin.getConfig().getInt("winpoints.size.expert"));
|
ps.increaseScore(statisticsPointsAcquired, (int) Math.floor((double) plugin.getConfig().getInt("winpoints.size.expert") /groupSize));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
ps.increaseScore(statisticsPointsAcquired, 0);
|
ps.increaseScore(statisticsPointsAcquired, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scheduleArenaReset(Player player, MinecleanerArena arena) {
|
||||||
|
plugin.getLogger().log(Level.INFO, "scheduled reset for arena '" + arena.getName() + "', loc: " + arena.getLocation() + " ArenaStatus: " + arena.getArenaStatus() + " in " + plugin.getManager().getSettingsValue("resettime", player) * 20 + " ticks. Current Players: " + Arrays.toString(arena.getCurrentPlayers()));
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
if(arena.getCurrentPlayer() == null) {
|
plugin.getLogger().log(Level.INFO, "ArenaStatus for arena '" + arena.getName() + "', loc: " + arena.getLocation() + " after 5 Ticks (should be completed): " + arena.getArenaStatus());
|
||||||
arena.removePlayer();
|
}, 5L);
|
||||||
} else {
|
schedulerGameOver = Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
leaveArena(player, false);
|
if(arena.getArenaStatus() == ArenaStatus.COMPLETED) {
|
||||||
|
if (arena.getCurrentPlayers() == null) {
|
||||||
|
arena.removePlayers();
|
||||||
|
} else {
|
||||||
|
int arraySize = plugin.getGroupManager().getGroup(player) != null ? plugin.getGroupManager().getGroupSize(player) : 1;
|
||||||
|
Player[] players = new Player[arraySize];
|
||||||
|
int i = 0;
|
||||||
|
if(plugin.getGroupManager().getGroup(player) != null) {
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
players[i] = iteratorPlayer;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Arrays.fill(players, player);
|
||||||
|
}
|
||||||
|
leaveArena(players, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 100L);
|
}, plugin.getManager().getSettingsValue("resettime", player) * 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllArenas() {
|
public void clearAllArenas() {
|
||||||
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
||||||
if(arena.hasPlayer()) {
|
if(arena.hasPlayers()) {
|
||||||
leaveArena(arena.getCurrentPlayer(), true);
|
leaveArena(arena.getCurrentPlayers(), true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getConfirmPlayingInventory() {
|
|
||||||
return confirmPlayingInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleFieldClick(@NotNull Player player, int x, int y, boolean hasRightClicked) {
|
public void handleFieldClick(@NotNull Player player, int x, int y, boolean hasRightClicked) {
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
Preconditions.checkArgument(arena != null, "player is in no arena");
|
Preconditions.checkArgument(arena != null, "player is in no arena");
|
||||||
|
|
@ -325,6 +505,42 @@ public class MinecleanerManager {
|
||||||
for(StatisticKey statsKey : statisticsTotalGamesPlayed.values()) {
|
for(StatisticKey statsKey : statisticsTotalGamesPlayed.values()) {
|
||||||
statsPlayer.deleteScore(statsKey);
|
statsPlayer.deleteScore(statsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSettingsValue(String settingsKeyString, Player player) {
|
||||||
|
PlayerStatistics playerStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||||
|
SettingKey settingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings." + settingsKeyString);
|
||||||
|
|
||||||
|
return playerStatistics.getSettingValueOrDefault(settingKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSettingsValue(String settingsKeyString, int newValue, Player player) {
|
||||||
|
PlayerStatistics playerStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||||
|
SettingKey settingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings." + settingsKeyString);
|
||||||
|
playerStatistics.setSettingValue(settingKey, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, String> getSizes() {
|
||||||
|
return sizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getConfirmPlayingInventory() {
|
||||||
|
return confirmPlayingInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getSettingsInventory() {
|
||||||
|
return settingsInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingKey getMinecleanerSettingTimerKey() {
|
||||||
|
return minecleanerSettingTimerKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingKey getMinecleanerAdditionalDisplaySettingKey() {
|
||||||
|
return minecleanerAdditionalDisplaySettingKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingKey getMinecleanerResetTimeSettingKey() {return minecleanerResetTimerSettingKey; }
|
||||||
|
|
||||||
|
public BukkitTask getSchedulerGameOver() { return schedulerGameOver; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,38 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
|
||||||
|
import de.lunarakai.minecleaner.commands.CreateCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.DeleteCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.DeletePlayerScoreCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.HelpCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.InfoCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.ListCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.ListPlayersInArenaCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.SettingsCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.StatsCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.groups.AcceptCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.groups.DenyCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.groups.DismantleGroupCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.groups.InviteCommand;
|
||||||
|
import de.lunarakai.minecleaner.commands.groups.ListGroupMembersCommand;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.kyori.adventure.translation.GlobalTranslator;
|
||||||
|
import net.kyori.adventure.translation.TranslationRegistry;
|
||||||
|
import net.kyori.adventure.util.UTF8ResourceBundleControl;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import de.iani.cubesidestats.api.CubesideStatisticsAPI;
|
import de.iani.cubesidestats.api.CubesideStatisticsAPI;
|
||||||
import de.iani.cubesideutils.bukkit.commands.CommandRouter;
|
import de.iani.cubesideutils.bukkit.commands.CommandRouter;
|
||||||
import de.iani.playerUUIDCache.PlayerUUIDCache;
|
import de.iani.playerUUIDCache.PlayerUUIDCache;
|
||||||
import de.lunarakai.minecleaner.commands.CreateCommand;
|
import java.util.Locale;
|
||||||
import de.lunarakai.minecleaner.commands.DeleteCommand;
|
import java.util.ResourceBundle;
|
||||||
import de.lunarakai.minecleaner.commands.DeletePlayerScoreCommand;
|
import java.util.logging.Level;
|
||||||
import de.lunarakai.minecleaner.commands.ListCommand;
|
|
||||||
import de.lunarakai.minecleaner.commands.StatsCommand;
|
|
||||||
|
|
||||||
public final class MinecleanerPlugin extends JavaPlugin {
|
public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
public static final String PERMISSION_PLAY = "minecleaner.play";
|
public static final String PERMISSION_PLAY = "minecleaner.play";
|
||||||
public static final String PERMISSION_ADMIN = "minecleaner.admin";
|
public static final String PERMISSION_ADMIN = "minecleaner.admin";
|
||||||
|
|
||||||
private MinecleanerManager minecleanerManager;
|
private MinecleanerManager minecleanerManager;
|
||||||
|
private MinecleanerGroupManager minecleanerGroupManager;
|
||||||
private ArenaList arenaList;
|
private ArenaList arenaList;
|
||||||
private CubesideStatisticsAPI cubesideStatistics;
|
private CubesideStatisticsAPI cubesideStatistics;
|
||||||
private PlayerUUIDCache playerUUIDCache;
|
private PlayerUUIDCache playerUUIDCache;
|
||||||
|
|
@ -22,25 +40,73 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
|
|
||||||
|
TranslationRegistry registry = TranslationRegistry.create(Key.key("minecleaner:lang"));
|
||||||
|
|
||||||
|
ResourceBundle bundle_en_US = ResourceBundle.getBundle("lang.en_US", Locale.US, UTF8ResourceBundleControl.get());
|
||||||
|
registry.registerAll(Locale.US, bundle_en_US, true);
|
||||||
|
GlobalTranslator.translator().addSource(registry);
|
||||||
|
|
||||||
|
ResourceBundle bundle_de_DE = ResourceBundle.getBundle("lang.de_DE", Locale.GERMAN, UTF8ResourceBundleControl.get());
|
||||||
|
registry.registerAll(Locale.GERMAN, bundle_de_DE, true);
|
||||||
|
|
||||||
|
GlobalTranslator.translator().addSource(registry);
|
||||||
|
|
||||||
getServer().getScheduler().runTask(this, this::onLateEnable);
|
getServer().getScheduler().runTask(this, this::onLateEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLateEnable() {
|
public void onLateEnable() {
|
||||||
playerUUIDCache = (PlayerUUIDCache) getServer().getPluginManager().getPlugin("PlayerUUIDCache");
|
checkForPlayerUUIDChache();
|
||||||
cubesideStatistics = getServer().getServicesManager().load(CubesideStatisticsAPI.class);
|
|
||||||
|
checkForCubesideStatistics();
|
||||||
|
|
||||||
arenaList = new ArenaList(this);
|
arenaList = new ArenaList(this);
|
||||||
arenaList.load();
|
arenaList.load();
|
||||||
|
|
||||||
minecleanerManager = new MinecleanerManager(this);
|
minecleanerManager = new MinecleanerManager(this);
|
||||||
|
minecleanerGroupManager = new MinecleanerGroupManager();
|
||||||
getServer().getPluginManager().registerEvents(new MinecleanerListener(this), this);
|
getServer().getPluginManager().registerEvents(new MinecleanerListener(this), this);
|
||||||
|
|
||||||
CommandRouter minecleanerCommand = new CommandRouter(getCommand("minecleaner"));
|
CommandRouter minecleanerCommand = new CommandRouter(getCommand("minecleaner"));
|
||||||
minecleanerCommand.addCommandMapping(new CreateCommand(this), "create");
|
minecleanerCommand.addCommandMapping(new CreateCommand(this), "create");
|
||||||
minecleanerCommand.addCommandMapping(new DeleteCommand(this), "delete");
|
minecleanerCommand.addCommandMapping(new DeleteCommand(this), "delete");
|
||||||
minecleanerCommand.addCommandMapping(new ListCommand(this), "list");
|
minecleanerCommand.addCommandMapping(new ListCommand(this), "list");
|
||||||
minecleanerCommand.addCommandMapping(new StatsCommand(this), "stats");
|
minecleanerCommand.addCommandMapping(new InfoCommand(this), "info");
|
||||||
minecleanerCommand.addCommandMapping(new DeletePlayerScoreCommand(this), "deleteplayerscores");
|
minecleanerCommand.addCommandMapping(new ListPlayersInArenaCommand(this), "currentplayers");
|
||||||
|
minecleanerCommand.addCommandMapping(new HelpCommand(this), "help");
|
||||||
|
|
||||||
|
// Groups
|
||||||
|
minecleanerCommand.addCommandMapping(new InviteCommand(this), "invite");
|
||||||
|
minecleanerCommand.addCommandMapping(new AcceptCommand(this), "accept");
|
||||||
|
minecleanerCommand.addCommandMapping(new DenyCommand(this), "deny");
|
||||||
|
minecleanerCommand.addCommandMapping(new DismantleGroupCommand(this), "dismantlegroup");
|
||||||
|
minecleanerCommand.addCommandMapping(new ListGroupMembersCommand(this), "groupmembers");
|
||||||
|
|
||||||
|
enableCubesideStatisticsCommands(minecleanerCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableCubesideStatisticsCommands(CommandRouter minecleanerCommand) {
|
||||||
|
if(isStatisticsEnabled()) {
|
||||||
|
minecleanerCommand.addCommandMapping(new SettingsCommand(this), "settings");
|
||||||
|
minecleanerCommand.addCommandMapping(new StatsCommand(this), "stats");
|
||||||
|
minecleanerCommand.addCommandMapping(new DeletePlayerScoreCommand(this), "deleteplayerscores");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForCubesideStatistics() {
|
||||||
|
if(getServer().getPluginManager().getPlugin("CubesideStatistics") != null) {
|
||||||
|
cubesideStatistics = getServer().getServicesManager().load(CubesideStatisticsAPI.class);
|
||||||
|
} else {
|
||||||
|
this.getLogger().log(Level.WARNING, "Cubeside Statistics not found. No Statistics will be available");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForPlayerUUIDChache() {
|
||||||
|
if(getServer().getPluginManager().getPlugin("PlayerUUIDCache") != null) {
|
||||||
|
playerUUIDCache = (PlayerUUIDCache) getServer().getPluginManager().getPlugin("PlayerUUIDCache");
|
||||||
|
} else {
|
||||||
|
this.getLogger().log(Level.WARNING, "PlayerUUIDCache not found.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -48,6 +114,9 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
if(minecleanerManager != null) {
|
if(minecleanerManager != null) {
|
||||||
minecleanerManager.clearAllArenas();
|
minecleanerManager.clearAllArenas();
|
||||||
}
|
}
|
||||||
|
if(minecleanerGroupManager != null) {
|
||||||
|
minecleanerGroupManager.deleteAllGroups();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArenaList getArenaList() {
|
public ArenaList getArenaList() {
|
||||||
|
|
@ -58,6 +127,11 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
return minecleanerManager;
|
return minecleanerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MinecleanerGroupManager getGroupManager() { return minecleanerGroupManager; }
|
||||||
|
|
||||||
|
public boolean isStatisticsEnabled() {
|
||||||
|
return cubesideStatistics != null;
|
||||||
|
}
|
||||||
public CubesideStatisticsAPI getCubesideStatistics() {
|
public CubesideStatisticsAPI getCubesideStatistics() {
|
||||||
return cubesideStatistics;
|
return cubesideStatistics;
|
||||||
}
|
}
|
||||||
|
|
@ -65,4 +139,12 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
public PlayerUUIDCache getPlayerUUIDCache() {
|
public PlayerUUIDCache getPlayerUUIDCache() {
|
||||||
return playerUUIDCache;
|
return playerUUIDCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayedPluginName() {
|
||||||
|
return this.getConfig().getString("generalSettings.displayedPluginName");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSizeWinpoints(String size) {
|
||||||
|
return this.getConfig().getInt("winpoints.size." + size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.iani.cubesideutils.bukkit.inventory.AbstractWindow;
|
||||||
|
import de.lunarakai.minecleaner.utils.ItemUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
public class MinecleanerSettingsInventory extends AbstractWindow {
|
||||||
|
|
||||||
|
private static final int SETTINGS_ALLOW_MANUEL_RESET = 10;
|
||||||
|
private static final int SETTINGS_ADDITIONAL_DISPLAY = 12;
|
||||||
|
private static final int SETTINGS_TIMER = 14;
|
||||||
|
private static final int SETTINGS_RESETTIME = 16;
|
||||||
|
private static final int WINDOW_SIZE = 27;
|
||||||
|
|
||||||
|
private MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public MinecleanerSettingsInventory(Player player, MinecleanerPlugin plugin) {
|
||||||
|
super(player, Bukkit.createInventory(player, InventoryType.CHEST, plugin.getDisplayedPluginName() + " Einstellungen"));
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void rebuildInventory() {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
for (int i = 0; i < WINDOW_SIZE; i++) {
|
||||||
|
ItemStack item;
|
||||||
|
switch (i) {
|
||||||
|
case SETTINGS_ALLOW_MANUEL_RESET -> {
|
||||||
|
if (plugin.getManager().getSettingsValue("allowmanualreset", player) == 0) {
|
||||||
|
item = ItemUtil.createGuiItem(Material.SHEARS, Component.translatable("settings.manualreset.deny", NamedTextColor.RED));
|
||||||
|
} else {
|
||||||
|
item = ItemUtil.createGuiItem(Material.SHEARS, Component.translatable("settings.manualreset.allow", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case SETTINGS_ADDITIONAL_DISPLAY -> {
|
||||||
|
if (plugin.getManager().getSettingsValue("additionaldisplay", player) == 0) {
|
||||||
|
item = ItemUtil.createGuiItem(Material.NAME_TAG, Component.translatable("settings.additionaltimer.deny", NamedTextColor.RED));
|
||||||
|
} else {
|
||||||
|
item = ItemUtil.createGuiItem(Material.NAME_TAG, Component.translatable("settings.additionaltimer.allow", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case SETTINGS_TIMER -> {
|
||||||
|
if (plugin.getManager().getSettingsValue("timer", player) == 0) {
|
||||||
|
item = ItemUtil.createGuiItem(Material.CLOCK, Component.translatable("settings.timer.deny", NamedTextColor.RED));
|
||||||
|
} else {
|
||||||
|
item = ItemUtil.createGuiItem(Material.CLOCK, Component.translatable("settings.timer.allow", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case SETTINGS_RESETTIME -> {
|
||||||
|
int current = plugin.getManager().getSettingsValue("resettime", player);
|
||||||
|
item = ItemUtil.createGuiItem(Material.CANDLE, Component.translatable("settings.resettime.text", NamedTextColor.GOLD).append(Component.text(": ")).append(Component.text(current, NamedTextColor.RED)).append(Component.text(" s", NamedTextColor.RED)));
|
||||||
|
}
|
||||||
|
default -> item = ItemUtil.EMPTY_ICON;
|
||||||
|
}
|
||||||
|
this.getInventory().setItem(i, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClicked(InventoryClickEvent event) {
|
||||||
|
if (!mayAffectThisInventory(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (!getInventory().equals(event.getClickedInventory())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
|
||||||
|
int slot = event.getSlot();
|
||||||
|
switch (slot) {
|
||||||
|
case SETTINGS_ALLOW_MANUEL_RESET -> {
|
||||||
|
if(plugin.getManager().getSettingsValue("allowmanualreset", player) == 0) {
|
||||||
|
plugin.getManager().updateSettingsValue("allowmanualreset", 1, player);
|
||||||
|
} else {
|
||||||
|
plugin.getManager().updateSettingsValue("allowmanualreset", 0, player);
|
||||||
|
}
|
||||||
|
rebuildInventory();
|
||||||
|
}
|
||||||
|
case SETTINGS_ADDITIONAL_DISPLAY -> {
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", player) == 0) {
|
||||||
|
plugin.getManager().updateSettingsValue("additionaldisplay", 1, player);
|
||||||
|
} else {
|
||||||
|
plugin.getManager().updateSettingsValue("additionaldisplay", 0, player);
|
||||||
|
}
|
||||||
|
rebuildInventory();
|
||||||
|
}
|
||||||
|
case SETTINGS_TIMER -> {
|
||||||
|
if(plugin.getManager().getSettingsValue("timer", player) == 0) {
|
||||||
|
plugin.getManager().updateSettingsValue("timer", 1, player);
|
||||||
|
} else {
|
||||||
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
|
plugin.getManager().updateSettingsValue("timer", 0, player);
|
||||||
|
if(arena != null) {
|
||||||
|
arena.updateIngameInfoTexts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rebuildInventory();
|
||||||
|
}
|
||||||
|
case SETTINGS_RESETTIME -> {
|
||||||
|
int current = plugin.getManager().getSettingsValue("resettime", player);
|
||||||
|
if(plugin.getManager().getSettingsValue("resettime", player) < 10) {
|
||||||
|
plugin.getManager().updateSettingsValue("resettime", current + 1, player);
|
||||||
|
} else {
|
||||||
|
plugin.getManager().updateSettingsValue("resettime", 1, player);
|
||||||
|
}
|
||||||
|
rebuildInventory();
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,8 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
|
@ -22,6 +24,8 @@ import de.lunarakai.minecleaner.MinecleanerArena;
|
||||||
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
public class CreateCommand extends SubCommand {
|
public class CreateCommand extends SubCommand {
|
||||||
private static final Pattern VALID_ARENA_NAME = Pattern.compile("^[a-z0-9_]+$");
|
private static final Pattern VALID_ARENA_NAME = Pattern.compile("^[a-z0-9_]+$");
|
||||||
|
|
||||||
|
|
@ -55,11 +59,11 @@ public class CreateCommand extends SubCommand {
|
||||||
}
|
}
|
||||||
String name = args.getNext().toLowerCase().trim();
|
String name = args.getNext().toLowerCase().trim();
|
||||||
if(!VALID_ARENA_NAME.matcher(name).matches()) {
|
if(!VALID_ARENA_NAME.matcher(name).matches()) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Ungültiger Arenaname. Erlaubt sind Buchstaben, Zahlen und der Unterstrich");
|
sender.sendMessage(createLangComponent("arena.name.invalid", NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(plugin.getArenaList().getArena(name) != null) {
|
if(plugin.getArenaList().getArena(name) != null) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Eine Arena mit diesem Namen existiert bereits");
|
sender.sendMessage(createLangComponent( "arena.name.exists", NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean noblocks = false;
|
boolean noblocks = false;
|
||||||
|
|
@ -73,13 +77,13 @@ public class CreateCommand extends SubCommand {
|
||||||
try {
|
try {
|
||||||
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(createLangComponent("arena.widthindex.invalid", NamedTextColor.DARK_RED));
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 12*12, 2 = 12*18, 3 = 12*33");
|
sender.sendMessage(createLangComponent("arena.widthindex.validOptions", NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(widthindex > 3) {
|
if(widthindex > 3) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Arena WidthIndex darf nicht größer als 3 sein");
|
sender.sendMessage(createLangComponent( "arena.widthindex.toolarge", NamedTextColor.DARK_RED));
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "0 (oder weglassen) = 9*9, 1 = 12*12, 2 = 12*18, 3 = 12*33");
|
sender.sendMessage(createLangComponent("arena.widthindex.validOptions", NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -94,12 +98,14 @@ public class CreateCommand extends SubCommand {
|
||||||
@Nullable
|
@Nullable
|
||||||
RayTraceResult target = player.rayTraceBlocks(6);
|
RayTraceResult target = player.rayTraceBlocks(6);
|
||||||
if(target == null || target.getHitBlock() == null) {
|
if(target == null || target.getHitBlock() == null) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke den Block an, der im Zentrum des Minecleaner-Spielfelds sein soll.");
|
//sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke den Block an, der im Zentrum des " + plugin.getDisplayedPluginName() + "-Spielfelds sein soll.");
|
||||||
|
sender.sendMessage(createLangComponent( "arena.create.lookAtCenter", plugin.getDisplayedPluginName(), NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
BlockFace face = target.getHitBlockFace();
|
BlockFace face = target.getHitBlockFace();
|
||||||
if(face != BlockFace.NORTH && face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.SOUTH) {
|
if(face != BlockFace.NORTH && face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.SOUTH) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke die Seite des Blockes an, wo das Minecleaner-Spielfeld erstellt werden soll.");
|
//sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke die Seite des Blockes an, wo das " + plugin.getDisplayedPluginName() + "-Spielfeld erstellt werden soll.");
|
||||||
|
sender.sendMessage(createLangComponent("arena.create.lookAtSide", plugin.getDisplayedPluginName(), NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
location = target.getHitBlock().getLocation();
|
location = target.getHitBlock().getLocation();
|
||||||
|
|
@ -107,7 +113,7 @@ public class CreateCommand extends SubCommand {
|
||||||
|
|
||||||
MinecleanerArena newArena = new MinecleanerArena(plugin, name, location, widthindex, orientation);
|
MinecleanerArena newArena = new MinecleanerArena(plugin, name, location, widthindex, orientation);
|
||||||
if(plugin.getArenaList().collidesWithArena(newArena)) {
|
if(plugin.getArenaList().collidesWithArena(newArena)) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "An dieser Stelle befindet sich bereits eine Arena.");
|
sender.sendMessage(createLangComponent("arena.create.otherArena", NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
newArena.generateBlockDisplays();
|
newArena.generateBlockDisplays();
|
||||||
|
|
@ -115,7 +121,7 @@ public class CreateCommand extends SubCommand {
|
||||||
newArena.generateBackgroundBlocks();
|
newArena.generateBackgroundBlocks();
|
||||||
}
|
}
|
||||||
plugin.getArenaList().addArena(newArena);
|
plugin.getArenaList().addArena(newArena);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Die Arena wurde erfolgreich angelegt.");
|
sender.sendMessage(createLangComponent("arena.create.success", NamedTextColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,5 +157,4 @@ public class CreateCommand extends SubCommand {
|
||||||
}
|
}
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
|
@ -16,7 +17,8 @@ import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
|
||||||
import de.iani.cubesideutils.commands.ArgsParser;
|
import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
import de.lunarakai.minecleaner.MinecleanerArena;
|
import de.lunarakai.minecleaner.MinecleanerArena;
|
||||||
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
public class DeleteCommand extends SubCommand {
|
public class DeleteCommand extends SubCommand {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
@ -52,9 +54,9 @@ public class DeleteCommand extends SubCommand {
|
||||||
}
|
}
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
plugin.getArenaList().removeArena(arena);
|
plugin.getArenaList().removeArena(arena);
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Die Minecleaner-Arena " + arena.getName() + " wurde gelöscht.");
|
sender.sendMessage(createLangComponent("arena.delete.success", plugin.getDisplayedPluginName(), arena.getName(), NamedTextColor.YELLOW));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Hier befindet sich keine Minecleaner-Arena.");
|
sender.sendMessage(createLangComponent("arena.delete.noarena", plugin.getDisplayedPluginName(), NamedTextColor.YELLOW));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -63,5 +65,4 @@ public class DeleteCommand extends SubCommand {
|
||||||
public Collection<String> onTabComplete(CommandSender sender, Command command, String alias, ArgsParser args) {
|
public Collection<String> onTabComplete(CommandSender sender, Command command, String alias, ArgsParser args) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package de.lunarakai.minecleaner.commands;
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
||||||
|
|
@ -13,6 +14,8 @@ import de.iani.playerUUIDCache.CachedPlayer;
|
||||||
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
public class DeletePlayerScoreCommand extends SubCommand{
|
public class DeletePlayerScoreCommand extends SubCommand{
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
|
@ -48,10 +51,10 @@ public class DeletePlayerScoreCommand extends SubCommand{
|
||||||
|
|
||||||
CachedPlayer cachedPlayer = plugin.getPlayerUUIDCache().getPlayer(player);
|
CachedPlayer cachedPlayer = plugin.getPlayerUUIDCache().getPlayer(player);
|
||||||
if(cachedPlayer == null) {
|
if(cachedPlayer == null) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Ein Spieler mit dem Namen '" + player + "' konnte nicht gefunden werden.");
|
sender.sendMessage(createLangComponent("data.delete.playerNotFound", player, NamedTextColor.DARK_RED));
|
||||||
}
|
}
|
||||||
plugin.getManager().deleteScores(cachedPlayer.getUUID());
|
plugin.getManager().deleteScores(cachedPlayer.getUUID());
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Alle Minecleaner-Statistiken von Spieler '" + cachedPlayer.getName() + "' wurden gelöscht.");
|
sender.sendMessage(createLangComponent("data.delete.deleted", plugin.getDisplayedPluginName(), cachedPlayer.getName(), NamedTextColor.DARK_RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class HelpCommand extends SubCommand {
|
||||||
|
MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public HelpCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "[(empty)|group]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
|
||||||
|
String subMenu = "";
|
||||||
|
if(args.remaining() == 1) {
|
||||||
|
subMenu = args.getNext().toLowerCase().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(subMenu.equals("group")) {
|
||||||
|
showHelpGroup(player);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
showGeneralHelp(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGeneralHelp(Player player) {
|
||||||
|
player.sendMessage(Component.text("--- " + plugin.getDisplayedPluginName() + " Help ---", NamedTextColor.AQUA)
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... info: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Allgemeine Auskunft zum Plugin", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... stats [playername]: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Zeigt dir entweder deine eigenen Stats (leer lassen) oder die Stats anderer Spieler an", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... settings: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Öffnet ein Menü in dem du Veränderungen an deinen eigenen Einstellungen für " + plugin.getDisplayedPluginName() + " vornehmen kannst", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... help [group]: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Zeigt dieses Menü (frei lassen) oder die Hilfe für Gruppen an (group)", NamedTextColor.GREEN)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showHelpGroup(Player player) {
|
||||||
|
player.sendMessage(Component.text("--- " + plugin.getDisplayedPluginName() + " Group Help ---", NamedTextColor.AQUA)
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... invite <playername>: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Lädt andere Spieler zu deiner " + plugin.getDisplayedPluginName() + " Gruppe ein", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... accept | deny: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Nehme eine erhaltene Einladung an (accept), oder lehne sie ab (deny)", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... dismantlegroup: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Löst die Gruppe, die du erstellt hast, auf", NamedTextColor.GREEN))
|
||||||
|
.append(Component.newline())
|
||||||
|
.append(Component.text(" /... groupmembers: ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text("Listet die Mitglieder deiner Gruppe auf", NamedTextColor.GREEN)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
import de.iani.cubesideutils.NamedChatColor;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
|
public class InfoCommand extends SubCommand{
|
||||||
|
MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public InfoCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String arg3,
|
||||||
|
ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException,
|
||||||
|
NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
sender.sendMessage(NamedChatColor.GREEN + "--- " + ChatColor.AQUA + plugin.getName() + ChatColor.GREEN + " ---");
|
||||||
|
sender.sendMessage(createLangComponent("minecleaner.info.version", ": ", plugin.getPluginMeta().getVersion(), NamedTextColor.AQUA, NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(createLangComponent("minecleaner.info.developer", ": ", plugin.getPluginMeta().getAuthors().get(0), NamedTextColor.AQUA, NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(createLangComponent("minecleaner.info.website", ": ", plugin.getPluginMeta().getWebsite(), NamedTextColor.AQUA, NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(createLangComponent("minecleaner.info.license", ": ", "GPL-3.0", NamedTextColor.AQUA, NamedTextColor.GREEN));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
@ -16,6 +17,8 @@ import de.lunarakai.minecleaner.MinecleanerArena;
|
||||||
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
public class ListCommand extends SubCommand{
|
public class ListCommand extends SubCommand{
|
||||||
|
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
@ -41,7 +44,7 @@ public class ListCommand extends SubCommand{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Angelegte Minecleaner-Arenen");
|
sender.sendMessage(createLangComponent("arena.list.created", plugin.getDisplayedPluginName(), NamedTextColor.YELLOW));
|
||||||
boolean any = false;
|
boolean any = false;
|
||||||
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
||||||
Location location = arena.getLocation();
|
Location location = arena.getLocation();
|
||||||
|
|
@ -49,7 +52,7 @@ public class ListCommand extends SubCommand{
|
||||||
any = true;
|
any = true;
|
||||||
}
|
}
|
||||||
if(!any) {
|
if(!any) {
|
||||||
sender.sendMessage(ChatColor.GRAY + " (keine)");
|
sender.sendMessage(" " + createLangComponent("arena.list.none", NamedTextColor.GRAY));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.*;
|
||||||
|
import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerArena;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListPlayersInArenaCommand extends SubCommand {
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public ListPlayersInArenaCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "<name>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String s1, ArgsParser argsParser) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
MinecleanerArena arena = plugin.getArenaList().getArenaAtBlock(player.getLocation().getBlock().getRelative(BlockFace.DOWN));
|
||||||
|
if(arena == null) {
|
||||||
|
Block target = player.getTargetBlockExact(6);
|
||||||
|
if(target != null) {
|
||||||
|
arena = plugin.getArenaList().getArenaAtBlock(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(arena != null) {
|
||||||
|
ChatUtils.sendSimpleSpecialMessage(player, "Players in Arena: " + Arrays.toString(arena.getCurrentPlayers()), NamedTextColor.GRAY);
|
||||||
|
} else {
|
||||||
|
ChatUtils.sendSimpleSpecialMessage(player, "arena.common.noarena", NamedTextColor.GRAY);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> onTabComplete(CommandSender sender, Command command, String alias, ArgsParser args) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerSettingsInventory;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SettingsCommand extends SubCommand {
|
||||||
|
MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public SettingsCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String s1, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
new MinecleanerSettingsInventory(player, plugin).open();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,11 @@ package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import de.iani.cubesideutils.StringUtil;
|
|
||||||
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
||||||
import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException;
|
import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException;
|
||||||
import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException;
|
import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException;
|
||||||
|
|
@ -16,7 +17,8 @@ import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
import de.lunarakai.minecleaner.PlayerStatisticsData;
|
import de.lunarakai.minecleaner.PlayerStatisticsData;
|
||||||
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
import static de.lunarakai.minecleaner.utils.MinecleanerComponentUtils.createLangComponent;
|
||||||
|
|
||||||
public class StatsCommand extends SubCommand {
|
public class StatsCommand extends SubCommand {
|
||||||
private final MinecleanerPlugin plugin;
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
@ -48,16 +50,30 @@ public class StatsCommand extends SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public void accept(PlayerStatisticsData data) {
|
public void accept(PlayerStatisticsData data) {
|
||||||
if(data == null) {
|
if(data == null) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Für Spieler '" + playerName + "' existieren keine Daten.");
|
sender.sendMessage(createLangComponent("data.player.noData", playerName, NamedTextColor.GREEN));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(playerName == null) {
|
if(playerName == null) {
|
||||||
sender.sendMessage(ChatColor.AQUA + "Deine Minecleaner Statistik:");
|
sender.sendMessage(createLangComponent("data.player.self", plugin.getDisplayedPluginName(), NamedTextColor.AQUA).append(Component.text(":")));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.AQUA + "Minecleaner-Statistik von " + data.getPlayerName() + ":");
|
sender.sendMessage(createLangComponent("data.player.other", plugin.getDisplayedPluginName(), data.getPlayerName(), NamedTextColor.AQUA).append(Component.text(":")));
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.BLUE + " Punkte erspielt: " + ChatColor.GREEN + data.getPointsAcquiredTotal() + " (Dieser Monat: " + data.getPointsAquiredMonth() + ")");
|
|
||||||
sender.sendMessage(ChatColor.BLUE + " Runden gewonnen: " + ChatColor.GREEN + data.getWonGamesPlayed() + " (Dieser Monat: " + data.getWonGamesPlayedThisMonth() + ")");
|
sender.sendMessage(createLangComponent("data.player.pointsscored", NamedTextColor.BLUE)
|
||||||
|
.append(Component.text(": ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text(String.valueOf(data.getPointsAcquiredTotal()), NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" (", NamedTextColor.GREEN))
|
||||||
|
.append(createLangComponent("data.player.thismonth", NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(": " + String.valueOf(data.getPointsAquiredMonth()) + ")", NamedTextColor.GREEN)));
|
||||||
|
|
||||||
|
|
||||||
|
sender.sendMessage(createLangComponent("data.player.roundswon", NamedTextColor.BLUE)
|
||||||
|
.append(Component.text(": ", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text(String.valueOf(data.getWonGamesPlayed()), NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" (", NamedTextColor.GREEN))
|
||||||
|
.append(createLangComponent("data.player.thismonth", NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(": " + String.valueOf(data.getWonGamesPlayedThisMonth()) + ")", NamedTextColor.GREEN)));
|
||||||
|
|
||||||
for(Entry<Integer, String> e : plugin.getManager().getSizes().entrySet()) {
|
for(Entry<Integer, String> e : plugin.getManager().getSizes().entrySet()) {
|
||||||
int totalWonSize = data.getGamesPlayedSize(e.getKey());
|
int totalWonSize = data.getGamesPlayedSize(e.getKey());
|
||||||
int totalWonMonth = data.getGamesPlayedSizeThisMonth(e.getKey());
|
int totalWonMonth = data.getGamesPlayedSizeThisMonth(e.getKey());
|
||||||
|
|
@ -65,14 +81,35 @@ public class StatsCommand extends SubCommand {
|
||||||
int totalSizeMonth = data.getTotalGamesPlayedSizeThisMonth(e.getKey());
|
int totalSizeMonth = data.getTotalGamesPlayedSizeThisMonth(e.getKey());
|
||||||
|
|
||||||
if(totalSize > 0) {
|
if(totalSize > 0) {
|
||||||
String sizeName = StringUtil.capitalizeFirstLetter(e.getValue(), false);
|
String sizeName = e.getValue();
|
||||||
sender.sendMessage(ChatColor.AQUA + " " + sizeName + ":");
|
if(sizeName.equals("groß")) {
|
||||||
sender.sendMessage(ChatColor.BLUE + " Runden gewonnen: " + ChatColor.GREEN + totalWonSize + " von " + totalSize + " (" + MinecleanerStringUtil.percentageString(totalWonSize, totalSize)+ ") ");
|
sizeName = "gross";
|
||||||
sender.sendMessage(ChatColor.BLUE + " Dieser Monat: " + ChatColor.GREEN + totalWonMonth + " von " + totalSizeMonth + " (" + MinecleanerStringUtil.percentageString(totalWonMonth, totalSizeMonth)+ ")");
|
}
|
||||||
|
sender.sendMessage(createLangComponent("arena.width." + sizeName, NamedTextColor.AQUA).append(Component.text(":", NamedTextColor.AQUA)));
|
||||||
|
|
||||||
|
sender.sendMessage(Component.text(" ")
|
||||||
|
.append(createLangComponent("data.player.roundswon", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text(" "))
|
||||||
|
.append(Component.text(String.valueOf(totalWonSize), NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" "))
|
||||||
|
.append(createLangComponent("data.player.outof", NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" " + totalSize + " (" + MinecleanerStringUtil.percentageString(totalWonSize, totalSize) + ")", NamedTextColor.GREEN)));
|
||||||
|
|
||||||
|
sender.sendMessage(Component.text(" ")
|
||||||
|
.append(createLangComponent("data.player.thismonth", NamedTextColor.BLUE))
|
||||||
|
.append(Component.text(" "))
|
||||||
|
.append(Component.text(String.valueOf(totalWonMonth), NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" "))
|
||||||
|
.append(createLangComponent("data.player.outof", NamedTextColor.GREEN))
|
||||||
|
.append(Component.text(" " + totalSizeMonth + " (" + MinecleanerStringUtil.percentageString(totalWonMonth, totalSizeMonth) + ")", NamedTextColor.GREEN)));
|
||||||
|
|
||||||
Integer time = data.getBestTime(e.getKey());
|
Integer time = data.getBestTime(e.getKey());
|
||||||
Integer timeThisMonth = data.getBestTimeThisMonth(e.getKey());
|
Integer timeThisMonth = data.getBestTimeThisMonth(e.getKey());
|
||||||
sender.sendMessage(ChatColor.BLUE + " Bestzeit: " + ChatColor.GREEN + (time == null ? "-" : MinecleanerStringUtil.timeToString(time)));
|
sender.sendMessage(Component.text(" ")
|
||||||
sender.sendMessage(ChatColor.BLUE + " Dieser Monat: " + ChatColor.GREEN + (timeThisMonth == null ? "-" : MinecleanerStringUtil.timeToString(timeThisMonth)));
|
.append(createLangComponent("data.player.besttime",": ", (time == null ? "-" : MinecleanerStringUtil.timeToString(time, false)), NamedTextColor.BLUE, NamedTextColor.GREEN)));
|
||||||
|
|
||||||
|
sender.sendMessage(Component.text(" ")
|
||||||
|
.append(createLangComponent("data.player.thismonth", ": ", (timeThisMonth == null ? "-" : MinecleanerStringUtil.timeToString(timeThisMonth, false)), NamedTextColor.BLUE, NamedTextColor.GREEN)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +118,7 @@ public class StatsCommand extends SubCommand {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
plugin.getManager().getStatisticsForPlayer((Player) sender, callback);
|
plugin.getManager().getStatisticsForPlayer((Player) sender, callback);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Für die Konsole existieren keine Daten.");
|
sender.sendMessage(createLangComponent("data.console.nodata", NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plugin.getManager().getStatisticsForPlayerIfExists(playerName, callback);
|
plugin.getManager().getStatisticsForPlayerIfExists(playerName, callback);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package de.lunarakai.minecleaner.commands.groups;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AcceptCommand extends SubCommand {
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public AcceptCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String s1, ArgsParser argsParser) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getInvitedGroup(player) != null && plugin.getGroupManager().getGroup(player) == null) {
|
||||||
|
Player groupOwner = Bukkit.getPlayer(plugin.getGroupManager().getInvitedGroup(player).getOwner());
|
||||||
|
if(plugin.getArenaList().getPlayerArena(groupOwner) != null) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.creatorinround");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plugin.getGroupManager().getInvitedGroup(player).addPlayerToGroup(player);
|
||||||
|
|
||||||
|
assert groupOwner != null;
|
||||||
|
ChatUtils.sendSimpleSuccessMessage(groupOwner, player.getName() + " hat deine Einladung angenommen.");
|
||||||
|
ChatUtils.sendSimpleSuccessMessage(player, "group.invite.accepted");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(player, "group.invite.notinvited");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package de.lunarakai.minecleaner.commands.groups;
|
||||||
|
|
||||||
|
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.bukkit.commands.SubCommand;
|
||||||
|
import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerGroupManager;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DenyCommand extends SubCommand {
|
||||||
|
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public DenyCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String s1, ArgsParser argsParser) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getInvitedGroup(player) != null && plugin.getGroupManager().getGroup(player) == null) {
|
||||||
|
Player groupOwner = Bukkit.getPlayer(plugin.getGroupManager().getInvitedGroup(player).getOwner());
|
||||||
|
MinecleanerGroupManager.MinecleanerGroup invitedGroup = plugin.getGroupManager().getInvitedGroup(player);
|
||||||
|
invitedGroup.removePlayerFromInvitedList(player);
|
||||||
|
if(plugin.getGroupManager().getGroup(Bukkit.getPlayer(invitedGroup.getOwner())).invitedPlayers.isEmpty()) {
|
||||||
|
plugin.getGroupManager().deleteGroup(invitedGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert groupOwner != null;
|
||||||
|
ChatUtils.sendSimpleWarningMessage(groupOwner, player.getName() + " hat deine Einladung abgelehnt.");
|
||||||
|
ChatUtils.sendSimpleInfoMessage(player, "group.invite.denied");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.notinvited");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package de.lunarakai.minecleaner.commands.groups;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DismantleGroupCommand extends SubCommand {
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public DismantleGroupCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String s1, ArgsParser argsParser) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
if(plugin.getGroupManager().getGroup(player) == null) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.common.notingroup");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player groupOwnerPlayer = Bukkit.getPlayer(plugin.getGroupManager().getGroup(player).getOwner());
|
||||||
|
|
||||||
|
if(player != groupOwnerPlayer) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.dismantle.nopermission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
ChatUtils.sendSimpleWarningMessage(iteratorPlayer, "group.dismantle.yourgroup");
|
||||||
|
}
|
||||||
|
plugin.getGroupManager().deleteGroup(plugin.getGroupManager().getGroup(player));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package de.lunarakai.minecleaner.commands.groups;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerGroupManager;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class InviteCommand extends SubCommand {
|
||||||
|
/*
|
||||||
|
TODO:
|
||||||
|
- Invite other Players to play in Duo Mode
|
||||||
|
- Add Functionality to support multiple Players in the same game
|
||||||
|
- use settings of player that invited the other player
|
||||||
|
*/
|
||||||
|
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public InviteCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "<Player>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if(plugin.getArenaList().getPlayerArena(player) != null) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.notwhileinround");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.remaining() < 1 || args.remaining() >= 2) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, commandString + getUsage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String playerName = args.getNext().trim();
|
||||||
|
Player invitedPlayer = plugin.getServer().getPlayer(playerName);
|
||||||
|
|
||||||
|
if(invitedPlayer == null) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.offline");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(invitedPlayer == player) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.notyourself");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plugin.getArenaList().getPlayerArena(invitedPlayer) != null) {
|
||||||
|
ChatUtils.sendSimpleWarningMessage(player, "group.invite.invitedinround");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MinecleanerGroupManager groupManager = plugin.getGroupManager();
|
||||||
|
if(groupManager.getInvitedGroup(player) != null) {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(player, "group.invite.alreadyinvited");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(groupManager.getGroup(player) != null && !Bukkit.getPlayer(groupManager.getGroup(player).getOwner()).equals(player)) {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(player, "group.invite.nopermission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(groupManager.getGroup(player) == null) {
|
||||||
|
groupManager.createGroup(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert invitedPlayer != null;
|
||||||
|
player.sendMessage(Component.text("Du hast " + invitedPlayer.getName() + " in eine " + plugin.getDisplayedPluginName() + "-Gruppe eingeladen", NamedTextColor.GREEN));
|
||||||
|
invitedPlayer.sendMessage(Component.text("Du wurdest von " + player.getName() + " in eine " + plugin.getDisplayedPluginName() + "-Gruppe eingeladen.", NamedTextColor.GREEN));
|
||||||
|
invitedPlayer.sendMessage(Component.text("[Annehmen] ", NamedTextColor.GREEN).clickEvent(ClickEvent.runCommand("/minesweeper accept")).append(Component.text(" [Ablehnen]", NamedTextColor.RED).clickEvent(ClickEvent.runCommand("/minesweeper deny"))));
|
||||||
|
groupManager.getGroup(player).invitePlayerToGroup(invitedPlayer);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package de.lunarakai.minecleaner.commands.groups;
|
||||||
|
|
||||||
|
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.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import de.lunarakai.minecleaner.utils.ChatUtils;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ListGroupMembersCommand extends SubCommand {
|
||||||
|
private final MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public ListGroupMembersCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String s1, ArgsParser argsParser) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) commandSender;
|
||||||
|
|
||||||
|
if(plugin.getGroupManager().getGroup(player) == null) {
|
||||||
|
ChatUtils.sendSimpleInfoMessage(player, "group.common.notingroup");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatUtils.sendSimpleSpecialMessage(player, "-- Mitglieder deiner " + plugin.getDisplayedPluginName() + "gruppe --", NamedTextColor.AQUA);
|
||||||
|
for(Iterator<UUID> iterator = plugin.getGroupManager().getGroup(player).getPlayers().iterator(); iterator.hasNext();) {
|
||||||
|
Player iteratorPlayer = Bukkit.getPlayer(iterator.next());
|
||||||
|
String ownerString = "";
|
||||||
|
if(iteratorPlayer == Bukkit.getPlayer(plugin.getGroupManager().getGroup(player).getOwner())) {
|
||||||
|
ownerString = " (Ersteller der Gruppe)";
|
||||||
|
}
|
||||||
|
player.sendMessage(Component.text(" - " + iteratorPlayer.getName(), NamedTextColor.GREEN).append(Component.text(ownerString, NamedTextColor.RED)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ public class BoardSize {
|
||||||
9,
|
9,
|
||||||
12,
|
12,
|
||||||
18,
|
18,
|
||||||
33,
|
36,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int[] boardSizesHeight = {
|
public static int[] boardSizesHeight = {
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,7 @@ public class Game {
|
||||||
|
|
||||||
switch (cell.getType()) {
|
switch (cell.getType()) {
|
||||||
case Mine: {
|
case Mine: {
|
||||||
|
resetFloodedFlaggedCellCounter();
|
||||||
explode(cell);
|
explode(cell);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
src/main/java/de/lunarakai/minecleaner/utils/ChatUtils.java
Normal file
42
src/main/java/de/lunarakai/minecleaner/utils/ChatUtils.java
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ChatUtils {
|
||||||
|
static Pattern langKeyPattern = Pattern.compile("^\\w+\\.\\w+\\.\\w+$");
|
||||||
|
|
||||||
|
public static void sendSimpleSuccessMessage(Player player, String message) {
|
||||||
|
if(message.matches(langKeyPattern.pattern())) {
|
||||||
|
player.sendMessage(Component.translatable(message, NamedTextColor.GREEN));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Component.text(message, NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendSimpleInfoMessage(Player player, String message) {
|
||||||
|
if(message.matches(langKeyPattern.pattern())) {
|
||||||
|
player.sendMessage(Component.translatable(message, NamedTextColor.GOLD));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Component.text(message, NamedTextColor.GOLD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendSimpleWarningMessage(Player player, String message) {
|
||||||
|
if(message.matches(langKeyPattern.pattern())) {
|
||||||
|
player.sendMessage(Component.translatable(message, NamedTextColor.DARK_RED));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Component.text(message, NamedTextColor.DARK_RED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendSimpleSpecialMessage(Player player, String message, NamedTextColor color) {
|
||||||
|
if(message.matches(langKeyPattern.pattern())) {
|
||||||
|
player.sendMessage(Component.translatable(message, color));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Component.text(message, color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/main/java/de/lunarakai/minecleaner/utils/ItemUtil.java
Normal file
33
src/main/java/de/lunarakai/minecleaner/utils/ItemUtil.java
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
|
import de.iani.cubesideutils.bukkit.items.ItemBuilder;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ItemUtil {
|
||||||
|
|
||||||
|
public static final ItemStack EMPTY_ICON = createGuiItem(Material.GRAY_STAINED_GLASS_PANE, Component.text(" "), true, true);
|
||||||
|
|
||||||
|
public static ItemStack createGuiItem(Material material, Component name, String... lore) {
|
||||||
|
return createGuiItem(material, name, false, lore);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack createGuiItem(Material material, Component name, boolean glowing, boolean showTooltip, String... lore) {
|
||||||
|
ItemBuilder builder = ItemBuilder.fromMaterial(material).displayName(name).lore(lore);
|
||||||
|
if (glowing) {
|
||||||
|
builder.enchantment(Enchantment.UNBREAKING, 1, true).flag(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
}
|
||||||
|
if (!showTooltip) {
|
||||||
|
builder.flag(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack createGuiItem(Material material, Component name, boolean glowing, String... lore) {
|
||||||
|
return createGuiItem(material, name, glowing, true, lore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
public class MinecleanerComponentUtils {
|
||||||
|
|
||||||
|
public static TextComponent createLangComponent(String langKey, NamedTextColor namedColor) {
|
||||||
|
return Component.text()
|
||||||
|
.color(namedColor)
|
||||||
|
.append(Component.translatable(langKey))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextComponent createLangComponent(String langKey, String arg0, NamedTextColor namedColor) {
|
||||||
|
return Component.text()
|
||||||
|
.color(namedColor)
|
||||||
|
.append(Component.translatable(langKey, Component.text(arg0)))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextComponent createLangComponent(String langKey, String arg0, String arg1, NamedTextColor namedColor) {
|
||||||
|
return Component.text()
|
||||||
|
.color(namedColor)
|
||||||
|
.append(Component.translatable(langKey, Component.text(arg0), Component.text(arg1)))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextComponent createLangComponent(String langKey, String filler, String arg1, NamedTextColor namedColor, NamedTextColor namedColorArg1) {
|
||||||
|
if(MinecleanerStringUtil.isValidURL(arg1)) {
|
||||||
|
TextComponent urlMessage = Component.text(arg1);
|
||||||
|
urlMessage = urlMessage.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, arg1));
|
||||||
|
urlMessage = urlMessage.color(namedColorArg1);
|
||||||
|
|
||||||
|
return Component.text()
|
||||||
|
.color(namedColor)
|
||||||
|
.append(Component.translatable(langKey))
|
||||||
|
.append(Component.text(filler))
|
||||||
|
.append(urlMessage)
|
||||||
|
.build();
|
||||||
|
} else {
|
||||||
|
return Component.text()
|
||||||
|
.color(namedColor)
|
||||||
|
.append(Component.translatable(langKey))
|
||||||
|
.append(Component.text(filler))
|
||||||
|
.append(Component.text(arg1, namedColorArg1))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
package de.lunarakai.minecleaner.utils;
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import de.iani.cubesideutils.bukkit.items.CustomHeads;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
|
||||||
|
|
||||||
public enum MinecleanerHeads {
|
public enum MinecleanerHeads {
|
||||||
MINESWEEPER_TILE_0("38206373-5653-4431-85aa-6276f3f9a046", "Minesweeper Tile 0", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzRjMjg0YTRlOTc0MDA1ZWE4ZDFkNGQwNjc0ZWMwODk0ZWZkOGY2ZGQwMjQ4NjM5YTZjZmE5NGY4NTM4OCJ9fX0="),
|
MINESWEEPER_TILE_0("38206373-5653-4431-85aa-6276f3f9a046", "Minesweeper Tile 0", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzRjMjg0YTRlOTc0MDA1ZWE4ZDFkNGQwNjc0ZWMwODk0ZWZkOGY2ZGQwMjQ4NjM5YTZjZmE5NGY4NTM4OCJ9fX0="),
|
||||||
|
|
@ -38,40 +32,11 @@ public enum MinecleanerHeads {
|
||||||
|
|
||||||
private ItemStack head;
|
private ItemStack head;
|
||||||
|
|
||||||
private MinecleanerHeads(String ownerUUIDString, String ownerName, String texturesProperty) {
|
MinecleanerHeads(String ownerUUIDString, String ownerName, String texturesProperty) {
|
||||||
head = createHead(UUID.fromString(ownerUUIDString), ownerName, texturesProperty);
|
head = CustomHeads.createHead(UUID.fromString(ownerUUIDString), ownerName, texturesProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHead() {
|
public ItemStack getHead() {
|
||||||
return new ItemStack(head);
|
return new ItemStack(head);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHead(String displayName) {
|
|
||||||
return getHead(displayName, (String[]) null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getHead(String displayName, String... lore) {
|
|
||||||
ItemStack stack = getHead();
|
|
||||||
ItemMeta meta = stack.getItemMeta();
|
|
||||||
meta.setDisplayName(displayName);
|
|
||||||
if (lore != null && lore.length > 0) {
|
|
||||||
meta.setLore(Arrays.asList(lore));
|
|
||||||
}
|
|
||||||
stack.setItemMeta(meta);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack createHead(UUID ownerUUID, String ownerName, String texturesProperty) {
|
|
||||||
if (ownerName == null) {
|
|
||||||
ownerName = ownerUUID.toString().substring(0, 16);
|
|
||||||
}
|
|
||||||
ItemStack stack = new ItemStack(Material.PLAYER_HEAD);
|
|
||||||
SkullMeta meta = (SkullMeta) stack.getItemMeta();
|
|
||||||
PlayerProfile profile = Bukkit.createProfile(ownerUUID, ownerName);
|
|
||||||
profile.setProperty(new ProfileProperty("textures", texturesProperty));
|
|
||||||
meta.setPlayerProfile(profile);
|
|
||||||
stack.setItemMeta(meta);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package de.lunarakai.minecleaner.utils;
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
public class MinecleanerStringUtil {
|
public class MinecleanerStringUtil {
|
||||||
private MinecleanerStringUtil() {
|
private MinecleanerStringUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String timeToString(long millis) {
|
public static String timeToString(long millis, boolean shorten) {
|
||||||
int sec = (int) (millis / 1000);
|
int sec = (int) (millis / 1000);
|
||||||
int min = sec / 60;
|
int min = sec / 60;
|
||||||
int hours = min / 60;
|
int hours = min / 60;
|
||||||
|
|
@ -12,27 +15,52 @@ public class MinecleanerStringUtil {
|
||||||
min = min % 60;
|
min = min % 60;
|
||||||
StringBuilder timeString = new StringBuilder();
|
StringBuilder timeString = new StringBuilder();
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
timeString.append(hours).append(" Stunden");
|
String hoursString = " " + Component.translatable("minecleaner.common.hours");
|
||||||
|
if(shorten) {
|
||||||
|
hoursString = " h";
|
||||||
|
}
|
||||||
|
timeString.append(hours).append(hoursString);
|
||||||
}
|
}
|
||||||
if (min > 0 || !timeString.isEmpty()) {
|
if (min > 0 || !timeString.isEmpty()) {
|
||||||
if (!timeString.isEmpty()) {
|
if (!timeString.isEmpty()) {
|
||||||
timeString.append(", ");
|
timeString.append(", ");
|
||||||
}
|
}
|
||||||
timeString.append(min).append(" Minuten");
|
String minString = " " + Component.translatable("minecleaner.common.minutes");
|
||||||
|
if(shorten) {
|
||||||
|
minString = " min";
|
||||||
|
}
|
||||||
|
timeString.append(min).append(minString);
|
||||||
}
|
}
|
||||||
if (sec > 0 || !timeString.isEmpty()) {
|
if (sec > 0 || !timeString.isEmpty()) {
|
||||||
if (!timeString.isEmpty()) {
|
if (!timeString.isEmpty()) {
|
||||||
timeString.append(" und ");
|
timeString.append(Component.text(" ")).append(Component.translatable("minecleaner.common.and").append(Component.text(" ")));
|
||||||
}
|
}
|
||||||
timeString.append(sec).append(" Sekunden");
|
String secondsString = " " + Component.translatable("minecleaner.common.seconds");
|
||||||
|
if(shorten) {
|
||||||
|
secondsString = " s";
|
||||||
|
}
|
||||||
|
timeString.append(sec).append(secondsString);
|
||||||
}
|
}
|
||||||
return timeString.toString();
|
return timeString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String percentageString(int whatPercentage, int fromPercentage) {
|
public static String percentageString(int whatPercentage, int fromPercentage) {
|
||||||
|
if(fromPercentage == 0) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
float percent = (float) whatPercentage/fromPercentage;
|
float percent = (float) whatPercentage/fromPercentage;
|
||||||
percent = percent * 100;
|
percent = percent * 100;
|
||||||
String percentageString = String.format("%.1f", percent);
|
String percentageString = String.format("%.1f", percent);
|
||||||
return percentageString + "%";
|
return percentageString + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidURL(String urlString) {
|
||||||
|
try {
|
||||||
|
URL url = new URL(urlString);
|
||||||
|
url.toURI();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package de.lunarakai.minecleaner.utils;
|
||||||
|
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MinecleanerUtils {
|
||||||
|
|
||||||
|
public static boolean isPlayerInGroup(MinecleanerPlugin plugin, Player player) {
|
||||||
|
return plugin.getGroupManager().getGroup(player) != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
generalSettings:
|
||||||
|
displayedPluginName: Minecleaner
|
||||||
winpoints:
|
winpoints:
|
||||||
size:
|
size:
|
||||||
small: 1
|
small: 1
|
||||||
|
|
|
||||||
77
src/main/resources/lang/de_DE.properties
Normal file
77
src/main/resources/lang/de_DE.properties
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
minecleaner.info.version=Version
|
||||||
|
minecleaner.info.developer=Entwickelt von
|
||||||
|
minecleaner.info.website=Website
|
||||||
|
minecleaner.info.license=Lizenz
|
||||||
|
|
||||||
|
minecleaner.common.hours=Stunden
|
||||||
|
minecleaner.common.minutes=Minuten
|
||||||
|
minecleaner.common.seconds=Sekunden
|
||||||
|
minecleaner.common.and=und
|
||||||
|
|
||||||
|
settings.manualreset.allow=Manuelles Resetten aktiviert
|
||||||
|
settings.manualreset.deny=Manuelles Resetten deaktiviert
|
||||||
|
settings.additionaltimer.allow=Zusätzliche Anzeige in der Action Bar aktiviert
|
||||||
|
settings.additionaltimer.deny=Zusätzliche Anzeige in der Action Bar deaktiviert
|
||||||
|
settings.timer.allow=Timer wird angezeigt
|
||||||
|
settings.timer.deny=Timer wird nicht angezeigt
|
||||||
|
settings.resettime.text=Resetzeit
|
||||||
|
|
||||||
|
|
||||||
|
arena.name.invalid=Ungültiger Arenaname. Erlaubt sind Buchstaben, Zahlen und der Unterstrich
|
||||||
|
arena.name.exists=Eine Arena mit diesem Namen existiert bereits
|
||||||
|
arena.width.klein=Klein
|
||||||
|
arena.width.mittel=Mittel
|
||||||
|
arena.width.gross=Gross
|
||||||
|
arena.width.experte=Experte
|
||||||
|
arena.widthindex.invalid=Kein Valider Arena WidthIndex!
|
||||||
|
arena.widthindex.validOptions=0 (oder weglassen) = 9*9, 1 = 12*12, 2 = 12*18, 3 = 12*33
|
||||||
|
arena.widthindex.toolarge=Arena WidthIndex darf nicht grösser als 3 sein
|
||||||
|
arena.create.lookAtCenter=Bitte gucke den Block an, der im Zentrum des {0}-Spielfelds sein soll.
|
||||||
|
arena.create.lookAtSide=Bitte gucke die Seite des Blockes an, wo das {0}-Spielfeld erstellt werden soll.
|
||||||
|
arena.create.otherArena=An dieser Stelle befindet sich bereits eine Arena.
|
||||||
|
arena.create.success=Die Arena wurde erfolgreich angelegt.
|
||||||
|
arena.delete.success=Die {0}-Arena {1} wurde gelöscht.
|
||||||
|
arena.delete.noarena=Hier befindet sich keine {0}-Arena.
|
||||||
|
|
||||||
|
arena.common.noarena=Hier befindet sich keine Arena.
|
||||||
|
arena.common.toofaraway=Du hast dich zu weit von der Arena entfernt. Das Spiel wurde abgebrochen.
|
||||||
|
arena.common.groupleadertoofaraway=Der Ersteller der Gruppe hat sich zu weit von der Arena entfernt. Das Spiel wurde abgebrochen.
|
||||||
|
|
||||||
|
arena.list.created=Angelegte {0}-Arenen
|
||||||
|
arena.list.none=(keine)
|
||||||
|
|
||||||
|
data.player.noData=Für Spieler "{0}" existieren keine Daten.
|
||||||
|
data.player.self=Deine {0} Statistik
|
||||||
|
data.player.other={0}-Statistik von {1}
|
||||||
|
data.player.roundswon=Runden gewonnen
|
||||||
|
data.player.pointsscored=Punkte erspielt
|
||||||
|
data.player.outof=von
|
||||||
|
data.player.besttime=Bestzeit
|
||||||
|
data.player.thismonth=Dieser Monat
|
||||||
|
|
||||||
|
data.delete.playerNotFound=Ein Spieler mit dem Namen "{0}" konnte nicht gefunden werden.
|
||||||
|
data.delete.deleted=Alle {0}-Statistiken von Spieler "{1}" wurden gelöscht.
|
||||||
|
|
||||||
|
data.console.nodata=Für die Konsole existieren keine Daten.
|
||||||
|
|
||||||
|
group.common.notingroup=Du bist in keiner Gruppe.
|
||||||
|
|
||||||
|
group.invite.accepted=Du hast die Einladung angenommen.
|
||||||
|
group.invite.denied=Du hast die Einladung abgelehnt.
|
||||||
|
group.invite.notinvited=Du wurdest in keine Gruppe eingeladen.
|
||||||
|
group.invite.creatorinround=Du kannst keine Einladung annehmen während die Person, die dich eingeladen hat, in einer Runde ist.
|
||||||
|
group.invite.notwhileinround=Du kannst keine Einladung verschicken während du in einer Runde bist.
|
||||||
|
group.invite.offline=Du kannst keine Person einladen, die entweder offline oder auf einen anderen Server ist.
|
||||||
|
group.invite.notyourself=Du kannst dich nicht selber in eine Gruppe einladen.
|
||||||
|
group.invite.invitedinround=Du kannst Spieler nicht einladen, die bereits in einer Runde sind.
|
||||||
|
group.invite.alreadyinvited=Du wurdest bereits in eine Gruppe eingeladen. Bitte kümmere dich zuerst um die Einladung bevor du eine eigene Gruppe erstellst.
|
||||||
|
group.invite.nopermission=Nur als Ersteller der Gruppe bist du berechtigt Leute einzuladen.
|
||||||
|
group.invite.accept=Annehmen
|
||||||
|
group.invite.deny=Ablehnen
|
||||||
|
|
||||||
|
group.dismantle.nopermission=Du bist nicht berechtigt deine Gruppe aufzulösen.
|
||||||
|
group.dismantle.yourgroup=Die Gruppe in der du dich befindest wurde aufgelöst.
|
||||||
|
|
||||||
|
group.game.nopermission=Nur der Ersteller der Gruppe kann eine neue Runde starten!
|
||||||
|
group.creator.removed=Die Gruppe wurde aufgelöst, da die Person, welche die Gruppe erstellt hat, aus der Gruppe entfernt wurde.
|
||||||
|
group.dismantled.alone=Die Gruppe wurde aufgelöst, da du nur noch alleine in der Gruppe bist.
|
||||||
76
src/main/resources/lang/en_US.properties
Normal file
76
src/main/resources/lang/en_US.properties
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
minecleaner.info.version=Version
|
||||||
|
minecleaner.info.developer=Developed by
|
||||||
|
minecleaner.info.website=Website
|
||||||
|
minecleaner.info.license=License
|
||||||
|
|
||||||
|
minecleaner.common.hours=hours
|
||||||
|
minecleaner.common.minutes=minutes
|
||||||
|
minecleaner.common.seconds=seconds
|
||||||
|
minecleaner.common.and=and
|
||||||
|
|
||||||
|
settings.manualreset.allow=Manual reset activated
|
||||||
|
settings.manualreset.deny=Manual reset deactivated
|
||||||
|
settings.additionaltimer.allow=Additional display activated in the action bar
|
||||||
|
settings.additionaltimer.deny=Additional display deactivated in the action bar
|
||||||
|
settings.timer.allow=Timer is displayed
|
||||||
|
settings.timer.deny=Timer is not displayed
|
||||||
|
settings.resettime.text=reset time
|
||||||
|
|
||||||
|
arena.name.invalid=Invalid arena name. Allowed are letters, numbers and the underscore
|
||||||
|
arena.name.exists=An arena with this name already exists
|
||||||
|
arena.width.klein=Small
|
||||||
|
arena.width.mittel=Medium
|
||||||
|
arena.width.gross=Large
|
||||||
|
arena.width.experte=Expert
|
||||||
|
arena.widthindex.invalid=Not a valid Arena WidthIndex
|
||||||
|
arena.widthindex.validOptions=0 (or leave empty) = 9*9, 1 = 12*12, 2 = 12*18, 3 = 12*33
|
||||||
|
arena.widthindex.toolarge=Arena WidthIndex must not be greater than 3
|
||||||
|
arena.create.lookAtCenter=Please look at the block that should be in the center of the {0} field.
|
||||||
|
arena.create.lookAtSide=Please look at the side of the block where the {0} field is to be created.
|
||||||
|
arena.create.otherArena=There is already an arena at this location.
|
||||||
|
arena.create.success=The arena has been created successfully.
|
||||||
|
arena.delete.success=The {0}-arena {1} has been deleted.
|
||||||
|
arena.delete.noarena=There is no {0}-arena here.
|
||||||
|
|
||||||
|
arena.common.noarena=There is no arena here.
|
||||||
|
arena.common.toofaraway=You have moved too far away from the arena. The match has been abandoned.
|
||||||
|
arena.common.groupleadertoofaraway=The creator of the group has moved too far away from the arena. The match has been abandoned.
|
||||||
|
|
||||||
|
arena.list.created=Created {0} arenas
|
||||||
|
arena.list.none=(none)
|
||||||
|
|
||||||
|
data.player.noData=No data exists for player "{0}".
|
||||||
|
data.player.self=Your {0} statistics
|
||||||
|
data.player.other={0} statistics from {1}
|
||||||
|
data.player.roundswon=Rounds won
|
||||||
|
data.player.pointsscored=Points scored
|
||||||
|
data.player.outof=out of
|
||||||
|
data.player.besttime=Best time
|
||||||
|
data.player.thismonth=This month
|
||||||
|
|
||||||
|
data.delete.playerNotFound=A player with the name "{0}" could not be found.
|
||||||
|
data.delete.deleted=All {0} stats of player "{1}" have been deleted.
|
||||||
|
|
||||||
|
data.console.nodata=No data exists for the console.
|
||||||
|
|
||||||
|
group.common.notingroup=You are not in a group.
|
||||||
|
|
||||||
|
group.invite.accepted=You have accepted the invitation.
|
||||||
|
group.invite.denied=You declined the invitation.
|
||||||
|
group.invite.notinvited=You have not been invited to any group.
|
||||||
|
group.invite.creatorinround=You cannot accept an invitation while the person who invited you is in a round.
|
||||||
|
group.invite.notwhileinround=You cannot send an invitation while you are in a round.
|
||||||
|
group.invite.offline=You cannot invite a person who is either offline or on another server.
|
||||||
|
group.invite.notyourself=You cannot invite yourself to a group.
|
||||||
|
group.invite.invitedinround=You cannot invite players who are already in a round.
|
||||||
|
group.invite.alreadyinvited=You have already been invited to a group. Please take care of the invitation first before you create your own group.
|
||||||
|
group.invite.nopermission=Only as the creator of the group are you authorized to invite people.
|
||||||
|
group.invite.accept=Accept
|
||||||
|
group.invite.deny=Deny
|
||||||
|
|
||||||
|
group.dismantle.nopermission=You are not authorized to dissolve your group.
|
||||||
|
group.dismantle.yourgroup=The group you are in has been disbanded.
|
||||||
|
|
||||||
|
group.game.nopermission=Only the creator of the group can start a new round!
|
||||||
|
group.creator.removed=The group has been dissolved because the person who created the group has been removed from the group.
|
||||||
|
group.dismantled.alone=The group has been dissolved as you are now only alone in the group.
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
name: Minecleaner
|
name: Minecleaner
|
||||||
version: '${project.version}'
|
version: '${project.version}-${git.commit.id.abbrev}'
|
||||||
|
author: LunarAkai
|
||||||
|
website: https://github.com/LunarAkai/Minecleaner
|
||||||
main: de.lunarakai.minecleaner.MinecleanerPlugin
|
main: de.lunarakai.minecleaner.MinecleanerPlugin
|
||||||
api-version: '1.20'
|
api-version: '1.20'
|
||||||
|
depend:
|
||||||
|
- CubesideUtils
|
||||||
|
softdepend: [CubesideSettings, PlayerUUIDCache]
|
||||||
commands:
|
commands:
|
||||||
minecleaner:
|
minecleaner:
|
||||||
description: main command
|
description: main command
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue