1
0
mirror of https://e.coding.net/circlecloud/ItemMamager.git synced 2024-11-21 01:48:53 +00:00

update project...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-22 20:41:00 +08:00
parent 12eacc3aef
commit f385164196
6 changed files with 80 additions and 32 deletions

View File

@ -1,9 +1,11 @@
package cn.citycraft.ItemMamager.manager;
import java.util.Date;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import cn.citycraft.ItemMamager.utils.ItemUtil.TAG;
@ -15,19 +17,38 @@ import cn.citycraft.ItemMamager.utils.ItemUtil.TAG;
*/
public class ItemHandler {
public static ItemStack bind(Player player, ItemStack itemStack) {
return TAG.BIND.bind(player, itemStack);
public ItemStack bind(Player player, ItemStack itemStack) {
if (isBound(itemStack))
return itemStack;
return itemStack;
}
public static boolean bingtime(ItemStack item) {
public boolean bingtime(ItemStack item) {
return bingtime(item, new Date());
}
public static boolean bingtime(ItemStack item, Date time) {
public boolean bingtime(ItemStack item, Date time) {
return false;
}
public static boolean unbind(ItemStack itemStack) {
public int getIndex(ItemStack itemStack, TAG tag) {
if (!itemStack.hasItemMeta())
return -1;
ItemMeta itemMeta = itemStack.getItemMeta();
if (!itemMeta.hasLore())
return -1;
List<String> lores = itemMeta.getLore();
return lores.lastIndexOf(tag.getTag());
}
public boolean isBound(ItemStack itemStack) {
for (TAG tag : TAG.values())
if (getIndex(itemStack, tag) != -1)
return true;
return false;
}
public boolean unbind(ItemStack itemStack) {
return false;
}
}

View File

@ -1,5 +1,11 @@
package cn.citycraft.ItemMamager.runnable;
public class ArmorHandlerTask {
public class ArmorHandlerTask implements Runnable {
@Override
public void run() {
// TODO 自动生成的方法存根
}
}

View File

@ -1,5 +1,11 @@
package cn.citycraft.ItemMamager.runnable;
public class InventoryHandlerTask {
public class InventoryHandlerTask implements Runnable {
@Override
public void run() {
// TODO 自动生成的方法存根
}
}

View File

@ -1,5 +1,11 @@
package cn.citycraft.ItemMamager.runnable;
public class ItemHandlerTask {
public class ItemHandlerTask implements Runnable {
@Override
public void run() {
// TODO 自动生成的方法存根
}
}

View File

@ -0,0 +1,30 @@
package cn.citycraft.ItemMamager.runnable;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
public class TaskManager {
static HashMap<String, BukkitTask> tasklist;
static Plugin plugin;
static int tasktime;
public static void add(Player p, Runnable run) {
tasklist.put(p.getName(), Bukkit.getScheduler().runTaskTimer(plugin, run, tasktime, tasktime));
}
public static void init(Plugin plugin) {
TaskManager.plugin = plugin;
tasktime = plugin.getConfig().getInt("CheckTime") * 20;
tasklist = new HashMap<String, BukkitTask>();
}
public static void remove(Player p) {
if (tasklist.containsKey(p.getName()))
tasklist.remove(p.getName()).cancel();
}
}

View File

@ -6,13 +6,10 @@ 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 蒋天蓓
*
*/
@ -76,28 +73,10 @@ public class ItemUtil {
this.tag = tag;
}
public ItemStack bind(Player player, ItemStack itemStack) {
if (isBound(itemStack))
return itemStack;
return itemStack;
public String getTag() {
return tag;
}
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;
}
}
}