mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-02 23:31:49 +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
|
//region Add backpack item
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onJoin(PlayerJoinEvent event)
|
public void onJoin(PlayerJoinEvent event)
|
||||||
@ -139,10 +151,17 @@ public void onSpawn(PlayerRespawnEvent event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onWorldChange(PlayerChangedWorldEvent event)
|
public void onWorldChange(final PlayerChangedWorldEvent event)
|
||||||
{
|
{
|
||||||
if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return;
|
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)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.4.2</revision>
|
<revision>2.4.3-RC1</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user