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])) {
|
||||
if(deletePlayers.contains(player.getUniqueId())) {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
if(deletePlayers.contains(player.getUniqueId())) {
|
||||
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
||||
file.delete();
|
||||
@ -162,11 +169,11 @@ 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 + "§cDer angegebene Schematic Name enthält verbotene Zeichen!");
|
||||
return false;
|
||||
@ -222,6 +229,9 @@ public class SchematicCommand implements CommandExecutor {
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null) {
|
||||
|
||||
player.sendMessage("§6Name: §7" + schematic.getSchemName());
|
||||
player.sendMessage("§6Typ: §7" + schematic.getSchemType().name());
|
||||
|
||||
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
|
||||
} else {
|
||||
@ -321,18 +331,26 @@ public class SchematicCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("addmember")) {
|
||||
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.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner()) != null) {
|
||||
|
||||
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.");
|
||||
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 {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet!");
|
||||
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.");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -344,22 +362,42 @@ public class SchematicCommand implements CommandExecutor {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler 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!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("delmember")) {
|
||||
if(isSchematicNameAllowed(args[1])) {
|
||||
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(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()) {
|
||||
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!");
|
||||
@ -369,10 +407,15 @@ public class SchematicCommand implements CommandExecutor {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler 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!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("lock")) {
|
||||
|
@ -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