hotfixes; schematic offset removed; schematic will now be removed after checking
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
6535e4f81e
Commit
2943b4d54f
@ -4,6 +4,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|||||||
import de.warking.schematicsystem.check.CheckUtils;
|
import de.warking.schematicsystem.check.CheckUtils;
|
||||||
import de.warking.schematicsystem.commands.CheckCommand;
|
import de.warking.schematicsystem.commands.CheckCommand;
|
||||||
import de.warking.schematicsystem.commands.SchematicCommand;
|
import de.warking.schematicsystem.commands.SchematicCommand;
|
||||||
|
import de.warking.schematicsystem.listener.PlayerCommandPreProcessListener;
|
||||||
import de.warking.schematicsystem.listener.PlayerJoinListener;
|
import de.warking.schematicsystem.listener.PlayerJoinListener;
|
||||||
import de.warking.schematicsystem.listener.PlayerQuitListener;
|
import de.warking.schematicsystem.listener.PlayerQuitListener;
|
||||||
import de.warking.schematicsystem.utils.CommandRemover;
|
import de.warking.schematicsystem.utils.CommandRemover;
|
||||||
@ -55,6 +56,7 @@ public class SchematicSystem extends JavaPlugin {
|
|||||||
PluginManager pm = Bukkit.getPluginManager();
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
pm.registerEvents(new PlayerJoinListener(), instance);
|
pm.registerEvents(new PlayerJoinListener(), instance);
|
||||||
pm.registerEvents(new PlayerQuitListener(), instance);
|
pm.registerEvents(new PlayerQuitListener(), instance);
|
||||||
|
pm.registerEvents(new PlayerCommandPreProcessListener(), instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.warking.schematicsystem.check;
|
package de.warking.schematicsystem.check;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
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.schematicsystem.utils.Config;
|
import de.warking.schematicsystem.utils.Config;
|
||||||
@ -23,6 +24,8 @@ public class CheckSession {
|
|||||||
private long startTime;
|
private long startTime;
|
||||||
private long stopTime;
|
private long stopTime;
|
||||||
|
|
||||||
|
EditSession editSession;
|
||||||
|
|
||||||
public CheckSession(UUID uuid, Schematic schematic, int position) {
|
public CheckSession(UUID uuid, Schematic schematic, int position) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.schematic = schematic;
|
this.schematic = schematic;
|
||||||
@ -36,7 +39,8 @@ public class CheckSession {
|
|||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
for(CheckSession checkSession : checkSessions) {
|
for(CheckSession checkSession : checkSessions) {
|
||||||
return checkSession.equals(uuid);
|
if(checkSession.getUuid().equals(uuid))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -116,23 +120,20 @@ public class CheckSession {
|
|||||||
public void allowSchematic() {
|
public void allowSchematic() {
|
||||||
if(schematic.getSchemType() == SchematicType.Cwargear) {
|
if(schematic.getSchemType() == SchematicType.Cwargear) {
|
||||||
schematic.setSchemType(SchematicType.wargear);
|
schematic.setSchemType(SchematicType.wargear);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(schematic.getSchemType() == SchematicType.Cminiwargear) {
|
if(schematic.getSchemType() == SchematicType.Cminiwargear) {
|
||||||
schematic.setSchemType(SchematicType.miniwargear);
|
schematic.setSchemType(SchematicType.miniwargear);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(schematic.getSchemType() == SchematicType.Cwarship) {
|
if(schematic.getSchemType() == SchematicType.Cwarship) {
|
||||||
schematic.setSchemType(SchematicType.warship);
|
schematic.setSchemType(SchematicType.warship);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(schematic.getSchemType() == SchematicType.Cairship) {
|
if(schematic.getSchemType() == SchematicType.Cairship) {
|
||||||
schematic.setSchemType(SchematicType.airship);
|
schematic.setSchemType(SchematicType.airship);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
//TODO: save position times and total time to file
|
//TODO: save position times and total time to file
|
||||||
//calculateTotalTime();
|
//calculateTotalTime();
|
||||||
|
|
||||||
|
removeSchematic();
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ public class CheckSession {
|
|||||||
this.schematic.setSchemType(SchematicType.normal);
|
this.schematic.setSchemType(SchematicType.normal);
|
||||||
//TODO: save position times and total time to file
|
//TODO: save position times and total time to file
|
||||||
//calculateTotalTime();
|
//calculateTotalTime();
|
||||||
|
removeSchematic();
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +149,10 @@ public class CheckSession {
|
|||||||
checkSessions.remove(this);
|
checkSessions.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSchematic() {
|
||||||
|
this.editSession.undo(editSession);
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@ -191,4 +197,12 @@ public class CheckSession {
|
|||||||
this.stopTime = System.currentTimeMillis();
|
this.stopTime = System.currentTimeMillis();
|
||||||
checkTimes.put(this.position, calculatePositionTime());
|
checkTimes.put(this.position, calculatePositionTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditSession getEditSession() {
|
||||||
|
return editSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEditSession(EditSession editSession) {
|
||||||
|
this.editSession = editSession;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,6 @@ public class CheckUtils {
|
|||||||
|
|
||||||
List<Schematic> schematicList = getAllCSchems();
|
List<Schematic> schematicList = getAllCSchems();
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.warking.schematicsystem.commands;
|
package de.warking.schematicsystem.commands;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -39,7 +40,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
if(args[0].equalsIgnoreCase("checklist")) {
|
if(args[0].equalsIgnoreCase("list")) {
|
||||||
CheckUtils.sendTeammemberSchematicList(player, 15, 0);
|
CheckUtils.sendTeammemberSchematicList(player, 15, 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 2) {
|
if(args.length == 2) {
|
||||||
if(args[0].equalsIgnoreCase("checklist")) {
|
if(args[0].equalsIgnoreCase("list")) {
|
||||||
int currentPage;
|
int currentPage;
|
||||||
try {
|
try {
|
||||||
currentPage = Integer.parseInt(args[1]);
|
currentPage = Integer.parseInt(args[1]);
|
||||||
@ -104,6 +105,11 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
String schemName = args[1];
|
String schemName = args[1];
|
||||||
String owner = args[2];
|
String owner = args[2];
|
||||||
|
|
||||||
|
if(CheckSession.getCheckSession(player) != null) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst schon eine Schematic!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!CheckUtils.isSchematicNameAllowed(schemName)) {
|
if(!CheckUtils.isSchematicNameAllowed(schemName)) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||||
return false;
|
return false;
|
||||||
@ -115,7 +121,8 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID());
|
Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID());
|
||||||
if(schematic != null) {
|
if(schematic != null) {
|
||||||
for(CheckSession checkSession : CheckSession.checkSessions) {
|
for(CheckSession checkSession : CheckSession.checkSessions) {
|
||||||
if(checkSession.getSchematic().equals(schematic)) {
|
if(checkSession.getSchematic().getSchemName().equals(schematic.getSchemName())
|
||||||
|
&& checkSession.getSchematic().getSchemOwner() == schematic.getSchemOwner()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -127,7 +134,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Map.Entry<String, UUID> entry : schematicList.entrySet()) {
|
for(Map.Entry<String, UUID> entry : schematicList.entrySet()) {
|
||||||
if(!(entry.getKey().equals(schematic.getSchemName()) && entry.getValue().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID()))) {
|
if(!(entry.getKey().equals(schematic.getSchemName()) || entry.getValue().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID()))) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! CONTAINS");
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! CONTAINS");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,17 +152,22 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
|
|
||||||
World weWorld = new BukkitWorld(player.getWorld());
|
World weWorld = new BukkitWorld(player.getWorld());
|
||||||
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
|
Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ());
|
||||||
schematicFAWE.paste(weWorld, vector);
|
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) {
|
} catch (IOException ex) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! PASTE");
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! PASTE");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckSession checkSession = new CheckSession(player.getUniqueId(), schematic, -1);
|
|
||||||
checkSession.sendNextCheck();
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NULL");
|
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NULL");
|
||||||
return false;
|
return false;
|
||||||
@ -168,7 +180,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length >= 3) {
|
if(args.length >= 2) {
|
||||||
if(args[0].equalsIgnoreCase("decline")) {
|
if(args[0].equalsIgnoreCase("decline")) {
|
||||||
|
|
||||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||||
@ -195,7 +207,7 @@ public class CheckCommand implements CommandExecutor {
|
|||||||
public void sendHelp(Player player) {
|
public void sendHelp(Player player) {
|
||||||
if(CheckUtils.allowedToCheck(player)) {
|
if(CheckUtils.allowedToCheck(player)) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
||||||
player.sendMessage("§8/ckeck checklist - §6Zeigt die Liste der ungeprüften Schematics");
|
player.sendMessage("§8/ckeck list - §6Zeigt die Liste der ungeprüften Schematics");
|
||||||
player.sendMessage("§8/ckeck schematic <SchematicName> <Besitzer> - §6Zum Checken einer Schematic");
|
player.sendMessage("§8/ckeck schematic <SchematicName> <Besitzer> - §6Zum Checken einer Schematic");
|
||||||
player.sendMessage("§8/ckeck allow - §6Schematic freigeben");
|
player.sendMessage("§8/ckeck allow - §6Schematic freigeben");
|
||||||
player.sendMessage("§8/ckeck decline <Grund> - §6Schematic nicht freigeben");
|
player.sendMessage("§8/ckeck decline <Grund> - §6Schematic nicht freigeben");
|
||||||
|
@ -11,9 +11,11 @@ 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))
|
if(CheckSession.doesPlayerCheck(player)) {
|
||||||
|
CheckSession.getCheckSession(player).removeSchematic();
|
||||||
CheckSession.getCheckSession(player).remove();
|
CheckSession.getCheckSession(player).remove();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren