1
0
mirror of https://e.coding.net/circlecloud/GuiACK.git synced 2024-12-04 16:38:48 +00:00

fix open error...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-09-20 22:49:19 +08:00
parent 5e1b2ce224
commit a4c389c53b
3 changed files with 23 additions and 3 deletions

View File

@ -11,9 +11,22 @@ import org.bukkit.inventory.ItemStack;
public class VerifyGui {
static List<String> verifylist = new ArrayList<String>();
static List<String> playerlist = new ArrayList<String>();
public static String invname = "§v§e§r§c防挂机验证 §3请选择验证码: ";
public static void add(Player p) {
playerlist.add(p.getName());
}
public static boolean checkopen(Player p) {
if (playerlist.contains(p.getName()))
return false;
else {
open(p);
return true;
}
}
public static void init(List<String> verifylist) {
VerifyGui.verifylist = verifylist;
}
@ -32,5 +45,10 @@ public class VerifyGui {
Inventory inv = Bukkit.createInventory(null, 9, invname + list[ri].getItemMeta().getDisplayName());
inv.setContents(list);
p.openInventory(inv);
add(p);
}
public static void remove(Player p) {
playerlist.remove(p.getName());
}
}

View File

@ -40,11 +40,11 @@ public class PlayerListen implements Listener {
Player p = (Player) e.getPlayer();
if (checklist.containsKey(p.getName()) && checklist.get(p.getName())) {
checklist.put(p.getName(), false);
VerifyGui.remove(p);
return;
}
if (p.isOnline())
Bukkit.getScheduler().runTaskLater(plugin, new VerifyTask(p), 3);
}
@EventHandler
@ -70,6 +70,7 @@ public class PlayerListen implements Listener {
p.sendMessage("§a验证成功 奖励金钱: " + plugin.reward);
checklist.put(p.getName(), true);
p.closeInventory();
VerifyGui.remove(p);
}
}

View File

@ -14,7 +14,8 @@ public class VerifyTask implements Runnable {
@Override
public void run() {
if (p.isOnline())
VerifyGui.open(p);
if (!VerifyGui.checkopen(p))
p.kickPlayer("验证码输入超时 请重新登录!");
}
}