From c8d5c39fe356fc3c0d02b6dacdf82f6d339e77c4 Mon Sep 17 00:00:00 2001 From: rlf Date: Sun, 14 Dec 2014 00:04:26 +0100 Subject: [PATCH] Fix-attempt at #56 WG region over-eager to create --- .../talabrek/ultimateskyblock/uSkyBlock.java | 77 ++++-------------- src/test/resources/Proskillplayer | Bin 0 -> 1191 bytes 2 files changed, 16 insertions(+), 61 deletions(-) create mode 100644 src/test/resources/Proskillplayer diff --git a/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java b/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java index 6ea92e623..3639cf8fe 100644 --- a/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java +++ b/src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java @@ -156,7 +156,7 @@ public void onEnable() { instance = this; configFiles.clear(); createFolders(); - this.pName = ChatColor.WHITE + "[" + ChatColor.GREEN + getDescription().getName() + ChatColor.WHITE + "] "; + uSkyBlock.pName = "[" + getDescription().getName() + "] "; VaultHandler.setupEconomy(); if (Settings.loadPluginConfig(getConfig())) { saveConfig(); @@ -167,8 +167,6 @@ public void onEnable() { this.levelLogic = new LevelLogic(getFileConfiguration("levelConfig.yml")); this.islandLogic = new IslandLogic(this); - this.loadPlayerFiles(); - registerEvents(); this.getCommand("island").setExecutor(new IslandCommand()); this.getCommand("challenges").setExecutor(new ChallengesCommand()); @@ -184,23 +182,22 @@ public void run() { log(Level.INFO, "Using vault for permissions"); VaultHandler.setupPermissions(); try { - if (!uSkyBlock.this.getLastIslandConfig().contains("options.general.lastIslandX") && uSkyBlock.this.getConfig().contains("options.general.lastIslandX")) { - uSkyBlock.this.getLastIslandConfig(); - FileConfiguration.createPath(uSkyBlock.this.getLastIslandConfig().getConfigurationSection("options.general"), "lastIslandX"); - uSkyBlock.this.getLastIslandConfig(); - FileConfiguration.createPath(uSkyBlock.this.getLastIslandConfig().getConfigurationSection("options.general"), "lastIslandZ"); - uSkyBlock.this.getLastIslandConfig().set("options.general.lastIslandX", uSkyBlock.this.getConfig().getInt("options.general.lastIslandX")); - uSkyBlock.this.getLastIslandConfig().set("options.general.lastIslandZ", uSkyBlock.this.getConfig().getInt("options.general.lastIslandZ")); - uSkyBlock.this.saveLastIslandConfig(); + FileConfiguration config = getLastIslandConfig(); + if (!config.contains("options.general.lastIslandX") && uSkyBlock.this.getConfig().contains("options.general.lastIslandX")) { + FileConfiguration.createPath(config.getConfigurationSection("options.general"), "lastIslandX"); + FileConfiguration.createPath(config.getConfigurationSection("options.general"), "lastIslandZ"); + config.set("options.general.lastIslandX", getConfig().getInt("options.general.lastIslandX")); + config.set("options.general.lastIslandZ", getConfig().getInt("options.general.lastIslandZ")); + saveLastIslandConfig(); } - setLastIsland(new Location(uSkyBlock.getSkyBlockWorld(), (double) uSkyBlock.this.getLastIslandConfig().getInt("options.general.lastIslandX"), (double) Settings.island_height, (double) uSkyBlock.this.getLastIslandConfig().getInt("options.general.lastIslandZ"))); + setLastIsland(new Location(uSkyBlock.getSkyBlockWorld(), (double) config.getInt("options.general.lastIslandX"), (double) Settings.island_height, (double) config.getInt("options.general.lastIslandZ"))); } catch (Exception e) { setLastIsland(new Location(uSkyBlock.getSkyBlockWorld(), (double) uSkyBlock.this.getConfig().getInt("options.general.lastIslandX"), (double) Settings.island_height, (double) uSkyBlock.this.getConfig().getInt("options.general.lastIslandZ"))); } if (uSkyBlock.this.lastIsland == null) { setLastIsland(new Location(uSkyBlock.getSkyBlockWorld(), 0.0, (double) Settings.island_height, 0.0)); } - uSkyBlock.getInstance().setupOrphans(); + setupOrphans(); } } }, 0L); @@ -234,35 +231,6 @@ public static uSkyBlock getInstance() { return uSkyBlock.instance; } - public void loadPlayerFiles() { - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.isOnline()) { - final File f = new File(getInstance().directoryPlayers, player.getName()); - final PlayerInfo pi = new PlayerInfo(player.getName()); - if (f.exists()) { - final PlayerInfo pi2 = readPlayerFile(player.getName()); - if (pi2 != null) { - pi.setIslandLocation(pi2.getIslandLocation()); - pi.setHomeLocation(pi2.getHomeLocation()); - pi.setHasIsland(pi2.getHasIsland()); - if (getIslandConfig(pi.locationForParty()) == null) { - createIslandConfig(pi.locationForParty(), player.getName()); - } - clearIslandConfig(pi.locationForParty(), player.getName()); - WorldGuardHandler.protectIsland(player, player.getName(), pi); - } - f.delete(); - } - addActivePlayer(player.getName(), pi); - if (pi.getHasIsland() && getTempIslandConfig(pi.locationForParty()) == null) { - createIslandConfig(pi.locationForParty(), player.getName()); - log(Level.INFO, "Creating new Config File"); - } - getIslandConfig(pi.locationForParty()); - } - } - } - // TODO: UUID support public void unloadPlayerFiles() { for (Player player : Bukkit.getServer().getOnlinePlayers()) { @@ -277,24 +245,6 @@ public void registerEvents() { manager.registerEvents(new PlayerEvents(this), this); } - public PlayerInfo readPlayerFile(final String playerName) { - final File f = new File(this.directoryPlayers, playerName); - if (!f.exists()) { - return null; - } - try { - final FileInputStream fileIn = new FileInputStream(f); - final ObjectInputStream in = new ObjectInputStream(fileIn); - final PlayerInfo p = (PlayerInfo) in.readObject(); - in.close(); - fileIn.close(); - return p; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - public boolean displayTopTen(final CommandSender sender) { int i = 1; int playerrank = 0; @@ -958,7 +908,12 @@ public void removeActivePlayer(final String player) { public PlayerInfo loadPlayerData(Player player) { final PlayerInfo pi = loadPlayerAndIsland(player); - WorldGuardHandler.protectIsland(player, player.getName(), pi); + if (!pi.getHasParty()) { + WorldGuardHandler.protectIsland(player, player.getName(), pi); + } else { + FileConfiguration islandConfig = getIslandConfig(player); + WorldGuardHandler.protectIsland(player, islandConfig.getString("party.leader"), pi); + } addActivePlayer(player.getName(), pi); uSkyBlock.log(Level.INFO, "Loaded player file for " + player.getName()); return pi; diff --git a/src/test/resources/Proskillplayer b/src/test/resources/Proskillplayer new file mode 100644 index 0000000000000000000000000000000000000000..bf7c24b6f0657f345f66f7bc53278d16233965c0 GIT binary patch literal 1191 zcmZWo&2G~`5T3LRY4cMkMO6ht;>L-zp^ZT0K#N30B!en(K@_>WYb0$yFMo&?*RkcUx zq8G|Yj&e0O;c5mO&z%wJfGz5gN+?hvI-$~Icn$LbEEgqRL@Nm;T{6}il>%7Ro=Z+{ z#=kcC6%h8w6d|j6BG5BTs6gtT=>^BJhEk#4J7C3EJ?W+=-P|(hM#^N~`LF#UGRy!rXz@1Hp+9YT4CGV>KVsEs0) zzKf3NYCXHzQEE3V6$(8&MuG<25eSfn$RE;0-D&ilvF8Y8AV^)6yI5|vuV zWG21!;B_W$rATNdT+Ll2sJ-Q2`M@X}3n}x>(*FR_&vrZj literal 0 HcmV?d00001