Solved #49 #54
@ -27,35 +27,53 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.10</version>
|
<version>1.10</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>WorldEdit</artifactId>
|
<artifactId>WorldEdit</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FAWE</artifactId>
|
<artifactId>FAWE</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_9</artifactId>
|
<artifactId>SchematicSystem_9</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_API</artifactId>
|
<artifactId>SchematicSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -1,8 +1,14 @@
|
|||||||
package de.steamwar.schematicsystem;
|
package de.steamwar.schematicsystem;
|
||||||
|
|
||||||
class CheckSchemType_10 {
|
import org.jetbrains.annotations.NotNull;
|
||||||
private CheckSchemType_10(){}
|
|
||||||
|
|
||||||
|
|
||||||
|
class CheckSchemType_10 {
|
||||||
|
|
||||||
|
private CheckSchemType_10() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
static AutoCheckResult autoCheck() {
|
static AutoCheckResult autoCheck() {
|
||||||
return new AutoCheckResult();
|
return new AutoCheckResult();
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,18 @@ 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 org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
class WorldEdit_10 {
|
class WorldEdit_10 {
|
||||||
private WorldEdit_10(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
|
private WorldEdit_10() {
|
||||||
return WorldEdit_8.pasteSchematic(player, schematic);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
|
||||||
|
return WorldEdit_8.pasteSchematic(player, schematic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,35 +27,53 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12</version>
|
<version>1.12</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>WorldEdit</artifactId>
|
<artifactId>WorldEdit</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FAWE</artifactId>
|
<artifactId>FAWE</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_10</artifactId>
|
<artifactId>SchematicSystem_10</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_API</artifactId>
|
<artifactId>SchematicSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -7,17 +7,20 @@ 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();
|
||||||
@ -25,11 +28,14 @@ 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 {
|
||||||
Set<Integer> inventory = new HashSet<>();
|
@NotNull 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());
|
||||||
@ -58,21 +64,23 @@ class CheckSchemType_12 {
|
|||||||
inventory.add(Material.PURPLE_SHULKER_BOX.getId());
|
inventory.add(Material.PURPLE_SHULKER_BOX.getId());
|
||||||
INVENTORY = inventory;
|
INVENTORY = inventory;
|
||||||
|
|
||||||
Set<Material> flowers = new HashSet<>();
|
@NotNull 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() {
|
||||||
|
}
|
||||||
|
|
||||||
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
|
@NotNull
|
||||||
AutoCheckResult result = new AutoCheckResult(type);
|
static AutoCheckResult autoCheck(@NotNull Schematic schematic, ICheckSchemType type) {
|
||||||
|
@NotNull AutoCheckResult result = new AutoCheckResult(type);
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
try {
|
try {
|
||||||
clipboard = schematic.load();
|
clipboard = schematic.load();
|
||||||
} catch (IOException | NoClipboardException e) {
|
} catch (@NotNull 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;
|
||||||
@ -89,24 +97,32 @@ 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(INVENTORY.contains(blockId)){
|
if (blockId != AIR) {
|
||||||
|
blocks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (INVENTORY.contains(blockId)) {
|
||||||
checkInventory(result, block, blockId, type);
|
checkInventory(result, block, blockId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,37 +133,41 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkInventory(AutoCheckResult result, BaseBlock block, int blockId, ICheckSchemType type){
|
@SuppressWarnings("unused")
|
||||||
CompoundTag nbt = block.getNbtData();
|
private static void checkInventory(@NotNull AutoCheckResult result, @NotNull BaseBlock block, int blockId, ICheckSchemType type) {
|
||||||
if(nbt == null){
|
@Nullable CompoundTag nbt = block.getNbtData();
|
||||||
|
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(CompoundTag item : items){
|
for (@NotNull 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"))
|
||||||
@ -163,4 +183,4 @@ class CheckSchemType_12 {
|
|||||||
|
|
||||||
result.dispenserItems(counter);
|
result.dispenserItems(counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,14 +3,18 @@ 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 org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
class WorldEdit_12 {
|
class WorldEdit_12 {
|
||||||
private WorldEdit_12(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
|
private WorldEdit_12() {
|
||||||
return WorldEdit_8.pasteSchematic(player, schematic);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
|
||||||
|
return WorldEdit_8.pasteSchematic(player, schematic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,22 +27,40 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_API</artifactId>
|
<artifactId>SchematicSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.14</version>
|
<version>1.14</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>WorldEdit</artifactId>
|
<artifactId>WorldEdit</artifactId>
|
||||||
<version>1.15</version>
|
<version>1.15</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -1,8 +1,14 @@
|
|||||||
package de.steamwar.schematicsystem;
|
package de.steamwar.schematicsystem;
|
||||||
|
|
||||||
class CheckSchemType_14 {
|
import org.jetbrains.annotations.NotNull;
|
||||||
private CheckSchemType_14(){}
|
|
||||||
|
|
||||||
|
|
||||||
|
class CheckSchemType_14 {
|
||||||
|
|
||||||
|
private CheckSchemType_14() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
static AutoCheckResult autoCheck() {
|
static AutoCheckResult autoCheck() {
|
||||||
return new AutoCheckResult();
|
return new AutoCheckResult();
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,25 @@ 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(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
private WorldEdit_14() {
|
||||||
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();
|
||||||
|
@ -49,5 +49,23 @@
|
|||||||
<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>
|
@ -7,16 +7,19 @@ 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,
|
||||||
@ -65,14 +68,16 @@ 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() {
|
||||||
|
}
|
||||||
|
|
||||||
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
|
@NotNull
|
||||||
AutoCheckResult result = new AutoCheckResult(type);
|
static AutoCheckResult autoCheck(@NotNull Schematic schematic, ICheckSchemType type) {
|
||||||
|
@NotNull AutoCheckResult result = new AutoCheckResult(type);
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
try {
|
try {
|
||||||
clipboard = schematic.load();
|
clipboard = schematic.load();
|
||||||
} catch (IOException | NoClipboardException e) {
|
} catch (@NotNull 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;
|
||||||
@ -89,71 +94,85 @@ 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));
|
||||||
final Material blockMaterial = Material.matchMaterial(block.getBlockType().getId());
|
@Nullable 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.DISPENSER)
|
if (blockMaterial == Material.AIR) {
|
||||||
|
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(AutoCheckResult result, BaseBlock block, Material blockMaterial){
|
private static void checkInventory(@NotNull AutoCheckResult result, @NotNull BaseBlock block, @NotNull Material blockMaterial) {
|
||||||
CompoundTag nbt = block.getNbtData();
|
@Nullable 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(CompoundTag item : items){
|
for (@NotNull CompoundTag item : items) {
|
||||||
if(!item.containsKey("id")){
|
if (!item.containsKey("id")) {
|
||||||
result.defunctNbt(blockMaterial.name());
|
result.defunctNbt(blockMaterial.name());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material itemType = Material.matchMaterial(item.getString("id"));
|
@Nullable 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);
|
||||||
|
@ -3,14 +3,18 @@ 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 org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
class WorldEdit_15 {
|
class WorldEdit_15 {
|
||||||
private WorldEdit_15(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
private WorldEdit_15() {
|
||||||
return WorldEdit_14.pasteSchematic(player, schematic);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws IOException, NoClipboardException {
|
||||||
|
return WorldEdit_14.pasteSchematic(player, schematic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,23 +27,41 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.8</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>WorldEdit</artifactId>
|
<artifactId>WorldEdit</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_API</artifactId>
|
<artifactId>SchematicSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -1,8 +1,14 @@
|
|||||||
package de.steamwar.schematicsystem;
|
package de.steamwar.schematicsystem;
|
||||||
|
|
||||||
class CheckSchemType_8 {
|
import org.jetbrains.annotations.NotNull;
|
||||||
private CheckSchemType_8(){}
|
|
||||||
|
|
||||||
|
|
||||||
|
class CheckSchemType_8 {
|
||||||
|
|
||||||
|
private CheckSchemType_8() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
static AutoCheckResult autoCheck() {
|
static AutoCheckResult autoCheck() {
|
||||||
return new AutoCheckResult();
|
return new AutoCheckResult();
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,25 @@ 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(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
|
private WorldEdit_8() {
|
||||||
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();
|
||||||
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
|
@NotNull Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
|
||||||
Clipboard clipboard = schematic.load();
|
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();
|
||||||
|
@ -27,35 +27,53 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.9</version>
|
<version>1.9</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>WorldEdit</artifactId>
|
<artifactId>WorldEdit</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FAWE</artifactId>
|
<artifactId>FAWE</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_8</artifactId>
|
<artifactId>SchematicSystem_8</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>SchematicSystem_API</artifactId>
|
<artifactId>SchematicSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -1,8 +1,14 @@
|
|||||||
package de.steamwar.schematicsystem;
|
package de.steamwar.schematicsystem;
|
||||||
|
|
||||||
class CheckSchemType_9 {
|
import org.jetbrains.annotations.NotNull;
|
||||||
private CheckSchemType_9(){}
|
|
||||||
|
|
||||||
|
|
||||||
|
class CheckSchemType_9 {
|
||||||
|
|
||||||
|
private CheckSchemType_9() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
static AutoCheckResult autoCheck() {
|
static AutoCheckResult autoCheck() {
|
||||||
return new AutoCheckResult();
|
return new AutoCheckResult();
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,18 @@ 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 org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
class WorldEdit_9 {
|
class WorldEdit_9 {
|
||||||
private WorldEdit_9(){}
|
|
||||||
|
|
||||||
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
|
private WorldEdit_9() {
|
||||||
return WorldEdit_8.pasteSchematic(player, schematic);
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
static EditSession pasteSchematic(@NotNull Player player, @NotNull Schematic schematic) throws NoClipboardException, IOException {
|
||||||
|
return WorldEdit_8.pasteSchematic(player, schematic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,29 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12</version>
|
<version>1.12</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
@ -1,11 +1,14 @@
|
|||||||
package de.steamwar.schematicsystem;
|
package de.steamwar.schematicsystem;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class AutoCheckResult {
|
public class AutoCheckResult {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private final ICheckSchemType type;
|
private final ICheckSchemType type;
|
||||||
|
|
||||||
private final boolean noChecksInThisVersion;
|
private final boolean noChecksInThisVersion;
|
||||||
@ -19,133 +22,168 @@ 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 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> defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname
|
|
||||||
private int records = 0; // Gefundene Schallplatten
|
private int records = 0; // Gefundene Schallplatten
|
||||||
private Map<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp
|
private int blocks = 0;
|
||||||
private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> errors(){
|
@NotNull
|
||||||
List<String> errors = new LinkedList<>();
|
public Collection<String> errors() {
|
||||||
|
@NotNull List<String> errors = new LinkedList<>();
|
||||||
|
|
||||||
if(noChecksInThisVersion){
|
if (noChecksInThisVersion) {
|
||||||
errors.add("In der 1." + Core.getVersion() + " können keine Schematics eingesendet werden");
|
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(Map.Entry<String, Integer> block : forbiddenMaterials.entrySet())
|
for (@NotNull Map.Entry<String, Integer> block : forbiddenMaterials.entrySet()) {
|
||||||
errors.add("Der Block " + block.getKey() + " ist verboten (" + block.getValue() + " verbaut)");
|
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(Map.Entry<String, Integer> item : block.getValue().entrySet())
|
for (@NotNull Map.Entry<String, Map<String, Integer>> block : forbiddenItems.entrySet()) {
|
||||||
|
for (@NotNull Map.Entry<String, Integer> item : block.getValue().entrySet()) {
|
||||||
errors.add("In " + block.getKey() + "s wurde das verbotene Item " + item.getKey() + " " + item.getValue() + " mal gefunden");
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> warnings(){
|
@NotNull
|
||||||
List<String> warnings = new LinkedList<>();
|
public Collection<String> warnings() {
|
||||||
|
@NotNull List<String> warnings = new LinkedList<>();
|
||||||
|
|
||||||
for(Map.Entry<String, Integer> nbtBlock : defunctNbt.entrySet()){
|
for (@NotNull 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWrongVersionException(){
|
@SuppressWarnings("unused")
|
||||||
|
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 checkMaterial(String name){
|
void setBlocks(int blocks) {
|
||||||
assert type != null;
|
this.blocks = blocks;
|
||||||
if(type.getForbidden().contains(name))
|
|
||||||
forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v+1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void defunctNbt(String name){
|
void checkMaterial(String name) {
|
||||||
defunctNbt.compute(name, (k, v) -> v == null ? 1 : v+1);
|
assert type != null;
|
||||||
|
if (type.getForbidden().contains(name)) {
|
||||||
|
forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void foundRecord(){
|
|
||||||
|
void defunctNbt(String name) {
|
||||||
|
defunctNbt.compute(name, (k, v) -> v == null ? 1 : v + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void foundRecord() {
|
||||||
records++;
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ 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(
|
||||||
|
@ -3,15 +3,26 @@ 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();
|
||||||
|
@ -98,5 +98,23 @@
|
|||||||
<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>
|
@ -3,29 +3,37 @@ 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(ConfigurationSection section) {
|
CheckSchemType(@NotNull ConfigurationSection section) {
|
||||||
name = section.getName();
|
name = section.getName();
|
||||||
width = section.getInt("width");
|
width = section.getInt("width");
|
||||||
height = section.getInt("height");
|
height = section.getInt("height");
|
||||||
@ -36,6 +44,7 @@ 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"));
|
||||||
@ -47,16 +56,18 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoCheckResult autoCheck(Schematic schematic) {
|
@NotNull
|
||||||
switch(Core.getVersion()){
|
public AutoCheckResult autoCheck(@NotNull Schematic schematic) {
|
||||||
|
switch (Core.getVersion()) {
|
||||||
case 15:
|
case 15:
|
||||||
return CheckSchemType_15.autoCheck(schematic, this);
|
return CheckSchemType_15.autoCheck(schematic, this);
|
||||||
case 14:
|
case 14:
|
||||||
@ -72,6 +83,7 @@ public class CheckSchemType implements ICheckSchemType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -102,6 +114,11 @@ 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;
|
||||||
@ -117,6 +134,7 @@ public class CheckSchemType implements ICheckSchemType {
|
|||||||
return maxSlime;
|
return maxSlime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<String> getForbidden() {
|
public List<String> getForbidden() {
|
||||||
return forbiddenMaterials;
|
return forbiddenMaterials;
|
||||||
|
@ -7,13 +7,16 @@ 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 {
|
||||||
|
|
||||||
@ -27,24 +30,26 @@ public class SchematicSystem extends JavaPlugin {
|
|||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration config = getConfig();
|
@NotNull FileConfiguration config = getConfig();
|
||||||
ConfigurationSection types = config.getConfigurationSection("Schematics");
|
@Nullable ConfigurationSection types = config.getConfigurationSection("Schematics");
|
||||||
for(String sectionName : types.getKeys(false))
|
for (@NotNull String sectionName : Objects.requireNonNull(types).getKeys(false)) {
|
||||||
new CheckSchemType(types.getConfigurationSection(sectionName));
|
new CheckSchemType(Objects.requireNonNull(types.getConfigurationSection(sectionName)));
|
||||||
|
}
|
||||||
|
|
||||||
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
|
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
|
||||||
|
|
||||||
getCommand("schem").setExecutor(new SchematicCommand());
|
Objects.requireNonNull(getCommand("schem")).setExecutor(new SchematicCommand());
|
||||||
getCommand("check").setExecutor(new CheckCommand());
|
Objects.requireNonNull(getCommand("check")).setExecutor(new CheckCommand());
|
||||||
|
|
||||||
PluginManager pm = Bukkit.getPluginManager();
|
@NotNull 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,19 @@ 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 org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
public class WorldEdit {
|
public class WorldEdit {
|
||||||
private WorldEdit(){}
|
|
||||||
|
|
||||||
public static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
private WorldEdit() {
|
||||||
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:
|
||||||
|
@ -7,29 +7,33 @@ 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 Set<CheckSession> checkSessions = new HashSet<>();
|
private static final Set<CheckSession> checkSessions = new HashSet<>();
|
||||||
|
|
||||||
private UUID uuid; //player
|
private final UUID uuid; //player
|
||||||
private Schematic schematic;
|
@NotNull
|
||||||
private ListIterator<String> checkList;
|
private final Schematic schematic;
|
||||||
|
@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, Schematic schematic) {
|
public CheckSession(UUID uuid, @NotNull 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();
|
||||||
@ -42,23 +46,27 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckSession getCheckSession(Player player) {
|
@Nullable
|
||||||
for(CheckSession session : checkSessions){
|
public static CheckSession getCheckSession(@NotNull Player player) {
|
||||||
if(session.uuid.equals(player.getUniqueId()))
|
for (@NotNull CheckSession session : checkSessions) {
|
||||||
|
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()) {
|
||||||
Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
|
Objects.requireNonNull(Bukkit.getPlayer(uuid)).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
|
||||||
schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType());
|
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");
|
||||||
|
|
||||||
@ -68,31 +76,31 @@ public class CheckSession {
|
|||||||
|
|
||||||
setStopTime();
|
setStopTime();
|
||||||
setStartTime();
|
setStartTime();
|
||||||
Bukkit.getPlayer(uuid).sendMessage(checkList.next());
|
Objects.requireNonNull(Bukkit.getPlayer(uuid)).sendMessage(checkList.next());
|
||||||
|
|
||||||
if(checkList.hasNext()){
|
if(checkList.hasNext()){
|
||||||
|
|
||||||
TextComponent next = new TextComponent("next ");
|
@NotNull 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"));
|
||||||
|
|
||||||
TextComponent decline = new TextComponent("decline");
|
@NotNull 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);
|
||||||
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
|
Objects.requireNonNull(Bukkit.getPlayer(uuid)).spigot().sendMessage(next);
|
||||||
}else{
|
}else{
|
||||||
TextComponent accept = new TextComponent("accept ");
|
@NotNull 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"));
|
||||||
|
|
||||||
TextComponent decline = new TextComponent("decline");
|
@NotNull 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);
|
||||||
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
|
Objects.requireNonNull(Bukkit.getPlayer(uuid)).spigot().sendMessage(accept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,17 +116,18 @@ 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() {
|
||||||
Date date = new Date();
|
@NotNull Date date = new Date();
|
||||||
this.startTime = new Timestamp(date.getTime());
|
this.startTime = new Timestamp(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStopTime() {
|
private void setStopTime() {
|
||||||
Date date = new Date();
|
@NotNull Date date = new Date();
|
||||||
this.stopTime = new Timestamp(date.getTime());
|
this.stopTime = new Timestamp(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,85 +5,93 @@ 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(String schematicName) {
|
public static boolean schemnameForbidden(@NotNull String schematicName) {
|
||||||
return schematicName.contains("/") ||
|
return schematicName.contains("/") ||
|
||||||
schematicName.contains("\\") ||
|
schematicName.contains("\\") ||
|
||||||
schematicName.contains("<") ||
|
schematicName.contains("<") ||
|
||||||
schematicName.contains(">") ||
|
schematicName.contains(">") ||
|
||||||
schematicName.contains("^") ||
|
schematicName.contains("^") ||
|
||||||
schematicName.contains("°") ||
|
schematicName.contains("°") ||
|
||||||
schematicName.contains("'") ||
|
schematicName.contains("'") ||
|
||||||
schematicName.contains("\"");
|
schematicName.contains("\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean allowedToCheck(Player player) {
|
public static boolean allowedToCheck(@NotNull Player player) {
|
||||||
SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId());
|
||||||
return warkingUser.getUserGroup() == UserGroup.Supporter ||
|
return warkingUser.getUserGroup() == UserGroup.Supporter ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Developer ||
|
warkingUser.getUserGroup() == UserGroup.Developer ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Moderator ||
|
warkingUser.getUserGroup() == UserGroup.Moderator ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Admin;
|
warkingUser.getUserGroup() == UserGroup.Admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTeamMembersCSchematics(String message) {
|
public static void sendTeamMembersCSchematics(@NotNull String message) {
|
||||||
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (@NotNull 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(SchematicType type : SchematicType.values()){
|
for (@NotNull 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();
|
||||||
|
|
||||||
String message = "";
|
@NotNull 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(Player player) {
|
public static void sendTeammemberSchematicList(@NotNull Player player) {
|
||||||
List<Schematic> schematicList = new LinkedList<>();
|
@NotNull List<Schematic> schematicList = new LinkedList<>();
|
||||||
|
|
||||||
for(SchematicType type : SchematicType.values()) {
|
for (@NotNull 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(Schematic schematic : schematicList) {
|
for (@NotNull Schematic schematic : schematicList) {
|
||||||
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
|
@NotNull 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()));
|
||||||
|
@ -7,41 +7,46 @@ 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, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, @NotNull String[] args) {
|
||||||
if(!(sender instanceof Player))
|
if (!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
@NotNull 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckSession checkSession;
|
@Nullable 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);
|
||||||
@ -52,7 +57,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
case "schematic":
|
case "schematic":
|
||||||
SteamwarUser checker = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser checker = SteamwarUser.get(player.getUniqueId());
|
||||||
String worldName = player.getWorld().getName();
|
@NotNull String worldName = player.getWorld().getName();
|
||||||
if(!worldName.equals(player.getUniqueId().toString()) && !worldName.equals(Integer.toString(checker.getId()))) {
|
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;
|
||||||
@ -71,23 +76,23 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Player> worldPlayers = player.getWorld().getPlayers();
|
@NotNull List<Player> worldPlayers = player.getWorld().getPlayers();
|
||||||
for(Player players : worldPlayers) {
|
for (@NotNull 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;
|
||||||
}
|
}
|
||||||
@ -98,7 +103,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 (IOException | NoClipboardException ex) {
|
} catch (@NotNull 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;
|
||||||
@ -116,7 +121,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
if(checkSession == null)
|
if(checkSession == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder();
|
@NotNull 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!");
|
||||||
@ -130,8 +135,8 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void help(Player player) {
|
private void help(@NotNull 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");
|
||||||
@ -140,10 +145,12 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckSession session(Player player){
|
@Nullable
|
||||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
private CheckSession session(@NotNull Player player) {
|
||||||
if(checkSession == null)
|
@Nullable CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,31 +5,36 @@ 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(){}
|
|
||||||
|
|
||||||
static void changeType(Player p, Schematic schem){
|
private GUI() {
|
||||||
List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
|
}
|
||||||
for(SchematicType type : SchematicType.values()){
|
|
||||||
if(!type.isAssignable())
|
static void changeType(@NotNull Player p, @NotNull Schematic schem) {
|
||||||
|
@NotNull List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
|
||||||
|
for (@NotNull SchematicType type : SchematicType.values()) {
|
||||||
|
if (!type.isAssignable()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
|
@NotNull 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
|
@NotNull SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
|
||||||
SchematicCommand.changetype(p, schem, schematicType);
|
SchematicCommand.changetype(p, schem, schematicType);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
});
|
});
|
||||||
@ -37,16 +42,17 @@ class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete(Player p, Schematic schem){
|
static void delete(@NotNull Player p, @NotNull Schematic schem) {
|
||||||
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
|
@NotNull 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(CheckedSchematic checkedSchematic : checkedSchematics) {
|
for (@NotNull 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();
|
||||||
@ -56,14 +62,14 @@ class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delmembers(Player p, Schematic schem){
|
static void delmembers(@NotNull Player p, @NotNull Schematic schem) {
|
||||||
List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
|
@NotNull List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
|
||||||
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
|
for (@NotNull 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
|
@NotNull SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
|
||||||
member.remove();
|
member.remove();
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
delmembers(p, schem);
|
delmembers(p, schem);
|
||||||
@ -72,15 +78,82 @@ class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void changeItem(Player p, Schematic schem){
|
static void list(@NotNull Player p) {
|
||||||
List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
|
list(p, SteamwarUser.get(p.getUniqueId()).getId());
|
||||||
for(Material material : Material.values()){
|
}
|
||||||
SWItem item = new SWItem(material, "§7" + material.name());
|
|
||||||
if(item.getItemMeta() != null && material.isItem())
|
static void list(@NotNull Player p, int pid) {
|
||||||
materials.add(new SWListInv.SWListEntry<>(item, material));
|
@NotNull List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
|
||||||
|
List<Schematic> schems = Schematic.getSchemsAccessibleByUser(pid);
|
||||||
|
|
||||||
|
//noinspection DuplicatedCode
|
||||||
|
for (@NotNull Schematic schem : schems) {
|
||||||
|
Material m;
|
||||||
|
if (schem.getItem().isEmpty()) {
|
||||||
|
m = SWItem.getMaterial("CAULDRON_ITEM");
|
||||||
|
} else {
|
||||||
|
m = SWItem.getMaterial(schem.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {
|
||||||
|
});
|
||||||
|
schemList.add(new SWListInv.SWListEntry<>(item, schem));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
|
@NotNull SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", schemList, (clickType, schem) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
info(p, schem);
|
||||||
|
});
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean listSearch(@NotNull Player player, @NotNull String search) {
|
||||||
|
@NotNull List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
|
||||||
|
@NotNull List<Schematic> filteredSchems = new ArrayList<>();
|
||||||
|
|
||||||
|
for (@NotNull Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) {
|
||||||
|
if (currentSchem.getSchemName().toLowerCase().contains(search.toLowerCase())) {
|
||||||
|
filteredSchems.add(currentSchem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filteredSchems.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (@NotNull Schematic currentSchem : filteredSchems) {
|
||||||
|
Material m;
|
||||||
|
if (currentSchem.getItem().isEmpty()) {
|
||||||
|
m = SWItem.getMaterial("CAULDRON_ITEM");
|
||||||
|
} else {
|
||||||
|
m = SWItem.getMaterial(currentSchem.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {
|
||||||
|
});
|
||||||
|
schemList.add(new SWListInv.SWListEntry<>(item, currentSchem));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull SWListInv<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", schemList, (clickType, schem) -> {
|
||||||
|
player.closeInventory();
|
||||||
|
info(player, schem);
|
||||||
|
});
|
||||||
|
inv.setCallback(-999, (ClickType click) -> player.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void changeItem(@NotNull Player p, @NotNull Schematic schem) {
|
||||||
|
@NotNull List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
|
||||||
|
for (@NotNull Material material : Material.values()) {
|
||||||
|
@NotNull SWItem item = new SWItem(material, "§7" + material.name());
|
||||||
|
if (item.getItemMeta() != null && material.isItem()) {
|
||||||
|
materials.add(new SWListInv.SWListEntry<>(item, material));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
|
||||||
schem.setItem(material.name());
|
schem.setItem(material.name());
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
info(p, schem);
|
info(p, schem);
|
||||||
@ -89,21 +162,23 @@ class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void info(Player p, Schematic schem){
|
private static void info(@NotNull Player p, @NotNull Schematic schem) {
|
||||||
SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
|
@NotNull 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(CheckedSchematic checkedSchematic : checkedSchematics) {
|
for (@NotNull 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,12 +208,13 @@ 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());
|
||||||
SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
|
@NotNull SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
|
||||||
SkullMeta headmeta = (SkullMeta)owner.getItemMeta();
|
@NotNull 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);
|
||||||
@ -148,63 +224,4 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,11 @@ 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;
|
||||||
@ -15,29 +20,28 @@ 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, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, @NotNull 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;
|
||||||
@ -77,13 +81,65 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(Player player, String[] args){
|
static void load(@NotNull Player player, @NotNull Schematic schematic) {
|
||||||
if(args.length <= 1){
|
try {
|
||||||
|
schematic.loadToPlayer(player);
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
|
||||||
|
} catch (@NotNull IOException | NoClipboardException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", e);
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Laden der Schematic. Bitte wende dich an einen Developer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void changetype(@NotNull Player player, @NotNull Schematic schematic, @NotNull SchematicType type) {
|
||||||
|
if (schematic.getSchemType() == type) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic hat bereits diesen Typen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.writeable()) {
|
||||||
|
schematic.setSchemType(type);
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
|
||||||
|
} else if (type.fightType()) {
|
||||||
|
if (schematic.getSchemType().check()) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast diese Schematic bereits eingesendet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoCheckResult result = CheckSchemType.get(type).autoCheck(schematic);
|
||||||
|
@NotNull Collection<String> errors = result.errors();
|
||||||
|
for (String warning : result.warnings()) {
|
||||||
|
player.sendMessage(" §e" + warning);
|
||||||
|
}
|
||||||
|
for (String error : errors) {
|
||||||
|
player.sendMessage(" §c" + error);
|
||||||
|
}
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic ist nicht regelkonform");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
schematic.setSchemType(type.checkType());
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void download(@NotNull Player player, @NotNull Schematic schematic) {
|
||||||
|
if (schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
|
||||||
|
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(DownloadSchematic.getLink(schematic));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void list(@NotNull Player player, @NotNull String[] args) {
|
||||||
|
if (args.length <= 1) {
|
||||||
sendPlayerSchematicList(0, SteamwarUser.get(player.getUniqueId()).getId(), player);
|
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;
|
||||||
}
|
}
|
||||||
@ -95,21 +151,24 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidSchemName(Player player, String name){
|
private boolean invalidSchemName(@NotNull Player player, @NotNull 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Schematic getSchem(Player player, String name){
|
@Nullable
|
||||||
if(invalidSchemName(player, name))
|
private Schematic getSchem(@NotNull Player player, @NotNull String 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");
|
||||||
@ -119,40 +178,32 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
return schematic;
|
return schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(Player player, String[] args){
|
private void load(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(args.length < 2){
|
if (args.length < 2) {
|
||||||
help(player);
|
help(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable Schematic schematic = getSchem(player, args[1]);
|
||||||
if(schematic == null)
|
if (schematic == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
load(player, schematic);
|
load(player, schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load(Player player, Schematic schematic){
|
private void delete(@NotNull Player player, @NotNull String[] args) {
|
||||||
try {
|
if (args.length < 2) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable 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;
|
||||||
}
|
}
|
||||||
@ -160,16 +211,17 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
GUI.delete(player, schematic);
|
GUI.delete(player, schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save(Player player, String[] args){
|
private void save(@NotNull Player player, @NotNull 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;
|
||||||
}
|
}
|
||||||
@ -197,34 +249,37 @@ 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(Player player, String[] args){
|
private void changetype(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(args.length < 2){
|
if (args.length < 2) {
|
||||||
help(player);
|
help(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable 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;
|
||||||
}
|
}
|
||||||
@ -232,149 +287,111 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
changetype(player, schematic, type);
|
changetype(player, schematic, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void changetype(Player player, Schematic schematic, SchematicType type){
|
private void info(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(schematic.getSchemType() == type){
|
if (args.length < 2) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable 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());
|
||||||
|
|
||||||
TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
|
@NotNull 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())) {
|
||||||
TextComponent download = new TextComponent("§eDownload Schematic");
|
@NotNull 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 {
|
||||||
List<String> schematicMembers = new ArrayList<>();
|
@NotNull List<String> schematicMembers = new ArrayList<>();
|
||||||
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
for (@NotNull 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()) {
|
||||||
TextComponent loadSchematic = new TextComponent("LADEN");
|
@NotNull 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(Player player, String[] args){
|
private void download(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(args.length < 2){
|
if (args.length < 2) {
|
||||||
help(player);
|
help(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable Schematic schematic = getSchem(player, args[1]);
|
||||||
if(schematic == null)
|
if (schematic == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
download(player, schematic);
|
download(player, schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search(Player player, String[] args) {
|
private void search(@NotNull Player player, @NotNull 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(DownloadSchematic.getLink(schematic));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addmember(Player player, String[] args){
|
private void addmember(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(args.length < 3){
|
if (args.length < 3) {
|
||||||
help(player);
|
help(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable 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;
|
||||||
}
|
}
|
||||||
@ -382,27 +399,29 @@ 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());
|
||||||
|
|
||||||
Player target = Bukkit.getPlayer(warkingUser.getUUID());
|
@Nullable 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(Player player, String[] args){
|
private void delmember(@NotNull Player player, @NotNull String[] args) {
|
||||||
if(args.length < 2){
|
if (args.length < 2) {
|
||||||
help(player);
|
help(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = getSchem(player, args[1]);
|
@Nullable 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;
|
||||||
}
|
}
|
||||||
@ -426,12 +445,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());
|
||||||
|
|
||||||
Player target = Bukkit.getPlayer(warkingUser.getUUID());
|
@Nullable 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(Player player) {
|
private void help(@NotNull 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");
|
||||||
@ -447,10 +466,10 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
|
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPlayerSchematicList(int currentPage, int schemOwner, Player player) {
|
private void sendPlayerSchematicList(int currentPage, int schemOwner, @NotNull Player player) {
|
||||||
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(schemOwner);
|
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;
|
||||||
}
|
}
|
||||||
@ -476,11 +495,11 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
Schematic schematic = schematicList.get(i);
|
Schematic schematic = schematicList.get(i);
|
||||||
|
|
||||||
String schematicPlayer = "";
|
@NotNull 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();
|
||||||
|
|
||||||
TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
|
@NotNull TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
|
||||||
schematics.setBold(true);
|
schematics.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()));
|
||||||
@ -491,7 +510,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(pages <= 1) return;
|
if(pages <= 1) return;
|
||||||
|
|
||||||
TextComponent beforePage = new TextComponent("««");
|
@NotNull 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()));
|
||||||
@ -499,7 +518,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}else
|
}else
|
||||||
beforePage.setColor(ChatColor.RED);
|
beforePage.setColor(ChatColor.RED);
|
||||||
|
|
||||||
TextComponent nextPage = new TextComponent(" Seite »»");
|
@NotNull 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()));
|
||||||
|
@ -2,23 +2,25 @@ 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(PlayerCommandPreprocessEvent event) {
|
public void handlePlayerCommandPreprocess(@NotNull PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
@NotNull 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!");
|
||||||
|
@ -6,41 +6,46 @@ 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(PlayerJoinEvent event) {
|
public void handlePlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
@NotNull Player player = event.getPlayer();
|
||||||
|
|
||||||
if(CheckSession.currentChecking()){
|
if (CheckSession.currentChecking()) {
|
||||||
CheckSession current = CheckSession.getCheckSession();
|
@Nullable 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());
|
||||||
|
|
||||||
List<Schematic> uncheckedSchematics = new LinkedList<>();
|
|
||||||
|
|
||||||
for(SchematicType type : SchematicType.values()){
|
|
||||||
if(type.check())
|
|
||||||
uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!uncheckedSchematics.isEmpty())
|
@NotNull List<Schematic> uncheckedSchematics = new LinkedList<>();
|
||||||
|
|
||||||
|
for (@NotNull SchematicType type : SchematicType.values()) {
|
||||||
|
if (type.check()) {
|
||||||
|
uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uncheckedSchematics.isEmpty()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§7Du hast noch §e" + uncheckedSchematics.size() + " §7ungeprüfte Schematic(s)!");
|
player.sendMessage(SchematicSystem.PREFIX + "§7Du hast noch §e" + uncheckedSchematics.size() + " §7ungeprüfte Schematic(s)!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,19 @@ 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(PlayerQuitEvent event) {
|
public void handlePlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
@NotNull Player player = event.getPlayer();
|
||||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
@Nullable CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
if(checkSession == null)
|
if (checkSession == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkSession.removeSchematic();
|
checkSession.removeSchematic();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren