Rework
Dieser Commit ist enthalten in:
Ursprung
bc8f0bae8c
Commit
8f8db48af7
10
pom.xml
10
pom.xml
@ -19,10 +19,6 @@
|
|||||||
<id>maven</id>
|
<id>maven</id>
|
||||||
<url>https://steamwar.de:81/maven/</url>
|
<url>https://steamwar.de:81/maven/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>spigotmc-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -51,9 +47,9 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
127
src/de/steamwar/schematicsystem/CheckSchemType.java
Normale Datei
127
src/de/steamwar/schematicsystem/CheckSchemType.java
Normale Datei
@ -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<SchematicType, CheckSchemType> types = new EnumMap<>(SchematicType.class);
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final int depth;
|
||||||
|
|
||||||
|
private final int maxTNT;
|
||||||
|
private final int maxSlime;
|
||||||
|
private final int maxTNTSlime;
|
||||||
|
private final int maxDispenser;
|
||||||
|
private final List<Integer> forbiddenIds;
|
||||||
|
private final LinkedList<String> checkList;
|
||||||
|
|
||||||
|
CheckSchemType(ConfigurationSection section) {
|
||||||
|
name = section.getName();
|
||||||
|
width = section.getInt("width");
|
||||||
|
height = section.getInt("height");
|
||||||
|
depth = section.getInt("depth");
|
||||||
|
|
||||||
|
maxTNT = section.getInt("maxTNT");
|
||||||
|
maxSlime = section.getInt("maxSlime");
|
||||||
|
maxTNTSlime = section.getInt("maxTNTSlime");
|
||||||
|
maxDispenser = section.getInt("maxDispenser");
|
||||||
|
|
||||||
|
forbiddenIds = section.getIntegerList("forbiddenIds");
|
||||||
|
checkList = new LinkedList<>(section.getStringList("checkList"));
|
||||||
|
types.put(SchematicType.fromDB(name), this);
|
||||||
|
types.put(SchematicType.fromDB("c" + name), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckSchemType get(SchematicType type){
|
||||||
|
return types.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> getCheckList() {
|
||||||
|
return checkList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SchematicType getAcceptedType(){
|
||||||
|
return SchematicType.fromDB(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
}
|
@ -2,63 +2,53 @@ package de.steamwar.schematicsystem;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import de.steamwar.schematicsystem.check.CheckUtils;
|
import de.steamwar.schematicsystem.check.CheckUtils;
|
||||||
import de.steamwar.schematicsystem.utils.CommandRemover;
|
|
||||||
import de.steamwar.schematicsystem.commands.CheckCommand;
|
import de.steamwar.schematicsystem.commands.CheckCommand;
|
||||||
import de.steamwar.schematicsystem.commands.SchematicCommand;
|
import de.steamwar.schematicsystem.commands.SchematicCommand;
|
||||||
import de.steamwar.schematicsystem.listener.PlayerCommandPreProcessListener;
|
import de.steamwar.schematicsystem.listener.PlayerCommandPreProcessListener;
|
||||||
import de.steamwar.schematicsystem.listener.PlayerJoinListener;
|
import de.steamwar.schematicsystem.listener.PlayerJoinListener;
|
||||||
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
|
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
|
||||||
import de.steamwar.schematicsystem.utils.Config;
|
import de.steamwar.schematicsystem.utils.CommandRemover;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class SchematicSystem extends JavaPlugin {
|
public class SchematicSystem extends JavaPlugin {
|
||||||
|
|
||||||
public static final String SCHEM_DIR = "/home/minecraft/schematics/";
|
public static final String SCHEM_DIR = "/home/minecraft/schematics/";
|
||||||
public static final String PREFIX = "§6Schematic§8» §7";
|
public static final String PREFIX = "§eSchematic§8» §7";
|
||||||
|
|
||||||
private static SchematicSystem instance;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
|
||||||
|
|
||||||
Config.load();
|
if (!new File("plugins/" + getName() + "/config.yml").exists()) {
|
||||||
|
saveDefaultConfig();
|
||||||
try {
|
Bukkit.getLogger().info(SchematicSystem.PREFIX + "config.yml erstellt und geladen!");
|
||||||
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
|
Bukkit.shutdown();
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
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("/schem").setExecutor(new SchematicCommand());
|
|
||||||
getCommand("check").setExecutor(new CheckCommand());
|
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)
|
if(CheckUtils.getCSchematicsSize() > 0)
|
||||||
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
|
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
|
||||||
}, 0, 20*60*10);
|
}, 0, 6000);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldEditPlugin getWorldEditPlugin() {
|
public static WorldEditPlugin getWorldEditPlugin() {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package de.steamwar.schematicsystem.check;
|
package de.steamwar.schematicsystem.check;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
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.Schematic;
|
||||||
import de.warking.hunjy.MySQL.SchematicType;
|
import de.warking.hunjy.MySQL.SchematicType;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
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.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -17,50 +18,57 @@ import java.util.*;
|
|||||||
|
|
||||||
public class CheckSession {
|
public class CheckSession {
|
||||||
|
|
||||||
public static ArrayList<CheckSession> checkSessions = new ArrayList<>();
|
private static Set<CheckSession> checkSessions = new HashSet<>();
|
||||||
|
|
||||||
private UUID uuid; //player
|
private UUID uuid; //player
|
||||||
private Schematic schematic;
|
private Schematic schematic;
|
||||||
private int position; //position in checklist
|
private ListIterator<String> checkList;
|
||||||
|
|
||||||
private Timestamp startTime;
|
private Timestamp startTime;
|
||||||
private Timestamp stopTime;
|
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.uuid = uuid;
|
||||||
this.schematic = schematic;
|
this.schematic = schematic;
|
||||||
this.position = position;
|
checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator();
|
||||||
|
|
||||||
checkSessions.add(this);
|
checkSessions.add(this);
|
||||||
setStartTime();
|
setStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doesPlayerCheck(Player player) {
|
public static boolean currentChecking(){
|
||||||
UUID uuid = player.getUniqueId();
|
return !checkSessions.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
for(CheckSession checkSession : checkSessions) {
|
public static CheckSession getCheckSession() {
|
||||||
if(checkSession.getUuid().equals(uuid))
|
return checkSessions.iterator().next();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckSession getCheckSession(Player player) {
|
public static CheckSession getCheckSession(Player player) {
|
||||||
for(CheckSession checkSession : checkSessions) {
|
for(CheckSession session : checkSessions){
|
||||||
if(checkSession.getUuid().equals(player.getUniqueId()))
|
if(session.uuid.equals(player.getUniqueId()))
|
||||||
return checkSession;
|
return session;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendNextCheck() {
|
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();
|
setStopTime();
|
||||||
this.position++;
|
|
||||||
setStartTime();
|
setStartTime();
|
||||||
if(getChecklist().size() > (this.position + 1)) {
|
Bukkit.getPlayer(uuid).sendMessage(checkList.next());
|
||||||
Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
|
|
||||||
|
if(checkList.hasNext()){
|
||||||
|
|
||||||
TextComponent next = new TextComponent("next ");
|
TextComponent next = new TextComponent("next ");
|
||||||
next.setColor(ChatColor.GREEN);
|
next.setColor(ChatColor.GREEN);
|
||||||
@ -72,10 +80,7 @@ public class CheckSession {
|
|||||||
|
|
||||||
next.addExtra(decline);
|
next.addExtra(decline);
|
||||||
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
|
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
|
||||||
return;
|
}else{
|
||||||
} else if(getChecklist().size() == (this.position + 1)) {
|
|
||||||
Bukkit.getPlayer(uuid).sendMessage(getCheckListEntry(this.position));
|
|
||||||
|
|
||||||
TextComponent accept = new TextComponent("accept ");
|
TextComponent accept = new TextComponent("accept ");
|
||||||
accept.setColor(ChatColor.GREEN);
|
accept.setColor(ChatColor.GREEN);
|
||||||
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
||||||
@ -86,107 +91,33 @@ public class CheckSession {
|
|||||||
|
|
||||||
accept.addExtra(decline);
|
accept.addExtra(decline);
|
||||||
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
|
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> 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) {
|
public void declineSchematic(String declineReason) {
|
||||||
this.schematic.setSchemType(SchematicType.normal);
|
schematic.setSchemType(SchematicType.Normal);
|
||||||
CheckedSchematic checkedSchematic = new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
|
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
|
||||||
removeSchematic();
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove() {
|
removeSchematic();
|
||||||
checkSessions.remove(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSchematic() {
|
public void removeSchematic() {
|
||||||
this.editSession.undo(editSession);
|
this.editSession.undo(editSession);
|
||||||
}
|
checkSessions.remove(this);
|
||||||
|
|
||||||
public UUID getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUuid(UUID uuid) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Schematic getSchematic() {
|
public Schematic getSchematic() {
|
||||||
return schematic;
|
return schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSchematic(Schematic schematic) {
|
private void setStartTime() {
|
||||||
this.schematic = schematic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(int position) {
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime() {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
Timestamp timestamp = new Timestamp(date.getTime());
|
this.startTime = new Timestamp(date.getTime());
|
||||||
this.startTime = timestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getStopTime() {
|
private void setStopTime() {
|
||||||
return stopTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStopTime() {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
Timestamp timestamp = new Timestamp(date.getTime());
|
this.stopTime = new Timestamp(date.getTime());
|
||||||
this.stopTime = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EditSession getEditSession() {
|
|
||||||
return editSession;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEditSession(EditSession editSession) {
|
public void setEditSession(EditSession editSession) {
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
package de.steamwar.schematicsystem.check;
|
package de.steamwar.schematicsystem.check;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import de.warking.hunjy.MySQL.Schematic;
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
import de.warking.hunjy.MySQL.SchematicType;
|
import de.warking.hunjy.MySQL.SchematicType;
|
||||||
import de.warking.hunjy.MySQL.UserGroup;
|
import de.warking.hunjy.MySQL.UserGroup;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
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.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
@ -17,148 +12,29 @@ import net.md_5.bungee.api.chat.TextComponent;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CheckUtils {
|
public class CheckUtils {
|
||||||
|
private CheckUtils(){}
|
||||||
|
|
||||||
public static boolean isSchematicNameAllowed(String schematicName) {
|
public static boolean schemnameForbidden(String schematicName) {
|
||||||
if(schematicName.contains("/") ||
|
return schematicName.contains("/") ||
|
||||||
schematicName.contains("\\") ||
|
schematicName.contains("\\") ||
|
||||||
schematicName.contains("<") ||
|
schematicName.contains("<") ||
|
||||||
schematicName.contains(">") ||
|
schematicName.contains(">") ||
|
||||||
schematicName.contains("^") ||
|
schematicName.contains("^") ||
|
||||||
schematicName.contains("°") ||
|
schematicName.contains("°") ||
|
||||||
schematicName.contains("'") ||
|
schematicName.contains("'") ||
|
||||||
schematicName.contains("\"")) {
|
schematicName.contains("\"");
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Checkresult checkSchematic(Clipboard clipboard, List<Integer> 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean allowedToCheck(Player player) {
|
public static boolean allowedToCheck(Player player) {
|
||||||
WarkingUser warkingUser = WarkingUser.get(player.getUniqueId());
|
WarkingUser warkingUser = WarkingUser.get(player.getUniqueId());
|
||||||
if(warkingUser.getUserGroup() == UserGroup.Supporter ||
|
return warkingUser.getUserGroup() == UserGroup.Supporter ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Developer ||
|
warkingUser.getUserGroup() == UserGroup.Developer ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Moderator ||
|
warkingUser.getUserGroup() == UserGroup.Moderator ||
|
||||||
warkingUser.getUserGroup() == UserGroup.Admin)
|
warkingUser.getUserGroup() == UserGroup.Admin;
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTeamMembersCSchematics(String message) {
|
public static void sendTeamMembersCSchematics(String message) {
|
||||||
@ -169,19 +45,16 @@ public class CheckUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getCSchematicsSize() {
|
public static int getCSchematicsSize() {
|
||||||
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
|
int size = 0;
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
|
for(SchematicType type : SchematicType.values()){
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
|
if(type.check())
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
|
size += Schematic.getAllSchemsOfType(type).size();
|
||||||
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sendTeamMembersCSchematicsInfo() {
|
public static String sendTeamMembersCSchematicsInfo() {
|
||||||
int size = Schematic.getAllSchemsOfType(SchematicType.Cairship).size() +
|
int size = getCSchematicsSize();
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cminiwargear).size() +
|
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cwargear).size() +
|
|
||||||
Schematic.getAllSchemsOfType(SchematicType.Cwarship).size();
|
|
||||||
|
|
||||||
String message = "";
|
String message = "";
|
||||||
if(size == 0)
|
if(size == 0)
|
||||||
@ -194,108 +67,27 @@ public class CheckUtils {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTeammemberSchematicList(Player player, int filesPerPage, int currentPage) {
|
public static void sendTeammemberSchematicList(Player player) {
|
||||||
|
List<Schematic> schematicList = new LinkedList<>();
|
||||||
|
|
||||||
List<Schematic> schematicList = getAllCSchems();
|
for(SchematicType type : SchematicType.values()) {
|
||||||
|
if (type.check())
|
||||||
|
schematicList.addAll(Schematic.getAllSchemsOfType(type));
|
||||||
|
}
|
||||||
|
|
||||||
if(schematicList.isEmpty()) {
|
if(schematicList.isEmpty()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
|
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pages;
|
player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
|
||||||
|
|
||||||
double doublePages = (Double.valueOf(schematicList.size()) / Double.valueOf(filesPerPage));
|
for(Schematic schematic : schematicList) {
|
||||||
int intPages = schematicList.size() / filesPerPage;
|
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
|
||||||
|
|
||||||
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());
|
|
||||||
schematics.setBold(true);
|
schematics.setBold(true);
|
||||||
|
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create()));
|
||||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen...").create()));
|
|
||||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + WarkingUser.get(schematic.getSchemOwner()).getUserName()));
|
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + WarkingUser.get(schematic.getSchemOwner()).getUserName()));
|
||||||
|
|
||||||
player.spigot().sendMessage(schematics);
|
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<Schematic> getAllCSchems() {
|
|
||||||
|
|
||||||
List<Schematic> wargears = Schematic.getAllSchemsOfType(SchematicType.Cwargear);
|
|
||||||
List<Schematic> miniwargears = Schematic.getAllSchemsOfType(SchematicType.Cminiwargear);
|
|
||||||
List<Schematic> warships = Schematic.getAllSchemsOfType(SchematicType.Cwarship);
|
|
||||||
List<Schematic> airships = Schematic.getAllSchemsOfType(SchematicType.Cairship);
|
|
||||||
|
|
||||||
List<Schematic> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
package de.steamwar.schematicsystem.check;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Checkresult {
|
|
||||||
|
|
||||||
public static ArrayList<Checkresult> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,8 +8,8 @@ import de.steamwar.schematicsystem.SchematicSystem;
|
|||||||
import de.steamwar.schematicsystem.check.CheckSession;
|
import de.steamwar.schematicsystem.check.CheckSession;
|
||||||
import de.steamwar.schematicsystem.check.CheckUtils;
|
import de.steamwar.schematicsystem.check.CheckUtils;
|
||||||
import de.warking.hunjy.MySQL.Schematic;
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
import de.warking.hunjy.MySQL.SchematicType;
|
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CheckCommand implements CommandExecutor {
|
public class CheckCommand implements CommandExecutor {
|
||||||
|
|
||||||
@ -29,216 +30,136 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if(CheckUtils.allowedToCheck(player)) {
|
if(CheckUtils.allowedToCheck(player)) {
|
||||||
|
|
||||||
if(args.length == 0) {
|
if(args.length == 0) {
|
||||||
sendHelp(player);
|
help(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 1) {
|
CheckSession checkSession;
|
||||||
if(args[0].equalsIgnoreCase("list")) {
|
|
||||||
CheckUtils.sendTeammemberSchematicList(player, 15, 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("next")) {
|
switch(args[0]){
|
||||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
case "list":
|
||||||
if(checkSession != null) {
|
CheckUtils.sendTeammemberSchematicList(player);
|
||||||
|
break;
|
||||||
|
case "next":
|
||||||
|
case "allow":
|
||||||
|
checkSession = session(player);
|
||||||
|
if(checkSession != null)
|
||||||
checkSession.sendNextCheck();
|
checkSession.sendNextCheck();
|
||||||
} else {
|
break;
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
|
case "cancel":
|
||||||
return false;
|
checkSession = session(player);
|
||||||
}
|
if(checkSession != null){
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
checkSession.removeSchematic();
|
checkSession.removeSchematic();
|
||||||
checkSession.remove();
|
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§aDer Prüfvorgang wurde abgebrochen!");
|
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);
|
break;
|
||||||
return false;
|
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;
|
||||||
if(args.length == 3) {
|
}else if(args.length < 3){
|
||||||
|
help(player);
|
||||||
if(args[0].equalsIgnoreCase("schematic")) {
|
return false;
|
||||||
String schemName = args[1];
|
}else if(CheckSession.getCheckSession(player) != null) {
|
||||||
String owner = args[2];
|
|
||||||
|
|
||||||
if(CheckSession.getCheckSession(player) != null) {
|
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst schon eine Schematic!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst schon eine Schematic!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CheckUtils.isSchematicNameAllowed(schemName)) {
|
WarkingUser user = WarkingUser.get(args[2]);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
if(user.getUUID() == null){
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
WarkingUser warkingUser = WarkingUser.get(owner);
|
Schematic schematic = Schematic.getSchemFromDB(args[1], user.getUUID());
|
||||||
if(warkingUser.getUUID() != null) {
|
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());
|
List<Player> worldPlayers = player.getWorld().getPlayers();
|
||||||
if(schematic != null) {
|
for(Player players : worldPlayers) {
|
||||||
if(schematic.getSchemType() != SchematicType.normal &&
|
if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
|
||||||
schematic.getSchemType() != SchematicType.airship &&
|
WarkingUser warkingUsers = WarkingUser.get(players.getUniqueId());
|
||||||
schematic.getSchemType() != SchematicType.warship &&
|
if(!CheckUtils.allowedToCheck(players) &&
|
||||||
schematic.getSchemType() != SchematicType.wargear &&
|
!warkingUsers.getUUID().toString().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID().toString())) {
|
||||||
schematic.getSchemType() != SchematicType.miniwargear) {
|
player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich kein Unbeteiligter auf deinem Bauserver befinden!");
|
||||||
|
|
||||||
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<Player> 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!");
|
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length >= 2) {
|
try {
|
||||||
if(args[0].equalsIgnoreCase("decline")) {
|
com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file);
|
||||||
|
Location playerLocation = player.getLocation();
|
||||||
|
|
||||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
World weWorld = new BukkitWorld(player.getWorld());
|
||||||
if(checkSession != null) {
|
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++) {
|
checkSession = new CheckSession(player.getUniqueId(), schematic);
|
||||||
message = message + args[i] + " ";
|
checkSession.sendNextCheck();
|
||||||
}
|
checkSession.setEditSession(schematicFAWE.paste(weWorld, v));
|
||||||
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!");
|
} catch (IOException ex) {
|
||||||
checkSession.declineSchematic(message);
|
player.sendMessage(SchematicSystem.PREFIX + "§cSchematic konnte nicht geladen/gepastet werden");
|
||||||
} else {
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to load schematic", ex);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!");
|
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHelp(Player player) {
|
private void help(Player player) {
|
||||||
if(CheckUtils.allowedToCheck(player)) {
|
if(CheckUtils.allowedToCheck(player)){
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
player.sendMessage("§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics");
|
||||||
player.sendMessage("§8/ckeck list - §6Zeigt die Liste der ungeprüften Schematics");
|
player.sendMessage("§8/§echeck schematic [SchematicName] [Besitzer] §8- §7Zum Checken einer Schematic");
|
||||||
player.sendMessage("§8/ckeck schematic <SchematicName> <Besitzer> - §6Zum Checken einer Schematic");
|
player.sendMessage("§8/§echeck allow §8- §7Schematic freigeben");
|
||||||
player.sendMessage("§8/ckeck allow - §6Schematic freigeben");
|
player.sendMessage("§8/§echeck decline [Grund] §8- §7Schematic nicht freigeben");
|
||||||
player.sendMessage("§8/ckeck decline <Grund> - §6Schematic nicht freigeben");
|
player.sendMessage("§8/§echeck cancel §8- §7Bricht das Prüfen ab");
|
||||||
player.sendMessage("§8/check cancel - §6Bricht 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
188
src/de/steamwar/schematicsystem/commands/GUI.java
Normale Datei
188
src/de/steamwar/schematicsystem/commands/GUI.java
Normale Datei
@ -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<Pair<SWItem, SchematicType>> 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<SchematicType> 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<CheckedSchematic> 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<Pair<SWItem, SchematicMember>> 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<SchematicMember> 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<Pair<SWItem, Material>> materials = new LinkedList<>();
|
||||||
|
for(Material material : Material.values()){
|
||||||
|
SWItem item = new SWItem(material, "§7" + material.name());
|
||||||
|
if(item.getItemMeta() != null && material.isItem())
|
||||||
|
materials.add(new Pair<>(item, material));
|
||||||
|
}
|
||||||
|
|
||||||
|
SWListInv<Material> 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<CheckedSchematic> 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<Pair<SWItem, Schematic>> schemList = new LinkedList<>();
|
||||||
|
List<Schematic> 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<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", (clickType, schem) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
info(p, schem);
|
||||||
|
}, schemList);
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -15,12 +15,9 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
|
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(CheckSession.doesPlayerCheck(player)) {
|
if(CheckSession.getCheckSession() != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt.");
|
||||||
//eventuell Admin Benachrichtigen
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,21 +21,33 @@ public class PlayerJoinListener implements Listener {
|
|||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
CheckSession currentChecking = null;
|
if(CheckSession.currentChecking()){
|
||||||
for(Player players : player.getWorld().getPlayers()) {
|
CheckSession current = CheckSession.getCheckSession();
|
||||||
if(CheckSession.doesPlayerCheck(players))
|
if(!CheckUtils.allowedToCheck(player) && !WarkingUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())){
|
||||||
currentChecking = CheckSession.getCheckSession(players);
|
|
||||||
}
|
|
||||||
if(currentChecking != null) {
|
|
||||||
if(!CheckUtils.allowedToCheck(player) && !WarkingUser.get(
|
|
||||||
currentChecking.getSchematic().getSchemOwner()).getUUID().toString()
|
|
||||||
.equals(player.getUniqueId().toString())) {
|
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!");
|
||||||
player.kickPlayer("");
|
player.kickPlayer("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
|
|
||||||
|
addNewSchems(player);
|
||||||
|
|
||||||
|
if(CheckUtils.allowedToCheck(player))
|
||||||
|
player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
|
||||||
|
|
||||||
|
List<Schematic> 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();
|
File[] files = file.listFiles();
|
||||||
|
|
||||||
if(files != null && files.length > 0) {
|
if(files != null && files.length > 0) {
|
||||||
@ -48,28 +60,12 @@ public class PlayerJoinListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < files.length; i++) {
|
for (File value : files) {
|
||||||
if(!schematicNames.contains(files[i].getName().substring(0, files[i].getName().lastIndexOf('.')))) {
|
if (!schematicNames.contains(value.getName().substring(0, value.getName().lastIndexOf('.')))) {
|
||||||
String fileName = files[i].getName();
|
String fileName = value.getName();
|
||||||
new Schematic(fileName.substring(0, fileName.lastIndexOf('.')), player.getUniqueId(), "", SchematicType.normal);
|
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<Schematic> 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)!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ public class PlayerQuitListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(CheckSession.doesPlayerCheck(player)) {
|
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
CheckSession.getCheckSession(player).removeSchematic();
|
if(checkSession == null)
|
||||||
CheckSession.getCheckSession(player).remove();
|
return;
|
||||||
}
|
|
||||||
|
checkSession.removeSchematic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,32 +3,34 @@ package de.steamwar.schematicsystem.utils;
|
|||||||
import de.warking.hunjy.Core;
|
import de.warking.hunjy.Core;
|
||||||
import de.warking.hunjy.MySQL.MySQL;
|
import de.warking.hunjy.MySQL.MySQL;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static de.warking.hunjy.Core.sql;
|
import static de.warking.hunjy.Core.sql;
|
||||||
|
|
||||||
public class CheckedSchematic {
|
public class CheckedSchematic {
|
||||||
|
|
||||||
private final String SchemName;
|
private final String schemName;
|
||||||
private final int SchemOwner;
|
private final int schemOwner;
|
||||||
private final int Validator;
|
private final int validator;
|
||||||
private final Timestamp StartTime;
|
private final Timestamp startTime;
|
||||||
private final Timestamp EndTime;
|
private final Timestamp endTime;
|
||||||
private final String DeclineReason;
|
private final String declineReason;
|
||||||
|
|
||||||
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
|
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
|
||||||
SchemName = MySQL.disarmString(schemName);
|
this.schemName = MySQL.disarmString(schemName);
|
||||||
SchemOwner = schemOwner;
|
this.schemOwner = schemOwner;
|
||||||
Validator = validator;
|
this.validator = validator;
|
||||||
StartTime = startTime;
|
this.startTime = startTime;
|
||||||
EndTime = endTime;
|
this.endTime = endTime;
|
||||||
DeclineReason = MySQL.disarmString(declineReason);
|
this.declineReason = MySQL.disarmString(declineReason);
|
||||||
if(insertDB)
|
if(insertDB)
|
||||||
insertDB();
|
insertDB();
|
||||||
}
|
}
|
||||||
@ -37,10 +39,6 @@ public class CheckedSchematic {
|
|||||||
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true);
|
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){
|
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);
|
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" +
|
sql.update("INSERT INTO CheckedSchematic" +
|
||||||
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason)" +
|
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason)" +
|
||||||
" VALUES" +
|
" VALUES" +
|
||||||
" ('"+ SchemName + "', '" + SchemOwner + "', '" + Validator + "', '" + StartTime.toString() + "', '" + EndTime.toString() + "', '" + DeclineReason + "')");
|
" ('"+ schemName + "', '" + schemOwner + "', '" + validator + "', '" + startTime.toString() + "', '" + endTime.toString() + "', '" + declineReason + "')");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
|
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
|
||||||
@ -57,7 +55,7 @@ public class CheckedSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDelined(int schemOwner){
|
public static List<CheckedSchematic> getLastDelined(int schemOwner){
|
||||||
List<CheckedSchematic> lastDeclined = new ArrayList<>();
|
List<CheckedSchematic> lastDeclined = new LinkedList<>();
|
||||||
try{
|
try{
|
||||||
ResultSet lastRS = sql.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = '" + schemOwner + "' AND DeclineReason != '' ORDER BY EndTime DESC");
|
ResultSet lastRS = sql.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = '" + schemOwner + "' AND DeclineReason != '' ORDER BY EndTime DESC");
|
||||||
while(lastRS.next()){
|
while(lastRS.next()){
|
||||||
@ -69,36 +67,36 @@ public class CheckedSchematic {
|
|||||||
lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false));
|
lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false));
|
||||||
}
|
}
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().log(Level.SEVERE, "getLastDeclined failed", e);
|
||||||
}
|
}
|
||||||
return lastDeclined;
|
return lastDeclined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
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() {
|
public String getSchemName() {
|
||||||
return SchemName;
|
return schemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSchemOwner() {
|
public int getSchemOwner() {
|
||||||
return SchemOwner;
|
return schemOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValidator() {
|
public int getValidator() {
|
||||||
return Validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getStartTime() {
|
public Timestamp getStartTime() {
|
||||||
return StartTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getEndTime() {
|
public Timestamp getEndTime() {
|
||||||
return EndTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeclineReason() {
|
public String getDeclineReason() {
|
||||||
return DeclineReason;
|
return declineReason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,30 +6,36 @@ import org.bukkit.command.SimpleCommandMap;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CommandRemover {
|
public class CommandRemover {
|
||||||
|
private CommandRemover(){}
|
||||||
|
|
||||||
private static String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
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 {
|
public static void removeAll(String... cmds){
|
||||||
for (int i = 0; i < cmds.length; i++)
|
for (String cmd : cmds) removeCommand(cmd);
|
||||||
removeCommand(cmds[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean removeCommand(String command) throws Exception {
|
private static void removeCommand(String command) {
|
||||||
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
|
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");
|
Field f1 = serverClass.getDeclaredField("commandMap");
|
||||||
f2.setAccessible(true);
|
f1.setAccessible(true);
|
||||||
Map<String, Command> knownCommands = (Map<String, Command>) f2.get(commandMap);
|
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
|
||||||
|
|
||||||
return knownCommands.remove(command.toLowerCase()) != null;
|
Field f2 = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||||
|
f2.setAccessible(true);
|
||||||
|
Map<String, Command> knownCommands = (Map<String, Command>) f2.get(commandMap);
|
||||||
|
|
||||||
|
knownCommands.remove(command.toLowerCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not remove command", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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<Integer> WarGearForbiddenIds;
|
|
||||||
public static List<String> 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<Integer> MiniWarGearForbiddenIds;
|
|
||||||
public static List<String> 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<Integer> WarShipForbiddenIds;
|
|
||||||
public static List<String> 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<Integer> AirShipForbiddenIds;
|
|
||||||
public static List<String> 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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,13 @@
|
|||||||
name: SchematicSystem
|
name: SchematicSystem
|
||||||
version: 1.0
|
version: "1.0"
|
||||||
author: [Yaruma3341, Lixfel]
|
authors: [Yaruma3341, Lixfel]
|
||||||
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
|
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
|
||||||
main: de.steamwar.schematicsystem.SchematicSystem
|
main: de.steamwar.schematicsystem.SchematicSystem
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
schematic:
|
|
||||||
/schematic:
|
|
||||||
schem:
|
schem:
|
||||||
/schem:
|
aliases:
|
||||||
|
- schematic
|
||||||
|
- /schematic
|
||||||
|
- /schem
|
||||||
check:
|
check:
|
In neuem Issue referenzieren
Einen Benutzer sperren