reworked some methods
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
9df919de52
Commit
3bc7057c59
@ -1,7 +1,10 @@
|
|||||||
package de.warking.schematicsystem.commands;
|
package de.warking.schematicsystem.commands;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import de.warking.hunjy.MySQL.Schematic;
|
import de.warking.hunjy.MySQL.Schematic;
|
||||||
import de.warking.schematicsystem.SchematicSystem;
|
import de.warking.schematicsystem.SchematicSystem;
|
||||||
@ -16,6 +19,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("load")) {
|
if(args[0].equalsIgnoreCase("load")) {
|
||||||
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
|
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
|
||||||
//load schematic to player clipboard
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(sender);
|
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(sender);
|
||||||
@ -61,6 +65,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
|
||||||
break;
|
break;
|
||||||
@ -69,13 +74,22 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("delete")) {
|
if(args[0].equalsIgnoreCase("delete")) {
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + args[1] + ".schematic");
|
File file = new File(SchematicSystem.SCHEM_DIR + args[1] + ".schematic");
|
||||||
|
if(file.exists()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + "§7gelöscht.");
|
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + "§7gelöscht.");
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("save")) {
|
if(args[0].equalsIgnoreCase("save")) {
|
||||||
//Save schematic
|
try {
|
||||||
|
File file = new File(SchematicSystem.SCHEM_DIR, args[1]);
|
||||||
|
ClipboardWriter writer = ClipboardFormat.findByFile(file).getWriter(new FileOutputStream(file));
|
||||||
|
writer.write(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard(), FaweAPI.wrapPlayer(player).getSession().getClipboard().getWorldData());
|
||||||
|
} catch (IOException ex) { } catch (EmptyClipboardException ex) { }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -132,4 +146,16 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
player.spigot().sendMessage(nextPage);
|
player.spigot().sendMessage(nextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSchematicNameAllowed(String schematicName) {
|
||||||
|
if(schematicName.contains("/") ||
|
||||||
|
schematicName.contains("\\") ||
|
||||||
|
schematicName.contains("<") ||
|
||||||
|
schematicName.contains(">") ||
|
||||||
|
schematicName.contains("^") ||
|
||||||
|
schematicName.contains("°")) {
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren