1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

UI item dupe glitch fix

This commit is contained in:
Zrips 2018-06-21 13:30:36 +03:00
parent 954c38be82
commit a91a041be4

View File

@ -81,6 +81,7 @@ import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsArmorChangeEvent;
import com.gamingmesh.jobs.container.JobsArmorChangeEvent.EquipMethod;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.Util;
public class JobsListener implements Listener {
@ -218,18 +219,19 @@ public class JobsListener implements Listener {
Jobs.getGUIManager().GuiList.remove(player.getUniqueId());
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.HIGHEST)
public void onGuiLeftClick(InventoryClickEvent event) {
if (Jobs.getGUIManager().GuiList.isEmpty())
return;
Player player = (Player) event.getWhoClicked();
final Player player = (Player) event.getWhoClicked();
if (!Jobs.getGUIManager().GuiList.containsKey(player.getUniqueId()))
return;
event.setCancelled(true);
final ItemStack clicked = event.getCurrentItem();
GuiInfoList joblist = Jobs.getGUIManager().GuiList.get(player.getUniqueId());
@ -261,6 +263,16 @@ public class JobsListener implements Listener {
}
}
}
player.updateInventory();
if (event.getClick().isShiftClick() && clicked != null && !clicked.getType().equals(Material.AIR))
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.getInventory().remove(clicked);
player.updateInventory();
}
}, 1L);
}
@EventHandler(priority = EventPriority.HIGHEST)