added nearly all functions
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
3bc7057c59
Commit
d666067915
@ -2,8 +2,10 @@ package de.warking.schematicsystem;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import de.warking.schematicsystem.commands.SchematicCommand;
|
||||
import de.warking.schematicsystem.listener.PlayerJoinListener;
|
||||
import de.warking.schematicsystem.utils.CommandRemover;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SchematicSystem extends JavaPlugin {
|
||||
@ -26,12 +28,19 @@ public class SchematicSystem extends JavaPlugin {
|
||||
getCommand("/schematic").setExecutor(new SchematicCommand());
|
||||
getCommand("schem").setExecutor(new SchematicCommand());
|
||||
getCommand("/schem").setExecutor(new SchematicCommand());
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new PlayerJoinListener(), instance);
|
||||
}
|
||||
|
||||
|
||||
public static SchematicSystem getInstance() {
|
||||
return instance;
|
||||
|
@ -7,6 +7,9 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
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 de.warking.schematicsystem.SchematicSystem;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -41,14 +44,18 @@ public class SchematicCommand implements CommandExecutor {
|
||||
|
||||
case 1:
|
||||
if(args[0].equalsIgnoreCase("list")) {
|
||||
sendPlayerScheamticList(0, 15, player);
|
||||
break;
|
||||
sendPlayerSchematicList(0, 15, player);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
if(args[0].equalsIgnoreCase("help")) {
|
||||
sendHelp(player);
|
||||
}
|
||||
return false;
|
||||
|
||||
case 2:
|
||||
if(args[0].equalsIgnoreCase("list")) {
|
||||
sendPlayerScheamticList(Integer.parseInt(args[1]), 15, player);
|
||||
sendPlayerSchematicList(Integer.parseInt(args[1]), 15, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,41 +64,160 @@ public class SchematicCommand implements CommandExecutor {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
|
||||
try {
|
||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(sender);
|
||||
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.PREFIX + args[1])).getClipboard());
|
||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
||||
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/", args[1] + ".schematic")).getClipboard());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7geladen.");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
return false;
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("delete")) {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + args[1] + ".schematic");
|
||||
if(file.exists()) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
||||
file.delete();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + "§7gelöscht.");
|
||||
break;
|
||||
schematic.remove();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gelöscht.");
|
||||
return false;
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("save")) {
|
||||
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
try {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR, args[1]);
|
||||
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
|
||||
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()).getSchemType() != SchematicType.normal) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst dieses Schematic Typ nicht überschreiben!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/", 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) { }
|
||||
Schematic schematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§Schematic §6" + args[1] + " §7gespeichert!");
|
||||
} catch (IOException ex) { ex.printStackTrace(); } catch (EmptyClipboardException ex) { ex.printStackTrace(); }
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case 3:
|
||||
if(args[0].equalsIgnoreCase("load")) {
|
||||
if(!player.hasPermission("bau.team")) return false;
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser != null) {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic");
|
||||
if(file.exists()) {
|
||||
try {
|
||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
||||
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic")).getClipboard());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7von §6" + warkingUser.getUserName() + "§7geladen.");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("changetype")) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(args[2].equalsIgnoreCase("airship")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[2].equalsIgnoreCase("miniwargear")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[2].equalsIgnoreCase("wargear")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[2].equalsIgnoreCase("warships")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[2].equalsIgnoreCase("normal")) {
|
||||
schematic.setSchemType(SchematicType.normal);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§Schematic Type §6normal §7gesetzt!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("addmember")) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser != null) {
|
||||
SchematicMember schematicMember = new SchematicMember(schematic.getSchemName(), player.getUniqueId(), warkingUser.getUUID());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
||||
return false;
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("delmember")) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser != null) {
|
||||
SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), player.getUniqueId(), warkingUser.getUUID()).remove();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
||||
return false;
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("lock")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("unlock")) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -104,12 +230,12 @@ public class SchematicCommand implements CommandExecutor {
|
||||
player.sendMessage("§8//schem load <Name> [Besitzer] - §6Du lädst eine Schematic");
|
||||
player.sendMessage("§8//schem save <Name> - §6Du speicherst dein Clipboard als Datei");
|
||||
player.sendMessage("§8//schem changetype <Name> <airship/miniwargear/wargear/normal> - §6Ändert den Typ deiner Schematic");
|
||||
player.sendMessage("§8//schem info <Name> - §6Zeigt dir Informationen zu der Schematic");
|
||||
//Vlt. später --> player.sendMessage("§8//schem info <Name> - §6Zeigt dir Informationen zu der Schematic");
|
||||
player.sendMessage("§8//schem delete <Name> - §6Löscht eine Schematic");
|
||||
player.sendMessage("§8//schem addmember <Schematic> <Spieler> - §6Fügt einen Spieler zu einer Schematic hinzu");
|
||||
player.sendMessage("§8//schem delmember <Schematic> <Spieler> - §6Entfernt einen Spieler von einer Schematic");
|
||||
|
||||
if (player.hasPermission("schemorg.help")) {
|
||||
if (player.hasPermission("bau.team")) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cTeambefehle:");
|
||||
player.sendMessage("§8//schem lock <Name> <Besitzer/Team> - §6Sperrt eine Schematic");
|
||||
player.sendMessage("§8//schem unlock <Name> <Besitzer/Team> - §6Entsperrt eine Schematic");
|
||||
@ -117,7 +243,7 @@ public class SchematicCommand implements CommandExecutor {
|
||||
|
||||
}
|
||||
|
||||
public static void sendPlayerScheamticList(int currentPage, int filesPerPage, Player player) {
|
||||
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
|
||||
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
|
||||
|
||||
int pages = schematicList.size() / filesPerPage;
|
||||
@ -153,7 +279,9 @@ public class SchematicCommand implements CommandExecutor {
|
||||
schematicName.contains("<") ||
|
||||
schematicName.contains(">") ||
|
||||
schematicName.contains("^") ||
|
||||
schematicName.contains("°")) {
|
||||
schematicName.contains("°") ||
|
||||
schematicName.contains("'") ||
|
||||
schematicName.contains("\"")) {
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
28
src/de/warking/schematicsystem/listener/PlayerJoinListener.java
Normale Datei
28
src/de/warking/schematicsystem/listener/PlayerJoinListener.java
Normale Datei
@ -0,0 +1,28 @@
|
||||
package de.warking.schematicsystem.listener;
|
||||
|
||||
import de.warking.hunjy.MySQL.Schematic;
|
||||
import de.warking.hunjy.MySQL.SchematicType;
|
||||
import de.warking.schematicsystem.SchematicSystem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
|
||||
File[] files = file.listFiles();
|
||||
for(int i = 0; i <= files.length; i++) {
|
||||
if(Schematic.getSchemFromDB(files[i].getName(), player.getUniqueId()) != null) {
|
||||
Schematic schematic = new Schematic(files[i].getName(), player.getUniqueId(), "", SchematicType.normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren