From b0aeef46d825d8e2cc25fd6eb6402db1f701d3ac Mon Sep 17 00:00:00 2001 From: lishd Date: Sun, 18 Sep 2011 19:34:06 -0400 Subject: [PATCH] Fix for character overflow --- src/lishid/openinv/OpenInv.java | 23 +++++++++++++++++++ .../openinv/utils/PlayerInventoryChest.java | 3 +-- src/plugin.yml | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/lishid/openinv/OpenInv.java b/src/lishid/openinv/OpenInv.java index a06dfa1..9dbc46c 100644 --- a/src/lishid/openinv/OpenInv.java +++ b/src/lishid/openinv/OpenInv.java @@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; import org.bukkit.plugin.Plugin; +import org.bukkit.util.config.Configuration; /** * Open other player's inventory @@ -27,6 +28,7 @@ public class OpenInv extends JavaPlugin { private final OpenInvEntityListener entityListener = new OpenInvEntityListener(this); //private final OpenInvInventoryListener inventoryListener = new OpenInvInventoryListener(this); public static PermissionHandler permissionHandler; + public static Configuration config; public void onDisable() { } @@ -43,6 +45,7 @@ public class OpenInv extends JavaPlugin { } public void onEnable() { + config = this.getConfiguration(); PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Normal, this); @@ -78,4 +81,24 @@ public class OpenInv extends JavaPlugin { System.out.println("[OpenInv] Error while trying to override player inventory, error: " + e.getMessage()); } } + + public static Object GetFromConfig(String data, Object defaultValue) + { + Object val = config.getProperty(data); + if (val == null) + { + config.setProperty(data, defaultValue); + return defaultValue; + } + else + { + return val; + } + } + + public static void SaveToConfig(String data, Object value) + { + config.setProperty(data, value); + config.save(); + } } \ No newline at end of file diff --git a/src/lishid/openinv/utils/PlayerInventoryChest.java b/src/lishid/openinv/utils/PlayerInventoryChest.java index c3279a9..3d0aebc 100644 --- a/src/lishid/openinv/utils/PlayerInventoryChest.java +++ b/src/lishid/openinv/utils/PlayerInventoryChest.java @@ -2,7 +2,6 @@ package lishid.openinv.utils; import net.minecraft.server.ContainerPlayer; import net.minecraft.server.EntityHuman; -import net.minecraft.server.EntityPlayer; import net.minecraft.server.InventoryPlayer; public class PlayerInventoryChest extends InventoryPlayer @@ -20,7 +19,7 @@ public class PlayerInventoryChest extends InventoryPlayer @Override public String getName() { - return ((EntityPlayer)this.d).displayName; + return "Player Inventory"; } @Override diff --git a/src/plugin.yml b/src/plugin.yml index e40710c..a13ca0d 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: lishid.openinv.OpenInv -version: 1.4.1 +version: 1.4.2 author: lishid description: > This plugin allows you to open another player's inventory as a chest