Fixing server stopping & removing commented code
Dieser Commit ist enthalten in:
Ursprung
2f5d577edb
Commit
1c4d6d65d1
@ -115,7 +115,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent e){
|
||||
if(Bukkit.getOnlinePlayers().isEmpty())
|
||||
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer())))
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -13,135 +13,7 @@ import java.util.UUID;
|
||||
|
||||
public class CommandBau implements CommandExecutor {
|
||||
|
||||
//TODO: Move to BungeeCore
|
||||
|
||||
/*@Command(name = "bau", aliases = {"bau.help", "gs", "gs.help"}, inGameOnly = true)
|
||||
public void onHelp(CommandArgs args) {
|
||||
Player p = args.getPlayer();
|
||||
p.sendMessage(BauSystem.PREFIX + "Hilfeseite 1 von 2:");
|
||||
p.sendMessage("§6/bau help §7- Zeigt dir diese Hilfe");
|
||||
p.sendMessage("§6/bau help 2 §7- Zeigt dir die Hilfe zum Member-System");
|
||||
p.sendMessage("§6/home §7- Teleportiert dich auf deine Welt");
|
||||
p.sendMessage("§6/tnt §7- (de)aktiviert Explosionsschaden");
|
||||
p.sendMessage("§6/fire §7- (de)aktiviert Feuerschaden");
|
||||
p.sendMessage("§6/testblock §7- Erneuert den nächsten Testblock");
|
||||
p.sendMessage("§6/reset §7- Setzt die derzeitige Region zurück");
|
||||
p.sendMessage("§6/bau resetall §7- Setzt deine Welt zurück");
|
||||
p.sendMessage("§6/speed §7- Ändert deine Fluggeschwindigkeit");
|
||||
p.sendMessage("§6/nv §7- (de)aktiviert Nachtsicht");
|
||||
p.sendMessage("§6/trace §7- Gibt einen Überblick über den TNT-Tracer");
|
||||
//p.sendMessage("§6/bau gui §7- Öffnet eine GUI");
|
||||
}
|
||||
|
||||
@Command(name = "bau.help.2", aliases = {"gs.help.2", "bau.2", "gs.2"}, inGameOnly = true)
|
||||
public void onHelp2(CommandArgs args) {
|
||||
Player p = args.getPlayer();
|
||||
p.sendMessage(BauSystem.PREFIX + "Hilfeseite 2 von 2:");
|
||||
p.sendMessage("§6/bau addmember §7- Fügt zu deiner Welt einen Spieler hinzu");
|
||||
p.sendMessage("§6/bau delmember §7- Entfernt einen Spieler von deiner Welt");
|
||||
p.sendMessage("§6/bau togglebuild §7- Berechtigung zum Bauen, Spielmodus wechseln, /tp");
|
||||
p.sendMessage("§6/bau togglewe §7- Berechtigung für: WorldEdit, /bau replace, /bau testblock");
|
||||
p.sendMessage("§6/bau toggleworld §7- Berechtigung für: /bau reset, /trace, /fire, /tnt");
|
||||
}
|
||||
|
||||
@Command(name = "bau.home", aliases = {"gs.home", "home"}, inGameOnly = true)
|
||||
public void onHome(CommandArgs args) {
|
||||
Player p = args.getPlayer();
|
||||
if (Bauwelt.getBauwelt(p.getUniqueId()) == null) {
|
||||
new Bauwelt(p.getUniqueId(), false, false);
|
||||
}
|
||||
if (Bukkit.getWorld(p.getUniqueId().toString()) == null){
|
||||
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet");
|
||||
try {
|
||||
Welt.loadWorld(p.getUniqueId());
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
p.teleport(Bukkit.getWorld(p.getUniqueId().toString()).getSpawnLocation());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> p.setGameMode(GameMode.CREATIVE),20L);
|
||||
}
|
||||
|
||||
@Command(name = "bau.tp", aliases = "gs.tp", inGameOnly = true)
|
||||
public void onTp(CommandArgs args) {
|
||||
Player p = args.getPlayer();
|
||||
if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau tp <Spieler>");
|
||||
return;
|
||||
}
|
||||
|
||||
UUID worldOwner = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||
if (!Welt.hasPermission(worldOwner, p, Permission.member)){
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich nicht auf diese Welt teleportieren");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.getWorld(worldOwner.toString()) == null){
|
||||
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Die Welt wird vorbereitet");
|
||||
try {
|
||||
Welt.loadWorld(worldOwner);
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
p.teleport(Bukkit.getWorld(worldOwner.toString()).getSpawnLocation());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> p.setGameMode(GameMode.CREATIVE), 20);
|
||||
}
|
||||
|
||||
@Command(name = "bau.addmember", aliases = "gs.addmember", inGameOnly = true)
|
||||
public void onAdd(CommandArgs args) {
|
||||
Player p = args.getPlayer();
|
||||
if (!hasWorld(p)){
|
||||
return;
|
||||
}else if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau addmember <Spieler>");
|
||||
return;
|
||||
}
|
||||
|
||||
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||
if (id == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||
return;
|
||||
}else if (BauweltMember.getBauMember(p.getUniqueId(), id) != null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
||||
return;
|
||||
}
|
||||
|
||||
new BauweltMember(p.getUniqueId(), id, true, false, false, false, false);
|
||||
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler wurde zu deiner Welt hinzugefügt");
|
||||
|
||||
Player z = Bukkit.getPlayer(id);
|
||||
if(z != null)
|
||||
z.sendMessage(BauSystem.PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
|
||||
}*/
|
||||
|
||||
private void onDel(Player p, String arg) {
|
||||
/*if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau delmember <Spieler>");
|
||||
return;
|
||||
}*/
|
||||
|
||||
UUID id = WarkingUser.get(arg).getUUID();
|
||||
if(!toggleCheck(p, id)){
|
||||
return;
|
||||
}
|
||||
|
||||
BauweltMember target = BauweltMember.getBauMember(id);
|
||||
Welt.removePlayer(p, target);
|
||||
}
|
||||
|
||||
private void onToggleBD(Player p, String arg) {
|
||||
/*if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau togglebuild <Spieler>");
|
||||
return;
|
||||
}*/
|
||||
|
||||
UUID id = WarkingUser.get(arg).getUUID();
|
||||
if(!toggleCheck(p, id)){
|
||||
return;
|
||||
@ -152,11 +24,6 @@ public class CommandBau implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void onToggleWE(Player p, String arg) {
|
||||
/*if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau togglewe <Spieler>");
|
||||
return;
|
||||
}*/
|
||||
|
||||
UUID id = WarkingUser.get(arg).getUUID();
|
||||
if(!toggleCheck(p, id)){
|
||||
return;
|
||||
@ -167,11 +34,6 @@ public class CommandBau implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void onToggleWorld(Player p, String arg) {
|
||||
/*if (args.length() == 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/bau toggleworld <Spieler>");
|
||||
return;
|
||||
}*/
|
||||
|
||||
UUID id = WarkingUser.get(arg).getUUID();
|
||||
if(!toggleCheck(p, id)){
|
||||
return;
|
||||
@ -181,39 +43,6 @@ public class CommandBau implements CommandExecutor {
|
||||
Welt.toggleTestblock(p, target);
|
||||
}
|
||||
|
||||
/*public void onResetAll(CommandArgs args) {
|
||||
final Player p = args.getPlayer();
|
||||
p.sendMessage(BauSystem.PREFIX + "§aDeine Welt wird zurückgesetzt. Einen Moment bitte");
|
||||
Welt.unloadWorld(p.getUniqueId());
|
||||
File directory = new File("plugins/BauSystem/worlds/" + p.getUniqueId().toString());
|
||||
del(directory);
|
||||
File directory1 = new File("plugins/WorldGuard/worlds/" + p.getUniqueId().toString());
|
||||
del(directory1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> onHome(args),20L);
|
||||
}
|
||||
|
||||
private void del(File dir){
|
||||
if (dir.isDirectory()){
|
||||
String[] entries = dir.list();
|
||||
for (String entry : entries) {
|
||||
File aktFile = new File(dir.getPath(), entry);
|
||||
del(aktFile);
|
||||
}
|
||||
dir.delete();
|
||||
}
|
||||
else{
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasWorld(Player p){
|
||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Bauwelt");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
|
||||
private boolean toggleCheck(Player p, UUID id){
|
||||
if (id == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||
@ -234,9 +63,7 @@ public class CommandBau implements CommandExecutor {
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args[0].equalsIgnoreCase("delmember")){
|
||||
onDel(player, args[1]);
|
||||
}else if(args[0].equalsIgnoreCase("togglebuild")){
|
||||
if(args[0].equalsIgnoreCase("togglebuild")){
|
||||
onToggleBD(player, args[1]);
|
||||
}else if(args[0].equalsIgnoreCase("togglewe")){
|
||||
onToggleWE(player, args[1]);
|
||||
|
@ -16,32 +16,28 @@ public class BauweltMember{
|
||||
private final int BauweltID;
|
||||
private final int MemberID;
|
||||
private boolean Build;
|
||||
private boolean ChangeGM;
|
||||
private boolean Teleport;
|
||||
private boolean WorldEdit;
|
||||
private boolean Testblock;
|
||||
private boolean World;
|
||||
|
||||
private static final List<BauweltMember> members = new ArrayList<>();
|
||||
|
||||
private BauweltMember(int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock, boolean updateDB){
|
||||
private BauweltMember(int memberID, boolean build, boolean worldEdit, boolean world, boolean updateDB){
|
||||
BauweltID = BauSystem.getOwnerID();
|
||||
MemberID = memberID;
|
||||
Build = build;
|
||||
ChangeGM = changeGM;
|
||||
Teleport = teleport;
|
||||
WorldEdit = worldEdit;
|
||||
Testblock = testblock;
|
||||
World = world;
|
||||
if(updateDB)
|
||||
updateDB();
|
||||
members.add(this);
|
||||
}
|
||||
|
||||
public BauweltMember(int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
|
||||
this(memberID, build, changeGM, teleport, worldEdit, testblock, true);
|
||||
public BauweltMember(int memberID, boolean build, boolean worldEdit, boolean world){
|
||||
this(memberID, build, worldEdit, world, true);
|
||||
}
|
||||
|
||||
public BauweltMember(UUID memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
|
||||
this(WarkingUser.get(memberID).getId(), build, changeGM, teleport, worldEdit, testblock, true);
|
||||
public BauweltMember(UUID memberID, boolean build, boolean worldEdit, boolean world){
|
||||
this(WarkingUser.get(memberID).getId(), build, worldEdit, world, true);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
@ -51,11 +47,11 @@ public class BauweltMember{
|
||||
|
||||
private void updateDB(){
|
||||
sql.update("INSERT INTO BauweltMember" +
|
||||
" (BauweltID, MemberID, Build, ChangeGM, Teleport, WorldEdit, Testblock)" +
|
||||
" (BauweltID, MemberID, Build, WorldEdit, World)" +
|
||||
" VALUES" +
|
||||
" ('" + BauweltID + "', '" + MemberID + "', '" + MySQL.booleanToInt(Build) + "', '" + MySQL.booleanToInt(ChangeGM) + "', '" + sql.booleanToInt(Teleport) + "', '" + sql.booleanToInt(WorldEdit) + "', '" + sql.booleanToInt(Testblock) + "')" +
|
||||
" ('" + BauweltID + "', '" + MemberID + "', '" + MySQL.booleanToInt(Build) + "', '" + sql.booleanToInt(WorldEdit) + "', '" + sql.booleanToInt(World) + "')" +
|
||||
" ON DUPLICATE KEY UPDATE" +
|
||||
" Build = VALUES(Build), ChangeGM = VALUES(ChangeGM), Teleport = VALUES(Teleport), WorldEdit = VALUES(WorldEdit), Testblock = VALUES(Testblock)");
|
||||
" Build = VALUES(Build), WorldEdit = VALUES(WorldEdit), World = VALUES(World)");
|
||||
}
|
||||
|
||||
public static BauweltMember getBauMember(UUID memberID){
|
||||
@ -72,11 +68,9 @@ public class BauweltMember{
|
||||
return null;
|
||||
}
|
||||
boolean build = member.getBoolean("Build");
|
||||
boolean changeGM = member.getBoolean("ChangeGM");
|
||||
boolean teleport = member.getBoolean("Teleport");
|
||||
boolean worldEdit = member.getBoolean("WorldEdit");
|
||||
boolean testblock = member.getBoolean("Testblock");
|
||||
return new BauweltMember(memberID, build, changeGM, teleport, worldEdit, testblock, false);
|
||||
boolean testblock = member.getBoolean("World");
|
||||
return new BauweltMember(memberID, build, worldEdit, testblock, false);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -94,11 +88,9 @@ public class BauweltMember{
|
||||
while(memberlist.next()){
|
||||
int memberID = memberlist.getInt("MemberID");
|
||||
boolean build = memberlist.getBoolean("Build");
|
||||
boolean changeGM = memberlist.getBoolean("ChangeGM");
|
||||
boolean teleport = memberlist.getBoolean("Teleport");
|
||||
boolean worldEdit = memberlist.getBoolean("WorldEdit");
|
||||
boolean testblock = memberlist.getBoolean("Testblock");
|
||||
members.add(new BauweltMember(memberID, build, changeGM, teleport, worldEdit, testblock, false));
|
||||
boolean testblock = memberlist.getBoolean("World");
|
||||
members.add(new BauweltMember(memberID, build, worldEdit, testblock, false));
|
||||
}
|
||||
return members;
|
||||
}catch(SQLException e){
|
||||
@ -124,24 +116,6 @@ public class BauweltMember{
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public boolean isChangeGM() {
|
||||
return ChangeGM;
|
||||
}
|
||||
|
||||
public void setChangeGM(boolean changeGM) {
|
||||
ChangeGM = changeGM;
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public boolean isTeleport() {
|
||||
return Teleport;
|
||||
}
|
||||
|
||||
public void setTeleport(boolean teleport) {
|
||||
Teleport = teleport;
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public boolean isWorldEdit() {
|
||||
return WorldEdit;
|
||||
}
|
||||
@ -151,12 +125,12 @@ public class BauweltMember{
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public boolean isTestblock() {
|
||||
return Testblock;
|
||||
public boolean isWorld() {
|
||||
return World;
|
||||
}
|
||||
|
||||
public void setTestblock(boolean testblock) {
|
||||
Testblock = testblock;
|
||||
public void setWorld(boolean world) {
|
||||
World = world;
|
||||
updateDB();
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ public class Welt {
|
||||
case worldedit:
|
||||
return member1.isWorldEdit();
|
||||
case world:
|
||||
return member1.isTestblock();
|
||||
return member1.isWorld();
|
||||
case member:
|
||||
return true;
|
||||
default:
|
||||
@ -98,28 +98,19 @@ public class Welt {
|
||||
}
|
||||
|
||||
public static void toggleTestblock(Player p, BauweltMember target){
|
||||
target.setTestblock(!target.isTestblock());
|
||||
target.setWorld(!target.isWorld());
|
||||
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||
if (z != null) {
|
||||
if (target.isTestblock()) {
|
||||
if (target.isWorld()) {
|
||||
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a Einstellungen vornehmen");
|
||||
}else {
|
||||
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c Einstellungen vornehmen");
|
||||
}
|
||||
}
|
||||
if (target.isTestblock()) {
|
||||
if (target.isWorld()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun Einstellungen vornehmen");
|
||||
} else {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr Einstellungen vornehmen");
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePlayer(Player p, BauweltMember target){
|
||||
target.remove();
|
||||
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||
if(z != null){
|
||||
z.kickPlayer(BauSystem.PREFIX + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt");
|
||||
}
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler wurde entfernt");
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren