- do not empty on first switch

- plugin.yml added
This commit is contained in:
Jascha Starke 2012-01-17 12:36:12 +01:00
parent 9cc0fb267d
commit 078fd69e08
3 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,9 @@
name: LimitedCreative
main: de.jaschastarke.minecraft.limitedcreative.LimitedCreativeCore
version: 0.1-alpha
depend: [WorldGuard]
commands:
limitedcreative:
description: Manually control the Creative-Features
aliases: lc
usage: /<command> load

View file

@ -70,4 +70,9 @@ public class Inventory {
new Armor(pinv).restore(yml.getConfigurationSection("armor"));
new Items(pinv).restore(yml.getConfigurationSection("inv"));
}
public boolean isStored(GameMode gm) {
File f = new File(LimitedCreativeCore.plugin.getDataFolder(), getFileName(player, gm));
return f.exists();
}
}

View file

@ -15,7 +15,7 @@ public class PlayerCore {
public void onSetCreative() {
Inventory inv = new Inventory(player);
inv.save();
if (plugin.config.getStoreCreative()) {
if (plugin.config.getStoreCreative() && inv.isStored(GameMode.CREATIVE)) {
inv.load(GameMode.CREATIVE);
} else {
inv.clear();
@ -26,6 +26,7 @@ public class PlayerCore {
if (plugin.config.getStoreCreative()) {
inv.save();
}
inv.load(GameMode.SURVIVAL);
if (inv.isStored(GameMode.SURVIVAL))
inv.load(GameMode.SURVIVAL);
}
}