13
0
Dieser Commit ist enthalten in:
Zeanon 2020-04-09 18:16:52 +02:00
Ursprung 3a173a5d69
Commit c6c9b4dda9
34 geänderte Dateien mit 1017 neuen und 639 gelöschten Zeilen

Datei anzeigen

@ -27,35 +27,53 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_9</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_9</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,8 +1,14 @@
package de.steamwar.schematicsystem;
class CheckSchemType_10 {
private CheckSchemType_10(){}
import org.jetbrains.annotations.NotNull;
class CheckSchemType_10 {
private CheckSchemType_10() {
}
@NotNull
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}

Datei anzeigen

@ -3,14 +3,18 @@ package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
class WorldEdit_10 {
private WorldEdit_10(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
private WorldEdit_10() {
}
@NotNull
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
}

Datei anzeigen

@ -27,35 +27,53 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_10</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_10</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -7,17 +7,20 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.Region;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@SuppressWarnings("deprecation")
class CheckSchemType_12 {
private static final int TNT = Material.TNT.getId();
private static final int SLIME = Material.SLIME_BLOCK.getId();
private static final int OBSIDIAN = Material.OBSIDIAN.getId();
@ -25,11 +28,14 @@ class CheckSchemType_12 {
private static final int DISPENSER = Material.DISPENSER.getId();
private static final int JUKEBOX = Material.JUKEBOX.getId();
private static final int CHEST = Material.CHEST.getId();
private static final int AIR = Material.AIR.getId();
@NotNull
private static final Set<Integer> INVENTORY;
@NotNull
private static final Set<Material> FLOWERS;
static{
Set<Integer> inventory = new HashSet<>();
static {
@NotNull Set<Integer> inventory = new HashSet<>();
inventory.add(CHEST);
inventory.add(Material.TRAPPED_CHEST.getId());
inventory.add(Material.HOPPER.getId());
@ -58,21 +64,23 @@ class CheckSchemType_12 {
inventory.add(Material.PURPLE_SHULKER_BOX.getId());
INVENTORY = inventory;
Set<Material> flowers = new HashSet<>();
@NotNull Set<Material> flowers = new HashSet<>();
flowers.add(Material.YELLOW_FLOWER);
flowers.add(Material.RED_ROSE);
flowers.add(Material.DOUBLE_PLANT);
FLOWERS = flowers;
}
private CheckSchemType_12(){}
private CheckSchemType_12() {
}
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
AutoCheckResult result = new AutoCheckResult(type);
@NotNull
static AutoCheckResult autoCheck(@NotNull Schematic schematic, ICheckSchemType type) {
@NotNull AutoCheckResult result = new AutoCheckResult(type);
Clipboard clipboard;
try {
clipboard = schematic.load();
} catch (IOException | NoClipboardException e) {
} catch (@NotNull IOException | NoClipboardException e) {
Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e);
result.setErrorLoadingSchematic();
return result;
@ -89,24 +97,32 @@ class CheckSchemType_12 {
int tnt = 0;
int slime = 0;
int blocks = 0;
int dispenser = 0;
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
final BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
final int blockId = block.getId();
if(blockId == TNT || blockId == OBSIDIAN)
if (blockId == TNT || blockId == OBSIDIAN) {
tnt++;
}
if(blockId == SLIME || blockId == BEDROCK)
if (blockId == SLIME || blockId == BEDROCK) {
slime++;
}
if(blockId == DISPENSER)
if (blockId == DISPENSER) {
dispenser++;
}
if(INVENTORY.contains(blockId)){
if (blockId != AIR) {
blocks++;
}
if (INVENTORY.contains(blockId)) {
checkInventory(result, block, blockId, type);
}
@ -117,37 +133,41 @@ class CheckSchemType_12 {
result.setTNT(tnt);
result.setSlime(slime);
result.setBlocks(blocks);
result.setDispenser(dispenser);
return result;
}
private static void checkInventory(AutoCheckResult result, BaseBlock block, int blockId, ICheckSchemType type){
CompoundTag nbt = block.getNbtData();
if(nbt == null){
@SuppressWarnings("unused")
private static void checkInventory(@NotNull AutoCheckResult result, @NotNull BaseBlock block, int blockId, ICheckSchemType type) {
@Nullable CompoundTag nbt = block.getNbtData();
if (nbt == null) {
result.defunctNbt(Material.getMaterial(blockId).name());
return;
}
if(blockId == JUKEBOX && nbt.getValue().containsKey("RecordItem")){
if (blockId == JUKEBOX && nbt.getValue().containsKey("RecordItem")) {
result.foundRecord();
return;
}
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
if(items.isEmpty())
if (items.isEmpty()) {
return; //Leeres Inventar
}
int counter = 0;
for(CompoundTag item : items){
if(!item.containsKey("id")){
for (@NotNull CompoundTag item : items) {
if (!item.containsKey("id")) {
result.defunctNbt(Material.getMaterial(blockId).name());
continue;
}
String materialName = item.getString("id");
if(materialName.contains(":"))
if (materialName.contains(":")) {
materialName = materialName.split(":")[1];
}
materialName = materialName.toUpperCase().replace("SHOVEL", "SPADE");
Material itemType = Material.getMaterial(materialName);
if(itemType == null && item.getString("id").equals("minecraft:fire_charge"))

Datei anzeigen

@ -3,14 +3,18 @@ package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
class WorldEdit_12 {
private WorldEdit_12(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
private WorldEdit_12() {
}
@NotNull
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
}

Datei anzeigen

@ -27,22 +27,40 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,8 +1,14 @@
package de.steamwar.schematicsystem;
class CheckSchemType_14 {
private CheckSchemType_14(){}
import org.jetbrains.annotations.NotNull;
class CheckSchemType_14 {
private CheckSchemType_14() {
}
@NotNull
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}

Datei anzeigen

@ -10,22 +10,25 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import java.io.IOException;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
class WorldEdit_14 {
private WorldEdit_14(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
World weWorld = new BukkitWorld(player.getWorld());
Location playerLocation = player.getLocation();
private WorldEdit_14() {
}
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws IOException, NoClipboardException {
@NotNull World weWorld = new BukkitWorld(player.getWorld());
@NotNull Location playerLocation = player.getLocation();
Clipboard clipboard = schematic.load();
BlockVector3 vector = BlockVector3.at(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
BlockVector3 v = vector.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ()).subtract(offset);
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(e).to(v).build());
e.flushSession();

Datei anzeigen

@ -49,5 +49,23 @@
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -7,16 +7,19 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.io.IOException;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class CheckSchemType_15 {
private static final Set<Material> INVENTORY = EnumSet.of(
Material.BARREL,
Material.BLAST_FURNACE,
@ -65,14 +68,16 @@ class CheckSchemType_15 {
Material.LILY_OF_THE_VALLEY,
Material.WITHER_ROSE);
private CheckSchemType_15(){}
private CheckSchemType_15() {
}
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
AutoCheckResult result = new AutoCheckResult(type);
@NotNull
static AutoCheckResult autoCheck(@NotNull Schematic schematic, ICheckSchemType type) {
@NotNull AutoCheckResult result = new AutoCheckResult(type);
Clipboard clipboard;
try {
clipboard = schematic.load();
} catch (IOException | NoClipboardException e) {
} catch (@NotNull IOException | NoClipboardException e) {
result.setErrorLoadingSchematic();
Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e);
return result;
@ -89,71 +94,85 @@ class CheckSchemType_15 {
int tnt = 0;
int slime = 0;
int blocks = 0;
int dispenser = 0;
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
final Material blockMaterial = Material.matchMaterial(block.getBlockType().getId());
if(blockMaterial == null)
@Nullable final Material blockMaterial = Material.matchMaterial(block.getBlockType().getId());
if (blockMaterial == null) {
continue;
}
result.checkMaterial(blockMaterial.name());
if(blockMaterial == Material.TNT || blockMaterial == Material.OBSIDIAN)
if (blockMaterial == Material.TNT || blockMaterial == Material.OBSIDIAN) {
tnt++;
}
if(blockMaterial == Material.SLIME_BLOCK || blockMaterial == Material.HONEY_BLOCK || blockMaterial == Material.BEDROCK)
if (blockMaterial == Material.SLIME_BLOCK || blockMaterial == Material.HONEY_BLOCK || blockMaterial == Material.BEDROCK) {
slime++;
}
if(blockMaterial == Material.DISPENSER)
if (blockMaterial == Material.AIR) {
blocks++;
}
if (blockMaterial == Material.DISPENSER) {
dispenser++;
}
if(INVENTORY.contains(blockMaterial))
if (INVENTORY.contains(blockMaterial)) {
checkInventory(result, block, blockMaterial);
}
}
}
}
result.setTNT(tnt);
result.setSlime(slime);
result.setBlocks(blocks);
result.setDispenser(dispenser);
return result;
}
private static void checkInventory(AutoCheckResult result, BaseBlock block, Material blockMaterial){
CompoundTag nbt = block.getNbtData();
if(nbt == null){
private static void checkInventory(@NotNull AutoCheckResult result, @NotNull BaseBlock block, @NotNull Material blockMaterial) {
@Nullable CompoundTag nbt = block.getNbtData();
if (nbt == null) {
result.defunctNbt(blockMaterial.name());
return;
}
if(blockMaterial == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){
if (blockMaterial == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")) {
result.foundRecord();
return;
}
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
if(items.isEmpty())
if (items.isEmpty()) {
return; //Leeres Inventar
}
int counter = 0;
for(CompoundTag item : items){
if(!item.containsKey("id")){
for (@NotNull CompoundTag item : items) {
if (!item.containsKey("id")) {
result.defunctNbt(blockMaterial.name());
continue;
}
Material itemType = Material.matchMaterial(item.getString("id"));
if(itemType == null) //Leere Slots
@Nullable Material itemType = Material.matchMaterial(item.getString("id"));
if (itemType == null) {//Leere Slots
continue;
}
if(blockMaterial == Material.DISPENSER && (itemType.equals(Material.FIRE_CHARGE) || itemType.equals(Material.ARROW)))
if (blockMaterial == Material.DISPENSER && (itemType.equals(Material.FIRE_CHARGE) || itemType.equals(Material.ARROW))) {
counter += item.getByte("Count");
else if(!FLOWERS.contains(itemType) && !(blockMaterial == Material.CHEST && itemType.equals(Material.TNT)))
} else if (!FLOWERS.contains(itemType) && !(blockMaterial == Material.CHEST && itemType.equals(Material.TNT))) {
result.foundForbiddenItem(blockMaterial.name(), itemType.name(), item.getByte("Count"));
}
}
result.dispenserItems(counter);

Datei anzeigen

@ -3,14 +3,18 @@ package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
class WorldEdit_15 {
private WorldEdit_15(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
return WorldEdit_14.pasteSchematic(player, schematic);
}
private WorldEdit_15() {
}
@NotNull
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws IOException, NoClipboardException {
return WorldEdit_14.pasteSchematic(player, schematic);
}
}

Datei anzeigen

@ -27,23 +27,41 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,8 +1,14 @@
package de.steamwar.schematicsystem;
class CheckSchemType_8 {
private CheckSchemType_8(){}
import org.jetbrains.annotations.NotNull;
class CheckSchemType_8 {
private CheckSchemType_8() {
}
@NotNull
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}

Datei anzeigen

@ -10,22 +10,25 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import java.io.IOException;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
class WorldEdit_8 {
private WorldEdit_8(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
World weWorld = new BukkitWorld(player.getWorld());
private WorldEdit_8() {
}
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
@NotNull World weWorld = new BukkitWorld(player.getWorld());
Location playerLocation = player.getLocation();
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
@NotNull Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
Clipboard clipboard = schematic.load();
Vector offset = new Vector(clipboard.getRegion().getMinimumPoint()).subtract(clipboard.getOrigin());
Vector dimensions = clipboard.getDimensions();
Vector v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
Vector v = vector.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ()).subtract(offset);
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard, weWorld.getWorldData()).createPaste(e, weWorld.getWorldData()).to(v).build());
e.flushQueue();

Datei anzeigen

@ -27,35 +27,53 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_8</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_8</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,8 +1,14 @@
package de.steamwar.schematicsystem;
class CheckSchemType_9 {
private CheckSchemType_9(){}
import org.jetbrains.annotations.NotNull;
class CheckSchemType_9 {
private CheckSchemType_9() {
}
@NotNull
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}

Datei anzeigen

@ -3,14 +3,18 @@ package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
class WorldEdit_9 {
private WorldEdit_9(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
private WorldEdit_9() {
}
@NotNull
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
return WorldEdit_8.pasteSchematic(player, schematic);
}
}

Datei anzeigen

@ -27,11 +27,29 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,11 +1,14 @@
package de.steamwar.schematicsystem;
import de.steamwar.core.Core;
import java.util.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class AutoCheckResult {
@Nullable
private final ICheckSchemType type;
private final boolean noChecksInThisVersion;
@ -19,133 +22,168 @@ public class AutoCheckResult {
private int tnt = 0;
private int slime = 0;
private int dispenser = 0;
private Map<String, Integer> forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material
private Map<String, Integer> defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname
private final Map<String, Integer> forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material
private final Map<String, Integer> defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname
private final Map<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp
private int records = 0; // Gefundene Schallplatten
private Map<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp
private int blocks = 0;
private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems
AutoCheckResult(ICheckSchemType type){
AutoCheckResult(ICheckSchemType type) {
this.type = type;
noChecksInThisVersion = false;
}
AutoCheckResult(){
AutoCheckResult() {
type = null;
noChecksInThisVersion = true;
}
public Collection<String> errors(){
List<String> errors = new LinkedList<>();
@NotNull
public Collection<String> errors() {
@NotNull List<String> errors = new LinkedList<>();
if(noChecksInThisVersion){
if (noChecksInThisVersion) {
errors.add("In der 1." + Core.getVersion() + " können keine Schematics eingesendet werden");
return errors;
}
if(wrongVersionException)
if (wrongVersionException) {
errors.add("Diese Schematic kann nicht in dieser Version geändert werden");
if(errorLoadingSchematic)
}
if (errorLoadingSchematic) {
errors.add("Die Schematic konnte nicht geladen werden");
}
assert type != null;
if(width > type.getDepth())
if (width > type.getDepth()) {
errors.add("Die Schematic ist zu breit (" + width + " > " + type.getDepth() + ")");
if(length > type.getWidth())
}
if (length > type.getWidth()) {
errors.add("Die Schematic ist zu lang (" + length + " > " + type.getWidth() + ")");
if(height > type.getHeight())
}
if (height > type.getHeight()) {
errors.add("Die Schematic ist zu hoch (" + height + " > " + type.getHeight() + ")");
}
int errorTNTSlime = slime + tnt;
if(type.getMaxTNT() != 0 && tnt > type.getMaxTNT())
if (type.getMaxTNT() != 0 && tnt > type.getMaxTNT()) {
errors.add("Zu viele TNT-Blöcke (" + tnt + " > " + type.getMaxTNT() + ")");
if(type.getMaxSlime() != 0 && slime > type.getMaxSlime())
}
if (type.getMaxSlime() != 0 && slime > type.getMaxSlime()) {
errors.add("Zu viele Schleim/Honig-Blöcke (" + slime + " > " + type.getMaxSlime() + ")");
if(type.getMaxDispenser() != 0 && dispenser > type.getMaxDispenser())
}
if (type.getMaxDispenser() != 0 && dispenser > type.getMaxDispenser()) {
errors.add("Zu viele Werfer (" + dispenser + " > " + type.getMaxDispenser() + ")");
if(type.getMaxTNTSlime() != 0 && errorTNTSlime > type.getMaxTNTSlime())
}
if (type.getMaxBlocks() != 0 && blocks > type.getMaxDispenser()) {
errors.add("Zu viele Blöcke (" + blocks + " > " + type.getMaxBlocks() + ")");
}
if (type.getMaxTNTSlime() != 0 && errorTNTSlime > type.getMaxTNTSlime()) {
errors.add("Zu viel Schleim+TNT" + errorTNTSlime + " > " + type.getMaxTNTSlime() + ")");
}
for(Map.Entry<String, Integer> block : forbiddenMaterials.entrySet())
for (@NotNull Map.Entry<String, Integer> block : forbiddenMaterials.entrySet()) {
errors.add("Der Block " + block.getKey() + " ist verboten (" + block.getValue() + " verbaut)");
}
if(records > 0)
if (records > 0) {
errors.add("Keine Schallplatten erlaubt (" + records + " gefunden)");
for(Map.Entry<String, Map<String, Integer>> block : forbiddenItems.entrySet())
for(Map.Entry<String, Integer> item : block.getValue().entrySet())
}
for (@NotNull Map.Entry<String, Map<String, Integer>> block : forbiddenItems.entrySet()) {
for (@NotNull Map.Entry<String, Integer> item : block.getValue().entrySet()) {
errors.add("In " + block.getKey() + "s wurde das verbotene Item " + item.getKey() + " " + item.getValue() + " mal gefunden");
if(tooManyDispenserItems == 1)
}
}
if (tooManyDispenserItems == 1) {
errors.add("Ein Werfer enthält mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
else if(tooManyDispenserItems > 1)
} else if (tooManyDispenserItems > 1) {
errors.add(tooManyDispenserItems + " Werfer enthalten mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
}
return errors;
}
public Collection<String> warnings(){
List<String> warnings = new LinkedList<>();
@NotNull
public Collection<String> warnings() {
@NotNull List<String> warnings = new LinkedList<>();
for(Map.Entry<String, Integer> nbtBlock : defunctNbt.entrySet()){
if(nbtBlock.getValue() > 1)
for (@NotNull Map.Entry<String, Integer> nbtBlock : defunctNbt.entrySet()) {
if (nbtBlock.getValue() > 1) {
warnings.add(nbtBlock.getValue() + " " + nbtBlock.getKey() + "s enthalten keine oder inkorrekte NBT-Daten");
else
} else {
warnings.add("Ein(e) " + nbtBlock.getKey() + " enthält keine oder inkorrekte NBT-Daten");
}
}
return warnings;
}
void setWrongVersionException(){
@SuppressWarnings("unused")
void setWrongVersionException() {
wrongVersionException = true;
}
void setErrorLoadingSchematic(){
void setErrorLoadingSchematic() {
errorLoadingSchematic = true;
}
void setWidth(int width){
void setWidth(int width) {
this.width = width;
}
void setLength(int length){
void setLength(int length) {
this.length = length;
}
void setHeight(int height){
void setHeight(int height) {
this.height = height;
}
void setTNT(int tnt){
void setTNT(int tnt) {
this.tnt = tnt;
}
void setSlime(int slime){
void setSlime(int slime) {
this.slime = slime;
}
void setDispenser(int dispenser){
void setDispenser(int dispenser) {
this.dispenser = dispenser;
}
void checkMaterial(String name){
assert type != null;
if(type.getForbidden().contains(name))
forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v+1);
void setBlocks(int blocks) {
this.blocks = blocks;
}
void defunctNbt(String name){
defunctNbt.compute(name, (k, v) -> v == null ? 1 : v+1);
void checkMaterial(String name) {
assert type != null;
if (type.getForbidden().contains(name)) {
forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v + 1);
}
}
void foundRecord(){
void defunctNbt(String name) {
defunctNbt.compute(name, (k, v) -> v == null ? 1 : v + 1);
}
void foundRecord() {
records++;
}
void foundForbiddenItem(String material, String item, int count){
void foundForbiddenItem(String material, String item, int count) {
forbiddenItems.compute(material, (k1, v) -> {
if(v == null)
if (v == null) {
v = new HashMap<>();
}
v.compute(item, (k2, v2) -> v2 == null ? count : v2 + count);
return v;
});
}
void dispenserItems(int counter){
void dispenserItems(int counter) {
assert type != null;
if(counter > type.getMaxDispenserItems())
if (counter > type.getMaxDispenserItems()) {
tooManyDispenserItems++;
}
}
}

Datei anzeigen

@ -4,7 +4,9 @@ import java.nio.file.attribute.PosixFilePermission;
import java.util.EnumSet;
import java.util.Set;
@SuppressWarnings({"ALL", "unused"})
public class Constants {
private Constants(){}
public static final Set<PosixFilePermission> FILE_PERMS = EnumSet.of(

Datei anzeigen

@ -3,15 +3,26 @@ package de.steamwar.schematicsystem;
import java.util.List;
interface ICheckSchemType {
@SuppressWarnings("unused")
String getName();
int getWidth();
int getHeight();
int getDepth();
int getMaxDispenserItems();
int getMaxDispenser();
int getMaxBlocks();
int getMaxTNT();
int getMaxTNTSlime();
int getMaxSlime();
List<String> getForbidden();

Datei anzeigen

@ -98,5 +98,23 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -3,29 +3,37 @@ package de.steamwar.schematicsystem;
import de.steamwar.core.Core;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class CheckSchemType implements ICheckSchemType {
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
@NotNull
private final String name;
private final int width;
private final int height;
private final int depth;
private final int maxDispenserItems;
@NotNull
private final List<String> forbiddenMaterials;
private final int maxTNT;
private final int maxSlime;
private final int maxTNTSlime;
private final int maxDispenser;
private final int maxBlocks;
@NotNull
private final LinkedList<String> checkList;
CheckSchemType(ConfigurationSection section) {
CheckSchemType(@NotNull ConfigurationSection section) {
name = section.getName();
width = section.getInt("width");
height = section.getInt("height");
@ -36,6 +44,7 @@ public class CheckSchemType implements ICheckSchemType {
maxTNTSlime = section.getInt("maxTNTSlime");
maxDispenser = section.getInt("maxDispenser");
maxDispenserItems = section.getInt("maxDispenserItems");
maxBlocks = section.getInt("maxBlocks"); //ADDED
forbiddenMaterials = section.getStringList("forbiddenMaterials");
checkList = new LinkedList<>(section.getStringList("checkList"));
@ -47,16 +56,18 @@ public class CheckSchemType implements ICheckSchemType {
return types.get(type);
}
@NotNull
public List<String> getCheckList() {
return checkList;
}
public SchematicType getAcceptedType(){
public SchematicType getAcceptedType() {
return SchematicType.fromDB(name);
}
public AutoCheckResult autoCheck(Schematic schematic) {
switch(Core.getVersion()){
@NotNull
public AutoCheckResult autoCheck(@NotNull Schematic schematic) {
switch (Core.getVersion()) {
case 15:
return CheckSchemType_15.autoCheck(schematic, this);
case 14:
@ -72,6 +83,7 @@ public class CheckSchemType implements ICheckSchemType {
}
}
@NotNull
@Override
public String getName() {
return name;
@ -102,6 +114,11 @@ public class CheckSchemType implements ICheckSchemType {
return maxDispenser;
}
@Override
public int getMaxBlocks() {
return maxBlocks;
}
@Override
public int getMaxTNT() {
return maxTNT;
@ -117,6 +134,7 @@ public class CheckSchemType implements ICheckSchemType {
return maxSlime;
}
@NotNull
@Override
public List<String> getForbidden() {
return forbiddenMaterials;

Datei anzeigen

@ -7,13 +7,16 @@ import de.steamwar.schematicsystem.commands.SchematicCommand;
import de.steamwar.schematicsystem.listener.PlayerCommandPreProcessListener;
import de.steamwar.schematicsystem.listener.PlayerJoinListener;
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
import java.io.File;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
public class SchematicSystem extends JavaPlugin {
@ -27,24 +30,26 @@ public class SchematicSystem extends JavaPlugin {
Bukkit.shutdown();
}
FileConfiguration config = getConfig();
ConfigurationSection types = config.getConfigurationSection("Schematics");
for(String sectionName : types.getKeys(false))
new CheckSchemType(types.getConfigurationSection(sectionName));
@NotNull FileConfiguration config = getConfig();
@Nullable ConfigurationSection types = config.getConfigurationSection("Schematics");
for (@NotNull String sectionName : Objects.requireNonNull(types).getKeys(false)) {
new CheckSchemType(Objects.requireNonNull(types.getConfigurationSection(sectionName)));
}
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
getCommand("schem").setExecutor(new SchematicCommand());
getCommand("check").setExecutor(new CheckCommand());
Objects.requireNonNull(getCommand("schem")).setExecutor(new SchematicCommand());
Objects.requireNonNull(getCommand("check")).setExecutor(new CheckCommand());
PluginManager pm = Bukkit.getPluginManager();
@NotNull PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), this);
pm.registerEvents(new PlayerQuitListener(), this);
pm.registerEvents(new PlayerCommandPreProcessListener(), this);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if(CheckUtils.getCSchematicsSize() > 0)
if (CheckUtils.getCSchematicsSize() > 0) {
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
}
}, 0, 6000);
}
}

Datei anzeigen

@ -4,15 +4,19 @@ import com.sk89q.worldedit.EditSession;
import de.steamwar.core.Core;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class WorldEdit {
private WorldEdit(){}
public static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
switch(Core.getVersion()){
private WorldEdit() {
}
@NotNull
public static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
switch (Core.getVersion()) {
case 15:
return WorldEdit_15.pasteSchematic(player, schematic);
case 14:

Datei anzeigen

@ -7,29 +7,33 @@ import de.steamwar.sql.CheckedSchematic;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import java.sql.Timestamp;
import java.util.*;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Timestamp;
import java.util.*;
public class CheckSession {
private static Set<CheckSession> checkSessions = new HashSet<>();
private static final Set<CheckSession> checkSessions = new HashSet<>();
private UUID uuid; //player
private Schematic schematic;
private ListIterator<String> checkList;
private final UUID uuid; //player
@NotNull
private final Schematic schematic;
@NotNull
private final ListIterator<String> checkList;
private Timestamp startTime;
private Timestamp stopTime;
private EditSession editSession;
public CheckSession(UUID uuid, Schematic schematic) {
public CheckSession(UUID uuid, @NotNull Schematic schematic) {
this.uuid = uuid;
this.schematic = schematic;
checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator();
@ -42,23 +46,27 @@ public class CheckSession {
return !checkSessions.isEmpty();
}
@Nullable
public static CheckSession getCheckSession() {
if(checkSessions.isEmpty())
if (checkSessions.isEmpty()) {
return null;
}
return checkSessions.iterator().next();
}
public static CheckSession getCheckSession(Player player) {
for(CheckSession session : checkSessions){
if(session.uuid.equals(player.getUniqueId()))
@Nullable
public static CheckSession getCheckSession(@NotNull Player player) {
for (@NotNull CheckSession session : checkSessions) {
if (session.uuid.equals(player.getUniqueId())) {
return session;
}
}
return null;
}
public void sendNextCheck() {
if(!checkList.hasNext()){
Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
if (!checkList.hasNext()) {
Objects.requireNonNull(Bukkit.getPlayer(uuid)).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType());
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben");
@ -68,31 +76,31 @@ public class CheckSession {
setStopTime();
setStartTime();
Bukkit.getPlayer(uuid).sendMessage(checkList.next());
Objects.requireNonNull(Bukkit.getPlayer(uuid)).sendMessage(checkList.next());
if(checkList.hasNext()){
TextComponent next = new TextComponent("next ");
@NotNull TextComponent next = new TextComponent("next ");
next.setColor(ChatColor.GREEN);
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
TextComponent decline = new TextComponent("decline");
@NotNull TextComponent decline = new TextComponent("decline");
decline.setColor(ChatColor.DARK_RED);
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
next.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
Objects.requireNonNull(Bukkit.getPlayer(uuid)).spigot().sendMessage(next);
}else{
TextComponent accept = new TextComponent("accept ");
@NotNull TextComponent accept = new TextComponent("accept ");
accept.setColor(ChatColor.GREEN);
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
TextComponent decline = new TextComponent("decline");
@NotNull TextComponent decline = new TextComponent("decline");
decline.setColor(ChatColor.DARK_RED);
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
accept.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
Objects.requireNonNull(Bukkit.getPlayer(uuid)).spigot().sendMessage(accept);
}
}
@ -108,17 +116,18 @@ public class CheckSession {
checkSessions.remove(this);
}
@NotNull
public Schematic getSchematic() {
return schematic;
}
private void setStartTime() {
Date date = new Date();
@NotNull Date date = new Date();
this.startTime = new Timestamp(date.getTime());
}
private void setStopTime() {
Date date = new Date();
@NotNull Date date = new Date();
this.stopTime = new Timestamp(date.getTime());
}

Datei anzeigen

@ -5,85 +5,93 @@ import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import java.util.LinkedList;
import java.util.List;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.List;
public class CheckUtils {
private CheckUtils(){}
public static boolean schemnameForbidden(String schematicName) {
public static boolean schemnameForbidden(@NotNull String schematicName) {
return schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"");
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"");
}
public static boolean allowedToCheck(Player player) {
public static boolean allowedToCheck(@NotNull Player player) {
SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId());
return warkingUser.getUserGroup() == UserGroup.Supporter ||
warkingUser.getUserGroup() == UserGroup.Developer ||
warkingUser.getUserGroup() == UserGroup.Moderator ||
warkingUser.getUserGroup() == UserGroup.Admin;
warkingUser.getUserGroup() == UserGroup.Developer ||
warkingUser.getUserGroup() == UserGroup.Moderator ||
warkingUser.getUserGroup() == UserGroup.Admin;
}
public static void sendTeamMembersCSchematics(String message) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(allowedToCheck(player))
public static void sendTeamMembersCSchematics(@NotNull String message) {
for (@NotNull Player player : Bukkit.getServer().getOnlinePlayers()) {
if (allowedToCheck(player)) {
player.sendMessage(message);
}
}
}
public static int getCSchematicsSize() {
int size = 0;
for(SchematicType type : SchematicType.values()){
if(type.check())
for (@NotNull SchematicType type : SchematicType.values()) {
if (type.check()) {
size += Schematic.getAllSchemsOfType(type).size();
}
}
return size;
}
@NotNull
public static String sendTeamMembersCSchematicsInfo() {
int size = getCSchematicsSize();
String message = "";
if(size == 0)
@NotNull String message = "";
if (size == 0) {
message = SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!";
if(size == 1)
}
if (size == 1) {
message = SchematicSystem.PREFIX + "§aEs gibt noch §6eine §aungeprüfte Schematic!";
if(size > 1)
}
if (size > 1) {
message = SchematicSystem.PREFIX + "§aEs gibt noch §6" + size + " §aungeprüfte Schematics!";
}
return message;
}
public static void sendTeammemberSchematicList(Player player) {
List<Schematic> schematicList = new LinkedList<>();
public static void sendTeammemberSchematicList(@NotNull Player player) {
@NotNull List<Schematic> schematicList = new LinkedList<>();
for(SchematicType type : SchematicType.values()) {
if (type.check())
for (@NotNull SchematicType type : SchematicType.values()) {
if (type.check()) {
schematicList.addAll(Schematic.getAllSchemsOfType(type));
}
}
if(schematicList.isEmpty()) {
if (schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
return;
}
player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
for(Schematic schematic : schematicList) {
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
for (@NotNull Schematic schematic : schematicList) {
@NotNull TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + SteamwarUser.get(schematic.getSchemOwner()).getUserName()));

Datei anzeigen

@ -7,41 +7,46 @@ import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
public class CheckCommand implements CommandExecutor {
@SuppressWarnings("NullableProblems")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
public boolean onCommand(CommandSender sender, Command command, String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
if(CheckUtils.allowedToCheck(player)) {
if(args.length == 0) {
@NotNull Player player = (Player) sender;
if (CheckUtils.allowedToCheck(player)) {
if (args.length == 0) {
help(player);
return false;
}
CheckSession checkSession;
@Nullable CheckSession checkSession;
switch(args[0]){
switch (args[0]) {
case "list":
CheckUtils.sendTeammemberSchematicList(player);
break;
case "next":
case "allow":
checkSession = session(player);
if(checkSession != null)
if (checkSession != null) {
checkSession.sendNextCheck();
}
break;
case "cancel":
checkSession = session(player);
@ -52,7 +57,7 @@ public class CheckCommand implements CommandExecutor {
break;
case "schematic":
SteamwarUser checker = SteamwarUser.get(player.getUniqueId());
String worldName = player.getWorld().getName();
@NotNull String worldName = player.getWorld().getName();
if(!worldName.equals(player.getUniqueId().toString()) && !worldName.equals(Integer.toString(checker.getId()))) {
player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen musst du dich auf deinem Bauserver befinden!");
return false;
@ -71,23 +76,23 @@ public class CheckCommand implements CommandExecutor {
}
Schematic schematic = Schematic.getSchemFromDB(args[1], user.getUUID());
if(schematic == null){
if (schematic == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cSchematic gibts nicht");
return false;
}else if(!schematic.getSchemType().check()){
} else if (!schematic.getSchemType().check()) {
player.sendMessage(SchematicSystem.PREFIX + "§cSchematic ist nicht zu prüfen");
return false;
}else if(schematic.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
} else if (schematic.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht deine eigenen Schematics prüfen");
return false;
}
List<Player> worldPlayers = player.getWorld().getPlayers();
for(Player players : worldPlayers) {
if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
@NotNull List<Player> worldPlayers = player.getWorld().getPlayers();
for (@NotNull Player players : worldPlayers) {
if (!players.getUniqueId().toString().equals(player.getWorld().getName())) {
SteamwarUser warkingUsers = SteamwarUser.get(players.getUniqueId());
if(!CheckUtils.allowedToCheck(players) &&
!warkingUsers.getUUID().toString().equals(SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString())) {
if (!CheckUtils.allowedToCheck(players) &&
!warkingUsers.getUUID().toString().equals(SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString())) {
player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich kein Unbeteiligter auf deinem Bauserver befinden!");
return false;
}
@ -98,7 +103,7 @@ public class CheckCommand implements CommandExecutor {
checkSession = new CheckSession(player.getUniqueId(), schematic);
checkSession.sendNextCheck();
checkSession.setEditSession(WorldEdit.pasteSchematic(player, schematic));
} catch (IOException | NoClipboardException ex) {
} catch (@NotNull IOException | NoClipboardException ex) {
player.sendMessage(SchematicSystem.PREFIX + "§cSchematic konnte nicht geladen/gepastet werden");
Bukkit.getLogger().log(Level.SEVERE, "Failed to load schematic", ex);
return false;
@ -116,7 +121,7 @@ public class CheckCommand implements CommandExecutor {
if(checkSession == null)
return false;
StringBuilder message = new StringBuilder();
@NotNull StringBuilder message = new StringBuilder();
for (int i = 1; i < args.length; i++) message.append(args[i]).append(" ");
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + SteamwarUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!");
@ -130,8 +135,8 @@ public class CheckCommand implements CommandExecutor {
return false;
}
private void help(Player player) {
if(CheckUtils.allowedToCheck(player)){
private void help(@NotNull Player player) {
if (CheckUtils.allowedToCheck(player)) {
player.sendMessage("§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics");
player.sendMessage("§8/§echeck schematic [SchematicName] [Besitzer] §8- §7Zum Checken einer Schematic");
player.sendMessage("§8/§echeck allow §8- §7Schematic freigeben");
@ -140,10 +145,12 @@ public class CheckCommand implements CommandExecutor {
}
}
private CheckSession session(Player player){
CheckSession checkSession = CheckSession.getCheckSession(player);
if(checkSession == null)
@Nullable
private CheckSession session(@NotNull Player player) {
@Nullable CheckSession checkSession = CheckSession.getCheckSession(player);
if (checkSession == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
}
return checkSession;
}
}

Datei anzeigen

@ -5,31 +5,36 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import java.util.*;
class GUI {
private GUI(){}
static void changeType(Player p, Schematic schem){
List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for(SchematicType type : SchematicType.values()){
if(!type.isAssignable())
private GUI() {
}
static void changeType(@NotNull Player p, @NotNull Schematic schem) {
@NotNull List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for (@NotNull SchematicType type : SchematicType.values()) {
if (!type.isAssignable()) {
continue;
}
SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
if(type.fightType())
@NotNull SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
if (type.fightType()) {
item.setEnchanted(true);
}
types.add(new SWListInv.SWListEntry<>(item, type));
}
SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
@NotNull SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
SchematicCommand.changetype(p, schem, schematicType);
p.closeInventory();
});
@ -37,16 +42,17 @@ class GUI {
inv.open();
}
static void delete(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
static void delete(@NotNull Player p, @NotNull Schematic schem) {
@NotNull SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
schem.remove();
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
for(CheckedSchematic checkedSchematic : checkedSchematics) {
if(checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
checkedSchematic.getSchemName().equals(schem.getSchemName()))
for (@NotNull CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
checkedSchematic.getSchemName().equals(schem.getSchemName())) {
checkedSchematic.remove();
}
}
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
p.closeInventory();
@ -56,14 +62,14 @@ class GUI {
inv.open();
}
static void delmembers(Player p, Schematic schem){
List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
static void delmembers(@NotNull Player p, @NotNull Schematic schem) {
@NotNull List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
for (@NotNull SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())) {
SteamwarUser user = SteamwarUser.get(member.getMember());
members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member));
}
SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
@NotNull SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
member.remove();
p.closeInventory();
delmembers(p, schem);
@ -72,15 +78,82 @@ class GUI {
inv.open();
}
private static void changeItem(Player p, Schematic schem){
List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
for(Material material : Material.values()){
SWItem item = new SWItem(material, "§7" + material.name());
if(item.getItemMeta() != null && material.isItem())
materials.add(new SWListInv.SWListEntry<>(item, material));
static void list(@NotNull Player p) {
list(p, SteamwarUser.get(p.getUniqueId()).getId());
}
static void list(@NotNull Player p, int pid) {
@NotNull List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
List<Schematic> schems = Schematic.getSchemsAccessibleByUser(pid);
//noinspection DuplicatedCode
for (@NotNull Schematic schem : schems) {
Material m;
if (schem.getItem().isEmpty()) {
m = SWItem.getMaterial("CAULDRON_ITEM");
} else {
m = SWItem.getMaterial(schem.getItem());
}
@NotNull SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {
});
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
@NotNull SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", schemList, (clickType, schem) -> {
p.closeInventory();
info(p, schem);
});
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
static boolean listSearch(@NotNull Player player, @NotNull String search) {
@NotNull List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
@NotNull List<Schematic> filteredSchems = new ArrayList<>();
for (@NotNull Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) {
if (currentSchem.getSchemName().toLowerCase().contains(search.toLowerCase())) {
filteredSchems.add(currentSchem);
}
}
if (filteredSchems.isEmpty()) {
return false;
}
for (@NotNull Schematic currentSchem : filteredSchems) {
Material m;
if (currentSchem.getItem().isEmpty()) {
m = SWItem.getMaterial("CAULDRON_ITEM");
} else {
m = SWItem.getMaterial(currentSchem.getItem());
}
@NotNull SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {
});
schemList.add(new SWListInv.SWListEntry<>(item, currentSchem));
}
@NotNull SWListInv<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", schemList, (clickType, schem) -> {
player.closeInventory();
info(player, schem);
});
inv.setCallback(-999, (ClickType click) -> player.closeInventory());
inv.open();
return true;
}
private static void changeItem(@NotNull Player p, @NotNull Schematic schem) {
@NotNull List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
for (@NotNull Material material : Material.values()) {
@NotNull SWItem item = new SWItem(material, "§7" + material.name());
if (item.getItemMeta() != null && material.isItem()) {
materials.add(new SWListInv.SWListEntry<>(item, material));
}
}
@NotNull SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
schem.setItem(material.name());
p.closeInventory();
info(p, schem);
@ -89,21 +162,23 @@ class GUI {
inv.open();
}
private static void info(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
if(schem.availible())
private static void info(@NotNull Player p, @NotNull Schematic schem) {
@NotNull SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
if (schem.availible()) {
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
SchematicCommand.load(p, schem);
p.closeInventory();
});
}
if(schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()){
if(schem.getSchemType().writeable()){
if (schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()) {
if (schem.getSchemType().writeable()) {
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
for(CheckedSchematic checkedSchematic : checkedSchematics) {
if(checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
for (@NotNull CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {
});
break;
}
}
@ -133,12 +208,13 @@ class GUI {
p.closeInventory();
delete(p, schem);
});
}else{
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
} else {
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {
});
SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
SkullMeta headmeta = (SkullMeta)owner.getItemMeta();
@NotNull SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
@NotNull SkullMeta headmeta = (SkullMeta) owner.getItemMeta();
headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID()));
headmeta.setDisplayName("§7von §e" + owneruser.getUserName());
owner.setItemMeta(headmeta);
@ -148,63 +224,4 @@ class GUI {
inv.setCallback(-999, click -> p.closeInventory());
inv.open();
}
static void list(Player p){
list(p, SteamwarUser.get(p.getUniqueId()).getId());
}
static void list(Player p, int pid){
List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
List<Schematic> schems = Schematic.getSchemsAccessibleByUser(pid);
for(Schematic schem : schems) {
Material m;
if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {});
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", schemList, (clickType, schem) -> {
p.closeInventory();
info(p, schem);
});
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
static boolean listSearch(Player player, String search) {
List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
List<Schematic> filteredSchems = new ArrayList<>();
for(Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) {
if(currentSchem.getSchemName().toLowerCase().contains(search.toLowerCase()))
filteredSchems.add(currentSchem);
}
if(filteredSchems.isEmpty())
return false;
for(Schematic currentSchem : filteredSchems) {
Material m;
if (currentSchem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(currentSchem.getItem());
SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {});
schemList.add(new SWListInv.SWListEntry<>(item, currentSchem));
}
SWListInv<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", schemList, (clickType, schem) -> {
player.closeInventory();
info(player, schem);
});
inv.setCallback(-999, (ClickType click) -> player.closeInventory());
inv.open();
return true;
}
}

Datei anzeigen

@ -5,6 +5,11 @@ import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -15,29 +20,28 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
public class SchematicCommand implements CommandExecutor {
private static final int FILES_PER_PAGE = 15;
@SuppressWarnings("NullableProblems")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
public boolean onCommand(CommandSender sender, Command command, String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
return false;
Player player = (Player) sender;
}
@NotNull Player player = (Player) sender;
if(args.length == 0){
if (args.length == 0) {
help(player);
return false;
}
switch(args[0].toLowerCase()){
switch (args[0].toLowerCase()) {
case "gui":
GUI.list(player);
break;
@ -77,13 +81,65 @@ public class SchematicCommand implements CommandExecutor {
return false;
}
private void list(Player player, String[] args){
if(args.length <= 1){
static void load(@NotNull Player player, @NotNull Schematic schematic) {
try {
schematic.loadToPlayer(player);
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
} catch (@NotNull IOException | NoClipboardException e) {
Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", e);
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Laden der Schematic. Bitte wende dich an einen Developer");
}
}
static void changetype(@NotNull Player player, @NotNull Schematic schematic, @NotNull SchematicType type) {
if (schematic.getSchemType() == type) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic hat bereits diesen Typen");
return;
}
if (type.writeable()) {
schematic.setSchemType(type);
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
} else if (type.fightType()) {
if (schematic.getSchemType().check()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast diese Schematic bereits eingesendet");
return;
}
AutoCheckResult result = CheckSchemType.get(type).autoCheck(schematic);
@NotNull Collection<String> errors = result.errors();
for (String warning : result.warnings()) {
player.sendMessage(" §e" + warning);
}
for (String error : errors) {
player.sendMessage(" §c" + error);
}
if (!errors.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic ist nicht regelkonform");
return;
}
schematic.setSchemType(type.checkType());
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft");
}
}
static void download(@NotNull Player player, @NotNull Schematic schematic) {
if (schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
return;
}
player.sendMessage(DownloadSchematic.getLink(schematic));
}
private void list(@NotNull Player player, @NotNull String[] args) {
if (args.length <= 1) {
sendPlayerSchematicList(0, SteamwarUser.get(player.getUniqueId()).getId(), player);
return;
}
if("public".equalsIgnoreCase(args[1])){
if ("public".equalsIgnoreCase(args[1])) {
GUI.list(player, 0);
return;
}
@ -95,21 +151,24 @@ public class SchematicCommand implements CommandExecutor {
}
}
private boolean invalidSchemName(Player player, String name){
if(CheckUtils.schemnameForbidden(name)){
private boolean invalidSchemName(@NotNull Player player, @NotNull String name) {
if (CheckUtils.schemnameForbidden(name)) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true;
}
return false;
}
private Schematic getSchem(Player player, String name){
if(invalidSchemName(player, name))
@Nullable
private Schematic getSchem(@NotNull Player player, @NotNull String name) {
if (invalidSchemName(player, name)) {
return null;
}
Schematic schematic = Schematic.getSchemFromDB(name, player.getUniqueId());
if(schematic == null)
if (schematic == null) {
schematic = Schematic.getSchemFromDB(name, 0); //public schematic
}
if (schematic == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
@ -119,40 +178,32 @@ public class SchematicCommand implements CommandExecutor {
return schematic;
}
private void load(Player player, String[] args){
if(args.length < 2){
private void load(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
load(player, schematic);
}
static void load(Player player, Schematic schematic){
try {
schematic.loadToPlayer(player);
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
}catch (IOException | NoClipboardException e){
Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", e);
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Laden der Schematic. Bitte wende dich an einen Developer");
}
}
private void delete(Player player, String[] args){
if(args.length < 2){
private void delete(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
if(SteamwarUser.get(player.getUniqueId()).getId() != schematic.getSchemOwner()){
if (SteamwarUser.get(player.getUniqueId()).getId() != schematic.getSchemOwner()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur deine eigenen Schematics löschen");
return;
}
@ -160,16 +211,17 @@ public class SchematicCommand implements CommandExecutor {
GUI.delete(player, schematic);
}
private void save(Player player, String[] args){
if(args.length < 2){
private void save(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
if(invalidSchemName(player, args[1]))
if (invalidSchemName(player, args[1])) {
return;
}
if(args[1].length() > 64){
if (args[1].length() > 64) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer Name der Schematic ist zu lang");
return;
}
@ -197,34 +249,37 @@ public class SchematicCommand implements CommandExecutor {
return;
}catch (NoClipboardException e) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer");
if(newSchem)
if (newSchem) {
schematic.remove();
}
return;
}
if (newSchem)
if (newSchem) {
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert");
else
} else {
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben");
}
}
private void changetype(Player player, String[] args){
if(args.length < 2){
private void changetype(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
if(args.length < 3) {
if (args.length < 3) {
GUI.changeType(player, schematic);
return;
}
SchematicType type = SchematicType.fromDB(args[2]);
if(type == null || !type.isAssignable()){
if (type == null || !type.isAssignable()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDiesen Schematictypen gibt es nicht");
return;
}
@ -232,149 +287,111 @@ public class SchematicCommand implements CommandExecutor {
changetype(player, schematic, type);
}
static void changetype(Player player, Schematic schematic, SchematicType type){
if(schematic.getSchemType() == type){
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic hat bereits diesen Typen");
return;
}
if(type.writeable()){
schematic.setSchemType(type);
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
}else if(type.fightType()){
if(schematic.getSchemType().check()){
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast diese Schematic bereits eingesendet");
return;
}
AutoCheckResult result = CheckSchemType.get(type).autoCheck(schematic);
Collection<String> errors = result.errors();
for(String warning : result.warnings()){
player.sendMessage(" §e" + warning);
}
for(String error : errors){
player.sendMessage(" §c" + error);
}
if(!errors.isEmpty()){
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic ist nicht regelkonform");
return;
}
schematic.setSchemType(type.checkType());
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft");
}
}
private void info(Player player, String[] args){
if(args.length < 2){
private void info(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
player.sendMessage("§eName: §7" + schematic.getSchemName());
TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId()) && schematic.availible()){
@NotNull TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
if (SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId()) && schematic.availible()) {
type.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eTyp ändern")));
type.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName()));
}
player.spigot().sendMessage(type);
if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){
TextComponent download = new TextComponent("§eDownload Schematic");
if (SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
@NotNull TextComponent download = new TextComponent("§eDownload Schematic");
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eGeneriere Downloadlink")));
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + schematic.getSchemName()));
player.spigot().sendMessage(download);
}
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
for(int i = checkedSchematics.size() -1; i >= 0; i--) {
if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
for (int i = checkedSchematics.size() - 1; i >= 0; i--) {
if (checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason());
break;
}
}
if(!SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
if (!SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
player.sendMessage("§eBesitzer: §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
} else {
List<String> schematicMembers = new ArrayList<>();
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
@NotNull List<String> schematicMembers = new ArrayList<>();
for (@NotNull SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
schematicMembers.add(SteamwarUser.get(schematicMember.getMember()).getUserName());
}
player.sendMessage("§eMitglieder: §7" + schematicMembers.toString());
}
if(schematic.availible()){
TextComponent loadSchematic = new TextComponent("LADEN");
if (schematic.availible()) {
@NotNull TextComponent loadSchematic = new TextComponent("LADEN");
loadSchematic.setColor(ChatColor.DARK_GREEN);
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
player.spigot().sendMessage(loadSchematic);
}
}
private void download(Player player, String[] args){
if(args.length < 2){
private void download(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
download(player, schematic);
}
private void search(Player player, String[] args) {
if(args.length < 2) {
private void search(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
if(!GUI.listSearch(player, args[1]))
if (!GUI.listSearch(player, args[1])) {
player.sendMessage("§cEs wurden keine Schematics gefunden!");
}
static void download(Player player, Schematic schematic){
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
return;
}
player.sendMessage(DownloadSchematic.getLink(schematic));
}
private void addmember(Player player, String[] args){
if(args.length < 3){
private void addmember(@NotNull Player player, @NotNull String[] args) {
if (args.length < 3) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
if (schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur auf deine eigene Schematic Mitglieder hinzufügen");
return;
}
SteamwarUser warkingUser = SteamwarUser.get(args[2]);
if(warkingUser == null){
if (warkingUser == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
return;
}
if(schematic.getSchemOwner() == warkingUser.getId()){
if (schematic.getSchemOwner() == warkingUser.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
return;
}
if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null){
if (SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
return;
}
@ -382,27 +399,29 @@ public class SchematicCommand implements CommandExecutor {
new SchematicMember(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §e" + schematic.getSchemName());
Player target = Bukkit.getPlayer(warkingUser.getUUID());
if(target != null)
@Nullable Player target = Bukkit.getPlayer(warkingUser.getUUID());
if (target != null) {
target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + schematic.getSchemName() + " §7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
}
}
private void delmember(Player player, String[] args){
if(args.length < 2){
private void delmember(@NotNull Player player, @NotNull String[] args) {
if (args.length < 2) {
help(player);
return;
}
Schematic schematic = getSchem(player, args[1]);
if(schematic == null)
@Nullable Schematic schematic = getSchem(player, args[1]);
if (schematic == null) {
return;
}
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
if (schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur von deinen eigenen Schematics Mitglieder entfernen");
return;
}
if(args.length < 3){
if (args.length < 3) {
GUI.delmembers(player, schematic);
return;
}
@ -426,12 +445,12 @@ public class SchematicCommand implements CommandExecutor {
schematicMember.remove();
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName());
Player target = Bukkit.getPlayer(warkingUser.getUUID());
@Nullable Player target = Bukkit.getPlayer(warkingUser.getUUID());
if(target != null)
target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName() + "§7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
}
private void help(Player player) {
private void help(@NotNull Player player) {
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
@ -447,10 +466,10 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
}
private void sendPlayerSchematicList(int currentPage, int schemOwner, Player player) {
private void sendPlayerSchematicList(int currentPage, int schemOwner, @NotNull Player player) {
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(schemOwner);
if(schematicList.isEmpty()) {
if (schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch keine Schematics");
return;
}
@ -476,11 +495,11 @@ public class SchematicCommand implements CommandExecutor {
Schematic schematic = schematicList.get(i);
String schematicPlayer = "";
@NotNull String schematicPlayer = "";
if(schematic.getSchemOwner() != schemOwner)
schematicPlayer = " §8von §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName();
TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
@NotNull TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
@ -491,7 +510,7 @@ public class SchematicCommand implements CommandExecutor {
if(pages <= 1) return;
TextComponent beforePage = new TextComponent("««");
@NotNull TextComponent beforePage = new TextComponent("««");
if(currentPage > 0){
beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
@ -499,7 +518,7 @@ public class SchematicCommand implements CommandExecutor {
}else
beforePage.setColor(ChatColor.RED);
TextComponent nextPage = new TextComponent(" Seite »»");
@NotNull TextComponent nextPage = new TextComponent(" Seite »»");
if(currentPage < pages-1){
nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));

Datei anzeigen

@ -2,23 +2,25 @@ package de.steamwar.schematicsystem.listener;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckSession;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.jetbrains.annotations.NotNull;
import java.util.logging.Level;
public class PlayerCommandPreProcessListener implements Listener {
@EventHandler
public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
public void handlePlayerCommandPreprocess(@NotNull PlayerCommandPreprocessEvent event) {
@NotNull Player player = event.getPlayer();
if (!event.getMessage().contains("copy") && !event.getMessage().contains("cut")) {
return;
}
if(CheckSession.getCheckSession() != null) {
if (CheckSession.getCheckSession() != null) {
event.setCancelled(true);
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt.");
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");

Datei anzeigen

@ -6,41 +6,46 @@ import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.LinkedList;
import java.util.List;
public class PlayerJoinListener implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
public void handlePlayerJoin(@NotNull PlayerJoinEvent event) {
@NotNull Player player = event.getPlayer();
if(CheckSession.currentChecking()){
CheckSession current = CheckSession.getCheckSession();
if (CheckSession.currentChecking()) {
@Nullable CheckSession current = CheckSession.getCheckSession();
assert current != null;
if(!CheckUtils.allowedToCheck(player) && !SteamwarUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())){
if (!CheckUtils.allowedToCheck(player) && !SteamwarUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())) {
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!");
player.kickPlayer("");
return;
}
}
if(CheckUtils.allowedToCheck(player))
if (CheckUtils.allowedToCheck(player)) {
player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
List<Schematic> uncheckedSchematics = new LinkedList<>();
for(SchematicType type : SchematicType.values()){
if(type.check())
uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type));
}
if(!uncheckedSchematics.isEmpty())
@NotNull List<Schematic> uncheckedSchematics = new LinkedList<>();
for (@NotNull SchematicType type : SchematicType.values()) {
if (type.check()) {
uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type));
}
}
if (!uncheckedSchematics.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§7Du hast noch §e" + uncheckedSchematics.size() + " §7ungeprüfte Schematic(s)!");
}
}
}

Datei anzeigen

@ -5,15 +5,19 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
CheckSession checkSession = CheckSession.getCheckSession(player);
if(checkSession == null)
public void handlePlayerQuit(@NotNull PlayerQuitEvent event) {
@NotNull Player player = event.getPlayer();
@Nullable CheckSession checkSession = CheckSession.getCheckSession(player);
if (checkSession == null) {
return;
}
checkSession.removeSchematic();
}