13
0

Refitting vor new Core + 1.14 support

Dieser Commit ist enthalten in:
Lixfel 2019-11-10 17:31:30 +01:00
Ursprung a46dfc6763
Commit d5f79a91dc
26 geänderte Dateien mit 828 neuen und 463 gelöschten Zeilen

55
SchematicSystem_12/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>SchematicSystem_12</artifactId>
<version>1.0</version>
<parent>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem</artifactId>
<version>1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot-1.12</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -6,20 +6,19 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import de.warking.hunjy.MySQL.Schematic; import de.steamwar.sql.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.steamwar.sql.SteamwarUser;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
public class CheckSchemType { class CheckSchemType_v12 {
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 DISPENSER = Material.DISPENSER.getId(); private static final int DISPENSER = Material.DISPENSER.getId();
@ -65,57 +64,13 @@ public class CheckSchemType {
FLOWERS = flowers; FLOWERS = flowers;
} }
private static final Map<SchematicType, CheckSchemType> types = new EnumMap<>(SchematicType.class); private CheckSchemType_v12(){}
private final String name; static void autoCheck(Schematic schematic, List<String> errors, List<String> warnings, ICheckSchemType type) {
private final int width;
private final int height;
private final int depth;
private final int maxTNT;
private final int maxSlime;
private final int maxTNTSlime;
private final int maxDispenser;
private final int maxDispenserItems;
private final List<Integer> forbiddenIds;
private final LinkedList<String> checkList;
CheckSchemType(ConfigurationSection section) {
name = section.getName();
width = section.getInt("width");
height = section.getInt("height");
depth = section.getInt("depth");
maxTNT = section.getInt("maxTNT");
maxSlime = section.getInt("maxSlime");
maxTNTSlime = section.getInt("maxTNTSlime");
maxDispenser = section.getInt("maxDispenser");
maxDispenserItems = section.getInt("maxDispenserItems");
forbiddenIds = section.getIntegerList("forbiddenIds");
checkList = new LinkedList<>(section.getStringList("checkList"));
types.put(SchematicType.fromDB(name), this);
types.put(SchematicType.fromDB("c" + name), this);
}
public static CheckSchemType get(SchematicType type){
return types.get(type);
}
public LinkedList<String> getCheckList() {
return checkList;
}
public SchematicType getAcceptedType(){
return SchematicType.fromDB(name);
}
public void autoCheck(Schematic schematic, List<String> errors, List<String> warnings) {
Clipboard clipboard; Clipboard clipboard;
try { try {
clipboard = FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + WarkingUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic")).getClipboard(); clipboard = FaweAPI.load(new File(Constants.SCHEM_DIR + SteamwarUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic")).getClipboard();
if(clipboard == null) if(clipboard == null)
throw new IOException(); throw new IOException();
} catch (IOException e) { } catch (IOException e) {
@ -126,8 +81,8 @@ public class CheckSchemType {
Vector dimensions = clipboard.getDimensions(); Vector dimensions = clipboard.getDimensions();
if(dimensions.getBlockX() > width || dimensions.getBlockY() > height || dimensions.getBlockZ() > depth) if(dimensions.getBlockX() > type.getWidth() || dimensions.getBlockY() > type.getHeight() || dimensions.getBlockZ() > type.getDepth())
errors.add("Das " + name + " überschreitet die Maximalmaße"); errors.add("Das " + type.getName() + " überschreitet die Maximalmaße");
Region region = clipboard.getRegion(); Region region = clipboard.getRegion();
Vector min = region.getMinimumPoint(); Vector min = region.getMinimumPoint();
@ -153,19 +108,19 @@ public class CheckSchemType {
dispenser++; dispenser++;
if(INVENTORY.contains(blockId)){ if(INVENTORY.contains(blockId)){
checkInventory(errors, warnings, block, blockId); checkInventory(errors, warnings, block, blockId, type);
} }
if(forbiddenIds.contains(blockId)) if(type.getForbidden().contains(Material.getMaterial(blockId).name()))
errors.add("Der Block " + Material.getMaterial(blockId).name() + " ist verboten"); errors.add("Der Block " + Material.getMaterial(blockId).name() + " ist verboten");
} }
} }
} }
finalChecks(errors, tnt, slime, dispenser); type.finalChecks(errors, tnt, slime, dispenser);
} }
private void checkInventory(List<String> errors, List<String> warnings, BaseBlock block, int blockId){ private static void checkInventory(List<String> errors, List<String> warnings, BaseBlock block, int blockId, ICheckSchemType type){
CompoundTag nbt = block.getNbtData(); CompoundTag nbt = block.getNbtData();
if(nbt == null){ if(nbt == null){
warnings.add("Ein(e) " + Material.getMaterial(blockId).name() + " ist defekt"); warnings.add("Ein(e) " + Material.getMaterial(blockId).name() + " ist defekt");
@ -188,31 +143,19 @@ public class CheckSchemType {
continue; continue;
} }
Material type = Material.getMaterial(item.getString("id").split(":")[1].toUpperCase().replace("SHOVEL", "SPADE")); Material t = Material.getMaterial(item.getString("id").split(":")[1].toUpperCase().replace("SHOVEL", "SPADE"));
if(type == null && item.getString("id").equals("minecraft:fire_charge")) if(t == null && item.getString("id").equals("minecraft:fire_charge"))
type = Material.FIREBALL; t = Material.FIREBALL;
if(type == null) //Leere Slots if(t == null) //Leere Slots
continue; continue;
if(blockId == DISPENSER && (type.equals(Material.FIREBALL) || type.equals(Material.ARROW))) if(blockId == DISPENSER && (t.equals(Material.FIREBALL) || t.equals(Material.ARROW)))
counter += item.getByte("Count"); counter += item.getByte("Count");
else if(!FLOWERS.contains(type) && !(blockId == CHEST && type.equals(Material.TNT))) else if(!FLOWERS.contains(t) && !(blockId == CHEST && t.equals(Material.TNT)))
errors.add("In einem/r " + Material.getMaterial(blockId).name() + " ist das verbotene Item " + type); errors.add("In einem/r " + Material.getMaterial(blockId).name() + " ist das verbotene Item " + t);
} }
if(counter > maxDispenserItems) if(counter > type.getMaxDispenserItems())
errors.add("Ein Werfer enthält mehr als " + maxDispenserItems + " Pfeile und Feuerbälle"); errors.add("Ein Werfer enthält mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
}
private void finalChecks(List<String> errors, int tnt, int slime, int dispenser){
int tntSlime = tnt + slime;
if(maxTNT != 0 && tnt > maxTNT)
errors.add("Zu viele TNT-Blöcke");
if(maxSlime != 0 && slime > maxSlime)
errors.add("Zu viele Schleim-Blöcke");
if(maxDispenser != 0 && dispenser > maxDispenser)
errors.add("Zu viele Werfer");
if(maxTNTSlime != 0 && tntSlime > maxTNTSlime)
errors.add("Zu viel Schleim+TNT");
} }
} }

Datei anzeigen

@ -0,0 +1,64 @@
package de.steamwar.schematicsystem;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
class WorldEdit_v12 {
static void saveSchematic(Player player, String name) throws IOException, EmptyClipboardException {
ClipboardHolder clipboardHolder = FaweAPI.wrapPlayer(player).getSession().getClipboard();
Clipboard clipboard = clipboardHolder.getClipboard();
if(clipboard == null)
throw new EmptyClipboardException();
File folder = new File(Constants.SCHEM_DIR + player.getUniqueId().toString());
if(!folder.exists()){
folder.mkdir();
Files.setPosixFilePermissions(folder.toPath(), Constants.FOLDER_PERMS);
}
File file = new File(folder, name + ".schematic");
file.createNewFile();
Files.setPosixFilePermissions(file.toPath(), Constants.FILE_PERMS);
Region region = clipboard.getRegion();
Schematic schem = new Schematic(region);
schem.save(file, ClipboardFormat.SCHEMATIC);
}
static void loadClipboardToPlayer(Player player, Clipboard clipboard){
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, FaweAPI.getWorld(player.getWorld().getName()).getWorldData()));
}
static EditSession pasteSchematic(Player player, Schematic schematic){
World weWorld = new BukkitWorld(player.getWorld());
Location playerLocation = player.getLocation();
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
Vector offset = new Vector(schematic.getClipboard().getRegion().getMinimumPoint()).subtract(schematic.getClipboard().getOrigin());
Vector dimensions = schematic.getClipboard().getDimensions();
Vector v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
return schematic.paste(weWorld, v);
}
private static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
}
}

48
SchematicSystem_14/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>SchematicSystem_14</artifactId>
<version>1.0</version>
<parent>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem</artifactId>
<version>1.0</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot-1.14</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.14</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,145 @@
package de.steamwar.schematicsystem;
import com.boydti.fawe.FaweAPI;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.io.File;
import java.io.IOException;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
class CheckSchemType_v14 {
private static final Set<Material> INVENTORY = EnumSet.of(
Material.CHEST,
Material.TRAPPED_CHEST,
Material.HOPPER,
Material.FURNACE,
Material.DROPPER,
Material.JUKEBOX,
Material.DISPENSER,
Material.ANVIL,
Material.BREWING_STAND,
Material.BLACK_SHULKER_BOX,
Material.RED_SHULKER_BOX,
Material.WHITE_SHULKER_BOX,
Material.ORANGE_SHULKER_BOX,
Material.BLUE_SHULKER_BOX,
Material.LIGHT_BLUE_SHULKER_BOX,
Material.YELLOW_SHULKER_BOX,
Material.GREEN_SHULKER_BOX,
Material.BROWN_SHULKER_BOX,
Material.CYAN_SHULKER_BOX,
Material.GRAY_SHULKER_BOX,
Material.LIGHT_GRAY_SHULKER_BOX,
Material.LIME_SHULKER_BOX,
Material.MAGENTA_SHULKER_BOX,
Material.PINK_SHULKER_BOX,
Material.PURPLE_SHULKER_BOX);
//TODO: New Inventory Items
//TODO: Adding flowers
private static final Set<Material> FLOWERS = EnumSet.of(
Material.CORNFLOWER);
private CheckSchemType_v14(){}
static void autoCheck(Schematic schematic, List<String> errors, List<String> warnings, ICheckSchemType type) {
Clipboard clipboard;
try {
clipboard = FaweAPI.load(new File(Constants.SCHEM_DIR + SteamwarUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic")).getClipboard();
if(clipboard == null)
throw new IOException();
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e);
errors.add("Die Schematic konnte nicht geladen werden");
return;
}
BlockVector3 dimensions = clipboard.getDimensions();
if(dimensions.getBlockX() > type.getWidth() || dimensions.getBlockY() > type.getHeight() || dimensions.getBlockZ() > type.getDepth())
errors.add("Das " + type.getName() + " überschreitet die Maximalmaße");
Region region = clipboard.getRegion();
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
int tnt = 0;
int slime = 0;
int dispenser = 0;
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
final Material blockMaterial = Material.matchMaterial(block.getBlockType().getId());
if(blockMaterial == Material.TNT)
tnt++;
if(blockMaterial == Material.SLIME_BLOCK)
slime++;
if(blockMaterial == Material.DISPENSER)
dispenser++;
if(INVENTORY.contains(blockMaterial)){
checkInventory(errors, warnings, block, blockMaterial, type);
}
if(type.getForbidden().contains(blockMaterial.name()))
errors.add("Der Block " + blockMaterial.name() + " ist verboten");
}
}
}
type.finalChecks(errors, tnt, slime, dispenser);
}
private static void checkInventory(List<String> errors, List<String> warnings, BaseBlock block, Material blockMaterial, ICheckSchemType type){
CompoundTag nbt = block.getNbtData();
if(nbt == null){
warnings.add("Ein(e) " + blockMaterial.name() + " ist defekt");
return;
}
if(blockMaterial == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){
errors.add("Schallplatten sind auch nicht in Schallplattenspielern gestattet");
return;
}
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
if(items.isEmpty())
return; //Leeres Inventar
int counter = 0;
for(CompoundTag item : items){
if(!item.containsKey("id")){
warnings.add("Ein(e) " + blockMaterial.name() + " ist defekt");
continue;
}
Material t = Material.matchMaterial(item.getString("id"));
if(t == null) //Leere Slots
continue;
if(blockMaterial == Material.DISPENSER && (t.equals(Material.FIRE_CHARGE) || t.equals(Material.ARROW)))
counter += item.getByte("Count");
else if(!FLOWERS.contains(t) && !(blockMaterial == Material.CHEST && t.equals(Material.TNT)))
errors.add("In einem/r " + blockMaterial.name() + " ist das verbotene Item " + t);
}
if(counter > type.getMaxDispenserItems())
errors.add("Ein Werfer enthält mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
}
}

Datei anzeigen

@ -0,0 +1,66 @@
package de.steamwar.schematicsystem;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
class WorldEdit_v14 {
private WorldEdit_v14(){}
static void saveSchematic(Player player, String name) throws IOException, EmptyClipboardException {
ClipboardHolder clipboardHolder = FaweAPI.wrapPlayer(player).getSession().getClipboard();
Clipboard clipboard = clipboardHolder.getClipboard();
if(clipboard == null)
throw new EmptyClipboardException();
File folder = new File(Constants.SCHEM_DIR + player.getUniqueId().toString());
if(!folder.exists()){
folder.mkdir();
Files.setPosixFilePermissions(folder.toPath(), Constants.FOLDER_PERMS);
}
File file = new File(folder, name + ".schematic");
file.createNewFile();
Files.setPosixFilePermissions(file.toPath(), Constants.FILE_PERMS);
Region region = clipboard.getRegion();
Schematic schem = new Schematic(region);
schem.save(file, ClipboardFormats.findByExtension("schem"));
}
static void loadClipboardToPlayer(Player player, Clipboard clipboard){
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
}
static EditSession pasteSchematic(Player player, Schematic schematic){
World weWorld = new BukkitWorld(player.getWorld());
Location playerLocation = player.getLocation();
BlockVector3 vector = BlockVector3.at(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
BlockVector3 offset = schematic.getClipboard().getRegion().getMinimumPoint().subtract(schematic.getClipboard().getOrigin());
BlockVector3 dimensions = schematic.getClipboard().getDimensions();
BlockVector3 v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
return schematic.paste(weWorld, v);
}
private static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
}
}

28
SchematicSystem_API/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
</project>

Datei anzeigen

@ -0,0 +1,29 @@
package de.steamwar.schematicsystem;
import java.nio.file.attribute.PosixFilePermission;
import java.util.EnumSet;
import java.util.Set;
public class Constants {
private Constants(){}
public static final Set<PosixFilePermission> FILE_PERMS = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.GROUP_WRITE,
PosixFilePermission.OTHERS_READ,
PosixFilePermission.OTHERS_WRITE);
public static final Set<PosixFilePermission> FOLDER_PERMS = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.GROUP_WRITE,
PosixFilePermission.OTHERS_READ,
PosixFilePermission.OTHERS_WRITE,
PosixFilePermission.OWNER_EXECUTE,
PosixFilePermission.GROUP_EXECUTE,
PosixFilePermission.OTHERS_EXECUTE);
public static final String SCHEM_DIR = "/home/minecraft/schematics/";
}

Datei anzeigen

@ -0,0 +1,16 @@
package de.steamwar.schematicsystem;
import java.util.List;
interface ICheckSchemType {
String getName();
int getWidth();
int getHeight();
int getDepth();
int getMaxDispenserItems();
List<String> getForbidden();
void finalChecks(List<String> errors, int tnt, int slime, int dispenser);
}

86
SchematicSystem_Main/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>SchematicSystem_Main</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot-1.12</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_14</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_12</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,113 @@
package de.steamwar.schematicsystem;
import de.steamwar.core.Core;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import org.bukkit.configuration.ConfigurationSection;
import java.util.EnumMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class CheckSchemType implements ICheckSchemType {
private static final Map<SchematicType, CheckSchemType> types = new EnumMap<>(SchematicType.class);
private final String name;
private final int width;
private final int height;
private final int depth;
private final int maxDispenserItems;
private final List<String> forbiddenMaterials;
private final int maxTNT;
private final int maxSlime;
private final int maxTNTSlime;
private final int maxDispenser;
private final LinkedList<String> checkList;
CheckSchemType(ConfigurationSection section) {
name = section.getName();
width = section.getInt("width");
height = section.getInt("height");
depth = section.getInt("depth");
maxTNT = section.getInt("maxTNT");
maxSlime = section.getInt("maxSlime");
maxTNTSlime = section.getInt("maxTNTSlime");
maxDispenser = section.getInt("maxDispenser");
maxDispenserItems = section.getInt("maxDispenserItems");
forbiddenMaterials = section.getStringList("forbiddenMaterials");
checkList = new LinkedList<>(section.getStringList("checkList"));
types.put(SchematicType.fromDB(name), this);
types.put(SchematicType.fromDB("c" + name), this);
}
public static CheckSchemType get(SchematicType type){
return types.get(type);
}
public List<String> getCheckList() {
return checkList;
}
public SchematicType getAcceptedType(){
return SchematicType.fromDB(name);
}
public void autoCheck(Schematic schematic, List<String> errors, List<String> warnings) {
switch(Core.getVersion()){
case 14:
CheckSchemType_v14.autoCheck(schematic, errors, warnings, this);
break;
default:
CheckSchemType_v12.autoCheck(schematic, errors, warnings, this);
}
}
@Override
public void finalChecks(List<String> errors, int tnt, int slime, int dispenser){
int tntSlime = tnt + slime;
if(maxTNT != 0 && tnt > maxTNT)
errors.add("Zu viele TNT-Blöcke");
if(maxSlime != 0 && slime > maxSlime)
errors.add("Zu viele Schleim-Blöcke");
if(maxDispenser != 0 && dispenser > maxDispenser)
errors.add("Zu viele Werfer");
if(maxTNTSlime != 0 && tntSlime > maxTNTSlime)
errors.add("Zu viel Schleim+TNT");
}
@Override
public String getName() {
return name;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public int getDepth() {
return depth;
}
@Override
public int getMaxDispenserItems() {
return maxDispenserItems;
}
@Override
public List<String> getForbidden() {
return forbiddenMaterials;
}
}

Datei anzeigen

@ -1,13 +1,12 @@
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import de.steamwar.core.CommandRemover;
import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.schematicsystem.commands.CheckCommand; import de.steamwar.schematicsystem.commands.CheckCommand;
import de.steamwar.schematicsystem.commands.SchematicCommand; 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 de.steamwar.schematicsystem.utils.CommandRemover;
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;
@ -18,7 +17,6 @@ import java.io.File;
public class SchematicSystem extends JavaPlugin { public class SchematicSystem extends JavaPlugin {
public static final String SCHEM_DIR = "/home/minecraft/schematics/";
public static final String PREFIX = "§eSchematic§8» §7"; public static final String PREFIX = "§eSchematic§8» §7";
@Override @Override
@ -50,8 +48,4 @@ public class SchematicSystem extends JavaPlugin {
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo()); CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
}, 0, 6000); }, 0, 6000);
} }
public static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
}
} }

Datei anzeigen

@ -0,0 +1,43 @@
package de.steamwar.schematicsystem;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core;
import org.bukkit.entity.Player;
import java.io.IOException;
public class WorldEdit {
private WorldEdit(){}
public static void saveSchematic(Player player, String name) throws IOException, EmptyClipboardException {
switch(Core.getVersion()){
case 14:
WorldEdit_v14.saveSchematic(player, name);
break;
default:
WorldEdit_v12.saveSchematic(player, name);
}
}
public static void loadClipboardToPlayer(Player player, Clipboard clipboard){
switch(Core.getVersion()){
case 14:
WorldEdit_v14.loadClipboardToPlayer(player, clipboard);
break;
default:
WorldEdit_v12.loadClipboardToPlayer(player, clipboard);
}
}
public static EditSession pasteSchematic(Player player, Schematic schematic){
switch(Core.getVersion()){
case 14:
return WorldEdit_v14.pasteSchematic(player, schematic);
default:
return WorldEdit_v12.pasteSchematic(player, schematic);
}
}
}

Datei anzeigen

@ -3,10 +3,10 @@ package de.steamwar.schematicsystem.check;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.utils.CheckedSchematic; import de.steamwar.sql.CheckedSchematic;
import de.warking.hunjy.MySQL.Schematic; import de.steamwar.sql.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.steamwar.sql.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser; import de.steamwar.sql.SteamwarUser;
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;
@ -58,9 +58,9 @@ public class CheckSession {
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" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!"); Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType()); schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType());
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.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");
removeSchematic(); removeSchematic();
return; return;
@ -98,7 +98,7 @@ public class CheckSession {
public void declineSchematic(String declineReason) { public void declineSchematic(String declineReason) {
schematic.setSchemType(SchematicType.Normal); schematic.setSchemType(SchematicType.Normal);
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason); new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
removeSchematic(); removeSchematic();
} }

Datei anzeigen

@ -1,10 +1,10 @@
package de.steamwar.schematicsystem.check; package de.steamwar.schematicsystem.check;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.warking.hunjy.MySQL.Schematic; import de.steamwar.sql.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.steamwar.sql.SchematicType;
import de.warking.hunjy.MySQL.UserGroup; import de.steamwar.sql.SteamwarUser;
import de.warking.hunjy.MySQL.WarkingUser; import de.steamwar.sql.UserGroup;
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;
@ -30,7 +30,7 @@ public class CheckUtils {
} }
public static boolean allowedToCheck(Player player) { public static boolean allowedToCheck(Player player) {
WarkingUser warkingUser = WarkingUser.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 ||
@ -83,10 +83,10 @@ public class CheckUtils {
player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics"); player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
for(Schematic schematic : schematicList) { for(Schematic schematic : schematicList) {
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName()); TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
schematics.setBold(true); schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create())); schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + WarkingUser.get(schematic.getSchemOwner()).getUserName())); schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + SteamwarUser.get(schematic.getSchemOwner()).getUserName()));
player.spigot().sendMessage(schematics); player.spigot().sendMessage(schematics);
} }
} }

Datei anzeigen

@ -1,16 +1,14 @@
package de.steamwar.schematicsystem.commands; package de.steamwar.schematicsystem.commands;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.Vector; import de.steamwar.schematicsystem.Constants;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.world.World;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.WorldEdit;
import de.steamwar.schematicsystem.check.CheckSession; import de.steamwar.schematicsystem.check.CheckSession;
import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.schematicsystem.check.CheckUtils;
import de.warking.hunjy.MySQL.Schematic; import de.steamwar.sql.Schematic;
import de.warking.hunjy.MySQL.WarkingUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
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;
@ -66,7 +64,7 @@ public class CheckCommand implements CommandExecutor {
return false; return false;
} }
WarkingUser user = WarkingUser.get(args[2]); SteamwarUser user = SteamwarUser.get(args[2]);
if(user.getUUID() == null){ if(user.getUUID() == null){
player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer"); player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer");
return false; return false;
@ -79,7 +77,7 @@ public class CheckCommand implements CommandExecutor {
}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() == WarkingUser.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;
} }
@ -87,16 +85,16 @@ public class CheckCommand implements CommandExecutor {
List<Player> worldPlayers = player.getWorld().getPlayers(); List<Player> worldPlayers = player.getWorld().getPlayers();
for(Player players : worldPlayers) { for(Player players : worldPlayers) {
if(!players.getUniqueId().toString().equals(player.getWorld().getName())) { if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
WarkingUser warkingUsers = WarkingUser.get(players.getUniqueId()); SteamwarUser warkingUsers = SteamwarUser.get(players.getUniqueId());
if(!CheckUtils.allowedToCheck(players) && if(!CheckUtils.allowedToCheck(players) &&
!warkingUsers.getUUID().toString().equals(WarkingUser.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;
} }
} }
} }
File file = new File(SchematicSystem.SCHEM_DIR + user.getUUID().toString(),schematic.getSchemName() + ".schematic"); File file = new File(Constants.SCHEM_DIR + user.getUUID().toString(),schematic.getSchemName() + ".schematic");
if(!file.exists()) { if(!file.exists()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic gibts nicht?!?!"); player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic gibts nicht?!?!");
return false; return false;
@ -104,19 +102,10 @@ public class CheckCommand implements CommandExecutor {
try { try {
com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file); com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file);
Location playerLocation = player.getLocation();
World weWorld = new BukkitWorld(player.getWorld());
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
Vector offset = new Vector(schematicFAWE.getClipboard().getRegion().getMinimumPoint()).subtract(schematicFAWE.getClipboard().getOrigin());
Vector v;
Vector dimensions = schematicFAWE.getClipboard().getDimensions();
v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
checkSession = new CheckSession(player.getUniqueId(), schematic); checkSession = new CheckSession(player.getUniqueId(), schematic);
checkSession.sendNextCheck(); checkSession.sendNextCheck();
checkSession.setEditSession(schematicFAWE.paste(weWorld, v)); checkSession.setEditSession(WorldEdit.pasteSchematic(player, schematicFAWE));
} catch (IOException ex) { } catch (IOException 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);
@ -135,7 +124,7 @@ public class CheckCommand implements CommandExecutor {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
for (int i = 1; i < args.length; i++) message.append(args[i]).append(" "); for (int i = 1; i < args.length; i++) message.append(args[i]).append(" ");
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.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!");
checkSession.declineSchematic(message.toString()); checkSession.declineSchematic(message.toString());
break; break;
default: default:

Datei anzeigen

@ -3,12 +3,9 @@ package de.steamwar.schematicsystem.commands;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.schematicsystem.Constants;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.utils.CheckedSchematic; import de.steamwar.sql.*;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicMember;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
import javafx.util.Pair; import javafx.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -18,7 +15,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
class GUI { class GUI {
private GUI(){} private GUI(){}
@ -29,7 +29,7 @@ class GUI {
if(!type.isAssignable()) if(!type.isAssignable())
continue; continue;
SWItem item = new SWItem(Material.STONE_BUTTON, type.name()); SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
if(type.fightType()) if(type.fightType())
item.setEnchanted(true); item.setEnchanted(true);
@ -46,8 +46,8 @@ class GUI {
static void delete(Player p, Schematic schem){ static void delete(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen"); SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
inv.setItem(0, Material.INK_SACK, (byte) 1, "§eLöschen", click -> { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
File file = new File(SchematicSystem.SCHEM_DIR + p.getUniqueId(), schem.getSchemName() + ".schematic"); File file = new File(Constants.SCHEM_DIR + p.getUniqueId(), schem.getSchemName() + ".schematic");
file.delete(); file.delete();
schem.remove(); schem.remove();
@ -60,7 +60,7 @@ class GUI {
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht"); p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
p.closeInventory(); p.closeInventory();
}); });
inv.setItem(8, Material.INK_SACK, (byte) 14, "§cAbbruch", click -> p.closeInventory()); inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
inv.setCallback(-999, click -> p.closeInventory()); inv.setCallback(-999, click -> p.closeInventory());
inv.open(); inv.open();
} }
@ -68,17 +68,8 @@ class GUI {
static void delmembers(Player p, Schematic schem){ static void delmembers(Player p, Schematic schem){
List<Pair<SWItem, SchematicMember>> members = new LinkedList<>(); List<Pair<SWItem, SchematicMember>> members = new LinkedList<>();
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){ for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
WarkingUser user = WarkingUser.get(member.getMember()); SteamwarUser user = SteamwarUser.get(member.getMember());
members.add(new Pair<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member));
SWItem item = new SWItem();
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
SkullMeta headmeta = (SkullMeta)head.getItemMeta();
headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(user.getUUID()));
headmeta.setDisplayName(user.getUserName());
head.setItemMeta(headmeta);
item.setItemStack(head);
members.add(new Pair<>(item, member));
} }
SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", (clickType, member) -> { SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", (clickType, member) -> {
@ -109,48 +100,48 @@ class GUI {
private static void info(Player p, Schematic schem){ private static void info(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName()); SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
inv.setItem(0, Material.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() == WarkingUser.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(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, Material.INK_SACK, (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;
} }
} }
} }
Material mat = Material.CAULDRON_ITEM; Material mat = SWItem.getMaterial("CAULDRON_ITEM");
if(schem.getItem() != null && !schem.getItem().equals("")) if(schem.getItem() != null && !schem.getItem().equals(""))
mat = Material.valueOf(schem.getItem()); mat = SWItem.getMaterial(schem.getItem());
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
p.closeInventory(); p.closeInventory();
changeItem(p, schem); changeItem(p, schem);
}); });
inv.setItem(4, Material.CAULDRON_ITEM, "§e" + schem.getSchemType().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
p.closeInventory(); p.closeInventory();
changeType(p, schem); changeType(p, schem);
}); });
inv.setItem(6, Material.SKULL_ITEM, "§eMitglieder", click -> { inv.setItem(6, SWItem.getMaterial("SKULL_ITEM"), "§eMitglieder", click -> {
p.closeInventory(); p.closeInventory();
delmembers(p, schem); delmembers(p, schem);
}); });
inv.setItem(8, Material.INK_SACK, (byte) 1, "§cLöschen", click -> { inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
p.closeInventory(); p.closeInventory();
delete(p, schem); delete(p, schem);
}); });
}else{ }else{
inv.setItem(4, Material.CAULDRON_ITEM, "§e" + schem.getSchemType().name(), click -> {}); inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
WarkingUser owneruser = WarkingUser.get(schem.getSchemOwner()); SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
SWItem owner = new SWItem(); SWItem owner = new SWItem();
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3); ItemStack head = new ItemStack(SWItem.getMaterial("SKULL_ITEM"), 1, (short)3);
SkullMeta headmeta = (SkullMeta)head.getItemMeta(); SkullMeta headmeta = (SkullMeta)head.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());
@ -164,7 +155,7 @@ class GUI {
} }
static void list(Player p){ static void list(Player p){
list(p, WarkingUser.get(p.getUniqueId()).getId()); list(p, SteamwarUser.get(p.getUniqueId()).getId());
} }
static void list(Player p, int pid){ static void list(Player p, int pid){
@ -174,9 +165,9 @@ class GUI {
for(Schematic schem : schems) { for(Schematic schem : schems) {
Material m; Material m;
if (schem.getItem().isEmpty()) if (schem.getItem().isEmpty())
m = Material.CAULDRON_ITEM; m = SWItem.getMaterial("CAULDRON_ITEM");
else else
m = Material.valueOf(schem.getItem()); m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {}); SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {});
schemList.add(new Pair<>(item, schem)); schemList.add(new Pair<>(item, schem));

Datei anzeigen

@ -2,18 +2,13 @@ package de.steamwar.schematicsystem.commands;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.session.ClipboardHolder;
import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.Constants;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.WorldEdit;
import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.schematicsystem.utils.CheckedSchematic; import de.steamwar.sql.*;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicMember;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
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;
@ -26,12 +21,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -39,23 +30,6 @@ 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;
private static final EnumSet<PosixFilePermission> FILE_PERMS = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.GROUP_WRITE,
PosixFilePermission.OTHERS_READ,
PosixFilePermission.OTHERS_WRITE);
private static final EnumSet<PosixFilePermission> FOLDER_PERMS = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.GROUP_WRITE,
PosixFilePermission.OTHERS_READ,
PosixFilePermission.OTHERS_WRITE,
PosixFilePermission.OWNER_EXECUTE,
PosixFilePermission.GROUP_EXECUTE,
PosixFilePermission.OTHERS_EXECUTE);
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -104,7 +78,7 @@ public class SchematicCommand implements CommandExecutor {
private void list(Player player, String[] args){ private void list(Player player, String[] args){
if(args.length <= 1){ if(args.length <= 1){
sendPlayerSchematicList(0, WarkingUser.get(player.getUniqueId()).getId(), player); sendPlayerSchematicList(0, SteamwarUser.get(player.getUniqueId()).getId(), player);
return; return;
} }
@ -114,7 +88,7 @@ public class SchematicCommand implements CommandExecutor {
} }
try { try {
sendPlayerSchematicList(Integer.parseInt(args[1]), WarkingUser.get(player.getUniqueId()).getId(), player); sendPlayerSchematicList(Integer.parseInt(args[1]), SteamwarUser.get(player.getUniqueId()).getId(), player);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl"); player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
} }
@ -159,9 +133,7 @@ public class SchematicCommand implements CommandExecutor {
static void load(Player player, Schematic schematic){ static void load(Player player, Schematic schematic){
try { try {
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player); File file = new File(Constants.SCHEM_DIR + SteamwarUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic");
File file = new File(SchematicSystem.SCHEM_DIR + WarkingUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic");
if (!file.exists()) { if (!file.exists()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht"); player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
@ -171,7 +143,7 @@ public class SchematicCommand implements CommandExecutor {
if (clipboard == null) if (clipboard == null)
throw new IOException("File not a schematic"); throw new IOException("File not a schematic");
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, FaweAPI.getWorld(player.getWorld().getName()).getWorldData())); WorldEdit.loadClipboardToPlayer(player, clipboard);
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen"); player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
}catch (IOException ex){ }catch (IOException ex){
Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", ex); Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", ex);
@ -189,7 +161,7 @@ public class SchematicCommand implements CommandExecutor {
if(schematic == null) if(schematic == null)
return; return;
if(WarkingUser.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;
} }
@ -213,34 +185,22 @@ public class SchematicCommand implements CommandExecutor {
} }
try { try {
ClipboardHolder clipboardHolder = FaweAPI.wrapPlayer(player).getSession().getClipboard(); WorldEdit.saveSchematic(player, args[1]);
Clipboard clipboard = clipboardHolder.getClipboard(); }catch(EmptyClipboardException e){
if(clipboard == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer"); player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer");
return; return;
}catch(IOException ex){
Bukkit.getLogger().log(Level.SEVERE, "Could not save schematic", ex);
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Speichern der Schematic. Bitte wende dich an einen Developer");
return;
} }
File folder = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString()); if (schematic != null && schematic.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
if(!folder.exists()){
folder.mkdir();
Files.setPosixFilePermissions(folder.toPath(), FOLDER_PERMS);
}
File file = new File(folder, args[1] + ".schematic");
file.createNewFile();
Files.setPosixFilePermissions(file.toPath(), FILE_PERMS);
ClipboardFormat.SCHEMATIC.getWriter(new FileOutputStream(file)).write(clipboard, clipboardHolder.getWorldData());
if(schematic != null && schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()){
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben"); player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben");
} else { } else {
new Schematic(args[1], player.getUniqueId(), "", SchematicType.Normal); new Schematic(args[1], player.getUniqueId(), "", SchematicType.Normal);
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert"); player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert");
} }
}catch(IOException | EmptyClipboardException ex){
Bukkit.getLogger().log(Level.SEVERE, "Could not save schematic", ex);
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Speichern der Schematic. Bitte wende dich an einen Developer");
}
} }
private void changetype(Player player, String[] args){ private void changetype(Player player, String[] args){
@ -315,7 +275,7 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage("§eName: §7" + schematic.getSchemName()); player.sendMessage("§eName: §7" + schematic.getSchemName());
TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name()); TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){ if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){
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()));
} }
@ -330,12 +290,12 @@ public class SchematicCommand implements CommandExecutor {
} }
} }
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { if(!SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
player.sendMessage("§eBesitzer: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName()); player.sendMessage("§eBesitzer: §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
} else { } else {
List<String> schematicMembers = new ArrayList<>(); List<String> schematicMembers = new ArrayList<>();
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) { for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName()); schematicMembers.add(SteamwarUser.get(schematicMember.getMember()).getUserName());
} }
player.sendMessage("§eMitglieder: §7" + schematicMembers.toString()); player.sendMessage("§eMitglieder: §7" + schematicMembers.toString());
} }
@ -356,12 +316,12 @@ public class SchematicCommand implements CommandExecutor {
if(schematic == null) if(schematic == null)
return; return;
if(schematic.getSchemOwner() != WarkingUser.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;
} }
WarkingUser warkingUser = WarkingUser.get(args[2]); SteamwarUser warkingUser = SteamwarUser.get(args[2]);
if(warkingUser.getUUID() == null){ if(warkingUser.getUUID() == null){
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht"); player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
return; return;
@ -371,17 +331,17 @@ public class SchematicCommand implements CommandExecutor {
return; return;
} }
if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.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;
} }
new SchematicMember(schematic.getSchemName(), WarkingUser.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()); 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" + WarkingUser.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(Player player, String[] args){
@ -394,7 +354,7 @@ public class SchematicCommand implements CommandExecutor {
if(schematic == null) if(schematic == null)
return; return;
if(schematic.getSchemOwner() != WarkingUser.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;
} }
@ -404,7 +364,7 @@ public class SchematicCommand implements CommandExecutor {
return; return;
} }
WarkingUser warkingUser = WarkingUser.get(args[2]); SteamwarUser warkingUser = SteamwarUser.get(args[2]);
if(warkingUser.getUUID() == null){ if(warkingUser.getUUID() == null){
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht"); player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
return; return;
@ -414,7 +374,7 @@ public class SchematicCommand implements CommandExecutor {
return; return;
} }
SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()); SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
if(schematicMember == null) { if(schematicMember == null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic hinzugefügt"); player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic hinzugefügt");
return; return;
@ -425,7 +385,7 @@ public class SchematicCommand implements CommandExecutor {
Player target = Bukkit.getPlayer(warkingUser.getUUID()); Player target = Bukkit.getPlayer(warkingUser.getUUID());
if(target != null) if(target != null)
target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName() + "§7von §e" + WarkingUser.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(Player player) {
@ -473,7 +433,7 @@ public class SchematicCommand implements CommandExecutor {
String schematicPlayer = ""; String schematicPlayer = "";
if(schematic.getSchemOwner() != schemOwner) if(schematic.getSchemOwner() != schemOwner)
schematicPlayer = " §8von §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName(); schematicPlayer = " §8von §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName();
TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer); TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
schematics.setBold(true); schematics.setBold(true);

Datei anzeigen

@ -1,11 +1,12 @@
package de.steamwar.schematicsystem.listener; package de.steamwar.schematicsystem.listener;
import de.steamwar.schematicsystem.Constants;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckSession; import de.steamwar.schematicsystem.check.CheckSession;
import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.schematicsystem.check.CheckUtils;
import de.warking.hunjy.MySQL.Schematic; import de.steamwar.sql.Schematic;
import de.warking.hunjy.MySQL.SchematicType; import de.steamwar.sql.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser; import de.steamwar.sql.SteamwarUser;
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;
@ -13,6 +14,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
public class PlayerJoinListener implements Listener { public class PlayerJoinListener implements Listener {
@ -23,7 +25,7 @@ public class PlayerJoinListener implements Listener {
if(CheckSession.currentChecking()){ if(CheckSession.currentChecking()){
CheckSession current = CheckSession.getCheckSession(); CheckSession current = CheckSession.getCheckSession();
if(!CheckUtils.allowedToCheck(player) && !WarkingUser.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;
@ -35,7 +37,7 @@ public class PlayerJoinListener implements Listener {
if(CheckUtils.allowedToCheck(player)) if(CheckUtils.allowedToCheck(player))
player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo()); player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
List<Schematic> uncheckedSchematics = new ArrayList<>(); List<Schematic> uncheckedSchematics = new LinkedList<>();
for(SchematicType type : SchematicType.values()){ for(SchematicType type : SchematicType.values()){
if(type.check()) if(type.check())
@ -47,7 +49,7 @@ public class PlayerJoinListener implements Listener {
} }
private void addNewSchems(Player player){ private void addNewSchems(Player player){
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId()); File file = new File(Constants.SCHEM_DIR + player.getUniqueId());
File[] files = file.listFiles(); File[] files = file.listFiles();
if(files != null && files.length > 0) { if(files != null && files.length > 0) {
@ -55,7 +57,7 @@ public class PlayerJoinListener implements Listener {
List<String> schematicNames = new ArrayList<>(); List<String> schematicNames = new ArrayList<>();
for(Schematic schematic : schematics) { for(Schematic schematic : schematics) {
if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) { if(schematic.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
schematicNames.add(schematic.getSchemName()); schematicNames.add(schematic.getSchemName());
} }
} }

Datei anzeigen

@ -1,7 +1,7 @@
name: SchematicSystem name: SchematicSystem
version: "1.0" version: "1.0"
authors: [Yaruma3341, Lixfel] authors: [Yaruma3341, Lixfel]
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit] depend: [SpigotCore, WorldEdit]
main: de.steamwar.schematicsystem.SchematicSystem main: de.steamwar.schematicsystem.SchematicSystem
commands: commands:

43
pom.xml
Datei anzeigen

@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.warking</groupId> <groupId>steamwar</groupId>
<artifactId>SchematicSystem</artifactId> <artifactId>SchematicSystem</artifactId>
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging>
<url>https://maven.apache.org</url> <url>https://maven.apache.org</url>
<packaging>pom</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -17,21 +17,11 @@
<repositories> <repositories>
<repository> <repository>
<id>maven</id> <id>maven</id>
<url>https://steamwar.de:81/maven/</url> <url>https://steamwar.de/maven/</url>
</repository> </repository>
</repositories> </repositories>
<build> <build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -45,29 +35,18 @@
</plugins> </plugins>
</build> </build>
<modules>
<module>SchematicSystem_12</module>
<module>SchematicSystem_14</module>
<module>SchematicSystem_API</module>
<module>SchematicSystem_Main</module>
</modules>
<dependencies> <dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SpigotCore</artifactId> <artifactId>SpigotCore</artifactId>
<version>1.0</version> <version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

Datei anzeigen

@ -1,41 +0,0 @@
Schematics:
WarGear:
Breite:
Höhe:
Tiefe:
TNT:
Schleim:
TNTSchleim:
Dispenser:
ForbiddenIds:
CheckList:
MiniWarGear:
Breite:
Höhe:
Tiefe:
TNT:
Schleim:
TNTSchleim:
Dispenser:
ForbiddenIds:
CheckList:
WarShip:
Breite:
Höhe:
Tiefe:
TNT:
Schleim:
TNTSchleim:
Dispenser:
ForbiddenIds:
CheckList:
AirShip:
Breite:
Höhe:
Tiefe:
TNT:
Schleim:
TNTSchleim:
Dispenser:
ForbiddenIds:
CheckList:

Datei anzeigen

@ -1,102 +0,0 @@
package de.steamwar.schematicsystem.utils;
import de.warking.hunjy.Core;
import de.warking.hunjy.MySQL.MySQL;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.Bukkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import static de.warking.hunjy.Core.sql;
public class CheckedSchematic {
private final String schemName;
private final int schemOwner;
private final int validator;
private final Timestamp startTime;
private final Timestamp endTime;
private final String declineReason;
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
this.schemName = MySQL.disarmString(schemName);
this.schemOwner = schemOwner;
this.validator = validator;
this.startTime = startTime;
this.endTime = endTime;
this.declineReason = MySQL.disarmString(declineReason);
if(insertDB)
insertDB();
}
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true);
}
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, WarkingUser.get(schemOwner).getId(), WarkingUser.get(validator).getId(), startTime, endTime, declineReason, true);
}
private void insertDB(){
sql.update("INSERT INTO CheckedSchematic" +
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason)" +
" VALUES" +
" ('"+ schemName + "', '" + schemOwner + "', '" + validator + "', '" + startTime.toString() + "', '" + endTime.toString() + "', '" + declineReason + "')");
}
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
return getLastDelined(WarkingUser.get(schemOwner).getId());
}
public static List<CheckedSchematic> getLastDelined(int schemOwner){
List<CheckedSchematic> lastDeclined = new LinkedList<>();
try{
ResultSet lastRS = sql.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = '" + schemOwner + "' AND DeclineReason != '' ORDER BY EndTime DESC");
while(lastRS.next()){
String schemName = lastRS.getString("SchemName");
int validator = lastRS.getInt("Validator");
Timestamp startTime = lastRS.getTimestamp("StartTime");
Timestamp endTime = lastRS.getTimestamp("EndTime");
String declineReason = lastRS.getString("DeclineReason");
lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false));
}
}catch(SQLException e){
Bukkit.getLogger().log(Level.SEVERE, "getLastDeclined failed", e);
}
return lastDeclined;
}
public void remove() {
Core.sql.update("DELETE FROM CheckedSchematic WHERE SchemOwner = " + this.schemOwner + " AND SchemName = '" + this.schemName + "'");
}
public String getSchemName() {
return schemName;
}
public int getSchemOwner() {
return schemOwner;
}
public int getValidator() {
return validator;
}
public Timestamp getStartTime() {
return startTime;
}
public Timestamp getEndTime() {
return endTime;
}
public String getDeclineReason() {
return declineReason;
}
}

Datei anzeigen

@ -1,43 +0,0 @@
package de.steamwar.schematicsystem.utils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.logging.Level;
public class CommandRemover {
private CommandRemover(){}
private static String packageName = Bukkit.getServer().getClass().getPackage().getName();
private static String version = packageName.substring(packageName.lastIndexOf('.') + 1);
public static void removeAll(String... cmds){
for (String cmd : cmds) removeCommand(cmd);
}
private static void removeCommand(String command) {
try {
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
Field f1 = serverClass.getDeclaredField("commandMap");
f1.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
Field f2 = SimpleCommandMap.class.getDeclaredField("knownCommands");
f2.setAccessible(true);
Map<String, Command> knownCommands = (Map<String, Command>) f2.get(commandMap);
knownCommands.remove(command.toLowerCase());
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not remove command", e);
}
}
}