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.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -63,6 +64,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
if(deletePlayers.contains(player.getUniqueId())) {
|
if(deletePlayers.contains(player.getUniqueId())) {
|
||||||
deletePlayers.remove(player.getUniqueId());
|
deletePlayers.remove(player.getUniqueId());
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§6Schematic wird nicht gelöscht.");
|
player.sendMessage(SchematicSystem.PREFIX + "§6Schematic wird nicht gelöscht.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -119,7 +121,11 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
if(!deletePlayers.contains(player.getUniqueId())) {
|
if(!deletePlayers.contains(player.getUniqueId())) {
|
||||||
deletePlayers.add(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.setBold(true);
|
||||||
ja.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem savedelete " + args[1]));
|
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.setBold(true);
|
||||||
nein.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem removesavedelete"));
|
nein.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem removesavedelete"));
|
||||||
|
|
||||||
ja.addExtra(nein);
|
message.addExtra(ja);
|
||||||
player.spigot().sendMessage(ja);
|
message.addExtra(nein);
|
||||||
|
player.spigot().sendMessage(message);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -148,9 +155,9 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("savedelete")) {
|
if(args[0].equalsIgnoreCase("savedelete")) {
|
||||||
if(isSchematicNameAllowed(args[1])) {
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
if(deletePlayers.contains(player.getUniqueId())) {
|
||||||
if(schematic != null) {
|
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
if(deletePlayers.contains(player.getUniqueId())) {
|
if(schematic != null) {
|
||||||
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||||
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
File file = new File(SchematicSystem.SCHEM_DIR + player.getUniqueId() + "/" + args[1] + ".schematic");
|
||||||
file.delete();
|
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!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cZum Löschen musst du der Owner der Schematic sein!");
|
||||||
return false;
|
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 {
|
} 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!");
|
||||||
@ -217,29 +224,32 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("info")) {
|
if(args[0].equalsIgnoreCase("info")) {
|
||||||
if(isSchematicNameAllowed(args[1])) {
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
if(schematic != null) {
|
if(schematic != null) {
|
||||||
|
|
||||||
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
player.sendMessage("§6Name: §7" + schematic.getSchemName());
|
||||||
player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
|
player.sendMessage("§6Typ: §7" + schematic.getSchemType().name());
|
||||||
} else {
|
|
||||||
|
|
||||||
List<String> schematicMembers = new ArrayList<>();
|
if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||||
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName());
|
||||||
schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
|
} else {
|
||||||
}
|
|
||||||
if(schematicMembers.size() <= 3) {
|
|
||||||
player.sendMessage("§6Member: §7" + schematicMembers.toString());
|
|
||||||
} else
|
|
||||||
player.sendMessage("§6Member: §7...");
|
|
||||||
}
|
|
||||||
|
|
||||||
TextComponent loadSchematic = new TextComponent("LADEN");
|
List<String> schematicMembers = new ArrayList<>();
|
||||||
loadSchematic.setColor(ChatColor.DARK_GREEN);
|
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
||||||
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
|
schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName());
|
||||||
player.spigot().sendMessage(loadSchematic);
|
}
|
||||||
|
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())) {
|
if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||||
TextComponent deleteSchematic = new TextComponent("LOESCHEN");
|
TextComponent deleteSchematic = new TextComponent("LOESCHEN");
|
||||||
@ -321,56 +331,89 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("addmember")) {
|
if(args[0].equalsIgnoreCase("addmember")) {
|
||||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
if(schematic != null) {
|
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
if(schematic != null) {
|
||||||
if(warkingUser.getUUID() != null) {
|
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
|
||||||
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
|
||||||
if(SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner()) != null) {
|
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 target = Bukkit.getPlayer(warkingUser.getUUID());
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §6" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §6" + schematic.getSchemName() + "§7.");
|
if(target != null)
|
||||||
return false;
|
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 {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
||||||
return false;
|
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 + "§cDiese Schematic existiert nicht!");
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("delmember")) {
|
if(args[0].equalsIgnoreCase("delmember")) {
|
||||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
if(isSchematicNameAllowed(args[1])) {
|
||||||
if(schematic != null) {
|
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||||
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
if(schematic != null) {
|
||||||
if(warkingUser != null) {
|
if(schematic.getSchemOwner() != WarkingUser.get(player.getUniqueId()).getId()) {
|
||||||
if(schematic.getSchemOwner() != warkingUser.getId()) {
|
player.sendMessage(SchematicSystem.PREFIX + "§cDafür musst du der Owner der Schematic sein!");
|
||||||
|
|
||||||
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;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst dich nicht von deiner eigenen Schematic removen!");
|
WarkingUser warkingUser = WarkingUser.get(args[2]);
|
||||||
return false;
|
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 {
|
} else {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!");
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class PlayerJoinListener implements Listener {
|
|||||||
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();
|
||||||
|
|
||||||
if(files.length == 0) return;
|
if(files == null || files.length == 0) return;
|
||||||
|
|
||||||
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) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren