13
0

Removing check system and simplifing structure

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-05-01 11:59:08 +02:00
Ursprung 6d86a32b49
Commit 29e0a9fb24
28 geänderte Dateien mit 15 neuen und 934 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -1,9 +0,0 @@
package de.steamwar.schematicsystem;
class CheckSchemType_10 {
private CheckSchemType_10(){}
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}
}

Datei anzeigen

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

Datei anzeigen

@ -39,18 +39,6 @@
<version>1.0</version> <version>1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_10</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId> <artifactId>SchematicSystem_API</artifactId>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,9 +0,0 @@
package de.steamwar.schematicsystem;
class CheckSchemType_14 {
private CheckSchemType_14(){}
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}
}

Datei anzeigen

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

Datei anzeigen

@ -32,11 +32,6 @@
<artifactId>SchematicSystem_API</artifactId> <artifactId>SchematicSystem_API</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_14</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>Spigot</artifactId> <artifactId>Spigot</artifactId>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,9 +0,0 @@
package de.steamwar.schematicsystem;
class CheckSchemType_8 {
private CheckSchemType_8(){}
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}
}

Datei anzeigen

@ -1,34 +0,0 @@
package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.IOException;
class WorldEdit_8 {
private WorldEdit_8(){}
static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException {
World weWorld = new BukkitWorld(player.getWorld());
Location playerLocation = player.getLocation();
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
Clipboard clipboard = schematic.load();
Vector offset = new Vector(clipboard.getRegion().getMinimumPoint()).subtract(clipboard.getOrigin());
Vector dimensions = clipboard.getDimensions();
Vector v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset);
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard, weWorld.getWorldData()).createPaste(e, weWorld.getWorldData()).to(v).build());
e.flushQueue();
return e;
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,9 +0,0 @@
package de.steamwar.schematicsystem;
class CheckSchemType_9 {
private CheckSchemType_9(){}
static AutoCheckResult autoCheck() {
return new AutoCheckResult();
}
}

Datei anzeigen

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

Datei anzeigen

@ -50,48 +50,18 @@
<version>1.15</version> <version>1.15</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SchematicSystem_15</artifactId> <artifactId>SchematicSystem_15</artifactId>
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_14</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SchematicSystem_12</artifactId> <artifactId>SchematicSystem_12</artifactId>
<version>1.0</version> <version>1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_10</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_9</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_8</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId> <artifactId>SchematicSystem_API</artifactId>

Datei anzeigen

