Update Permission #220
@ -20,8 +20,10 @@
|
||||
package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -30,7 +32,9 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockMultiPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@Linked
|
||||
public class SpectatorListener implements Listener {
|
||||
@ -44,6 +48,38 @@ public class SpectatorListener implements Listener {
|
||||
if (!anySupervisorOnline(null)) {
|
||||
event.getPlayer().kickPlayer("");
|
||||
}
|
||||
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
|
||||
Player p = event.getPlayer();
|
||||
ItemStack[] content = event.getPlayer().getInventory().getContents();
|
||||
for (int i = 0; i < content.length; i++) {
|
||||
if (content[i] == null) continue;
|
||||
if (checkItemStack(content[i])) {
|
||||
p.getInventory().setItem(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
ItemStack itemStack = event.getCurrentItem();
|
||||
if (itemStack == null || !itemStack.hasItemMeta()) {
|
||||
return;
|
||||
}
|
||||
if (checkItemStack(itemStack)) {
|
||||
event.setCancelled(true);
|
||||
event.setCurrentItem(null);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkItemStack(ItemStack itemStack) {
|
||||
switch (itemStack.getType()) {
|
||||
case WOODEN_AXE:
|
||||
case DEBUG_STICK:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren