diff --git a/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java b/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java index 65c6873..fb3582a 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java @@ -335,7 +335,7 @@ public class LCPlayer { * Attention: "Creative" stands for "the other gamemode". So true may mean, "be survival in creative world". */ public void setRegionCreativeAllowed(boolean rcreative, PlayerChangedAreaEvent changearea_event) { - Core.debug(getName()+": changed region: "+rcreative+": "+changearea_event.toString()); + Core.debug(getName()+": changed region: "+rcreative+": " + (changearea_event == null ? "null" : changearea_event.toString())); PlayerMoveEvent event = null; if (changearea_event != null) @@ -388,6 +388,8 @@ public class LCPlayer { // 3. (because of else) we are not longer in that mode // result: advise him to not longer allowed to that region setRegionGameMode(null); + } else if (this.isRegionGameMode()) { + // TODO: Add check to switch to optional selected gamemode } } diff --git a/src/de/jaschastarke/minecraft/limitedcreative/store/InvYamlStorage.java b/src/de/jaschastarke/minecraft/limitedcreative/store/InvYamlStorage.java index f211d22..44fee87 100644 --- a/src/de/jaschastarke/minecraft/limitedcreative/store/InvYamlStorage.java +++ b/src/de/jaschastarke/minecraft/limitedcreative/store/InvYamlStorage.java @@ -17,7 +17,11 @@ */ package de.jaschastarke.minecraft.limitedcreative.store; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import org.bukkit.configuration.file.YamlConfiguration; @@ -36,6 +40,31 @@ public class InvYamlStorage extends InvConfStorage { @Override public void load(Inventory pinv, Target target) { +// BEGIN: VERY dirty Workaround for 1.1-R4-Bug (will be removed when r5 released) + try { + BufferedReader in = new BufferedReader(new FileReader(getFile(pinv, target))); + String line; + StringBuilder file = new StringBuilder(); + Boolean changed = false; + while ((line = in.readLine()) != null) { + if (!line.matches("\\s*==:\\s+org\\.bukkit\\.inventory\\.ItemStack\\s*")) { + file.append(line); + file.append("\n"); + } else { + changed = true; + } + } + in.close(); + + if (changed) { + BufferedWriter out = new BufferedWriter(new FileWriter(getFile(pinv, target))); + out.write(file.toString()); + out.close(); + } + } catch (IOException e1) { + e1.printStackTrace(); + } +// END: workaround load(pinv, YamlConfiguration.loadConfiguration(getFile(pinv, target))); }