13
0

Solved #49 #54

Zusammengeführt
Lixfel hat 3 Commits von zeanon nach master 2020-04-09 21:00:29 +02:00 zusammengeführt
34 geänderte Dateien mit 626 neuen und 1004 gelöschten Zeilen
Nur Änderungen aus Commit 91a8c38ede werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -57,23 +57,5 @@
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -57,23 +57,5 @@
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -44,23 +44,5 @@
<version>1.15</version> <version>1.15</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

@ -10,25 +10,22 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import java.io.IOException;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
class WorldEdit_14 { class WorldEdit_14 {
private 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();
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(); Clipboard clipboard = schematic.load();
BlockVector3 vector = BlockVector3.at(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()); BlockVector3 vector = BlockVector3.at(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
BlockVector3 dimensions = clipboard.getDimensions(); 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); EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(e).to(v).build()); Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(e).to(v).build());
e.flushSession(); e.flushSession();

Datei anzeigen

@ -49,23 +49,5 @@
<version>1.15</version> <version>1.15</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -45,23 +45,5 @@
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -57,23 +57,5 @@
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -33,23 +33,5 @@
<version>1.12</version> <version>1.12</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -98,23 +98,5 @@
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -5,36 +5,31 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import java.util.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import java.util.*;
class GUI { class GUI {
private GUI(){}
private GUI() { static void changeType(Player p, Schematic schem){
} List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for(SchematicType type : SchematicType.values()){
static void changeType(@NotNull Player p, @NotNull Schematic schem) { if(!type.isAssignable())
@NotNull List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for (@NotNull SchematicType type : SchematicType.values()) {
if (!type.isAssignable()) {
continue; continue;
}
@NotNull SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name()); SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
if (type.fightType()) { if(type.fightType())
item.setEnchanted(true); item.setEnchanted(true);
}
types.add(new SWListInv.SWListEntry<>(item, type)); types.add(new SWListInv.SWListEntry<>(item, type));
} }
@NotNull SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> { SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
SchematicCommand.changetype(p, schem, schematicType); SchematicCommand.changetype(p, schem, schematicType);
p.closeInventory(); p.closeInventory();
}); });
@ -42,18 +37,17 @@ class GUI {
inv.open(); inv.open();
} }
static void delete(@NotNull Player p, @NotNull Schematic schem) { static void delete(Player p, Schematic schem){
@NotNull SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen"); SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
schem.remove(); schem.remove();
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId()); List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
for (@NotNull CheckedSchematic checkedSchematic : checkedSchematics) { for(CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemOwner() == schem.getSchemOwner() && if(checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
checkedSchematic.getSchemName().equals(schem.getSchemName())) { checkedSchematic.getSchemName().equals(schem.getSchemName()))
checkedSchematic.remove(); checkedSchematic.remove();
} }
}
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht"); p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
p.closeInventory(); p.closeInventory();
}); });
@ -62,14 +56,14 @@ class GUI {
inv.open(); inv.open();
} }
static void delmembers(@NotNull Player p, @NotNull Schematic schem) { static void delmembers(Player p, Schematic schem){
@NotNull List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>(); List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
for (@NotNull SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())) { for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
SteamwarUser user = SteamwarUser.get(member.getMember()); SteamwarUser user = SteamwarUser.get(member.getMember());
members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member)); members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member));
} }
@NotNull SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> { SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
member.remove(); member.remove();
p.closeInventory(); p.closeInventory();
delmembers(p, schem); delmembers(p, schem);
@ -78,82 +72,15 @@ class GUI {
inv.open(); inv.open();
} }
static void list(@NotNull Player p) { private static void changeItem(Player p, Schematic schem){
list(p, SteamwarUser.get(p.getUniqueId()).getId()); List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
} for(Material material : Material.values()){
SWItem item = new SWItem(material, "§7" + material.name());
static void list(@NotNull Player p, int pid) { if(item.getItemMeta() != null && material.isItem())
@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));
}
@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)); materials.add(new SWListInv.SWListEntry<>(item, material));
} }
}
@NotNull SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> { SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
schem.setItem(material.name()); schem.setItem(material.name());
p.closeInventory(); p.closeInventory();
info(p, schem); info(p, schem);
@ -162,23 +89,21 @@ class GUI {
inv.open(); inv.open();
} }
private static void info(@NotNull Player p, @NotNull Schematic schem) { private static void info(Player p, Schematic schem){
@NotNull SWInventory inv = new SWInventory(p, 9, schem.getSchemName()); SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
if (schem.availible()) { if(schem.availible())
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> { inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
SchematicCommand.load(p, schem); SchematicCommand.load(p, schem);
p.closeInventory(); p.closeInventory();
}); });
}
if (schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()) { if(schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()){
if (schem.getSchemType().writeable()) { if(schem.getSchemType().writeable()){
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId()); List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
for (@NotNull CheckedSchematic checkedSchematic : checkedSchematics) { for(CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemName().equals(schem.getSchemName()) && if(checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
checkedSchematic.getSchemOwner() == schem.getSchemOwner()) { checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> { inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
});
break; break;
} }
} }
@ -208,13 +133,12 @@ class GUI {
p.closeInventory(); p.closeInventory();
delete(p, schem); delete(p, schem);
}); });
} else { }else{
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
});
SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner()); SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
@NotNull SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName()); SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
@NotNull SkullMeta headmeta = (SkullMeta) owner.getItemMeta(); SkullMeta headmeta = (SkullMeta)owner.getItemMeta();
headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID())); headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID()));
headmeta.setDisplayName("§7von §e" + owneruser.getUserName()); headmeta.setDisplayName("§7von §e" + owneruser.getUserName());
owner.setItemMeta(headmeta); owner.setItemMeta(headmeta);
@ -224,4 +148,63 @@ class GUI {
inv.setCallback(-999, click -> p.closeInventory()); inv.setCallback(-999, click -> p.closeInventory());
inv.open(); 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,11 +5,6 @@ import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.*; 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.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
@ -20,28 +15,29 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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 { public class SchematicCommand implements CommandExecutor {
private static final int FILES_PER_PAGE = 15; private static final int FILES_PER_PAGE = 15;
@SuppressWarnings("NullableProblems")
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, @NotNull String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) { if(!(sender instanceof Player))
return false; return false;
} Player player = (Player) sender;
@NotNull Player player = (Player) sender;
if (args.length == 0) { if(args.length == 0){
help(player); help(player);
return false; return false;
} }
switch (args[0].toLowerCase()) { switch(args[0].toLowerCase()){
case "gui": case "gui":
GUI.list(player); GUI.list(player);
break; break;
@ -81,65 +77,13 @@ public class SchematicCommand implements CommandExecutor {
return false; return false;
} }
static void load(@NotNull Player player, @NotNull Schematic schematic) { private void list(Player player, String[] args){
try { if(args.length <= 1){
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); sendPlayerSchematicList(0, SteamwarUser.get(player.getUniqueId()).getId(), player);
return; return;
} }
if ("public".equalsIgnoreCase(args[1])) { if("public".equalsIgnoreCase(args[1])){
GUI.list(player, 0); GUI.list(player, 0);
return; return;
} }
@ -151,24 +95,21 @@ public class SchematicCommand implements CommandExecutor {
} }
} }
private boolean invalidSchemName(@NotNull Player player, @NotNull String name) { private boolean invalidSchemName(Player player, String name){
if (CheckUtils.schemnameForbidden(name)) { if(CheckUtils.schemnameForbidden(name)){
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen"); player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true; return true;
} }
return false; return false;
} }
@Nullable private Schematic getSchem(Player player, String name){
private Schematic getSchem(@NotNull Player player, @NotNull String name) { if(invalidSchemName(player, name))
if (invalidSchemName(player, name)) {
return null; return null;
}
Schematic schematic = Schematic.getSchemFromDB(name, player.getUniqueId()); Schematic schematic = Schematic.getSchemFromDB(name, player.getUniqueId());
if (schematic == null) { if(schematic == null)
schematic = Schematic.getSchemFromDB(name, 0); //public schematic schematic = Schematic.getSchemFromDB(name, 0); //public schematic
}
if (schematic == null) { if (schematic == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht"); player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
@ -178,32 +119,40 @@ public class SchematicCommand implements CommandExecutor {
return schematic; return schematic;
} }
private void load(@NotNull Player player, @NotNull String[] args) { private void load(Player player, String[] args){
if (args.length < 2) { if(args.length < 2){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; return;
}
load(player, schematic); load(player, schematic);
} }
private void delete(@NotNull Player player, @NotNull String[] args) { static void load(Player player, Schematic schematic){
if (args.length < 2) { 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){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; 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"); player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur deine eigenen Schematics löschen");
return; return;
} }
@ -211,17 +160,16 @@ public class SchematicCommand implements CommandExecutor {
GUI.delete(player, schematic); GUI.delete(player, schematic);
} }
private void save(@NotNull Player player, @NotNull String[] args) { private void save(Player player, String[] args){
if (args.length < 2) { if(args.length < 2){
help(player); help(player);
return; return;
} }
if (invalidSchemName(player, args[1])) { if(invalidSchemName(player, args[1]))
return; return;
}
if (args[1].length() > 64) { if(args[1].length() > 64){
player.sendMessage(SchematicSystem.PREFIX + "§cDer Name der Schematic ist zu lang"); player.sendMessage(SchematicSystem.PREFIX + "§cDer Name der Schematic ist zu lang");
return; return;
} }
@ -249,37 +197,34 @@ public class SchematicCommand implements CommandExecutor {
return; return;
}catch (NoClipboardException e) { }catch (NoClipboardException e) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer"); player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer");
if (newSchem) { if(newSchem)
schematic.remove(); schematic.remove();
}
return; return;
} }
if (newSchem) { if (newSchem)
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert"); player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert");
} else { else
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben"); player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben");
} }
}
private void changetype(@NotNull Player player, @NotNull String[] args) { private void changetype(Player player, String[] args){
if (args.length < 2) { if(args.length < 2){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; return;
}
if (args.length < 3) { if(args.length < 3) {
GUI.changeType(player, schematic); GUI.changeType(player, schematic);
return; return;
} }
SchematicType type = SchematicType.fromDB(args[2]); 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"); player.sendMessage(SchematicSystem.PREFIX + "§cDiesen Schematictypen gibt es nicht");
return; return;
} }
@ -287,111 +232,149 @@ public class SchematicCommand implements CommandExecutor {
changetype(player, schematic, type); changetype(player, schematic, type);
} }
private void info(@NotNull Player player, @NotNull String[] args) { static void changetype(Player player, Schematic schematic, SchematicType type){
if (args.length < 2) { 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){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; return;
}
player.sendMessage("§eName: §7" + schematic.getSchemName()); player.sendMessage("§eName: §7" + schematic.getSchemName());
@NotNull TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name()); TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
if (SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId()) && schematic.availible()) { if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId()) && schematic.availible()){
type.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eTyp ändern"))); type.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eTyp ändern")));
type.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName())); type.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName()));
} }
player.spigot().sendMessage(type); player.spigot().sendMessage(type);
if (SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){
@NotNull TextComponent download = new TextComponent("§eDownload Schematic"); TextComponent download = new TextComponent("§eDownload Schematic");
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eGeneriere Downloadlink"))); download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eGeneriere Downloadlink")));
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + schematic.getSchemName())); download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + schematic.getSchemName()));
player.spigot().sendMessage(download); player.spigot().sendMessage(download);
} }
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
for (int i = checkedSchematics.size() - 1; i >= 0; i--) { for(int i = checkedSchematics.size() -1; i >= 0; i--) {
if (checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) && if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) { checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason()); player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason());
break; 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()); player.sendMessage("§eBesitzer: §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
} else { } else {
@NotNull List<String> schematicMembers = new ArrayList<>(); List<String> schematicMembers = new ArrayList<>();
for (@NotNull SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) { for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
schematicMembers.add(SteamwarUser.get(schematicMember.getMember()).getUserName()); schematicMembers.add(SteamwarUser.get(schematicMember.getMember()).getUserName());
} }
player.sendMessage("§eMitglieder: §7" + schematicMembers.toString()); player.sendMessage("§eMitglieder: §7" + schematicMembers.toString());
} }
if (schematic.availible()) { if(schematic.availible()){
@NotNull TextComponent loadSchematic = new TextComponent("LADEN"); TextComponent loadSchematic = new TextComponent("LADEN");
loadSchematic.setColor(ChatColor.DARK_GREEN); loadSchematic.setColor(ChatColor.DARK_GREEN);
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName())); loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
player.spigot().sendMessage(loadSchematic); player.spigot().sendMessage(loadSchematic);
} }
} }
private void download(@NotNull Player player, @NotNull String[] args) { private void download(Player player, String[] args){
if (args.length < 2) { if(args.length < 2){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; return;
}
download(player, schematic); download(player, schematic);
} }
private void search(@NotNull Player player, @NotNull String[] args) { private void search(Player player, String[] args) {
if (args.length < 2) { if(args.length < 2) {
help(player); help(player);
return; return;
} }
if (!GUI.listSearch(player, args[1])) { if(!GUI.listSearch(player, args[1]))
player.sendMessage("§cEs wurden keine Schematics gefunden!"); 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;
} }
private void addmember(@NotNull Player player, @NotNull String[] args) { player.sendMessage(DownloadSchematic.getLink(schematic));
if (args.length < 3) { }
private void addmember(Player player, String[] args){
if(args.length < 3){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; 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"); player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur auf deine eigene Schematic Mitglieder hinzufügen");
return; return;
} }
SteamwarUser warkingUser = SteamwarUser.get(args[2]); SteamwarUser warkingUser = SteamwarUser.get(args[2]);
if (warkingUser == null) { if(warkingUser == null){
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht"); player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
return; return;
} }
if (schematic.getSchemOwner() == warkingUser.getId()) { if(schematic.getSchemOwner() == warkingUser.getId()){
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!"); player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
return; 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"); player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
return; return;
} }
@ -399,29 +382,27 @@ public class SchematicCommand implements CommandExecutor {
new SchematicMember(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()); 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.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §e" + schematic.getSchemName());
@Nullable Player target = Bukkit.getPlayer(warkingUser.getUUID()); Player target = Bukkit.getPlayer(warkingUser.getUUID());
if (target != null) { if(target != null)
target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + schematic.getSchemName() + " §7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName()); target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + schematic.getSchemName() + " §7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
} }
}
private void delmember(@NotNull Player player, @NotNull String[] args) { private void delmember(Player player, String[] args){
if (args.length < 2) { if(args.length < 2){
help(player); help(player);
return; return;
} }
@Nullable Schematic schematic = getSchem(player, args[1]); Schematic schematic = getSchem(player, args[1]);
if (schematic == null) { if(schematic == null)
return; 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"); player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur von deinen eigenen Schematics Mitglieder entfernen");
return; return;
} }
if (args.length < 3) { if(args.length < 3){
GUI.delmembers(player, schematic); GUI.delmembers(player, schematic);
return; return;
} }
@ -445,12 +426,12 @@ public class SchematicCommand implements CommandExecutor {
schematicMember.remove(); schematicMember.remove();
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName()); player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName());
@Nullable Player target = Bukkit.getPlayer(warkingUser.getUUID()); Player target = Bukkit.getPlayer(warkingUser.getUUID());
if(target != null) 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()); 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(@NotNull Player player) { private void help(Player player) {
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:"); player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI"); player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an"); player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
@ -466,10 +447,10 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic"); player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
} }
private void sendPlayerSchematicList(int currentPage, int schemOwner, @NotNull Player player) { private void sendPlayerSchematicList(int currentPage, int schemOwner, Player player) {
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(schemOwner); List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(schemOwner);
if (schematicList.isEmpty()) { if(schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch keine Schematics"); player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch keine Schematics");
return; return;
} }
@ -495,11 +476,11 @@ public class SchematicCommand implements CommandExecutor {
Schematic schematic = schematicList.get(i); Schematic schematic = schematicList.get(i);
@NotNull String schematicPlayer = ""; String schematicPlayer = "";
if(schematic.getSchemOwner() != schemOwner) if(schematic.getSchemOwner() != schemOwner)
schematicPlayer = " §8von §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName(); schematicPlayer = " §8von §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName();
@NotNull TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer); TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
schematics.setBold(true); schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create())); schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
@ -510,7 +491,7 @@ public class SchematicCommand implements CommandExecutor {
if(pages <= 1) return; if(pages <= 1) return;
@NotNull TextComponent beforePage = new TextComponent("««"); TextComponent beforePage = new TextComponent("««");
if(currentPage > 0){ if(currentPage > 0){
beforePage.setColor(ChatColor.YELLOW); beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create())); beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
@ -518,7 +499,7 @@ public class SchematicCommand implements CommandExecutor {
}else }else
beforePage.setColor(ChatColor.RED); beforePage.setColor(ChatColor.RED);
@NotNull TextComponent nextPage = new TextComponent(" Seite »»"); TextComponent nextPage = new TextComponent(" Seite »»");
if(currentPage < pages-1){ if(currentPage < pages-1){
nextPage.setColor(ChatColor.YELLOW); nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create())); nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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