mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +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.JobInfo;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.Perm;
|
import com.gamingmesh.jobs.stuff.Perm;
|
||||||
|
|
||||||
public class GuiManager {
|
public class GuiManager {
|
||||||
@ -70,8 +71,9 @@ public class GuiManager {
|
|||||||
guiInfo.setJobList(JobsList);
|
guiInfo.setJobList(JobsList);
|
||||||
|
|
||||||
Inventory topinv = player.getOpenInventory().getTopInventory();
|
Inventory topinv = player.getOpenInventory().getTopInventory();
|
||||||
if (topinv != null && !GuiList.containsKey(player.getName()))
|
if (topinv != null && !GuiList.containsKey(player.getName())) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
GuiList.put(player.getName(), guiInfo);
|
GuiList.put(player.getName(), guiInfo);
|
||||||
|
|
||||||
@ -153,12 +155,14 @@ public class GuiManager {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
}
|
||||||
|
|
||||||
for (int y = 0; y < GuiInv.getContents().length; y++) {
|
ItemStack filler = Jobs.getGCManager().guiFiller;
|
||||||
ItemStack item = GuiInv.getItem(y);
|
|
||||||
if (item == null || item.getType() == Material.AIR)
|
for (int y = 0; y < GuiInv.getSize(); y++) {
|
||||||
GuiInv.setItem(y, filler);
|
ItemStack item = GuiInv.getItem(y);
|
||||||
|
if (item == null || item.getType() == Material.AIR) {
|
||||||
|
GuiInv.setItem(y, filler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GuiInv;
|
return GuiInv;
|
||||||
@ -269,7 +273,7 @@ public class GuiManager {
|
|||||||
|
|
||||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
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);
|
ItemStack item = GuiInv.getItem(y);
|
||||||
if (item == null || item.getType() == Material.AIR)
|
if (item == null || item.getType() == Material.AIR)
|
||||||
GuiInv.setItem(y, filler);
|
GuiInv.setItem(y, filler);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Jobs Plugin for Bukkit
|
* 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
|
* 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
|
* 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.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.Perm;
|
import com.gamingmesh.jobs.stuff.Perm;
|
||||||
|
|
||||||
public class browse implements Cmd {
|
public class browse implements Cmd {
|
||||||
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
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.JobLimitedItems;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
|
|
||||||
public class JobsListener implements Listener {
|
public class JobsListener implements Listener {
|
||||||
// hook to the main plugin
|
// hook to the main plugin
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
|
|
||||||
|
private HashMap<UUID, Long> interactDelay = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
public JobsListener(Jobs plugin) {
|
public JobsListener(Jobs plugin) {
|
||||||
this.plugin = 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)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onSelection(PlayerInteractEvent event) {
|
public void onSelection(PlayerInteractEvent event) {
|
||||||
if (event.getPlayer() == null)
|
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)
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||||
return;
|
return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||||
if (iih == null || iih.getType() == Material.AIR)
|
if (iih == null || iih.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
@ -143,15 +160,13 @@ public class JobsListener implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onShopClose(InventoryCloseEvent event) {
|
public void onGuiClose(InventoryCloseEvent event) {
|
||||||
if (Jobs.getShopManager().GuiList.isEmpty())
|
if (Jobs.getGUIManager().GuiList.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
|
if (Jobs.getGUIManager().GuiList.containsKey(player.getName()))
|
||||||
if (Jobs.getShopManager().GuiList.containsKey(player.getName()))
|
Jobs.getGUIManager().GuiList.remove(player.getName());
|
||||||
Jobs.getShopManager().GuiList.remove(player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@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)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
|
|
||||||
@ -261,7 +265,7 @@ public class JobsListener implements Listener {
|
|||||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onSignInteract(PlayerInteractEvent event) {
|
public void onSignInteract(PlayerInteractEvent event) {
|
||||||
|
|
||||||
if (!plugin.isEnabled())
|
if (!plugin.isEnabled())
|
||||||
@ -281,6 +285,11 @@ public class JobsListener implements Listener {
|
|||||||
if (!(block.getState() instanceof Sign))
|
if (!(block.getState() instanceof Sign))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!isInteractOk(player))
|
||||||
|
return;
|
||||||
|
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
String FirstLine = sign.getLine(0);
|
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)));
|
player.performCommand("jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user