mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
Fix for double sign click issue with off hand double event
This commit is contained in:
parent
7b55e161ea
commit
31ce825224
@ -21,6 +21,7 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
|
||||
public class GuiManager {
|
||||
@ -70,8 +71,9 @@ public class GuiManager {
|
||||
guiInfo.setJobList(JobsList);
|
||||
|
||||
Inventory topinv = player.getOpenInventory().getTopInventory();
|
||||
if (topinv != null && !GuiList.containsKey(player.getName()))
|
||||
if (topinv != null && !GuiList.containsKey(player.getName())) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
GuiList.put(player.getName(), guiInfo);
|
||||
|
||||
@ -153,12 +155,14 @@ public class GuiManager {
|
||||
i++;
|
||||
}
|
||||
|
||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
||||
}
|
||||
|
||||
for (int y = 0; y < GuiInv.getContents().length; y++) {
|
||||
ItemStack item = GuiInv.getItem(y);
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
GuiInv.setItem(y, filler);
|
||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
||||
|
||||
for (int y = 0; y < GuiInv.getSize(); y++) {
|
||||
ItemStack item = GuiInv.getItem(y);
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
GuiInv.setItem(y, filler);
|
||||
}
|
||||
}
|
||||
return GuiInv;
|
||||
@ -269,7 +273,7 @@ public class GuiManager {
|
||||
|
||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
||||
|
||||
for (int y = 0; y < GuiInv.getContents().length; y++) {
|
||||
for (int y = 0; y < GuiInv.getSize(); y++) {
|
||||
ItemStack item = GuiInv.getItem(y);
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
GuiInv.setItem(y, filler);
|
||||
|
@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Jobs Plugin for Bukkit
|
||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -11,6 +11,7 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
|
||||
public class browse implements Cmd {
|
||||
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -68,15 +69,30 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class JobsListener implements Listener {
|
||||
// hook to the main plugin
|
||||
private Jobs plugin;
|
||||
|
||||
private HashMap<UUID, Long> interactDelay = new HashMap<UUID, Long>();
|
||||
|
||||
public JobsListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private boolean isInteractOk(Player player) {
|
||||
if (!interactDelay.containsKey(player.getUniqueId())) {
|
||||
interactDelay.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
long time = System.currentTimeMillis() - interactDelay.get(player.getUniqueId());
|
||||
interactDelay.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
if (time > 100)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onSelection(PlayerInteractEvent event) {
|
||||
if (event.getPlayer() == null)
|
||||
@ -87,6 +103,7 @@ public class JobsListener implements Listener {
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return;
|
||||
@ -143,15 +160,13 @@ public class JobsListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||
public void onShopClose(InventoryCloseEvent event) {
|
||||
if (Jobs.getShopManager().GuiList.isEmpty())
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onGuiClose(InventoryCloseEvent event) {
|
||||
if (Jobs.getGUIManager().GuiList.isEmpty())
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
if (Jobs.getShopManager().GuiList.containsKey(player.getName()))
|
||||
Jobs.getShopManager().GuiList.remove(player.getName());
|
||||
if (Jobs.getGUIManager().GuiList.containsKey(player.getName()))
|
||||
Jobs.getGUIManager().GuiList.remove(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -199,17 +214,6 @@ public class JobsListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||
public void onGuiClose(InventoryCloseEvent event) {
|
||||
if (Jobs.getGUIManager().GuiList.isEmpty())
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
if (Jobs.getGUIManager().GuiList.containsKey(player.getName()))
|
||||
Jobs.getGUIManager().GuiList.remove(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
|
||||
@ -261,7 +265,7 @@ public class JobsListener implements Listener {
|
||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignInteract(PlayerInteractEvent event) {
|
||||
|
||||
if (!plugin.isEnabled())
|
||||
@ -281,6 +285,11 @@ public class JobsListener implements Listener {
|
||||
if (!(block.getState() instanceof Sign))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!isInteractOk(player))
|
||||
return;
|
||||
|
||||
Sign sign = (Sign) block.getState();
|
||||
String FirstLine = sign.getLine(0);
|
||||
|
||||
@ -296,7 +305,6 @@ public class JobsListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
player.performCommand("jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user