- CraftBukkit 1.1-R4 Workaround

- login fix
This commit is contained in:
Jascha Starke 2012-02-20 21:54:38 +01:00
parent 2e8708f661
commit b9de1f4f31
2 changed files with 32 additions and 1 deletions

View file

@ -335,7 +335,7 @@ public class LCPlayer {
* Attention: "Creative" stands for "the other gamemode". So true may mean, "be survival in creative world". * Attention: "Creative" stands for "the other gamemode". So true may mean, "be survival in creative world".
*/ */
public void setRegionCreativeAllowed(boolean rcreative, PlayerChangedAreaEvent changearea_event) { 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; PlayerMoveEvent event = null;
if (changearea_event != null) if (changearea_event != null)
@ -388,6 +388,8 @@ public class LCPlayer {
// 3. (because of else) we are not longer in that mode // 3. (because of else) we are not longer in that mode
// result: advise him to not longer allowed to that region // result: advise him to not longer allowed to that region
setRegionGameMode(null); setRegionGameMode(null);
} else if (this.isRegionGameMode()) {
// TODO: Add check to switch to optional selected gamemode
} }
} }

View file

@ -17,7 +17,11 @@
*/ */
package de.jaschastarke.minecraft.limitedcreative.store; package de.jaschastarke.minecraft.limitedcreative.store;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -36,6 +40,31 @@ public class InvYamlStorage extends InvConfStorage {
@Override @Override
public void load(Inventory pinv, Target target) { 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))); load(pinv, YamlConfiguration.loadConfiguration(getFile(pinv, target)));
} }