mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Remove shortcut item in worlds where the player doesn't have the permission to use it (#184)
This commit is contained in:
parent
272d674007
commit
ce1a5fca45
@ -123,6 +123,18 @@ else if(isItemShortcut(itemStack))
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItem(Player player)
|
||||
{
|
||||
for(ItemStack itemStack : player.getInventory())
|
||||
{
|
||||
if(isItemShortcut(itemStack))
|
||||
{
|
||||
itemStack.setAmount(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//region Add backpack item
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
@ -139,10 +151,17 @@ public void onSpawn(PlayerRespawnEvent event)
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onWorldChange(PlayerChangedWorldEvent event)
|
||||
public void onWorldChange(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return;
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> addItem(event.getPlayer()), 2L);
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
Player player = event.getPlayer();
|
||||
if(!player.isOnline()) return;
|
||||
if(player.hasPermission(Permissions.USE))
|
||||
addItem(player);
|
||||
else
|
||||
removeItem(player);
|
||||
}, 2L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
Loading…
Reference in New Issue
Block a user