mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Added configuration, save toggle states, can change stickopeninv to
anyother item.
This commit is contained in:
parent
b0aeef46d8
commit
616ea0fad8
6 changed files with 37 additions and 26 deletions
|
@ -82,6 +82,22 @@ public class OpenInv extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean GetPlayerItemOpenInvStatus(String name)
|
||||
{
|
||||
return config.getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false);
|
||||
}
|
||||
|
||||
public static void SetPlayerItemOpenInvStatus(String name, boolean status)
|
||||
{
|
||||
config.setProperty("ItemOpenInv." + name.toLowerCase() + ".toggle", status);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static int GetItemOpenInvItem()
|
||||
{
|
||||
return config.getInt("ItemOpenInvItemID", 280);
|
||||
}
|
||||
|
||||
public static Object GetFromConfig(String data, Object defaultValue)
|
||||
{
|
||||
Object val = config.getProperty(data);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package lishid.openinv;
|
||||
|
||||
import lishid.openinv.utils.OpenInvToggleState;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
@ -29,9 +26,8 @@ public class OpenInvEntityListener extends EntityListener{
|
|||
|
||||
Player player = (Player)attacker;
|
||||
|
||||
if(!(player.getItemInHand().getType() == Material.STICK)
|
||||
|| (OpenInvToggleState.openInvState.get(player.getName()) == null)
|
||||
|| !(OpenInvToggleState.openInvState.get(player.getName()) == 1)
|
||||
if(!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem())
|
||||
|| (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
|
||||
|| !PermissionRelay.hasPermission(player, "openinv"))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package lishid.openinv;
|
||||
|
||||
import lishid.openinv.utils.OpenInvToggleState;
|
||||
import net.minecraft.server.Block;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
|
@ -35,11 +35,17 @@ public class OpenInvPlayerListener extends PlayerListener{
|
|||
{
|
||||
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
if(event.getClickedBlock() == Block.CHEST ||
|
||||
event.getClickedBlock() == Block.FURNACE ||
|
||||
event.getClickedBlock() == Block.DISPENSER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!(player.getItemInHand().getType() == Material.STICK)
|
||||
|| (OpenInvToggleState.openInvState.get(player.getName()) == null)
|
||||
|| !(OpenInvToggleState.openInvState.get(player.getName()) == 1)
|
||||
|| (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
|
||||
|| !PermissionRelay.hasPermission(player, "openinv"))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -4,13 +4,13 @@ import java.util.HashMap;
|
|||
|
||||
import lishid.openinv.PermissionRelay;
|
||||
import lishid.openinv.OpenInv;
|
||||
import lishid.openinv.utils.OpenInvToggleState;
|
||||
import lishid.openinv.utils.PlayerInventoryChest;
|
||||
import lishid.openinv.utils.OpenInvHistory;
|
||||
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -50,21 +50,21 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
|||
{
|
||||
if(args[0].equalsIgnoreCase("check"))
|
||||
{
|
||||
if(OpenInvToggleState.openInvState.containsKey(player.getName()))
|
||||
player.sendMessage("OpenInv with stick is ON.");
|
||||
if(OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
|
||||
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is ON.");
|
||||
else
|
||||
player.sendMessage("OpenInv with stick is OFF.");
|
||||
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is OFF.");
|
||||
}
|
||||
}
|
||||
if(OpenInvToggleState.openInvState.containsKey(player.getName()))
|
||||
if(OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
|
||||
{
|
||||
OpenInvToggleState.openInvState.remove(player.getName());
|
||||
player.sendMessage("OpenInv with stick is OFF.");
|
||||
OpenInv.SetPlayerItemOpenInvStatus(player.getName(), false);
|
||||
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is OFF.");
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenInvToggleState.openInvState.put(player.getName(), 1);
|
||||
player.sendMessage("OpenInv with stick is ON.");
|
||||
OpenInv.SetPlayerItemOpenInvStatus(player.getName(), true);
|
||||
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is ON.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package lishid.openinv.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class OpenInvToggleState {
|
||||
public static HashMap<String, Integer> openInvState = new HashMap<String, Integer>();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
name: OpenInv
|
||||
main: lishid.openinv.OpenInv
|
||||
version: 1.4.2
|
||||
version: 1.4.3
|
||||
author: lishid
|
||||
description: >
|
||||
This plugin allows you to open another player's inventory as a chest
|
||||
|
|
Loading…
Reference in a new issue