13
0

fixed some methods

Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-03-30 10:47:18 +01:00 committet von yaruma3341
Ursprung d666067915
Commit a20b9fd2aa
3 geänderte Dateien mit 68 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -60,8 +60,8 @@ public class SchematicCommand implements CommandExecutor {
}
if(args[0].equalsIgnoreCase("load")) {
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
if(isSchematicNameAllowed(args[1])) {
if (Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
try {
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
@ -73,16 +73,17 @@ public class SchematicCommand implements CommandExecutor {
return false;
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
return false;
}
}
if(args[0].equalsIgnoreCase("delete")) {
if(isSchematicNameAllowed(args[1])) {
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
if(schematic != null) {
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
@ -94,6 +95,10 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
return false;
}
}
if(args[0].equalsIgnoreCase("save")) {
@ -106,12 +111,16 @@ public class SchematicCommand implements CommandExecutor {
return false;
}
}
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/", args[1]);
ClipboardWriter writer = ClipboardFormat.findByFile(file).getWriter(new FileOutputStream(file));
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null)
Schematic.getSchemFromDB(args[1], player.getUniqueId()).remove();
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
file.createNewFile();
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(new FileOutputStream(file));
writer.write(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard(), FaweAPI.wrapPlayer(player).getSession().getClipboard().getWorldData());
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(); }
} catch (IOException ex) { ex.printStackTrace(); } catch (EmptyClipboardException ex) { ex.printStackTrace(); player.sendMessage(SchematicSystem.PREFIX + "§cBeim Speichern der Schematic ist ein Fehler aufgetreten!");}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
return false;
@ -124,7 +133,8 @@ public class SchematicCommand implements CommandExecutor {
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(isSchematicNameAllowed(args[1])) {
File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + args[1] + ".schematic");
if(file.exists()) {
try {
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
@ -137,6 +147,10 @@ public class SchematicCommand implements CommandExecutor {
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
return false;
@ -180,9 +194,16 @@ public class SchematicCommand implements CommandExecutor {
if(schematic != null) {
WarkingUser warkingUser = WarkingUser.get(args[2]);
if(warkingUser != null) {
if(schematic.getSchemOwner() != warkingUser.getId()) {
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 + "§cDu kannst dich nicht auf deine eigenen Schematics adden!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
return false;
@ -198,9 +219,16 @@ public class SchematicCommand implements CommandExecutor {
if(schematic != null) {
WarkingUser warkingUser = WarkingUser.get(args[2]);
if(warkingUser != null) {
if(schematic.getSchemOwner() != warkingUser.getId()) {
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 + "§cDu kannst dich nicht von deiner eigenen Schematic removen!");
return false;
}
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
return false;
@ -246,6 +274,7 @@ public class SchematicCommand implements CommandExecutor {
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
int pages = schematicList.size() / filesPerPage;
int currPage = currentPage;
if(currPage > pages) {
@ -253,6 +282,7 @@ public class SchematicCommand implements CommandExecutor {
}
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
if(schematicList.get(i) == null) return;
TextComponent schematics = new TextComponent(schematicList.get(i).getSchemName());
schematics.setColor(ChatColor.AQUA);
@ -268,7 +298,7 @@ public class SchematicCommand implements CommandExecutor {
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Naechste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "schematic list " + currentPage + 1)); //COMMAND MISSING
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "schematic list " + currentPage + 1));
player.spigot().sendMessage(nextPage);
}

Datei anzeigen

@ -17,7 +17,7 @@ public class PlayerJoinListener implements Listener {
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++) {
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);
}

Datei anzeigen

@ -2,5 +2,10 @@ name: SchematicSystem
version: 1.0
author: [Yaruma3341, Lixfel]
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
main: de.warking.schematicsystem.SchematicSystem
commands:
schematic:
/schematic:
schem:
/schem: