1
0
mirror of https://e.coding.net/circlecloud/ItemMamager.git synced 2024-11-22 01:58:54 +00:00

add Bind Time TimeBind and so on...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-19 17:36:22 +08:00
parent 0169108bd3
commit 12eacc3aef
12 changed files with 354 additions and 21 deletions

View File

@ -8,8 +8,7 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
public class BindCommand extends BaseCommand { public class BindCommand extends BaseCommand {
public BindCommand() { public BindCommand() {
super("imbind"); super("bind", "b");
// TODO 自动生成的构造函数存根
} }
@Override @Override
@ -20,26 +19,22 @@ public class BindCommand extends BaseCommand {
@Override @Override
public String getDescription() { public String getDescription() {
// TODO 自动生成的方法存根 return "物品绑定";
return null;
} }
@Override @Override
public int getMinimumArguments() { public int getMinimumArguments() {
// TODO 自动生成的方法存根
return 0; return 0;
} }
@Override @Override
public String getPossibleArguments() { public String getPossibleArguments() {
// TODO 自动生成的方法存根 return "";
return null;
} }
@Override @Override
public boolean isOnlyPlayerExecutable() { public boolean isOnlyPlayerExecutable() {
// TODO 自动生成的方法存根 return true;
return false;
} }
} }

View File

@ -0,0 +1,55 @@
package cn.citycraft.ItemMamager.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
import cn.citycraft.ItemMamager.utils.ItemUtil.BIND;
public class BindEvent extends PlayerEvent implements Cancellable {
ItemStack itemstack;
BIND bind;
boolean cancelled;
public BindEvent(Player player, BIND bind, ItemStack itemstack) {
super(player);
this.itemstack = itemstack;
this.cancelled = false;
}
public BIND getBind() {
return bind;
}
@Override
public HandlerList getHandlers() {
return null;
}
public ItemStack getItemstack() {
return itemstack;
}
@Override
public boolean isCancelled() {
return cancelled;
}
public void setBind(BIND bind) {
this.bind = bind;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
public void setItemstack(ItemStack itemstack) {
this.itemstack = itemstack;
}
}

View File

@ -0,0 +1,62 @@
/**
*
*/
package cn.citycraft.ItemMamager.listen;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import cn.citycraft.ItemMamager.ItemMamager;
/**
* @author Administrator
*
*/
public class InventoryListen implements Listener {
ItemMamager plugin;
/**
* @param timeItem
*/
public InventoryListen(ItemMamager timeItem) {
plugin = timeItem;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryPickupItem(InventoryPickupItemEvent event) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onCraftItem(CraftItemEvent event) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEnchantItem(EnchantItemEvent event) {
}
}

View File

@ -3,7 +3,14 @@
*/ */
package cn.citycraft.ItemMamager.listen; package cn.citycraft.ItemMamager.listen;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import cn.citycraft.ItemMamager.ItemMamager; import cn.citycraft.ItemMamager.ItemMamager;
@ -21,4 +28,23 @@ public class PlayerListen implements Listener {
plugin = timeItem; plugin = timeItem;
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onDropItem(PlayerDropItemEvent e) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent e) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemConsume(final PlayerItemConsumeEvent e) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onJoin(PlayerJoinEvent e) {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPickUp(PlayerPickupItemEvent e) {
}
} }

View File

@ -0,0 +1,28 @@
package cn.citycraft.ItemMamager.manager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ArmorHandler {
public static void handleInventory(Player player) {
// TODO 自动生成的方法存根
}
public static void handleVar(ItemStack itemStack) {
// TODO 自动生成的方法存根
}
public static boolean isExpirable(ItemStack item) {
// TODO 自动生成的方法存根
return false;
}
public static boolean isExpired(ItemStack itemStack) {
// TODO 自动生成的方法存根
return false;
}
}

View File

@ -0,0 +1,28 @@
package cn.citycraft.ItemMamager.manager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class InventoryHandler {
public static void handleInventory(Player player) {
// TODO 自动生成的方法存根
}
public static void handleVar(ItemStack itemStack) {
// TODO 自动生成的方法存根
}
public static boolean isExpirable(ItemStack item) {
// TODO 自动生成的方法存根
return false;
}
public static boolean isExpired(ItemStack itemStack) {
// TODO 自动生成的方法存根
return false;
}
}

View File

@ -0,0 +1,33 @@
package cn.citycraft.ItemMamager.manager;
import java.util.Date;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import cn.citycraft.ItemMamager.utils.ItemUtil.TAG;
/**
* 物品处理类
*
* @author 蒋天蓓
*
*/
public class ItemHandler {
public static ItemStack bind(Player player, ItemStack itemStack) {
return TAG.BIND.bind(player, itemStack);
}
public static boolean bingtime(ItemStack item) {
return bingtime(item, new Date());
}
public static boolean bingtime(ItemStack item, Date time) {
return false;
}
public static boolean unbind(ItemStack itemStack) {
return false;
}
}

View File

@ -0,0 +1,5 @@
package cn.citycraft.ItemMamager.runnable;
public class ArmorHandlerTask {
}

View File

@ -0,0 +1,5 @@
package cn.citycraft.ItemMamager.runnable;
public class InventoryHandlerTask {
}

View File

@ -0,0 +1,5 @@
package cn.citycraft.ItemMamager.runnable;
public class ItemHandlerTask {
}

View File

@ -0,0 +1,103 @@
/**
*
*/
package cn.citycraft.ItemMamager.utils;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* 物品绑定类
*
* @author 蒋天蓓
*
*/
public class ItemUtil {
public enum BIND {
PICKUP(ChatColor.DARK_RED + "拾取后绑定"),
USE(ChatColor.DARK_RED + "使用后绑定"),
EQUIP(ChatColor.DARK_RED + "装备后绑定");
String tag;
BIND(String tag) {
this.tag = tag;
}
}
public enum MARK {
BIND("§b§m"),
TIME("§t§m");
String tag;
MARK(String tag) {
this.tag = tag;
}
public boolean isMark(String lore) {
return lore.startsWith(tag);
}
}
public enum STONE {
BIND(ChatColor.DARK_RED + "绑定石"),
TIMEBIND(ChatColor.DARK_RED + "限时绑定石"),
UNBIND(ChatColor.DARK_RED + "解绑石");
String tag;
STONE(String tag) {
this.tag = tag;
}
public int getIndex(List<String> lores) {
return lores.lastIndexOf(tag);
}
public boolean is(List<String> lores) {
return lores.lastIndexOf(tag) != -1;
}
}
public enum TAG {
TIME(ChatColor.DARK_RED + "限时物品"),
BIND(ChatColor.DARK_RED + "绑定物品"),
TIMEBIND(ChatColor.DARK_RED + "限时绑定物品"),
NOTRADE(ChatColor.DARK_RED + "不可交易物品");
String tag;
TAG(String tag) {
this.tag = tag;
}
public ItemStack bind(Player player, ItemStack itemStack) {
if (isBound(itemStack))
return itemStack;
return itemStack;
}
public int getIndex(ItemStack itemStack) {
if (!itemStack.hasItemMeta())
return -1;
ItemMeta itemMeta = itemStack.getItemMeta();
if (!itemMeta.hasLore())
return -1;
List<String> lores = itemMeta.getLore();
return lores.lastIndexOf(tag);
}
public boolean isBound(ItemStack itemStack) {
for (TAG tag : TAG.values())
if (tag.getIndex(itemStack) != -1)
return true;
return false;
}
}
}

View File

@ -1,12 +0,0 @@
/**
*
*/
package cn.citycraft.ItemMamager.utils;
/**
* @author Administrator
*
*/
public class Misc {
public static String TIME_TAG = "\u00A76限时物品";
}