@ -24,7 +24,6 @@ public class CheckSchemType implements ICheckSchemType {
private final int maxTNTSlime; private final int maxTNTSlime;
private final int maxDispenser; private final int maxDispenser;
private final int maxBlocks; private final int maxBlocks;
private final LinkedList<String> checkList;
CheckSchemType(ConfigurationSection section) { CheckSchemType(ConfigurationSection section) {
name = section.getName(); name = section.getName();
@ -40,7 +39,6 @@ public class CheckSchemType implements ICheckSchemType {
maxBlocks = section.getInt("maxBlocks"); maxBlocks = section.getInt("maxBlocks");
forbiddenMaterials = section.getStringList("forbiddenMaterials"); forbiddenMaterials = section.getStringList("forbiddenMaterials");
checkList = new LinkedList<>(section.getStringList("checkList"));
types.put(SchematicType.fromDB(name), this); types.put(SchematicType.fromDB(name), this);
types.put(SchematicType.fromDB("c" + name), this); types.put(SchematicType.fromDB("c" + name), this);
} }
@ -49,28 +47,14 @@ public class CheckSchemType implements ICheckSchemType {
return types.get(type); return types.get(type);
} }
public List<String> getCheckList() {
return checkList;
}
public SchematicType getAcceptedType(){
return SchematicType.fromDB(name);
}
public AutoCheckResult autoCheck(Schematic schematic) { public AutoCheckResult autoCheck(Schematic schematic) {
switch(Core.getVersion()){ switch(Core.getVersion()){
case 15: case 15:
return CheckSchemType_15.autoCheck(schematic, this); return CheckSchemType_15.autoCheck(schematic, this);
case 14: case 12:
return CheckSchemType_14.autoCheck();
case 10:
return CheckSchemType_10.autoCheck();
case 9:
return CheckSchemType_9.autoCheck();
case 8:
return CheckSchemType_8.autoCheck();
default:
return CheckSchemType_12.autoCheck(schematic, this); return CheckSchemType_12.autoCheck(schematic, this);
default:
return new AutoCheckResult();
} }
} }

Datei anzeigen

@ -1,12 +1,8 @@
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
import de.steamwar.core.CommandRemover; import de.steamwar.core.CommandRemover;
import de.steamwar.schematicsystem.check.CheckUtils;
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.PlayerJoinListener; import de.steamwar.schematicsystem.listener.PlayerJoinListener;
import de.steamwar.schematicsystem.listener.PlayerQuitListener;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -35,16 +31,8 @@ public class SchematicSystem extends JavaPlugin {
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem"); CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
getCommand("schem").setExecutor(new SchematicCommand()); getCommand("schem").setExecutor(new SchematicCommand());
getCommand("check").setExecutor(new CheckCommand());
PluginManager pm = Bukkit.getPluginManager(); PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), this); pm.registerEvents(new PlayerJoinListener(), this);
pm.registerEvents(new PlayerQuitListener(), this);
pm.registerEvents(new PlayerCommandPreProcessListener(), this);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if(CheckUtils.getCSchematicsSize() > 0)
CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo());
}, 0, 6000);
} }
} }

Datei anzeigen

@ -1,30 +0,0 @@
package de.steamwar.schematicsystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.core.Core;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.entity.Player;
import java.io.IOException;
public class WorldEdit {
private WorldEdit(){}
public static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException {
switch(Core.getVersion()){
case 15:
return WorldEdit_15.pasteSchematic(player, schematic);
case 14:
return WorldEdit_14.pasteSchematic(player, schematic);
case 10:
return WorldEdit_10.pasteSchematic(player, schematic);
case 9:
return WorldEdit_9.pasteSchematic(player, schematic);
case 8:
return WorldEdit_8.pasteSchematic(player, schematic);
default:
return WorldEdit_12.pasteSchematic(player, schematic);
}
}
}

Datei anzeigen

@ -1,128 +0,0 @@
package de.steamwar.schematicsystem.check;
import com.sk89q.worldedit.EditSession;
import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.CheckedSchematic;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.sql.Timestamp;
import java.util.*;
public class CheckSession {
private static Set<CheckSession> checkSessions = new HashSet<>();
private UUID uuid; //player
private Schematic schematic;
private ListIterator<String> checkList;
private Timestamp startTime;
private Timestamp stopTime;
private EditSession editSession;
public CheckSession(UUID uuid, Schematic schematic) {
this.uuid = uuid;
this.schematic = schematic;
checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator();
checkSessions.add(this);
setStartTime();
}
public static boolean currentChecking(){
return !checkSessions.isEmpty();
}
public static CheckSession getCheckSession() {
if(checkSessions.isEmpty())
return null;
return checkSessions.iterator().next();
}
public static CheckSession getCheckSession(Player player) {
for(CheckSession session : checkSessions){
if(session.uuid.equals(player.getUniqueId()))
return session;
}
return null;
}
public void sendNextCheck() {
if(!checkList.hasNext()){
Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType());
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben");
removeSchematic();
return;
}
setStopTime();
setStartTime();
Bukkit.getPlayer(uuid).sendMessage(checkList.next());
if(checkList.hasNext()){
TextComponent next = new TextComponent("next ");
next.setColor(ChatColor.GREEN);
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
TextComponent decline = new TextComponent("decline");
decline.setColor(ChatColor.DARK_RED);
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
next.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(next);
}else{
TextComponent accept = new TextComponent("accept ");
accept.setColor(ChatColor.GREEN);
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
TextComponent decline = new TextComponent("decline");
decline.setColor(ChatColor.DARK_RED);
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline <GRUND>"));
accept.addExtra(decline);
Bukkit.getPlayer(uuid).spigot().sendMessage(accept);
}
}
public void declineSchematic(String declineReason) {
schematic.setSchemType(SchematicType.Normal);
new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason);
removeSchematic();
}
public void removeSchematic() {
this.editSession.undo(editSession);
checkSessions.remove(this);
}
public Schematic getSchematic() {
return schematic;
}
private void setStartTime() {
Date date = new Date();
this.startTime = new Timestamp(date.getTime());
}
private void setStopTime() {
Date date = new Date();
this.stopTime = new Timestamp(date.getTime());
}
public void setEditSession(EditSession editSession) {
this.editSession = editSession;
}
}

Datei anzeigen

@ -1,93 +0,0 @@
package de.steamwar.schematicsystem.check;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.LinkedList;
import java.util.List;
public class CheckUtils {
private CheckUtils(){}
public static boolean schemnameForbidden(String schematicName) {
return schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"");
}
public static boolean allowedToCheck(Player player) {
SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId());
return warkingUser.getUserGroup() == UserGroup.Supporter ||
warkingUser.getUserGroup() == UserGroup.Developer ||
warkingUser.getUserGroup() == UserGroup.Moderator ||
warkingUser.getUserGroup() == UserGroup.Admin;
}
public static void sendTeamMembersCSchematics(String message) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(allowedToCheck(player))
player.sendMessage(message);
}
}
public static int getCSchematicsSize() {
int size = 0;
for(SchematicType type : SchematicType.values()){
if(type.check())
size += Schematic.getAllSchemsOfType(type).size();
}
return size;
}
public static String sendTeamMembersCSchematicsInfo() {
int size = getCSchematicsSize();
String message = "";
if(size == 0)
message = SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!";
if(size == 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6eine §aungeprüfte Schematic!";
if(size > 1)
message = SchematicSystem.PREFIX + "§aEs gibt noch §6" + size + " §aungeprüfte Schematics!";
return message;
}
public static void sendTeammemberSchematicList(Player player) {
List<Schematic> schematicList = new LinkedList<>();
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;
}
player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics");
for(Schematic schematic : schematicList) {
TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + SteamwarUser.get(schematic.getSchemOwner()).getUserName()));
player.spigot().sendMessage(schematics);
}
}
}

Datei anzeigen

@ -1,149 +0,0 @@
package de.steamwar.schematicsystem.commands;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.WorldEdit;
import de.steamwar.schematicsystem.check.CheckSession;
import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
public class CheckCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(CheckUtils.allowedToCheck(player)) {
if(args.length == 0) {
help(player);
return false;
}
CheckSession checkSession;
switch(args[0]){
case "list":
CheckUtils.sendTeammemberSchematicList(player);
break;
case "next":
case "allow":
checkSession = session(player);
if(checkSession != null)
checkSession.sendNextCheck();
break;
case "cancel":
checkSession = session(player);
if(checkSession != null){
checkSession.removeSchematic();
player.sendMessage(SchematicSystem.PREFIX + "§aDer Prüfvorgang wurde abgebrochen!");
}
break;
case "schematic":
SteamwarUser checker = SteamwarUser.get(player.getUniqueId());
String worldName = player.getWorld().getName();
if(!worldName.equals(player.getUniqueId().toString()) && !worldName.equals(Integer.toString(checker.getId()))) {
player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen musst du dich auf deinem Bauserver befinden!");
return false;
}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;
}
SteamwarUser user = SteamwarUser.get(args[2]);
if(user.getUUID() == null){
player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer");
return false;
}
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() == SteamwarUser.get(player.getUniqueId()).getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht deine eigenen Schematics prüfen");
return false;
}
List<Player> worldPlayers = player.getWorld().getPlayers();
for(Player players : worldPlayers) {
if(!players.getUniqueId().toString().equals(player.getWorld().getName())) {
SteamwarUser warkingUsers = SteamwarUser.get(players.getUniqueId());
if(!CheckUtils.allowedToCheck(players) &&
!warkingUsers.getUUID().toString().equals(SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString())) {
player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich kein Unbeteiligter auf deinem Bauserver befinden!");
return false;
}
}
}
try {
checkSession = new CheckSession(player.getUniqueId(), schematic);
checkSession.sendNextCheck();
checkSession.setEditSession(WorldEdit.pasteSchematic(player, schematic));
} catch (IOException | NoClipboardException ex) {
player.sendMessage(SchematicSystem.PREFIX + "§cSchematic konnte nicht geladen/gepastet werden");
Bukkit.getLogger().log(Level.SEVERE, "Failed to load schematic", ex);
return false;
} catch (Schematic.WrongVersionException e) {
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic kann nicht in dieser Minecraft-Version geladen werden");
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" + SteamwarUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!");
checkSession.declineSchematic(message.toString());
break;
default:
help(player);
}
}
return false;
}
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;
}
}

Datei anzeigen

@ -3,7 +3,6 @@ package de.steamwar.schematicsystem.commands;
import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.AutoCheckResult;
import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.*; import de.steamwar.sql.*;
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;
@ -95,8 +94,19 @@ public class SchematicCommand implements CommandExecutor {
} }
} }
private boolean schemnameForbidden(String schematicName) {
return schematicName.contains("/") ||
schematicName.contains("\\") ||
schematicName.contains("<") ||
schematicName.contains(">") ||
schematicName.contains("^") ||
schematicName.contains("°") ||
schematicName.contains("'") ||
schematicName.contains("\"");
}
private boolean invalidSchemName(Player player, String name){ private boolean invalidSchemName(Player player, String name){
if(CheckUtils.schemnameForbidden(name)){ if(schemnameForbidden(name)){
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen"); player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true; return true;
} }

Datei anzeigen

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

Datei anzeigen

@ -1,11 +1,8 @@
package de.steamwar.schematicsystem.listener; package de.steamwar.schematicsystem.listener;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.check.CheckSession;
import de.steamwar.schematicsystem.check.CheckUtils;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -20,21 +17,8 @@ public class PlayerJoinListener implements Listener {
public void handlePlayerJoin(PlayerJoinEvent event) { public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(CheckSession.currentChecking()){
CheckSession current = CheckSession.getCheckSession();
assert current != null;
if(!CheckUtils.allowedToCheck(player) && !SteamwarUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())){
player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!");
player.kickPlayer("");
return;
}
}
if(CheckUtils.allowedToCheck(player))
player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo());
List<Schematic> uncheckedSchematics = new LinkedList<>(); List<Schematic> uncheckedSchematics = new LinkedList<>();
for(SchematicType type : SchematicType.values()){ for(SchematicType type : SchematicType.values()){
if(type.check()) if(type.check())
uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type)); uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type));

Datei anzeigen

@ -1,20 +0,0 @@
package de.steamwar.schematicsystem.listener;
import de.steamwar.schematicsystem.check.CheckSession;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
CheckSession checkSession = CheckSession.getCheckSession(player);
if(checkSession == null)
return;
checkSession.removeSchematic();
}
}

Datei anzeigen

@ -36,11 +36,7 @@
</build> </build>
<modules> <modules>
<module>SchematicSystem_8</module>
<module>SchematicSystem_9</module>
<module>SchematicSystem_10</module>
<module>SchematicSystem_12</module> <module>SchematicSystem_12</module>
<module>SchematicSystem_14</module>
<module>SchematicSystem_15</module> <module>SchematicSystem_15</module>
<module>SchematicSystem_API</module> <module>SchematicSystem_API</module>
<module>SchematicSystem_Main</module> <module>SchematicSystem_Main</module>