Updated to MC 1.0.0
Fixed inventory not updating problem.
This commit is contained in:
@@ -6,7 +6,6 @@ import lishid.openinv.utils.PlayerInventoryChest;
|
||||
|
||||
import net.minecraft.server.ContainerPlayer;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.ICrafting;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.event.Event;
|
||||
@@ -16,7 +15,6 @@ 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
|
||||
@@ -28,7 +26,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 static OpenInv mainPlugin;
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
@@ -45,14 +43,17 @@ public class OpenInv extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
config = this.getConfiguration();
|
||||
mainPlugin = this;
|
||||
mainPlugin.getConfig().addDefault("ItemOpenInvItemID", 280);
|
||||
mainPlugin.getConfig().options().copyDefaults(true);
|
||||
mainPlugin.saveConfig();
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
//pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Highest, this);
|
||||
//pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Event.Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Event.Priority.Lowest, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.Lowest, this);
|
||||
//pm.registerEvent(Event.Type.INVENTORY_CLOSE, inventoryListener, Event.Priority.Normal, this);
|
||||
//pm.registerEvent(Event.Type.CUSTOM_EVENT, inventoryListener, Event.Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this);
|
||||
setupPermissions();
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
@@ -67,12 +68,16 @@ public class OpenInv extends JavaPlugin {
|
||||
{
|
||||
try{
|
||||
EntityPlayer entityplayer = player.getHandle();
|
||||
entityplayer.inventory = new PlayerInventoryChest(entityplayer.inventory);
|
||||
entityplayer.inventory = new PlayerInventoryChest(entityplayer.inventory, entityplayer);
|
||||
entityplayer.defaultContainer = new ContainerPlayer(entityplayer.inventory, !entityplayer.world.isStatic);
|
||||
entityplayer.activeContainer = entityplayer.defaultContainer;
|
||||
//sync
|
||||
((ICrafting)entityplayer).a(entityplayer.activeContainer, entityplayer.activeContainer.b());
|
||||
try
|
||||
{
|
||||
entityplayer.syncInventory();
|
||||
}catch(Exception e){}
|
||||
entityplayer.a(entityplayer.activeContainer, entityplayer.activeContainer.b());
|
||||
entityplayer.activeContainer.a();
|
||||
entityplayer.defaultContainer.a();
|
||||
|
||||
player.setHandle(entityplayer);
|
||||
}
|
||||
@@ -84,26 +89,26 @@ public class OpenInv extends JavaPlugin {
|
||||
|
||||
public static boolean GetPlayerItemOpenInvStatus(String name)
|
||||
{
|
||||
return config.getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false);
|
||||
return mainPlugin.getConfig().getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false);
|
||||
}
|
||||
|
||||
public static void SetPlayerItemOpenInvStatus(String name, boolean status)
|
||||
{
|
||||
config.setProperty("ItemOpenInv." + name.toLowerCase() + ".toggle", status);
|
||||
config.save();
|
||||
mainPlugin.getConfig().set("ItemOpenInv." + name.toLowerCase() + ".toggle", status);
|
||||
mainPlugin.saveConfig();
|
||||
}
|
||||
|
||||
public static int GetItemOpenInvItem()
|
||||
{
|
||||
return config.getInt("ItemOpenInvItemID", 280);
|
||||
return mainPlugin.getConfig().getInt("ItemOpenInvItemID", 280);
|
||||
}
|
||||
|
||||
public static Object GetFromConfig(String data, Object defaultValue)
|
||||
{
|
||||
Object val = config.getProperty(data);
|
||||
Object val = mainPlugin.getConfig().get(data);
|
||||
if (val == null)
|
||||
{
|
||||
config.setProperty(data, defaultValue);
|
||||
mainPlugin.getConfig().set(data, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
@@ -114,7 +119,7 @@ public class OpenInv extends JavaPlugin {
|
||||
|
||||
public static void SaveToConfig(String data, Object value)
|
||||
{
|
||||
config.setProperty(data, value);
|
||||
config.save();
|
||||
mainPlugin.getConfig().set(data, value);
|
||||
mainPlugin.saveConfig();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user