From 078fd69e0823849b6d9aa3e63d0f0a4a039c9466 Mon Sep 17 00:00:00 2001 From: Jascha Starke Date: Tue, 17 Jan 2012 12:36:12 +0100 Subject: [PATCH] - do not empty on first switch - plugin.yml added --- LimitedCreative/plugin.yml | 9 +++++++++ .../minecraft/limitedcreative/Inventory.java | 5 +++++ .../minecraft/limitedcreative/PlayerCore.java | 5 +++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 LimitedCreative/plugin.yml diff --git a/LimitedCreative/plugin.yml b/LimitedCreative/plugin.yml new file mode 100644 index 0000000..58bf17b --- /dev/null +++ b/LimitedCreative/plugin.yml @@ -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: / load \ No newline at end of file diff --git a/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java b/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java index b7bae58..5829cbd 100644 --- a/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java +++ b/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/Inventory.java @@ -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(); + } } diff --git a/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/PlayerCore.java b/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/PlayerCore.java index 51daf98..bf5e0dc 100644 --- a/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/PlayerCore.java +++ b/LimitedCreative/src/de/jaschastarke/minecraft/limitedcreative/PlayerCore.java @@ -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); } }