closed some security leaks; deleting schematics still buggy(TextComponents)
Signed-off-by: yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
b23ee2dd59
Commit
e21495a77a
@ -15,6 +15,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -63,6 +64,7 @@ public class SchematicCommand implements CommandExecutor {
|
||||
if(deletePlayers.contains(player.getUniqueId())) {
|
||||
deletePlayers.remove(player.getUniqueId());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§6Schematic wird nicht gelöscht.");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -119,7 +121,11 @@ public class SchematicCommand implements CommandExecutor {
|
||||
if(!deletePlayers.contains(player.getUniqueId())) {
|
||||
deletePlayers.add(player.getUniqueId());
|
||||
|
||||
TextComponent ja = new TextComponent("§6Moechtest du die Schematic wirklich loeschen? §aja ");
|
||||
TextComponent message = new TextComponent("§6Moechtest du die Schematic wirklich loeschen? ");
|
||||
message.setBold(true);
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Waehle eine Option...").create()));
|
||||
|
||||
TextComponent ja = new TextComponent("§aja ");
|
||||
ja.setBold(true);
|
||||
ja.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem savedelete " + args[1]));
|
||||
|
||||
@ -128,8 +134,9 @@ public class SchematicCommand implements CommandExecutor {
|
||||
nein.setBold(true);
|
||||
nein.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem removesavedelete"));
|
||||
|
||||
ja.addExtra(nein);
|
||||
player.spigot().sendMessage(ja);
|
||||
message.addExtra(ja);
|
||||
message.addExtra(nein);
|
||||
player.spigot().sendMessage(message);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
@ -148,9 +155,9 @@ public class SchematicCommand implements CommandExecutor {
|
||||
|
||||
if(args[0].equalsIgnoreCase("savedelete")) {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(deletePlayers.contains(player.getUniqueId())) {
|
||||
if(deletePlayers.contains(player.getUniqueId())) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
||||
file.delete();
|
||||
@ -162,10 +169,10 @@ public class SchematicCommand implements CommandExecutor {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cZum Löschen musst du der Owner der Schematic sein!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
@ -217,29 +224,32 @@ public class SchematicCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("info")) {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(args[0].equalsIgnoreCase("info")) {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
|
||||
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
|
||||
} else {
|
||||
player.sendMessage("§6Name: §7" + schematic.getSchemName());
|
||||
player.sendMessage("§6Typ: §7" + schematic.getSchemType().name());
|
||||
|
||||
List<String> schematicMembers = new ArrayList<>();
|
||||
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
||||
schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
|
||||
}
|
||||
if(schematicMembers.size() <= 3) {
|
||||
player.sendMessage("§6Member: §7" + schematicMembers.toString());
|
||||
} else
|
||||
player.sendMessage("§6Member: §7...");
|
||||
}
|
||||
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
|
||||
} else {
|
||||
|
||||
TextComponent loadSchematic = new TextComponent("LADEN");
|
||||
loadSchematic.setColor(ChatColor.DARK_GREEN);
|
||||
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
|
||||
player.spigot().sendMessage(loadSchematic);
|
||||
List<String> schematicMembers = new ArrayList<>();
|
||||
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
||||
schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
|
||||
}
|
||||
if(schematicMembers.size() <= 3) {
|
||||
player.sendMessage("§6Member: §7" + schematicMembers.toString());
|
||||
} else
|
||||
player.sendMessage("§6Member: §7...");
|
||||
}
|
||||
|
||||
TextComponent loadSchematic = new TextComponent("LADEN");
|
||||
loadSchematic.setColor(ChatColor.DARK_GREEN);
|
||||
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
|
||||
player.spigot().sendMessage(loadSchematic);
|
||||
|
||||
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
TextComponent deleteSchematic = new TextComponent("LOESCHEN");
|
||||
@ -321,56 +331,89 @@ public class SchematicCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("addmember")) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser.getUUID() != null) {
|
||||
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
||||
if(SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner()) != null) {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
|
||||
return false;
|
||||
} else {
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser.getUUID() != null) {
|
||||
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
||||
if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet!");
|
||||
return false;
|
||||
} else {
|
||||
SchematicMember schematicMember = new SchematicMember(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
||||
|
||||
SchematicMember schematicMember = new SchematicMember(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
||||
return false;
|
||||
Player target = Bukkit.getPlayer(warkingUser.getUUID());
|
||||
if(target != null)
|
||||
target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7von §6" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§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 ist bereits auf diese Schematic geaddet!");
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||
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!");
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
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) {
|
||||
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.");
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
|
||||
return false;
|
||||
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst dich nicht von deiner eigenen Schematic removen!");
|
||||
return false;
|
||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||
if(warkingUser.getUUID() != null) {
|
||||
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
||||
SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), WarkingUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
|
||||
if(schematicMember != null) {
|
||||
|
||||
schematicMember.remove();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
||||
|
||||
Player target = Bukkit.getPlayer(warkingUser.getUUID());
|
||||
if(target != null)
|
||||
target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §6" + schematic.getSchemName() + "§7von §6" + WarkingUser.get(schematic.getSchemOwner()).getUserName() + "§7.");
|
||||
return false;
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic geaddet!");
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class PlayerJoinListener implements Listener {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/");
|
||||
File[] files = file.listFiles();
|
||||
|
||||
if(files.length == 0) return;
|
||||
if(files == null || files.length == 0) return;
|
||||
|
||||
for(int i = 0; i < files.length; i++) {
|
||||
if(Schematic.getSchemFromDB(files[i].getName(), player.getUniqueId()) == null) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren