13
0
This reverts commit c6c9b4dda9.
Dieser Commit ist enthalten in:
Zeanon 2020-04-09 18:23:51 +02:00
Ursprung c6c9b4dda9
Commit 91a8c38ede
34 geänderte Dateien mit 626 neuen und 1004 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -3,37 +3,29 @@ package de.steamwar.schematicsystem;
import de.steamwar.core.Core;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class CheckSchemType implements ICheckSchemType {
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
@NotNull
private final String name;
private final int width;
private final int height;
private final int depth;
private final int maxDispenserItems;
@NotNull
private final List<String> forbiddenMaterials;
private final int maxTNT;
private final int maxSlime;
private final int maxTNTSlime;
private final int maxDispenser;
private final int maxBlocks;
@NotNull
private final LinkedList<String> checkList;
CheckSchemType(@NotNull ConfigurationSection section) {
CheckSchemType(ConfigurationSection section) {
name = section.getName();
width = section.getInt("width");
height = section.getInt("height");
@ -44,7 +36,6 @@ public class CheckSchemType implements ICheckSchemType {
maxTNTSlime = section.getInt("maxTNTSlime");
maxDispenser = section.getInt("maxDispenser");
maxDispenserItems = section.getInt("maxDispenserItems");
maxBlocks = section.getInt("maxBlocks"); //ADDED
forbiddenMaterials = section.getStringList("forbiddenMaterials");
checkList = new LinkedList<>(section.getStringList("checkList"));
@ -56,18 +47,16 @@ public class CheckSchemType implements ICheckSchemType {
return types.get(type);
}
@NotNull
public List<String> getCheckList() {
return checkList;
}
public SchematicType getAcceptedType() {
public SchematicType getAcceptedType(){
return SchematicType.fromDB(name);
}
@NotNull
public AutoCheckResult autoCheck(@NotNull Schematic schematic) {
switch (Core.getVersion()) {
public AutoCheckResult autoCheck(Schematic schematic) {
switch(Core.getVersion()){
case 15:
return CheckSchemType_15.autoCheck(schematic, this);
case 14:
@ -83,7 +72,6 @@ public class CheckSchemType implements ICheckSchemType {
}
}
@NotNull
@Override
public String getName() {
return name;
@ -114,11 +102,6 @@ public class CheckSchemType implements ICheckSchemType {
return maxDispenser;
}
@Override
public int getMaxBlocks() {
return maxBlocks;
}
@Override
public int getMaxTNT() {
return maxTNT;
@ -134,7 +117,6 @@ public class CheckSchemType implements ICheckSchemType {
return maxSlime;
}
@NotNull
@Override
public List<String> getForbidden() {
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.PlayerJoinListener;
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
import java.io.File;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
public class SchematicSystem extends JavaPlugin {
@ -30,26 +27,24 @@ public class SchematicSystem extends JavaPlugin {
Bukkit.shutdown();
}
@NotNull FileConfiguration config = getConfig();
@Nullable ConfigurationSection types = config.getConfigurationSection("Schematics");
for (@NotNull String sectionName : Objects.requireNonNull(types).getKeys(false)) {
new CheckSchemType(Objects.requireNonNull(types.getConfigurationSection(sectionName)));
}
FileConfiguration config = getConfig();
ConfigurationSection types = config.getConfigurationSection("Schematics");
for(String sectionName : types.getKeys(false))
new CheckSchemType(types.getConfigurationSection(sectionName));
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
Objects.requireNonNull(getCommand("schem")).setExecutor(new SchematicCommand());
Objects.requireNonNull(getCommand("check")).setExecutor(new CheckCommand());
getCommand("schem").setExecutor(new SchematicCommand());
getCommand("check").setExecutor(new CheckCommand());
@NotNull PluginManager pm = Bukkit.getPluginManager();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), this);
pm.registerEvents(new PlayerQuitListener(), this);
pm.registerEvents(new PlayerCommandPreProcessListener(), this);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if (CheckUtils.getCSchematicsSize() > 0) {
if(CheckUtils.getCSchematicsSize() > 0)
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
}
}, 0, 6000);
}
}

Datei anzeigen

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

Datei anzeigen

@ -7,33 +7,29 @@ import de.steamwar.sql.CheckedSchematic;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import java.sql.Timestamp;
import java.util.*;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Timestamp;
import java.util.*;
public class CheckSession {
private static final Set<CheckSession> checkSessions = new HashSet<>();
private static Set<CheckSession> checkSessions = new HashSet<>();
private final UUID uuid; //player
@NotNull
private final Schematic schematic;
@NotNull
private final ListIterator<String> checkList;
private UUID uuid; //player
private Schematic schematic;
private ListIterator<String> checkList;
private Timestamp startTime;
private Timestamp stopTime;
private EditSession editSession;
public CheckSession(UUID uuid, @NotNull Schematic schematic) {
public CheckSession(UUID uuid, Schematic schematic) {
this.uuid = uuid;
this.schematic = schematic;
checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator();
@ -46,27 +42,23 @@ public class CheckSession {
return !checkSessions.isEmpty();
}
@Nullable
public static CheckSession getCheckSession() {
if (checkSessions.isEmpty()) {
if(checkSessions.isEmpty())
return null;
}
return checkSessions.iterator().next();
}
@Nullable
public static CheckSession getCheckSession(@NotNull Player player) {
for (@NotNull CheckSession session : checkSessions) {
if (session.uuid.equals(player.getUniqueId())) {
public static CheckSession getCheckSession(Player player) {
for(CheckSession session : checkSessions){
if(session.uuid.equals(player.getUniqueId()))
return session;
}
}
return null;
}
public void sendNextCheck() {
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!");
if(!checkList.hasNext()){
Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType());
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben");
@ -76,31 +68,31 @@ public class CheckSession {
setStopTime();
setStartTime();
Objects.requireNonNull(Bukkit.getPlayer(uuid)).sendMessage(checkList.next());
Bukkit.getPlayer(uuid).sendMessage(checkList.next());
if(checkList.hasNext()){
@NotNull TextComponent next = new TextComponent("next ");
TextComponent next = new TextComponent("next ");
next.setColor(ChatColor.GREEN);
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.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
next.addExtra(decline);
Objects.requireNonNull(Bukkit.getPlayer(uuid)).spigot().sendMessage(next);
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
}else{
@NotNull TextComponent accept = new TextComponent("accept ");
TextComponent accept = new TextComponent("accept ");
accept.setColor(ChatColor.GREEN);
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.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
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);
}
@NotNull
public Schematic getSchematic() {
return schematic;
}
private void setStartTime() {
@NotNull Date date = new Date();
Date date = new Date();
this.startTime = new Timestamp(date.getTime());
}
private void setStopTime() {
@NotNull Date date = new Date();
Date date = new Date();
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.SteamwarUser;
import de.steamwar.sql.UserGroup;
import java.util.LinkedList;
import java.util.List;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.List;
public class CheckUtils {
private CheckUtils(){}
public static boolean schemnameForbidden(@NotNull String schematicName) {
public static boolean schemnameForbidden(String schematicName) {
return schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
@ -30,7 +29,7 @@ public class CheckUtils {
schematicName.contains("\"");
}
public static boolean allowedToCheck(@NotNull Player player) {
public static boolean allowedToCheck(Player player) {
SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId());
return warkingUser.getUserGroup() == UserGroup.Supporter ||
warkingUser.getUserGroup() == UserGroup.Developer ||
@ -38,60 +37,53 @@ public class CheckUtils {
warkingUser.getUserGroup() == UserGroup.Admin;
}
public static void sendTeamMembersCSchematics(@NotNull String message) {
for (@NotNull Player player : Bukkit.getServer().getOnlinePlayers()) {
if (allowedToCheck(player)) {
public static void sendTeamMembersCSchematics(String message) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(allowedToCheck(player))
player.sendMessage(message);
}
}
}
public static int getCSchematicsSize() {
int size = 0;
for (@NotNull SchematicType type : SchematicType.values()) {
if (type.check()) {
for(SchematicType type : SchematicType.values()){
if(type.check())
size += Schematic.getAllSchemsOfType(type).size();
}
}
return size;
}
@NotNull
public static String sendTeamMembersCSchematicsInfo() {
int size = getCSchematicsSize();
@NotNull String message = "";
if (size == 0) {
String message = "";
if(size == 0)
message = SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!";
}
if (size == 1) {
if(size == 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6eine §aungeprüfte Schematic!";
}
if (size > 1) {
if(size > 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6" + size + " §aungeprüfte Schematics!";
}
return message;
}
public static void sendTeammemberSchematicList(@NotNull Player player) {
@NotNull List<Schematic> schematicList = new LinkedList<>();
public static void sendTeammemberSchematicList(Player player) {
List<Schematic> schematicList = new LinkedList<>();
for (@NotNull SchematicType type : SchematicType.values()) {
if (type.check()) {
for(SchematicType type : SchematicType.values()) {
if (type.check())
schematicList.addAll(Schematic.getAllSchemsOfType(type));
}
}
if (schematicList.isEmpty()) {
if(schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
return;
}
player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
for (@NotNull Schematic schematic : schematicList) {
@NotNull TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
for(Schematic schematic : schematicList) {
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + SteamwarUser.get(schematic.getSchemOwner()).getUserName()));

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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