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.commands.CheckCommand;
|
||||
import de.warking.schematicsystem.commands.SchematicCommand;
|
||||
import de.warking.schematicsystem.listener.PlayerCommandPreProcessListener;
|
||||
import de.warking.schematicsystem.listener.PlayerJoinListener;
|
||||
import de.warking.schematicsystem.listener.PlayerQuitListener;
|
||||
import de.warking.schematicsystem.utils.CommandRemover;
|
||||
@ -55,6 +56,7 @@ public class SchematicSystem extends JavaPlugin {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new PlayerJoinListener(), instance);
|
||||
pm.registerEvents(new PlayerQuitListener(), instance);
|
||||
pm.registerEvents(new PlayerCommandPreProcessListener(), instance);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.warking.schematicsystem.check;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.warking.hunjy.MySQL.Schematic;
|
||||
import de.warking.hunjy.MySQL.SchematicType;
|
||||
import de.warking.schematicsystem.utils.Config;
|
||||
@ -23,6 +24,8 @@ public class CheckSession {
|
||||
private long startTime;
|
||||
private long stopTime;
|
||||
|
||||
EditSession editSession;
|
||||
|
||||
public CheckSession(UUID uuid, Schematic schematic, int position) {
|
||||
this.uuid = uuid;
|
||||
this.schematic = schematic;
|
||||
@ -36,7 +39,8 @@ public class CheckSession {
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
for(CheckSession checkSession : checkSessions) {
|
||||
return checkSession.equals(uuid);
|
||||
if(checkSession.getUuid().equals(uuid))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -116,23 +120,20 @@ public class CheckSession {
|
||||
public void allowSchematic() {
|
||||
if(schematic.getSchemType() == SchematicType.Cwargear) {
|
||||
schematic.setSchemType(SchematicType.wargear);
|
||||
return;
|
||||
}
|
||||
if(schematic.getSchemType() == SchematicType.Cminiwargear) {
|
||||
schematic.setSchemType(SchematicType.miniwargear);
|
||||
return;
|
||||
}
|
||||
if(schematic.getSchemType() == SchematicType.Cwarship) {
|
||||
schematic.setSchemType(SchematicType.warship);
|
||||
return;
|
||||
}
|
||||
if(schematic.getSchemType() == SchematicType.Cairship) {
|
||||
schematic.setSchemType(SchematicType.airship);
|
||||
return;
|
||||
}
|
||||
//TODO: save position times and total time to file
|
||||
//calculateTotalTime();
|
||||
|
||||
removeSchematic();
|
||||
remove();
|
||||
}
|
||||
|
||||
@ -140,6 +141,7 @@ public class CheckSession {
|
||||
this.schematic.setSchemType(SchematicType.normal);
|
||||
//TODO: save position times and total time to file
|
||||
//calculateTotalTime();
|
||||
removeSchematic();
|
||||
remove();
|
||||
}
|
||||
|
||||
@ -147,6 +149,10 @@ public class CheckSession {
|
||||
checkSessions.remove(this);
|
||||
}
|
||||
|
||||
public void removeSchematic() {
|
||||
this.editSession.undo(editSession);
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
@ -191,4 +197,12 @@ public class CheckSession {
|
||||
this.stopTime = System.currentTimeMillis();
|
||||
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();
|
||||
|
||||
|
||||
if(schematicList.isEmpty()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!");
|
||||
return;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.warking.schematicsystem.commands;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -39,7 +40,7 @@ public class CheckCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if(args.length == 1) {
|
||||
if(args[0].equalsIgnoreCase("checklist")) {
|
||||
if(args[0].equalsIgnoreCase("list")) {
|
||||
CheckUtils.sendTeammemberSchematicList(player, 15, 0);
|
||||
return false;
|
||||
}
|
||||
@ -85,7 +86,7 @@ public class CheckCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if(args.length == 2) {
|
||||
if(args[0].equalsIgnoreCase("checklist")) {
|
||||
if(args[0].equalsIgnoreCase("list")) {
|
||||
int currentPage;
|
||||
try {
|
||||
currentPage = Integer.parseInt(args[1]);
|
||||
@ -104,6 +105,11 @@ public class CheckCommand implements CommandExecutor {
|
||||
String schemName = args[1];
|
||||
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)) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
return false;
|
||||
@ -115,8 +121,9 @@ public class CheckCommand implements CommandExecutor {
|
||||
Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID());
|
||||
if(schematic != null) {
|
||||
for(CheckSession checkSession : CheckSession.checkSessions) {
|
||||
if(checkSession.getSchematic().equals(schematic)) {
|
||||
player.sendMessage(SchematicSystem.PREFIX +"§cDiese Schematic wird bereits geprüft!");
|
||||
if(checkSession.getSchematic().getSchemName().equals(schematic.getSchemName())
|
||||
&& checkSession.getSchematic().getSchemOwner() == schematic.getSchemOwner()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -127,7 +134,7 @@ public class CheckCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
@ -145,17 +152,22 @@ public class CheckCommand implements CommandExecutor {
|
||||
|
||||
World weWorld = new BukkitWorld(player.getWorld());
|
||||
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) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! PASTE");
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
CheckSession checkSession = new CheckSession(player.getUniqueId(), schematic, -1);
|
||||
checkSession.sendNextCheck();
|
||||
|
||||
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NULL");
|
||||
return false;
|
||||
@ -168,7 +180,7 @@ public class CheckCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if(args.length >= 3) {
|
||||
if(args.length >= 2) {
|
||||
if(args[0].equalsIgnoreCase("decline")) {
|
||||
|
||||
CheckSession checkSession = CheckSession.getCheckSession(player);
|
||||
@ -195,7 +207,7 @@ public class CheckCommand implements CommandExecutor {
|
||||
public void sendHelp(Player player) {
|
||||
if(CheckUtils.allowedToCheck(player)) {
|
||||
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 allow - §6Schematic freigeben");
|
||||
player.sendMessage("§8/ckeck decline <Grund> - §6Schematic nicht freigeben");
|
||||
|
@ -11,8 +11,10 @@ public class PlayerQuitListener implements Listener {
|
||||
@EventHandler
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(CheckSession.doesPlayerCheck(player))
|
||||
if(CheckSession.doesPlayerCheck(player)) {
|
||||
CheckSession.getCheckSession(player).removeSchematic();
|
||||
CheckSession.getCheckSession(player).remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren