fixed some methods
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
d666067915
Commit
a20b9fd2aa
@ -60,8 +60,8 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("load")) {
|
if(args[0].equalsIgnoreCase("load")) {
|
||||||
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
if(isSchematicNameAllowed(args[1])) {
|
if (Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
||||||
@ -73,25 +73,30 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("delete")) {
|
if(args[0].equalsIgnoreCase("delete")) {
|
||||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
if(schematic != null) {
|
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
if(schematic != null) {
|
||||||
file.delete();
|
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
||||||
schematic.remove();
|
file.delete();
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gelöscht.");
|
schematic.remove();
|
||||||
return false;
|
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gelöscht.");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,12 +111,16 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/", args[1]);
|
if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null)
|
||||||
ClipboardWriter writer = ClipboardFormat.findByFile(file).getWriter(new FileOutputStream(file));
|
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());
|
writer.write(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard(), FaweAPI.wrapPlayer(player).getSession().getClipboard().getWorldData());
|
||||||
Schematic schematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal);
|
Schematic schematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§Schematic §6" + args[1] + " §7gespeichert!");
|
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 {
|
} else {
|
||||||
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;
|
||||||
@ -124,17 +133,22 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
if(!player.hasPermission("bau.team")) return false;
|
if(!player.hasPermission("bau.team")) return false;
|
||||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||||
if(warkingUser != null) {
|
if(warkingUser != null) {
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic");
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
if(file.exists()) {
|
File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + args[1] + ".schematic");
|
||||||
try {
|
if(file.exists()) {
|
||||||
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
try {
|
||||||
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic")).getClipboard());
|
Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player);
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7von §6" + warkingUser.getUserName() + "§7geladen.");
|
SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic")).getClipboard());
|
||||||
} catch (IOException ex) {
|
player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7von §6" + warkingUser.getUserName() + "§7geladen.");
|
||||||
ex.printStackTrace();
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -180,9 +194,16 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
if(schematic != null) {
|
if(schematic != null) {
|
||||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||||
if(warkingUser != null) {
|
if(warkingUser != null) {
|
||||||
SchematicMember schematicMember = new SchematicMember(schematic.getSchemName(), player.getUniqueId(), warkingUser.getUUID());
|
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
|
||||||
return false;
|
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 {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||||
return false;
|
return false;
|
||||||
@ -198,9 +219,16 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
if(schematic != null) {
|
if(schematic != null) {
|
||||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||||
if(warkingUser != null) {
|
if(warkingUser != null) {
|
||||||
SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), player.getUniqueId(), warkingUser.getUUID()).remove();
|
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
|
||||||
return false;
|
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 {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||||
return false;
|
return false;
|
||||||
@ -246,6 +274,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
|
public static void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player) {
|
||||||
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
|
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
|
||||||
|
|
||||||
|
|
||||||
int pages = schematicList.size() / filesPerPage;
|
int pages = schematicList.size() / filesPerPage;
|
||||||
int currPage = currentPage;
|
int currPage = currentPage;
|
||||||
if(currPage > pages) {
|
if(currPage > pages) {
|
||||||
@ -253,6 +282,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
|
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
|
||||||
|
if(schematicList.get(i) == null) return;
|
||||||
|
|
||||||
TextComponent schematics = new TextComponent(schematicList.get(i).getSchemName());
|
TextComponent schematics = new TextComponent(schematicList.get(i).getSchemName());
|
||||||
schematics.setColor(ChatColor.AQUA);
|
schematics.setColor(ChatColor.AQUA);
|
||||||
@ -268,7 +298,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
nextPage.setColor(ChatColor.RED);
|
nextPage.setColor(ChatColor.RED);
|
||||||
|
|
||||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Naechste Seite...").create()));
|
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);
|
player.spigot().sendMessage(nextPage);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class PlayerJoinListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
|
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
|
||||||
File[] files = file.listFiles();
|
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) {
|
if(Schematic.getSchemFromDB(files[i].getName(), player.getUniqueId()) != null) {
|
||||||
Schematic schematic = new Schematic(files[i].getName(), player.getUniqueId(), "", SchematicType.normal);
|
Schematic schematic = new Schematic(files[i].getName(), player.getUniqueId(), "", SchematicType.normal);
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,10 @@ name: SchematicSystem
|
|||||||
version: 1.0
|
version: 1.0
|
||||||
author: [Yaruma3341, Lixfel]
|
author: [Yaruma3341, Lixfel]
|
||||||
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
|
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit]
|
||||||
|
|
||||||
main: de.warking.schematicsystem.SchematicSystem
|
main: de.warking.schematicsystem.SchematicSystem
|
||||||
|
|
||||||
|
commands:
|
||||||
|
schematic:
|
||||||
|
/schematic:
|
||||||
|
schem:
|
||||||
|
/schem:
|
In neuem Issue referenzieren
Einen Benutzer sperren