diff --git a/pom.xml b/pom.xml
index 1c7aee5..1e73429 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,10 +19,6 @@
maven
https://steamwar.de:81/maven/
-
- spigotmc-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
@@ -51,9 +47,9 @@
- org.spigotmc
- spigot-api
- 1.12.2-R0.1-SNAPSHOT
+ steamwar
+ Spigot
+ 1.0
provided
diff --git a/src/de/steamwar/schematicsystem/CheckSchemType.java b/src/de/steamwar/schematicsystem/CheckSchemType.java
new file mode 100644
index 0000000..ddf544b
--- /dev/null
+++ b/src/de/steamwar/schematicsystem/CheckSchemType.java
@@ -0,0 +1,127 @@
+package de.steamwar.schematicsystem;
+
+import com.boydti.fawe.FaweAPI;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import com.sk89q.worldedit.regions.Region;
+import de.warking.hunjy.MySQL.Schematic;
+import de.warking.hunjy.MySQL.SchematicType;
+import de.warking.hunjy.MySQL.WarkingUser;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.logging.Level;
+
+public class CheckSchemType {
+
+ private static final int TNT = Material.TNT.getId();
+ private static final int SLIME = Material.SLIME_BLOCK.getId();
+ private static final int DISPENSER = Material.DISPENSER.getId();
+
+ private static final Map types = new EnumMap<>(SchematicType.class);
+
+ private final String name;
+
+ 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 List forbiddenIds;
+ private final LinkedList 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");
+
+ 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 getCheckList() {
+ return checkList;
+ }
+
+ public SchematicType getAcceptedType(){
+ return SchematicType.fromDB(name);
+ }
+
+ public String autoCheck(Schematic schematic) {
+ Clipboard clipboard;
+
+ try {
+ clipboard = FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + WarkingUser.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);
+ return "Die Schematic konnte nicht geladen werden";
+ }
+
+ Vector dimensions = clipboard.getDimensions();
+
+ if(dimensions.getBlockX() > width || dimensions.getBlockY() > height || dimensions.getBlockZ() > depth)
+ return "Das " + name + " überschreitet die Maximalmaße";
+
+ Region region = clipboard.getRegion();
+ Vector min = region.getMinimumPoint();
+ Vector 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++){
+ Vector vector = new Vector(x, y, z);
+ final int blockId = clipboard.getBlock(vector).getId();
+
+ if(blockId == TNT)
+ tnt++;
+
+ if(blockId == SLIME)
+ slime++;
+
+ if(blockId == DISPENSER)
+ dispenser++;
+
+ if(forbiddenIds.contains(blockId))
+ return "Der Block " + Material.getMaterial(blockId).name() + " ist verboten";
+ }
+ }
+ }
+
+ int tntSlime = tnt + slime;
+ if(maxTNT != 0 && tnt > maxTNT)
+ return "Zu viele TNT-Blöcke";
+ if(maxSlime != 0 && slime > maxSlime)
+ return "Zu viele Schleim-Blöcke";
+ if(maxDispenser != 0 && dispenser > maxDispenser)
+ return "Zu viele Werfer";
+ if(maxTNTSlime != 0 && tntSlime > maxTNTSlime)
+ return "Zu viel Schleim+TNT";
+
+ return null;
+ }
+}
diff --git a/src/de/steamwar/schematicsystem/SchematicSystem.java b/src/de/steamwar/schematicsystem/SchematicSystem.java
index 46482e7..b13ec5b 100644
--- a/src/de/steamwar/schematicsystem/SchematicSystem.java
+++ b/src/de/steamwar/schematicsystem/SchematicSystem.java
@@ -2,63 +2,53 @@ package de.steamwar.schematicsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.steamwar.schematicsystem.check.CheckUtils;
-import de.steamwar.schematicsystem.utils.CommandRemover;
import de.steamwar.schematicsystem.commands.CheckCommand;
import de.steamwar.schematicsystem.commands.SchematicCommand;
import de.steamwar.schematicsystem.listener.PlayerCommandPreProcessListener;
import de.steamwar.schematicsystem.listener.PlayerJoinListener;
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
-import de.steamwar.schematicsystem.utils.Config;
+import de.steamwar.schematicsystem.utils.CommandRemover;
import org.bukkit.Bukkit;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
+import java.io.File;
+
public class SchematicSystem extends JavaPlugin {
public static final String SCHEM_DIR = "/home/minecraft/schematics/";
- public static final String PREFIX = "§6Schematic§8» §7";
-
- private static SchematicSystem instance;
+ public static final String PREFIX = "§eSchematic§8» §7";
+ @Override
public void onEnable() {
- instance = this;
- Config.load();
-
- try {
- CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
- } catch (Exception ex) {
- ex.printStackTrace();
+ if (!new File("plugins/" + getName() + "/config.yml").exists()) {
+ saveDefaultConfig();
+ Bukkit.getLogger().info(SchematicSystem.PREFIX + "config.yml erstellt und geladen!");
+ Bukkit.shutdown();
}
+ FileConfiguration config = getConfig();
+
+ ConfigurationSection types = config.getConfigurationSection("Schematics");
+ for(String sectionName : types.getKeys(false))
+ new CheckSchemType(types.getConfigurationSection(sectionName));
+
+ CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
- getCommand("schematic").setExecutor(new SchematicCommand());
- getCommand("/schematic").setExecutor(new SchematicCommand());
getCommand("schem").setExecutor(new SchematicCommand());
- getCommand("/schem").setExecutor(new SchematicCommand());
getCommand("check").setExecutor(new CheckCommand());
- init();
+ PluginManager pm = Bukkit.getPluginManager();
+ pm.registerEvents(new PlayerJoinListener(), this);
+ pm.registerEvents(new PlayerQuitListener(), this);
+ pm.registerEvents(new PlayerCommandPreProcessListener(), this);
- Bukkit.getScheduler().scheduleAsyncRepeatingTask(instance, () -> {
+ Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if(CheckUtils.getCSchematicsSize() > 0)
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
- }, 0, 20*60*10);
- }
-
- public void onDisable() {
-
- }
-
- public void init() {
- PluginManager pm = Bukkit.getPluginManager();
- pm.registerEvents(new PlayerJoinListener(), instance);
- pm.registerEvents(new PlayerQuitListener(), instance);
- pm.registerEvents(new PlayerCommandPreProcessListener(), instance);
- }
-
-
- public static SchematicSystem getInstance() {
- return instance;
+ }, 0, 6000);
}
public static WorldEditPlugin getWorldEditPlugin() {
diff --git a/src/de/steamwar/schematicsystem/check/CheckSession.java b/src/de/steamwar/schematicsystem/check/CheckSession.java
index c28b062..8cfa079 100644
--- a/src/de/steamwar/schematicsystem/check/CheckSession.java
+++ b/src/de/steamwar/schematicsystem/check/CheckSession.java
@@ -1,11 +1,12 @@
package de.steamwar.schematicsystem.check;
import com.sk89q.worldedit.EditSession;
+import de.steamwar.schematicsystem.CheckSchemType;
+import de.steamwar.schematicsystem.SchematicSystem;
+import de.steamwar.schematicsystem.utils.CheckedSchematic;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
-import de.steamwar.schematicsystem.utils.CheckedSchematic;
-import de.steamwar.schematicsystem.utils.Config;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
@@ -17,50 +18,57 @@ import java.util.*;
public class CheckSession {
- public static ArrayList checkSessions = new ArrayList<>();
+ private static Set checkSessions = new HashSet<>();
private UUID uuid; //player
private Schematic schematic;
- private int position; //position in checklist
+ private ListIterator checkList;
private Timestamp startTime;
private Timestamp stopTime;
- EditSession editSession;
+ private EditSession editSession;
- public CheckSession(UUID uuid, Schematic schematic, int position) {
+ public CheckSession(UUID uuid, Schematic schematic) {
this.uuid = uuid;
this.schematic = schematic;
- this.position = position;
+ checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator();
checkSessions.add(this);
setStartTime();
}
- public static boolean doesPlayerCheck(Player player) {
- UUID uuid = player.getUniqueId();
+ public static boolean currentChecking(){
+ return !checkSessions.isEmpty();
+ }
- for(CheckSession checkSession : checkSessions) {
- if(checkSession.getUuid().equals(uuid))
- return true;
- }
- return false;
+ public static CheckSession getCheckSession() {
+ return checkSessions.iterator().next();
}
public static CheckSession getCheckSession(Player player) {
- for(CheckSession checkSession : checkSessions) {
- if(checkSession.getUuid().equals(player.getUniqueId()))
- return checkSession;
+ for(CheckSession session : checkSessions){
+ if(session.uuid.equals(player.getUniqueId()))
+ return session;
}
return null;
}
public void sendNextCheck() {
+ if(!checkList.hasNext()){
+ Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
+ 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");
+
+ removeSchematic();
+ return;
+ }
+
setStopTime();
- this.position++;
setStartTime();
- if(getChecklist().size() > (this.position + 1)) {
- Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
+ Bukkit.getPlayer(uuid).sendMessage(checkList.next());
+
+ if(checkList.hasNext()){
TextComponent next = new TextComponent("next ");
next.setColor(ChatColor.GREEN);
@@ -72,10 +80,7 @@ public class CheckSession {
next.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
- return;
- } else if(getChecklist().size() == (this.position + 1)) {
- Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
-
+ }else{
TextComponent accept = new TextComponent("accept ");
accept.setColor(ChatColor.GREEN);
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
@@ -86,107 +91,33 @@ public class CheckSession {
accept.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
- return;
}
}
- public List getChecklist() {
- if(schematic.getSchemType() == SchematicType.Cwargear)
- return Config.WarGearCheckList;
- if(schematic.getSchemType() == SchematicType.Cminiwargear)
- return Config.MiniWarGearCheckList;
- if(schematic.getSchemType() == SchematicType.Cwarship)
- return Config.WarShipCheckList;
- if(schematic.getSchemType() == SchematicType.Cairship)
- return Config.AirShipCheckList;
-
- return null;
- }
-
- public String getCheckListEntry(int position) {
- return getChecklist().get(position);
- }
-
- public void allowSchematic() {
- if(schematic.getSchemType() == SchematicType.Cwargear) {
- schematic.setSchemType(SchematicType.wargear);
- }
- if(schematic.getSchemType() == SchematicType.Cminiwargear) {
- schematic.setSchemType(SchematicType.miniwargear);
- }
- if(schematic.getSchemType() == SchematicType.Cwarship) {
- schematic.setSchemType(SchematicType.warship);
- }
- if(schematic.getSchemType() == SchematicType.Cairship) {
- schematic.setSchemType(SchematicType.airship);
- }
- CheckedSchematic checkedSchematic = new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben");
-
- removeSchematic();
- remove();
- }
-
public void declineSchematic(String declineReason) {
- this.schematic.setSchemType(SchematicType.normal);
- CheckedSchematic checkedSchematic = new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
- removeSchematic();
- remove();
- }
+ schematic.setSchemType(SchematicType.Normal);
+ new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
- public void remove() {
- checkSessions.remove(this);
+ removeSchematic();
}
public void removeSchematic() {
this.editSession.undo(editSession);
- }
-
- public UUID getUuid() {
- return uuid;
- }
-
- public void setUuid(UUID uuid) {
- this.uuid = uuid;
+ checkSessions.remove(this);
}
public Schematic getSchematic() {
return schematic;
}
- public void setSchematic(Schematic schematic) {
- this.schematic = schematic;
- }
-
- public int getPosition() {
- return position;
- }
-
- public void setPosition(int position) {
- this.position = position;
- }
-
- public Timestamp getStartTime() {
- return startTime;
- }
-
- public void setStartTime() {
+ private void setStartTime() {
Date date = new Date();
- Timestamp timestamp = new Timestamp(date.getTime());
- this.startTime = timestamp;
+ this.startTime = new Timestamp(date.getTime());
}
- public Timestamp getStopTime() {
- return stopTime;
- }
-
- public void setStopTime() {
+ private void setStopTime() {
Date date = new Date();
- Timestamp timestamp = new Timestamp(date.getTime());
- this.stopTime = timestamp;
- }
-
- public EditSession getEditSession() {
- return editSession;
+ this.stopTime = new Timestamp(date.getTime());
}
public void setEditSession(EditSession editSession) {
diff --git a/src/de/steamwar/schematicsystem/check/CheckUtils.java b/src/de/steamwar/schematicsystem/check/CheckUtils.java
index cbe8cae..8807c43 100644
--- a/src/de/steamwar/schematicsystem/check/CheckUtils.java
+++ b/src/de/steamwar/schematicsystem/check/CheckUtils.java
@@ -1,15 +1,10 @@
package de.steamwar.schematicsystem.check;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.regions.Region;
+import de.steamwar.schematicsystem.SchematicSystem;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.UserGroup;
import de.warking.hunjy.MySQL.WarkingUser;
-import de.steamwar.schematicsystem.SchematicSystem;
-import de.steamwar.schematicsystem.utils.Config;
-import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@@ -17,148 +12,29 @@ import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
public class CheckUtils {
+ private CheckUtils(){}
- public static boolean isSchematicNameAllowed(String schematicName) {
- if(schematicName.contains("/") ||
+ public static boolean schemnameForbidden(String schematicName) {
+ return schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
- schematicName.contains("\"")) {
- return false;
- } else
- return true;
- }
-
- public static Checkresult checkSchematic(Clipboard clipboard, List forbiddenBlocks, String modus) {
-
- Region region = clipboard.getRegion();
- Vector min = region.getMinimumPoint();
- Vector 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++) {
- Vector vector = new Vector(x, y, z);
-
- //tnt check
- if(clipboard.getBlock(vector).getId() == 46)
- tnt++;
-
- //slime check
- if(clipboard.getBlock(vector).getId() == 165) {
- if(!modus.equals("WarGear") && !modus.equals("MiniWarGear"))
- slime++;
- }
-
- //dispenser check
- if(clipboard.getBlock(vector).getId() == 23)
- dispenser++;
-
- //forbidden check
- if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId())) {
- Checkresult checkresult = new Checkresult(false, "VERBOTENE ID", clipboard.getBlock(vector).getId());
- return checkresult;
- }
- }
- }
- }
-
- int tntSlime = tnt + slime;
- if(modus.equalsIgnoreCase("WarGear")) {
- if(Config.WarGearMaxTNT < tnt) {
- Checkresult checkresult = new Checkresult(false, "zu viel TNT");
- return checkresult;
- }
- if(Config.WarGearMaxSchleim < slime) {
- Checkresult checkresult = new Checkresult(false, "zu viel SCHLEIM");
- return checkresult;
- }
- if(Config.WarGearMaxDispenser < dispenser) {
- Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER");
- return checkresult;
- }
- if(Config.WarGearTNTSchleim < tntSlime) {
- Checkresult checkresult = new Checkresult(false, "TNT und SCHLEIM Summe überschritten");
- return checkresult;
- }
- }
- if(modus.equalsIgnoreCase("MiniWarGear")) {
- if(Config.MiniWarGearMaxTNT < tnt) {
- Checkresult checkresult = new Checkresult(false, "zu viel TNT");
- return checkresult;
- }
- if(Config.MiniWarGearMaxSchleim < slime) {
- Checkresult checkresult = new Checkresult(false, "zu viel SCHLEIM");
- return checkresult;
- }
- if(Config.MiniWarGearMaxDispenser < dispenser) {
- Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER");
- return checkresult;
- }
- if(Config.MiniWarGearTNTSchleim < tntSlime) {
- Checkresult checkresult = new Checkresult(false, "TNT und SCHLEIM Summe überschritten");
- return checkresult;
- }
- }
- if(modus.equalsIgnoreCase("WarShip")) {
- if(Config.WarShipMaxTNT < tnt) {
- Checkresult checkresult = new Checkresult(false, "zu viel TNT");
- return checkresult;
- }
- if(Config.WarShipMaxSchleim < slime) {
- Checkresult checkresult = new Checkresult(false, "zu viel SCHLEIM");
- return checkresult;
- }
- if(Config.WarShipMaxDispenser < dispenser) {
- Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER");
- return checkresult;
- }
- if(Config.WarShipTNTSchleim < tntSlime) {
- Checkresult checkresult = new Checkresult(false, "TNT und SCHLEIM Summe überschritten");
- return checkresult;
- }
- }
- if(modus.equalsIgnoreCase("AirShip")) {
- if(Config.AirShipMaxTNT < tnt) {
- Checkresult checkresult = new Checkresult(false, "zu viel TNT");
- return checkresult;
- }
- if(Config.AirShipMaxSchleim < slime) {
- Checkresult checkresult = new Checkresult(false, "zu viel SCHLEIM");
- return checkresult;
- }
- if(Config.AirShipMaxDispenser < dispenser) {
- Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER");
- return checkresult;
- }
- if(Config.AirShipTNTSchleim < tntSlime) {
- Checkresult checkresult = new Checkresult(false, "TNT und SCHLEIM Summe überschritten");
- return checkresult;
- }
- }
- Checkresult checkresult = new Checkresult(true);
- return checkresult;
+ schematicName.contains("\"");
}
public static boolean allowedToCheck(Player player) {
WarkingUser warkingUser = WarkingUser.get(player.getUniqueId());
- if(warkingUser.getUserGroup() == UserGroup.Supporter ||
+ return warkingUser.getUserGroup() == UserGroup.Supporter ||
warkingUser.getUserGroup() == UserGroup.Developer ||
warkingUser.getUserGroup() == UserGroup.Moderator ||
- warkingUser.getUserGroup() == UserGroup.Admin)
- return true;
- return false;
+ warkingUser.getUserGroup() == UserGroup.Admin;
}
public static void sendTeamMembersCSchematics(String message) {
@@ -169,19 +45,16 @@ public class CheckUtils {
}
public static int getCSchematicsSize() {
- int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
-
+ int size = 0;
+ for(SchematicType type : SchematicType.values()){
+ if(type.check())
+ size += Schematic.getAllSchemsOfType(type).size();
+ }
return size;
}
public static String sendTeamMembersCSchematicsInfo() {
- int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
- Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
+ int size = getCSchematicsSize();
String message = "";
if(size == 0)
@@ -194,108 +67,27 @@ public class CheckUtils {
return message;
}
- public static void sendTeammemberSchematicList(Player player, int filesPerPage, int currentPage) {
+ public static void sendTeammemberSchematicList(Player player) {
+ List schematicList = new LinkedList<>();
- List schematicList = getAllCSchems();
+ for(SchematicType type : SchematicType.values()) {
+ if (type.check())
+ schematicList.addAll(Schematic.getAllSchemsOfType(type));
+ }
if(schematicList.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
return;
}
- int pages;
+ player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
- double doublePages = (Double.valueOf(schematicList.size()) / Double.valueOf(filesPerPage));
- int intPages = schematicList.size() / filesPerPage;
-
- if(schematicList.size() <= filesPerPage) {
- pages = 1;
- } else if(doublePages > intPages) {
- pages = (intPages + 1);
- } else
- pages = intPages;
-
- int currPage = currentPage;
-
- if(currPage >= pages) return;
-
- player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " ungeprüfte Schematic(s)§8]§5======");
-
- for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
- if(schematicList.size() <= i) break;
-
- Schematic schematic = schematicList.get(i);
-
- String schematicType = "";
- if(schematic.getSchemType() == SchematicType.Cairship)
- schematicType = "§7[§8CAS§7] ";
- if(schematic.getSchemType() == SchematicType.Cminiwargear)
- schematicType = "§7[§8CMWG§7] ";
- if(schematic.getSchemType() == SchematicType.Cwargear)
- schematicType = "§7[§8CWG§7] ";
- if(schematic.getSchemType() == SchematicType.Cwarship)
- schematicType = "§7[§8CWS§7] ";
-
- String schematicPlayer = "§7[§a" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§7] ";
-
- TextComponent schematics = new TextComponent(schematicType + schematicPlayer + "§b" + schematic.getSchemName());
+ for(Schematic schematic : schematicList) {
+ TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
schematics.setBold(true);
-
- schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen...").create()));
+ schematics.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()));
-
player.spigot().sendMessage(schematics);
}
-
- if(pages <= 1) return;
-
- if(currPage == 0) {
- TextComponent nextPage = new TextComponent("Nächste Seite >>");
- nextPage.setColor(ChatColor.RED);
- nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
- nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist 1"));
- player.spigot().sendMessage(nextPage);
- } else if((currPage + 1) == pages) {
- TextComponent beforePage = new TextComponent("<< Vorherige Seite");
- beforePage.setColor(ChatColor.RED);
- beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
- beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage - 1)));
- player.spigot().sendMessage(beforePage);
- } else {
- TextComponent beforePage = new TextComponent("<< Seite ");
- beforePage.setColor(ChatColor.RED);
- beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
- beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage - 1)));
-
- TextComponent nextPage = new TextComponent(">>");
- nextPage.setColor(ChatColor.RED);
- nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
- nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check checklist " + (currPage + 1)));
-
- beforePage.addExtra(nextPage);
- player.spigot().sendMessage(beforePage);
- }
}
-
- public static List getAllCSchems() {
-
- List wargears = Schematic.getAllSchemsOfType(SchematicType.Cwargear);
- List miniwargears = Schematic.getAllSchemsOfType(SchematicType.Cminiwargear);
- List warships = Schematic.getAllSchemsOfType(SchematicType.Cwarship);
- List airships = Schematic.getAllSchemsOfType(SchematicType.Cairship);
-
- List schematicList = new ArrayList<>();
-
- for(Schematic schematic : wargears)
- schematicList.add(schematic);
- for(Schematic schematic : miniwargears)
- schematicList.add(schematic);
- for(Schematic schematic : warships)
- schematicList.add(schematic);
- for(Schematic schematic : airships)
- schematicList.add(schematic);
-
- return schematicList;
- }
-
}
diff --git a/src/de/steamwar/schematicsystem/check/Checkresult.java b/src/de/steamwar/schematicsystem/check/Checkresult.java
deleted file mode 100644
index 2b7090d..0000000
--- a/src/de/steamwar/schematicsystem/check/Checkresult.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package de.steamwar.schematicsystem.check;
-
-import java.util.ArrayList;
-
-public class Checkresult {
-
- public static ArrayList checkresults = new ArrayList<>();
-
- private boolean check; //schematic allowed / declined
- private String reason; //general reason
- private int blockID = -1; //not allowed block id / must be initialized -1
-
- public Checkresult(boolean check) {
- this.check = check;
- checkresults.add(this);
- }
-
- public Checkresult(boolean check, String reason) {
- this.check = check;
- this.reason = reason;
- checkresults.add(this);
- }
-
- public Checkresult(boolean check, String reason, int blockID) {
- this.check = check;
- this.reason = reason;
- this.blockID = blockID;
- checkresults.add(this);
- }
-
- public void remove() {
- checkresults.remove(this);
- }
-
- public boolean isCheck() {
- return check;
- }
-
- public void setCheck(boolean check) {
- this.check = check;
- }
-
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public int getBlockID() {
- return blockID;
- }
-
- public void setBlockID(int blockID) {
- this.blockID = blockID;
- }
-}
diff --git a/src/de/steamwar/schematicsystem/commands/CheckCommand.java b/src/de/steamwar/schematicsystem/commands/CheckCommand.java
index 0f73531..666a600 100644
--- a/src/de/steamwar/schematicsystem/commands/CheckCommand.java
+++ b/src/de/steamwar/schematicsystem/commands/CheckCommand.java
@@ -8,8 +8,8 @@ import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckSession;
import de.steamwar.schematicsystem.check.CheckUtils;
import de.warking.hunjy.MySQL.Schematic;
-import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
+import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.logging.Level;
public class CheckCommand implements CommandExecutor {
@@ -29,216 +30,136 @@ public class CheckCommand implements CommandExecutor {
Player player = (Player) sender;
if(CheckUtils.allowedToCheck(player)) {
-
if(args.length == 0) {
- sendHelp(player);
+ help(player);
return false;
}
- if(args.length == 1) {
- if(args[0].equalsIgnoreCase("list")) {
- CheckUtils.sendTeammemberSchematicList(player, 15, 0);
- return false;
- }
+ CheckSession checkSession;
- if(args[0].equalsIgnoreCase("next")) {
- CheckSession checkSession = CheckSession.getCheckSession(player);
- if(checkSession != null) {
+ switch(args[0]){
+ case "list":
+ CheckUtils.sendTeammemberSchematicList(player);
+ break;
+ case "next":
+ case "allow":
+ checkSession = session(player);
+ if(checkSession != null)
checkSession.sendNextCheck();
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
- return false;
- }
- }
-
- if(args[0].equalsIgnoreCase("allow")) {
- CheckSession checkSession = CheckSession.getCheckSession(player);
- if(checkSession != null) {
- if(checkSession.getPosition() == (checkSession.getChecklist().size() - 1)) {
-
- String schemType = "";
- if(checkSession.getSchematic().getSchemType() == SchematicType.Cwargear)
- schemType = SchematicType.wargear.name();
- if(checkSession.getSchematic().getSchemType() == SchematicType.Cminiwargear)
- schemType = SchematicType.miniwargear.name();
- if(checkSession.getSchematic().getSchemType() == SchematicType.Cwarship)
- schemType = SchematicType.warship.name();
- if(checkSession.getSchematic().getSchemType() == SchematicType.Cairship)
- schemType = SchematicType.airship.name();
-
- player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §aist nun als §6" + schemType + " §afreigegeben!");
- checkSession.allowSchematic();
- return false;
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch nicht alles überprüft!");
- return false;
- }
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
- return false;
- }
- }
-
- if(args[0].equalsIgnoreCase("cancel")) {
- if(CheckSession.doesPlayerCheck(player)) {
- CheckSession checkSession = CheckSession.getCheckSession(player);
+ break;
+ case "cancel":
+ checkSession = session(player);
+ if(checkSession != null){
checkSession.removeSchematic();
- checkSession.remove();
player.sendMessage(SchematicSystem.PREFIX + "§aDer Prüfvorgang wurde abgebrochen!");
- return false;
- } else
- player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
- return false;
- }
- return false;
- }
-
- if(args.length == 2) {
- if(args[0].equalsIgnoreCase("list")) {
- int currentPage;
- try {
- currentPage = Integer.parseInt(args[1]);
- } catch (NumberFormatException ex) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Zahl angeben!");
- return false;
}
- CheckUtils.sendTeammemberSchematicList(player, 15, currentPage);
- return false;
- }
- }
-
- if(args.length == 3) {
-
- if(args[0].equalsIgnoreCase("schematic")) {
- String schemName = args[1];
- String owner = args[2];
-
- if(CheckSession.getCheckSession(player) != null) {
+ break;
+ case "schematic":
+ if(!player.getWorld().getName().equals(player.getUniqueId().toString())) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen musst du dich auf deinem Bauserver befinden!");
+ return false;
+ }else if(args.length < 3){
+ help(player);
+ return false;
+ }else if(CheckSession.getCheckSession(player) != null) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst schon eine Schematic!");
return false;
}
- if(!CheckUtils.isSchematicNameAllowed(schemName)) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
+ WarkingUser user = WarkingUser.get(args[2]);
+ if(user.getUUID() == null){
+ player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer");
return false;
}
- WarkingUser warkingUser = WarkingUser.get(owner);
- if(warkingUser.getUUID() != null) {
+ Schematic schematic = Schematic.getSchemFromDB(args[1], user.getUUID());
+ if(schematic == null){
+ player.sendMessage(SchematicSystem.PREFIX + "§cSchematic gibts nicht");
+ return false;
+ }else if(!schematic.getSchemType().check()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cSchematic ist nicht zu prüfen");
+ return false;
+ }else if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht deine eigenen Schematics prüfen");
+ return false;
+ }
- Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID());
- if(schematic != null) {
- if(schematic.getSchemType() != SchematicType.normal &&
- schematic.getSchemType() != SchematicType.airship &&
- schematic.getSchemType() != SchematicType.warship &&
- schematic.getSchemType() != SchematicType.wargear &&
- schematic.getSchemType() != SchematicType.miniwargear) {
-
- if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht deine eigenen Schematics prüfen!");
- return false;
- }
- if(!player.getWorld().getName().equals(player.getUniqueId().toString())) {
- player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen musst du dich auf deinem Bauserver befinden!");
- return false;
- }
-
- List worldPlayers = player.getWorld().getPlayers();
- for(Player players : worldPlayers) {
- if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
- WarkingUser warkingUsers = WarkingUser.get(players.getUniqueId());
- if(!CheckUtils.allowedToCheck(players) &&
- !warkingUsers.getUUID().toString().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID().toString())) {
- player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich niemand außer dir, " +
- "der Schematic Owner oder ein anderes zum Prüfen befähigtes Teammitglied auf deinem Bauserver befinden!");
- return false;
- }
- }
- }
- for(CheckSession checkSession : CheckSession.checkSessions) {
- if(checkSession.getSchematic().getSchemName().equals(schematic.getSchemName())
- && checkSession.getSchematic().getSchemOwner() == schematic.getSchemOwner()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!");
- return false;
- }
- }
-
- File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + schemName + ".schematic");
- if(!file.exists()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NO SUCH FILE");
- return false;
- }
-
- try {
- 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 checkSession = new CheckSession(player.getUniqueId(), schematic, -1);
- checkSession.sendNextCheck();
-
- checkSession.setEditSession(schematicFAWE.paste(weWorld, v));
- } catch (IOException ex) {
- player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! ERROR: PASTE / CHECK_SESSION");
- ex.printStackTrace();
- return false;
- }
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic ist nicht zum Prüfen eingesendet!");
+ List worldPlayers = player.getWorld().getPlayers();
+ for(Player players : worldPlayers) {
+ if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
+ WarkingUser warkingUsers = WarkingUser.get(players.getUniqueId());
+ if(!CheckUtils.allowedToCheck(players) &&
+ !warkingUsers.getUUID().toString().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID().toString())) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich kein Unbeteiligter auf deinem Bauserver befinden!");
return false;
}
-
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! SCHEMATIC DOES NOT EXIST");
- return false;
}
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! USER DOES NOT EXIST");
+ }
+
+ File file = new File(SchematicSystem.SCHEM_DIR + user.getUUID().toString(),schematic.getSchemName() + ".schematic");
+ if(!file.exists()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic gibts nicht?!?!");
return false;
}
- return false;
- }
- }
- if(args.length >= 2) {
- if(args[0].equalsIgnoreCase("decline")) {
+ try {
+ com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file);
+ Location playerLocation = player.getLocation();
- CheckSession checkSession = CheckSession.getCheckSession(player);
- if(checkSession != null) {
+ 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);
- String message = "";
- for (int i = 1; i < args.length; i++) {
- message = message + args[i] + " ";
- }
- 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!");
- checkSession.declineSchematic(message);
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
+
+ checkSession = new CheckSession(player.getUniqueId(), schematic);
+ checkSession.sendNextCheck();
+ checkSession.setEditSession(schematicFAWE.paste(weWorld, v));
+ } catch (IOException ex) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cSchematic konnte nicht geladen/gepastet werden");
+ Bukkit.getLogger().log(Level.SEVERE, "Failed to load schematic", ex);
return false;
}
- return false;
- }
+ break;
+ case "decline":
+ if(args.length < 2) {
+ help(player);
+ return false;
+ }
+ checkSession = CheckSession.getCheckSession(player);
+ if(checkSession == null)
+ return false;
+
+ StringBuilder message = new StringBuilder();
+ for (int i = 1; i < args.length; i++) message.append(args[i]).append(" ");
+
+ player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!");
+ checkSession.declineSchematic(message.toString());
+ break;
+ default:
+ help(player);
}
}
return false;
}
- public void sendHelp(Player player) {
- if(CheckUtils.allowedToCheck(player)) {
- player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
- player.sendMessage("§8/ckeck list - §6Zeigt die Liste der ungeprüften Schematics");
- player.sendMessage("§8/ckeck schematic - §6Zum Checken einer Schematic");
- player.sendMessage("§8/ckeck allow - §6Schematic freigeben");
- player.sendMessage("§8/ckeck decline - §6Schematic nicht freigeben");
- player.sendMessage("§8/check cancel - §6Bricht das Prüfen ab");
+ private void help(Player player) {
+ if(CheckUtils.allowedToCheck(player)){
+ player.sendMessage("§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics");
+ player.sendMessage("§8/§echeck schematic [SchematicName] [Besitzer] §8- §7Zum Checken einer Schematic");
+ player.sendMessage("§8/§echeck allow §8- §7Schematic freigeben");
+ player.sendMessage("§8/§echeck decline [Grund] §8- §7Schematic nicht freigeben");
+ player.sendMessage("§8/§echeck cancel §8- §7Bricht das Prüfen ab");
}
}
+
+ private CheckSession session(Player player){
+ CheckSession checkSession = CheckSession.getCheckSession(player);
+ if(checkSession == null)
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
+ return checkSession;
+ }
}
diff --git a/src/de/steamwar/schematicsystem/commands/GUI.java b/src/de/steamwar/schematicsystem/commands/GUI.java
new file mode 100644
index 0000000..468249e
--- /dev/null
+++ b/src/de/steamwar/schematicsystem/commands/GUI.java
@@ -0,0 +1,188 @@
+package de.steamwar.schematicsystem.commands;
+
+import de.steamwar.inventory.SWInventory;
+import de.steamwar.inventory.SWItem;
+import de.steamwar.inventory.SWListInv;
+import de.steamwar.schematicsystem.SchematicSystem;
+import de.steamwar.schematicsystem.utils.CheckedSchematic;
+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 org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.SkullMeta;
+
+import java.io.File;
+import java.util.*;
+
+class GUI {
+ private GUI(){}
+
+ static void changeType(Player p, Schematic schem){
+ List> types = new LinkedList<>();
+ for(SchematicType type : SchematicType.values()){
+ if(!type.isAssignable())
+ continue;
+
+ SWItem item = new SWItem(Material.STONE_BUTTON, type.name());
+ if(type.fightType())
+ item.setEnchanted(true);
+
+ types.add(new Pair<>(item, type));
+ }
+
+ SWListInv inv = new SWListInv<>(p, "Typ ändern", (clickType, schematicType) -> {
+ SchematicCommand.changetype(p, schem, schematicType);
+ p.closeInventory();
+ }, types);
+ inv.setCallback(-999, (ClickType click) -> p.closeInventory());
+ inv.open();
+ }
+
+ static void delete(Player p, Schematic schem){
+ SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
+ inv.setItem(0, Material.INK_SACK, (byte) 1, "§eLöschen", click -> {
+ File file = new File(SchematicSystem.SCHEM_DIR + p.getUniqueId(), schem.getSchemName() + ".schematic");
+ file.delete();
+ schem.remove();
+
+ List checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
+ for(CheckedSchematic checkedSchematic : checkedSchematics) {
+ if(checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
+ checkedSchematic.getSchemName().equals(schem.getSchemName()))
+ checkedSchematic.remove();
+ }
+ p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
+ p.closeInventory();
+ });
+ inv.setItem(8, Material.INK_SACK, (byte) 14, "§cAbbruch", click -> p.closeInventory());
+ inv.setCallback(-999, click -> p.closeInventory());
+ inv.open();
+ }
+
+ static void delmembers(Player p, Schematic schem){
+ List> members = new LinkedList<>();
+ for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
+ WarkingUser user = WarkingUser.get(member.getMember());
+
+ 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 inv = new SWListInv<>(p, "Mitglieder entfernen", (clickType, member) -> {
+ member.remove();
+ p.closeInventory();
+ delmembers(p, schem);
+ }, members);
+ inv.setCallback(-999, (ClickType click) -> p.closeInventory());
+ inv.open();
+ }
+
+ private static void changeItem(Player p, Schematic schem){
+ List> materials = new LinkedList<>();
+ for(Material material : Material.values()){
+ SWItem item = new SWItem(material, "§7" + material.name());
+ if(item.getItemMeta() != null && material.isItem())
+ materials.add(new Pair<>(item, material));
+ }
+
+ SWListInv inv = new SWListInv<>(p, "Item ändern", (clickType, material) -> {
+ schem.setItem(material.name());
+ p.closeInventory();
+ info(p, schem);
+ }, materials);
+ inv.setCallback(-999, (ClickType click) -> p.closeInventory());
+ inv.open();
+ }
+
+ private static void info(Player p, Schematic schem){
+ SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
+ inv.setItem(0, Material.WOOD_AXE, "§eLaden", click -> {
+ SchematicCommand.load(p, schem);
+ p.closeInventory();
+ });
+
+ if(schem.getSchemOwner() == WarkingUser.get(p.getUniqueId()).getId()){
+ if(schem.getSchemType().writeable()){
+ List checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
+ for(CheckedSchematic checkedSchematic : checkedSchematics) {
+ if(checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
+ checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
+ inv.setItem(1, Material.INK_SACK, (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
+ break;
+ }
+ }
+ }
+ Material mat = Material.CAULDRON_ITEM;
+ if(schem.getItem() != null && !schem.getItem().equals(""))
+ mat = Material.valueOf(schem.getItem());
+
+ inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
+ p.closeInventory();
+ changeItem(p, schem);
+ });
+ inv.setItem(4, Material.CAULDRON_ITEM, "§e" + schem.getSchemType().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
+ p.closeInventory();
+ changeType(p, schem);
+ });
+ inv.setItem(6, Material.SKULL_ITEM, "§eMitglieder", click -> {
+ p.closeInventory();
+ delmembers(p, schem);
+ });
+ inv.setItem(8, Material.INK_SACK, (byte) 1, "§cLöschen", click -> {
+ p.closeInventory();
+ delete(p, schem);
+ });
+ }else{
+ inv.setItem(4, Material.CAULDRON_ITEM, "§e" + schem.getSchemType().name(), click -> {});
+
+ WarkingUser owneruser = WarkingUser.get(schem.getSchemOwner());
+ SWItem owner = new SWItem();
+ ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
+ SkullMeta headmeta = (SkullMeta)head.getItemMeta();
+ headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID()));
+ headmeta.setDisplayName("§7von §e" + owneruser.getUserName());
+ head.setItemMeta(headmeta);
+ owner.setItemStack(head);
+ inv.setItem(6, owner);
+ }
+
+ inv.setCallback(-999, click -> p.closeInventory());
+ inv.open();
+ }
+
+ static void list(Player p){
+ List> schemList = new LinkedList<>();
+ List schems = Schematic.getSchemsAccessibleByUser(p.getUniqueId());
+
+ for(Schematic schem : schems) {
+ Material m;
+ if (schem.getItem().isEmpty())
+ m = Material.CAULDRON_ITEM;
+ else
+ m = Material.valueOf(schem.getItem());
+
+ SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {});
+ schemList.add(new Pair<>(item, schem));
+ }
+
+ SWListInv inv = new SWListInv<>(p, "§eSchematicliste", (clickType, schem) -> {
+ p.closeInventory();
+ info(p, schem);
+ }, schemList);
+ inv.setCallback(-999, (ClickType click) -> p.closeInventory());
+ inv.open();
+ }
+}
diff --git a/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/src/de/steamwar/schematicsystem/commands/SchematicCommand.java
index 1468ce1..fdd3d39 100644
--- a/src/de/steamwar/schematicsystem/commands/SchematicCommand.java
+++ b/src/de/steamwar/schematicsystem/commands/SchematicCommand.java
@@ -2,17 +2,18 @@ package de.steamwar.schematicsystem.commands;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EmptyClipboardException;
-import com.sk89q.worldedit.Vector;
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.session.ClipboardHolder;
+import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckUtils;
-import de.steamwar.schematicsystem.check.Checkresult;
-import de.warking.hunjy.MySQL.*;
import de.steamwar.schematicsystem.utils.CheckedSchematic;
-import de.steamwar.schematicsystem.utils.Config;
+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.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@@ -32,667 +33,468 @@ import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
+import java.util.logging.Level;
public class SchematicCommand implements CommandExecutor {
+ private static final int FILES_PER_PAGE = 15;
+ private static final EnumSet 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 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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if(!(sender instanceof Player))
+ return false;
+ Player player = (Player) sender;
- if(!(sender instanceof Player)) {
+ if(args.length == 0){
+ help(player);
return false;
}
- Player player = (Player) sender;
-
- switch (args.length) {
- case 0:
- sendHelp(player);
+ switch(args[0].toLowerCase()){
+ case "gui":
+ GUI.list(player);
break;
-
- case 1:
- if(args[0].equalsIgnoreCase("list")) {
- sendPlayerSchematicList(0, 15, WarkingUser.get(player.getUniqueId()).getId(), player);
- return false;
- }
-
- if(args[0].equalsIgnoreCase("help")) {
- sendHelp(player);
- return false;
- }
-
- sendHelp(player);
- return false;
-
- case 2:
- if(args[0].equalsIgnoreCase("list")) {
- if(args[1].equalsIgnoreCase("public")) {
- sendPlayerSchematicList(0, 15, 0, player);
- return false;
- }
-
- try {
- sendPlayerSchematicList(Integer.parseInt(args[1]), 15, WarkingUser.get(player.getUniqueId()).getId(), player);
- return false;
- } catch (NumberFormatException ex) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!");
- return false;
- }
- }
-
- if(args[0].equalsIgnoreCase("load")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
-
- if(schematic == null)
- schematic = Schematic.getSchemFromDB(args[1], 0); //public schematic
-
- if (schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
- return false;
- }
-
- try {
- Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
-
- File folder = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString() + "/");
- if(!folder.exists()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
- return false;
- }
- File file;
-
- if(WarkingUser.get(schematic.getSchemOwner()).getUUID() != player.getUniqueId()) {
- file = new File(SchematicSystem.SCHEM_DIR + WarkingUser.get(schematic.getSchemOwner()).getUUID() + "/", args[1] + ".schematic");
- } else {
- file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/", args[1] + ".schematic");
- }
- SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(FaweAPI.load(file).getClipboard(), FaweAPI.getWorld(player.getWorld().getName()).getWorldData()));
- player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7geladen.");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
- if(args[0].equalsIgnoreCase("delete")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
- player.sendMessage(SchematicSystem.PREFIX + "§cZum Löschen musst du der Owner der Schematic sein!");
- return false;
- }
-
- TextComponent message = new TextComponent("§6Möchtest du die Schematic wirklich löschen?");
- message.setBold(true);
- message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Wähle eine Option...").create()));
-
- TextComponent ja = new TextComponent("§aja");
- ja.setBold(true);
- ja.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§4Schematic löschen...").create()));
- ja.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem savedelete " + args[1]));
-
- player.spigot().sendMessage(message);
- player.spigot().sendMessage(ja);
- return false;
- }
-
- if(args[0].equalsIgnoreCase("savedelete")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
- player.sendMessage(SchematicSystem.PREFIX + "§cZum Löschen musst du der Owner der Schematic sein!");
- return false;
- }
-
- File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
- file.delete();
- schematic.remove();
-
- List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
- for(CheckedSchematic checkedSchematic : checkedSchematics) {
- if(checkedSchematic.getSchemOwner() == schematic.getSchemOwner() &&
- checkedSchematic.getSchemName().equals(schematic.getSchemName()))
- checkedSchematic.remove();
- }
-
- player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gelöscht.");
- return false;
- }
-
- if(args[0].equalsIgnoreCase("save")) {
-
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- try {
- if(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard() == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic != null) {
- if(schematic.getSchemType() != SchematicType.normal) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diesen Schematic Typ nicht überschreiben!");
- return false;
- }
- }
-
- File folder = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString() + "/");
- if(!folder.exists()) {
- folder.mkdir();
- Files.setPosixFilePermissions(folder.toPath(),
- EnumSet.of(PosixFilePermission.OWNER_READ,
- PosixFilePermission.OWNER_WRITE,
- PosixFilePermission.GROUP_READ,
- PosixFilePermission.OTHERS_READ,
- PosixFilePermission.OTHERS_WRITE,
- PosixFilePermission.OWNER_EXECUTE,
- PosixFilePermission.OTHERS_EXECUTE));
- }
-
- File file = new File(folder, args[1] + ".schematic");
- file.createNewFile();
-
- try {
- Files.setPosixFilePermissions(file.toPath(),
- EnumSet.of(PosixFilePermission.OWNER_READ,
- PosixFilePermission.OWNER_WRITE,
- PosixFilePermission.GROUP_READ,
- PosixFilePermission.OTHERS_READ,
- PosixFilePermission.OTHERS_WRITE));
- } catch (Exception ex) { }
-
- ClipboardFormat.SCHEMATIC.getWriter(new FileOutputStream(file)).write(
- FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard(),
- FaweAPI.wrapPlayer(player).getSession().getClipboard().getWorldData());
-
-
- if(schematic != null && schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) {
- player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7überschrieben!");
- } else {
- Schematic newSchematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gespeichert!");
- }
-
- } catch (IOException ex) { ex.printStackTrace(); } catch (EmptyClipboardException ex) { ex.printStackTrace(); }
- return false;
- }
-
- if(args[0].equalsIgnoreCase("getschemchangetype")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- TextComponent normal = new TextComponent("§7[§anormal§7]");
- normal.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " normal"));
-
- TextComponent wargear = new TextComponent("§7[§awargear§7]");
- wargear.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " wargear"));
-
- TextComponent miniwargear = new TextComponent("§7[§aminiwargear§7]");
- miniwargear.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " miniwargear"));
-
- TextComponent airship = new TextComponent("§7[§aairship§7]");
- airship.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " airship"));
-
- TextComponent warship = new TextComponent("§7[§awarship§7]");
- warship.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " warship"));
-
- player.spigot().sendMessage(normal);
- player.spigot().sendMessage(wargear);
- player.spigot().sendMessage(miniwargear);
- player.spigot().sendMessage(airship);
- player.spigot().sendMessage(warship);
- return false;
- }
-
- if(args[0].equalsIgnoreCase("getmoreinfo")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
- for(CheckedSchematic checkedSchematic : checkedSchematics) {
- if(checkedSchematic.getSchemName().equals(schematic.getSchemName()) &&
- checkedSchematic.getSchemOwner() == schematic.getSchemOwner()) {
- player.sendMessage("§bStart: " + checkedSchematic.getStartTime());
- player.sendMessage("§bEnde: " + checkedSchematic.getEndTime());
- player.sendMessage("§bPrüfer: " + WarkingUser.get(checkedSchematic.getValidator()).getUserName());
- player.sendMessage("§bGrund: " + checkedSchematic.getDeclineReason());
- }
- }
- return false;
- }
-
- sendHelp(player);
- return false;
-
- case 3:
- if(args[0].equalsIgnoreCase("info")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- WarkingUser warkingUser = WarkingUser.get(Integer.valueOf(args[2]));
- if(warkingUser.getUUID() == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Benutzer hat keine Schematic mit diesem Namen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], warkingUser.getId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- player.sendMessage("§6Name: §7" + schematic.getSchemName());
-
- if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) {
- TextComponent typ = new TextComponent("§6Typ: §7" + schematic.getSchemType().name());
- typ.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Typ ändern").create()));
- typ.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getschemchangetype " + schematic.getSchemName()));
- player.spigot().sendMessage(typ);
- } else
- player.sendMessage("§6Typ: §7" + schematic.getSchemType().name());
-
- List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
- for(int i = checkedSchematics.size() -1; i >= 0; i--) {
- if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
- checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
- player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason());
- TextComponent mehr = new TextComponent("§9mehr...");
- mehr.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getmoreinfo " + schematic.getSchemName()));
- player.spigot().sendMessage(mehr);
- break;
- }
- }
-
- if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
- player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
- } else {
-
- List schematicMembers = new ArrayList<>();
- for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
- schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
- }
- if(schematicMembers.size() <= 3) {
- player.sendMessage("§6Member: §7" + schematicMembers.toString());
- } else
- player.sendMessage("§6Member: §7...");
- }
-
- TextComponent loadSchematic = new TextComponent("LADEN");
- loadSchematic.setColor(ChatColor.DARK_GREEN);
- loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
- player.spigot().sendMessage(loadSchematic);
-
- if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
- TextComponent deleteSchematic = new TextComponent("LÖSCHEN");
- deleteSchematic.setColor(ChatColor.RED);
- deleteSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + schematic.getSchemName()));
- player.spigot().sendMessage(deleteSchematic);
- }
- return false;
- }
-
- if(args[0].equalsIgnoreCase("list")) {
- if(args[1].equalsIgnoreCase("public")) {
- try {
- sendPlayerSchematicList(Integer.parseInt(args[2]), 15, 0, player);
- return false;
- } catch (NumberFormatException ex) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!");
- return false;
- }
- }
- return false;
- }
-
- if(args[0].equalsIgnoreCase("changetype")) {
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- Clipboard clipboard;
- try {
- clipboard = FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic")).getClipboard();
- } catch (IOException ex) {
- player.sendMessage(SchematicSystem.PREFIX + "§cBeim Ausführen des Commands ist ein Fehler aufgetreten!");
- return false;
- }
-
- Vector origin = clipboard.getOrigin();
- Vector dimensions = clipboard.getDimensions();
- if(schematic.getSchemType() != SchematicType.normal) {
-
- if(args[2].equalsIgnoreCase("normal")) {
- schematic.setSchemType(SchematicType.normal);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6normal §7gesetzt!");
- return false;
- } else if(args[2].equalsIgnoreCase("airship") ||
- args[2].equalsIgnoreCase("miniwargear") ||
- args[2].equalsIgnoreCase("wargear") ||
- args[2].equalsIgnoreCase("warship")) {
- player.sendMessage(SchematicSystem.PREFIX + "Diese Schematic ist entweder schon freigegeben oder du versuchst eine bereits zum Prüfen gesendete Schematic erneut einzusenden!");
- return false;
- }
- } else {
-
- if(args[2].equalsIgnoreCase("airship")) {
- if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe) {
- Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.AirShipForbiddenIds, "AirShip");
- if(!checkresult.isCheck()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]");
- checkresult.remove();
- return false;
- }
- schematic.setSchemType(SchematicType.Cairship);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!");
- CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]");
- checkresult.remove();
- } else
- player.sendMessage(SchematicSystem.PREFIX + "§cDein Airship überschreitet die Maximalmaße!");
- return false;
- }
-
- if(args[2].equalsIgnoreCase("miniwargear")) {
- if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe) {
- Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, "MiniWarGear");
- if(!checkresult.isCheck()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]");
- checkresult.remove();
- return false;
- }
- schematic.setSchemType(SchematicType.Cminiwargear);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!");
- CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]");
- checkresult.remove();
- } else
- player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear überschreitet die Maximalmaße!");
- return false;
- }
-
- if(args[2].equalsIgnoreCase("wargear")) {
- if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe) {
- Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.WarGearForbiddenIds, "WarGear");
- if(!checkresult.isCheck()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]");
- checkresult.remove();
- return false;
- }
- schematic.setSchemType(SchematicType.Cwargear);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!");
- CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]");
- checkresult.remove();
- } else
- player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear überschreitet die Maximalmaße!");
- return false;
- }
-
- if(args[2].equalsIgnoreCase("warship")) {
- if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe) {
- Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.WarShipForbiddenIds, "WarShip");
- if(!checkresult.isCheck()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]");
- checkresult.remove();
- return false;
- }
- schematic.setSchemType(SchematicType.Cwarship);
- player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!");
- CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]");
- checkresult.remove();
- } else
- player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip überschreitet die Maximalmaße!");
- return false;
- }
- }
- player.sendMessage("§8/schem changetype ");
-
- return false;
- }
-
- if(args[0].equalsIgnoreCase("addmember")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
- return false;
- } else {
- WarkingUser warkingUser = WarkingUser.get(args[2]);
- if(warkingUser.getUUID() != null) {
- if(schematic.getSchemOwner() != warkingUser.getId()) {
- if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet!");
- return false;
- } else {
- SchematicMember schematicMember = new SchematicMember(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
- player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
-
- Player target = Bukkit.getPlayer(warkingUser.getUUID());
- if(target != null)
- target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §6" + schematic.getSchemName() + " §7von §6" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§7.");
- return false;
- }
-
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst dich nicht auf deine eigene Schematic adden!");
- return false;
- }
- } else {
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
- return false;
- }
- }
- }
-
- if(args[0].equalsIgnoreCase("delmember")) {
- if(!CheckUtils.isSchematicNameAllowed(args[1])) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!");
- return false;
- }
-
- Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
- if(schematic == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
- return false;
- }
-
- if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
- return false;
- } else {
- WarkingUser warkingUser = WarkingUser.get(args[2]);
- if(warkingUser.getUUID() == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
- return false;
- }
-
- if(schematic.getSchemOwner() == warkingUser.getId()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst dich nicht von deiner eigenen Schematic removen!");
- return false;
- }
-
- SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
- if(schematicMember == null) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic geaddet!");
- return false;
- }
-
- schematicMember.remove();
- player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7.");
-
- Player target = Bukkit.getPlayer(warkingUser.getUUID());
- if(target != null)
- target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7von §6" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§7.");
- return false;
- }
- }
-
- sendHelp(player);
+ case "list":
+ list(player, args);
+ break;
+ case "load":
+ load(player, args);
+ break;
+ case "delete":
+ delete(player, args);
+ break;
+ case "save":
+ save(player, args);
+ break;
+ case "info":
+ info(player, args);
+ break;
+ case "changetype":
+ changetype(player, args);
+ break;
+ case "addmember":
+ addmember(player, args);
+ break;
+ case "delmember":
+ delmember(player, args);
+ break;
+ default:
+ help(player);
}
return false;
}
- public void sendHelp(Player player) {
- player.sendMessage(SchematicSystem.PREFIX + "Befehle:");
- player.sendMessage("§8/schem - §6Zeigt Informationen zum Plugin");
- player.sendMessage("§8/schem help - §6Zeigt eine Liste mit Befehlen");
- player.sendMessage("§8/schem list (public) - §6Listet deine (oder Public) Schematics auf");
- player.sendMessage("§8/schem load - §6Du lädst eine Schematic");
- player.sendMessage("§8/schem save - §6Du speicherst dein Clipboard als Datei");
- player.sendMessage("§8/schem changetype - §6Ändert den Typ deiner Schematic");
- player.sendMessage("§8/schem delete - §6Löscht eine Schematic");
- player.sendMessage("§8/schem info - §6Zeigt dir Informationen zu der Schematic");
- player.sendMessage("§8/schem addmember - §6Fügt einen Spieler zu einer Schematic hinzu");
- player.sendMessage("§8/schem delmember - §6Entfernt einen Spieler von einer Schematic");
+ private void list(Player player, String[] args){
+ if(args.length <= 1){
+ sendPlayerSchematicList(0, WarkingUser.get(player.getUniqueId()).getId(), player);
+ return;
+ }
+ if("public".equalsIgnoreCase(args[1])){
+ if(args.length == 3){
+ try {
+ sendPlayerSchematicList(Integer.parseInt(args[2]), 0, player);
+ } catch (NumberFormatException ex) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
+ }
+ }else
+ sendPlayerSchematicList(0, 0, player);
+ return;
+ }
+
+ try {
+ sendPlayerSchematicList(Integer.parseInt(args[1]), WarkingUser.get(player.getUniqueId()).getId(), player);
+ } catch (NumberFormatException ex) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
+ }
}
- public static void sendPlayerSchematicList(int currentPage, int filesPerPage, int schemOwner, Player player) {
+ private boolean invalidSchemName(Player player, String name){
+ if(CheckUtils.schemnameForbidden(name)){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
+ return true;
+ }
+ return false;
+ }
+
+ private Schematic getSchem(Player player, String name){
+ if(invalidSchemName(player, name))
+ return null;
+
+ Schematic schematic = Schematic.getSchemFromDB(name, player.getUniqueId());
+ if(schematic == null)
+ schematic = Schematic.getSchemFromDB(name, 0); //public schematic
+
+ if (schematic == null) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
+ return null;
+ }
+
+ return schematic;
+ }
+
+ private void load(Player player, String[] args){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ load(player, schematic);
+ }
+
+ static void load(Player player, Schematic schematic){
+ try{
+ Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
+
+ File file = new File(SchematicSystem.SCHEM_DIR + WarkingUser.get(schematic.getSchemOwner()).getUUID(), schematic.getSchemName() + ".schematic");
+
+ if(!file.exists()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
+ return;
+ }
+ Clipboard clipboard = FaweAPI.load(file).getClipboard();
+ if(clipboard == null)
+ throw new IOException("File not a schematic");
+
+ SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, FaweAPI.getWorld(player.getWorld().getName()).getWorldData()));
+ player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
+ }catch (IOException ex){
+ Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", ex);
+ player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Laden der Schematic. Bitte wende dich an einen Developer");
+ }
+ }
+
+ private void delete(Player player, String[] args){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ if(WarkingUser.get(player.getUniqueId()).getId() != schematic.getSchemOwner()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur deine eigenen Schematics löschen");
+ return;
+ }
+
+ GUI.delete(player, schematic);
+ }
+
+ private void save(Player player, String[] args){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ if(invalidSchemName(player, args[1]))
+ return;
+
+ Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
+ if(schematic != null && !schematic.getSchemType().writeable()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diese Schematic nicht überschreiben");
+ return;
+ }
+
+ try {
+ ClipboardHolder clipboardHolder = FaweAPI.wrapPlayer(player).getSession().getClipboard();
+ Clipboard clipboard = clipboardHolder.getClipboard();
+ if(clipboard == null) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer");
+ return;
+ }
+
+ File folder = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId().toString());
+ 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");
+ }else{
+ new Schematic(args[1], player.getUniqueId(), "", SchematicType.Normal);
+ 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){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ if(args.length < 3) {
+ GUI.changeType(player, schematic);
+ return;
+ }
+
+ SchematicType type = SchematicType.fromDB(args[2]);
+ if(type == null || !type.isAssignable()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDiesen Schematictypen gibt es nicht");
+ return;
+ }
+
+ changetype(player, schematic, type);
+ }
+
+ static void changetype(Player player, Schematic schematic, SchematicType type){
+ if(schematic.getSchemType() == type){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic hat bereits diesen Typen");
+ return;
+ }
+
+ if(type.writeable()){
+ schematic.setSchemType(type);
+ player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
+ }else if(type.fightType()){
+ if(schematic.getSchemType().check()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu hast diese Schematic bereits eingesendet");
+ return;
+ }
+
+ String reason = CheckSchemType.get(type).autoCheck(schematic);
+ if(reason != null){
+ player.sendMessage(SchematicSystem.PREFIX + "§c" + reason);
+ return;
+ }
+
+ schematic.setSchemType(type.checkType());
+ player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah auf Regelkonformität überprüft");
+ CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + player.getName() + " §7hat ein " + type.name() + " eingesendet");
+ }
+ }
+
+ private void info(Player player, String[] args){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ player.sendMessage("§eName: §7" + schematic.getSchemName());
+ player.sendMessage("§eTyp: §7" + schematic.getSchemType().name());
+
+ List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
+ for(int i = checkedSchematics.size() -1; i >= 0; i--) {
+ if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
+ checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
+ player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason());
+ break;
+ }
+ }
+
+ if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
+ player.sendMessage("§eBesitzer: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
+ } else {
+ List schematicMembers = new ArrayList<>();
+ for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
+ schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
+ }
+ player.sendMessage("§eMitglieder: §7" + schematicMembers.toString());
+ }
+
+ TextComponent loadSchematic = new TextComponent("LADEN");
+ loadSchematic.setColor(ChatColor.DARK_GREEN);
+ loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
+ player.spigot().sendMessage(loadSchematic);
+ }
+
+ private void addmember(Player player, String[] args){
+ if(args.length < 3){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur auf deine eigene Schematic Mitglieder hinzufügen");
+ return;
+ }
+
+ WarkingUser warkingUser = WarkingUser.get(args[2]);
+ if(warkingUser.getUUID() == null){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
+ return;
+ }
+ if(schematic.getSchemOwner() == warkingUser.getId()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
+ return;
+ }
+
+ if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
+ return;
+ }
+
+ new SchematicMember(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
+ player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §e" + schematic.getSchemName());
+
+ Player target = Bukkit.getPlayer(warkingUser.getUUID());
+ if(target != null)
+ target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + schematic.getSchemName() + " §7von §e" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
+ }
+
+ private void delmember(Player player, String[] args){
+ if(args.length < 2){
+ help(player);
+ return;
+ }
+
+ Schematic schematic = getSchem(player, args[1]);
+ if(schematic == null)
+ return;
+
+ if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur von deinen eigenen Schematics Mitglieder entfernen");
+ return;
+ }
+
+ if(args.length < 3){
+ GUI.delmembers(player, schematic);
+ return;
+ }
+
+ WarkingUser warkingUser = WarkingUser.get(args[2]);
+ if(warkingUser.getUUID() == null){
+ player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
+ return;
+ }
+ if(schematic.getSchemOwner() == warkingUser.getId()){
+ player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
+ return;
+ }
+
+ SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
+ if(schematicMember == null) {
+ player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic hinzugefügt");
+ return;
+ }
+
+ schematicMember.remove();
+ player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName());
+
+ Player target = Bukkit.getPlayer(warkingUser.getUUID());
+ 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());
+ }
+
+ private void help(Player player) {
+ player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
+ player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
+ player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
+ player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
+ player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
+ player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
+ player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
+ player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic");
+ player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic");
+ player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu");
+ 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) {
List schematicList = Schematic.getSchemsAccessibleByUser(schemOwner);
if(schematicList.isEmpty()) {
- player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch keine Schematic(s)!");
+ player.sendMessage(SchematicSystem.PREFIX + "§cDu hast noch keine Schematics");
return;
}
int pages;
- double doublePages = (Double.valueOf(schematicList.size()) / Double.valueOf(filesPerPage));
- int intPages = schematicList.size() / filesPerPage;
+ double doublePages = schematicList.size() / (double) FILES_PER_PAGE;
+ int intPages = schematicList.size() / FILES_PER_PAGE;
- if(schematicList.size() <= filesPerPage) {
+ if(schematicList.size() <= FILES_PER_PAGE) {
pages = 1;
- } else if(doublePages > intPages) {
+ }else if(doublePages > intPages){
pages = (intPages + 1);
- } else
+ }else
pages = intPages;
- int currPage = currentPage;
+ if(currentPage >= pages) return;
- if(currPage >= pages) return;
+ player.sendMessage("§eSeite " + (currentPage + 1) + " §8/ " + pages + " §8| §e" + schematicList.size() + " Schematics");
- player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " Schematic(s)§8]§5======");
-
- for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
+ for(int i = currentPage * FILES_PER_PAGE; i < (currentPage * FILES_PER_PAGE) + FILES_PER_PAGE; i++) {
if(schematicList.size() <= i) break;
Schematic schematic = schematicList.get(i);
- String schematicType = "";
- if(schematic.getSchemType() == SchematicType.normal)
- schematicType = "§7[§8---§7] ";
- if(schematic.getSchemType() == SchematicType.airship)
- schematicType = "§7[§8AS§7] ";
- if(schematic.getSchemType() == SchematicType.miniwargear)
- schematicType = "§7[§8MWG§7] ";
- if(schematic.getSchemType() == SchematicType.wargear)
- schematicType = "§7[§8WG§7] ";
- if(schematic.getSchemType() == SchematicType.warship)
- schematicType = "§7[§8WS§7] ";
- if(schematic.getSchemType() == SchematicType.Cairship)
- schematicType = "§7[§8CAS§7] ";
- if(schematic.getSchemType() == SchematicType.Cminiwargear)
- schematicType = "§7[§8CMWG§7] ";
- if(schematic.getSchemType() == SchematicType.Cwargear)
- schematicType = "§7[§8CWG§7] ";
- if(schematic.getSchemType() == SchematicType.Cwarship)
- schematicType = "§7[§8CWS§7] ";
+ String schematicPlayer = "";
+ if(schematic.getSchemOwner() != schemOwner)
+ schematicPlayer = " §8von §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName();
- String schematicPlayer;
- if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
- schematicPlayer = "§7[§aM§7] ";
- } else
- schematicPlayer = "§7[§cO§7] ";
-
- TextComponent schematics = new TextComponent(schematicType + schematicPlayer + "§b" + schematic.getSchemName());
+ TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
schematics.setBold(true);
- schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic verwalten...").create()));
- schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName() + " " + schematic.getSchemOwner()));
+ schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
+ schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName()));
player.spigot().sendMessage(schematics);
}
if(pages <= 1) return;
- if(currPage == 0) {
- TextComponent nextPage = new TextComponent("Nächste Seite >>");
- nextPage.setColor(ChatColor.RED);
- nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
- nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list 1"));
- player.spigot().sendMessage(nextPage);
- } else if((currPage + 1) == pages) {
- TextComponent beforePage = new TextComponent("<< Vorherige Seite");
+ TextComponent beforePage = new TextComponent("««");
+ if(currentPage > 0){
+ beforePage.setColor(ChatColor.YELLOW);
+ beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
+ beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currentPage - 1)));
+ }else
beforePage.setColor(ChatColor.RED);
- beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
- beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage - 1)));
- player.spigot().sendMessage(beforePage);
- } else {
- TextComponent beforePage = new TextComponent("<< Seite ");
- beforePage.setColor(ChatColor.RED);
- beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
- beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage - 1)));
- TextComponent nextPage = new TextComponent(">>");
+ TextComponent nextPage = new TextComponent(" Seite »»");
+ if(currentPage < pages-1){
+ nextPage.setColor(ChatColor.YELLOW);
+ nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));
+ nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currentPage + 1)));
+ }else
nextPage.setColor(ChatColor.RED);
- nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
- nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (currPage + 1)));
- beforePage.addExtra(nextPage);
- player.spigot().sendMessage(beforePage);
- }
+ beforePage.addExtra(nextPage);
+ player.spigot().sendMessage(beforePage);
}
-
}
diff --git a/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java b/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java
index 3ef5480..b0928ee 100644
--- a/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java
+++ b/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java
@@ -15,12 +15,9 @@ public class PlayerCommandPreProcessListener implements Listener {
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
return;
- if(CheckSession.doesPlayerCheck(player)) {
+ if(CheckSession.getCheckSession() != null) {
event.setCancelled(true);
- player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt!");
- //eventuell Admin Benachrichtigen
+ player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt.");
}
}
-
-
}
diff --git a/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java b/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java
index 0b788dd..c43718f 100644
--- a/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java
+++ b/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java
@@ -21,21 +21,33 @@ public class PlayerJoinListener implements Listener {
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
- CheckSession currentChecking = null;
- for(Player players : player.getWorld().getPlayers()) {
- if(CheckSession.doesPlayerCheck(players))
- currentChecking = CheckSession.getCheckSession(players);
- }
- if(currentChecking != null) {
- if(!CheckUtils.allowedToCheck(player) && !WarkingUser.get(
- currentChecking.getSchematic().getSchemOwner()).getUUID().toString()
- .equals(player.getUniqueId().toString())) {
+ if(CheckSession.currentChecking()){
+ CheckSession current = CheckSession.getCheckSession();
+ if(!CheckUtils.allowedToCheck(player) && !WarkingUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())){
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!");
player.kickPlayer("");
return;
}
}
- File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
+
+ addNewSchems(player);
+
+ if(CheckUtils.allowedToCheck(player))
+ player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
+
+ List uncheckedSchematics = new ArrayList<>();
+
+ for(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)!");
+ }
+
+ private void addNewSchems(Player player){
+ File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId());
File[] files = file.listFiles();
if(files != null && files.length > 0) {
@@ -48,28 +60,12 @@ public class PlayerJoinListener implements Listener {
}
}
- for(int i = 0; i < files.length; i++) {
- if(!schematicNames.contains(files[i].getName().substring(0, files[i].getName().lastIndexOf('.')))) {
- String fileName = files[i].getName();
- new Schematic(fileName.substring(0, fileName.lastIndexOf('.')), player.getUniqueId(), "", SchematicType.normal);
+ for (File value : files) {
+ if (!schematicNames.contains(value.getName().substring(0, value.getName().lastIndexOf('.')))) {
+ String fileName = value.getName();
+ new Schematic(fileName.substring(0, fileName.lastIndexOf('.')), player.getUniqueId(), "", SchematicType.Normal);
}
}
}
-
- if(CheckUtils.allowedToCheck(player))
- player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
-
- WarkingUser warkingUser = WarkingUser.get(player.getUniqueId());
- List uncheckedSchematics = new ArrayList<>();
-
- uncheckedSchematics.addAll(Schematic.getSchemsOfType(warkingUser.getId(), SchematicType.Cairship));
- uncheckedSchematics.addAll(Schematic.getSchemsOfType(warkingUser.getId(), SchematicType.Cwarship));
- uncheckedSchematics.addAll(Schematic.getSchemsOfType(warkingUser.getId(), SchematicType.Cwargear));
- uncheckedSchematics.addAll(Schematic.getSchemsOfType(warkingUser.getId(), SchematicType.Cminiwargear));
-
- if(!uncheckedSchematics.isEmpty())
- player.sendMessage(SchematicSystem.PREFIX + "§7Du hast noch §6" + uncheckedSchematics.size() + " §7ungeprüfte Schematic(s)!");
}
-
-
}
diff --git a/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java b/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java
index bed5d41..90178bd 100644
--- a/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java
+++ b/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java
@@ -11,11 +11,10 @@ public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
- if(CheckSession.doesPlayerCheck(player)) {
- CheckSession.getCheckSession(player).removeSchematic();
- CheckSession.getCheckSession(player).remove();
- }
+ CheckSession checkSession = CheckSession.getCheckSession(player);
+ if(checkSession == null)
+ return;
+
+ checkSession.removeSchematic();
}
-
-
}
diff --git a/src/de/steamwar/schematicsystem/utils/CheckedSchematic.java b/src/de/steamwar/schematicsystem/utils/CheckedSchematic.java
index 887990f..0b5bfdf 100644
--- a/src/de/steamwar/schematicsystem/utils/CheckedSchematic.java
+++ b/src/de/steamwar/schematicsystem/utils/CheckedSchematic.java
@@ -3,32 +3,34 @@ 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.ArrayList;
+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 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){
- SchemName = MySQL.disarmString(schemName);
- SchemOwner = schemOwner;
- Validator = validator;
- StartTime = startTime;
- EndTime = endTime;
- DeclineReason = MySQL.disarmString(declineReason);
+ 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();
}
@@ -37,10 +39,6 @@ public class CheckedSchematic {
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true);
}
- public CheckedSchematic(String schemName, int schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
- this(schemName, schemOwner, WarkingUser.get(validator).getId(), 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);
}
@@ -49,7 +47,7 @@ public class CheckedSchematic {
sql.update("INSERT INTO CheckedSchematic" +
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason)" +
" VALUES" +
- " ('"+ SchemName + "', '" + SchemOwner + "', '" + Validator + "', '" + StartTime.toString() + "', '" + EndTime.toString() + "', '" + DeclineReason + "')");
+ " ('"+ schemName + "', '" + schemOwner + "', '" + validator + "', '" + startTime.toString() + "', '" + endTime.toString() + "', '" + declineReason + "')");
}
public static List getLastDeclined(UUID schemOwner){
@@ -57,7 +55,7 @@ public class CheckedSchematic {
}
public static List getLastDelined(int schemOwner){
- List lastDeclined = new ArrayList<>();
+ List lastDeclined = new LinkedList<>();
try{
ResultSet lastRS = sql.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = '" + schemOwner + "' AND DeclineReason != '' ORDER BY EndTime DESC");
while(lastRS.next()){
@@ -69,36 +67,36 @@ public class CheckedSchematic {
lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false));
}
}catch(SQLException e){
- e.printStackTrace();
+ 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 + "'");
+ Core.sql.update("DELETE FROM CheckedSchematic WHERE SchemOwner = " + this.schemOwner + " AND SchemName = '" + this.schemName + "'");
}
public String getSchemName() {
- return SchemName;
+ return schemName;
}
public int getSchemOwner() {
- return SchemOwner;
+ return schemOwner;
}
public int getValidator() {
- return Validator;
+ return validator;
}
public Timestamp getStartTime() {
- return StartTime;
+ return startTime;
}
public Timestamp getEndTime() {
- return EndTime;
+ return endTime;
}
public String getDeclineReason() {
- return DeclineReason;
+ return declineReason;
}
}
diff --git a/src/de/steamwar/schematicsystem/utils/CommandRemover.java b/src/de/steamwar/schematicsystem/utils/CommandRemover.java
index ff44620..d5fbf5c 100644
--- a/src/de/steamwar/schematicsystem/utils/CommandRemover.java
+++ b/src/de/steamwar/schematicsystem/utils/CommandRemover.java
@@ -6,30 +6,36 @@ 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);
+ private static String version = packageName.substring(packageName.lastIndexOf('.') + 1);
- public static void removeAll(String... cmds) throws Exception {
- for (int i = 0; i < cmds.length; i++)
- removeCommand(cmds[i]);
+ public static void removeAll(String... cmds){
+ for (String cmd : cmds) removeCommand(cmd);
}
- public static boolean removeCommand(String command) throws Exception {
- Class> serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
+ 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 knownCommands = (Map) f2.get(commandMap);
+ Field f1 = serverClass.getDeclaredField("commandMap");
+ f1.setAccessible(true);
+ SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
- return knownCommands.remove(command.toLowerCase()) != null;
+ Field f2 = SimpleCommandMap.class.getDeclaredField("knownCommands");
+ f2.setAccessible(true);
+ Map knownCommands = (Map) f2.get(commandMap);
+
+ knownCommands.remove(command.toLowerCase());
+ } catch (Exception e) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not remove command", e);
+ }
}
diff --git a/src/de/steamwar/schematicsystem/utils/Config.java b/src/de/steamwar/schematicsystem/utils/Config.java
deleted file mode 100644
index 5dab586..0000000
--- a/src/de/steamwar/schematicsystem/utils/Config.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package de.steamwar.schematicsystem.utils;
-
-import de.steamwar.schematicsystem.SchematicSystem;
-import org.bukkit.Bukkit;
-import org.bukkit.configuration.file.FileConfiguration;
-
-import java.io.File;
-import java.util.List;
-
-public class Config {
-
- public static double WarGearBreite;
- public static double WarGearHöhe;
- public static double WarGearTiefe;
- public static int WarGearMaxTNT;
- public static int WarGearMaxSchleim;
- public static int WarGearTNTSchleim;
- public static int WarGearMaxDispenser;
- public static List WarGearForbiddenIds;
- public static List WarGearCheckList;
-
- public static double MiniWarGearBreite;
- public static double MiniWarGearHöhe;
- public static double MiniWarGearTiefe;
- public static int MiniWarGearMaxTNT;
- public static int MiniWarGearMaxSchleim;
- public static int MiniWarGearTNTSchleim;
- public static int MiniWarGearMaxDispenser;
- public static List MiniWarGearForbiddenIds;
- public static List MiniWarGearCheckList;
-
- public static double WarShipBreite;
- public static double WarShipHöhe;
- public static double WarShipTiefe;
- public static int WarShipMaxTNT;
- public static int WarShipMaxSchleim;
- public static int WarShipTNTSchleim;
- public static int WarShipMaxDispenser;
- public static List WarShipForbiddenIds;
- public static List WarShipCheckList;
-
- public static double AirShipBreite;
- public static double AirShipHöhe;
- public static double AirShipTiefe;
- public static int AirShipMaxTNT;
- public static int AirShipMaxSchleim;
- public static int AirShipTNTSchleim;
- public static int AirShipMaxDispenser;
- public static List AirShipForbiddenIds;
- public static List AirShipCheckList;
-
- public static void load() {
- if (!new File("plugins/" + SchematicSystem.getInstance().getName() + "/config.yml").exists()) {
- SchematicSystem.getInstance().saveDefaultConfig();
- System.out.println(SchematicSystem.PREFIX + "config.yml erstellt und geladen!");
- Bukkit.shutdown();
- }
- FileConfiguration config = SchematicSystem.getInstance().getConfig();
-
- WarGearBreite = config.getDouble("Schematics.WarGear.Breite");
- WarGearHöhe = config.getDouble("Schematics.WarGear.Höhe");
- WarGearTiefe = config.getDouble("Schematics.WarGear.Tiefe");
- WarGearMaxTNT = config.getInt("Schematics.WarGear.TNT");
- WarGearMaxSchleim = config.getInt("Schematics.WarGear.Schleim");
- WarGearTNTSchleim = config.getInt("Schematics.WarGear.TNTSchleim");
- WarGearMaxDispenser = config.getInt("Schematics.WarGear.Dispenser");
- WarGearForbiddenIds = config.getIntegerList("Schematics.WarGear.ForbiddenIds");
- WarGearCheckList = config.getStringList("Schematics.WarGear.CheckList");
-
- MiniWarGearBreite = config.getDouble("Schematics.MiniWarGear.Breite");
- MiniWarGearHöhe = config.getDouble("Schematics.MiniWarGear.Höhe");
- MiniWarGearTiefe = config.getDouble("Schematics.MiniWarGear.Tiefe");
- MiniWarGearMaxTNT = config.getInt("Schematics.MiniWarGear.TNT");
- MiniWarGearMaxSchleim = config.getInt("Schematics.MiniWarGear.Schleim");
- MiniWarGearTNTSchleim = config.getInt("Schematics.MiniWarGear.TNTSchleim");
- MiniWarGearMaxDispenser = config.getInt("Schematics.MiniWarGear.Dispenser");
- MiniWarGearForbiddenIds = config.getIntegerList("Schematics.MiniWarGear.ForbiddenIds");
- MiniWarGearCheckList = config.getStringList("Schematics.MiniWarGear.CheckList");
-
- WarShipBreite = config.getDouble("Schematics.WarShip.Breite");
- WarShipHöhe = config.getDouble("Schematics.WarShip.Höhe");
- WarShipTiefe = config.getDouble("Schematics.WarShip.Tiefe");
- WarShipMaxTNT = config.getInt("Schematics.WarShip.TNT");
- WarShipMaxSchleim = config.getInt("Schematics.WarShip.Schleim");
- WarShipTNTSchleim = config.getInt("Schematics.WarShip.TNTSchleim");
- WarShipMaxDispenser = config.getInt("Schematics.WarShip.Dispenser");
- WarShipForbiddenIds = config.getIntegerList("Schematics.WarShip.ForbiddenIds");
- WarShipCheckList = config.getStringList("Schematics.WarShip.CheckList");
-
- AirShipBreite = config.getDouble("Schematics.AirShip.Breite");
- AirShipHöhe = config.getDouble("Schematics.AirShip.Höhe");
- AirShipTiefe = config.getDouble("Schematics.AirShip.Tiefe");
- AirShipMaxTNT = config.getInt("Schematics.AirShip.TNT");
- AirShipMaxSchleim = config.getInt("Schematics.AirShip.Schleim");
- AirShipTNTSchleim = config.getInt("Schematics.AirShip.TNTSchleim");
- AirShipMaxDispenser = config.getInt("Schematics.AirShip.Dispenser");
- AirShipForbiddenIds = config.getIntegerList("Schematics.AirShip.ForbiddenIds");
- AirShipCheckList = config.getStringList("Schematics.AirShip.CheckList");
- }
-}
diff --git a/src/plugin.yml b/src/plugin.yml
index e0a5766..442c679 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -1,12 +1,13 @@
name: SchematicSystem
-version: 1.0
-author: [Yaruma3341, Lixfel]
+version: "1.0"
+authors: [Yaruma3341, Lixfel]
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
main: de.steamwar.schematicsystem.SchematicSystem
commands:
- schematic:
- /schematic:
schem:
- /schem:
+ aliases:
+ - schematic
+ - /schematic
+ - /schem
check:
\ No newline at end of file