SteamWar/BauSystem2.0
Archiviert
12
0

Update Permission #220

Zusammengeführt
YoyoNow hat 35 Commits von PermissionUpdate nach master 2024-02-17 08:53:31 +01:00 zusammengeführt
Nur Änderungen aus Commit 37e6628aaa werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -20,8 +20,10 @@
package de.steamwar.bausystem.features.world; package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; 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.BlockCanBuildEvent;
import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.block.BlockMultiPlaceEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
@Linked @Linked
public class SpectatorListener implements Listener { public class SpectatorListener implements Listener {
@ -44,6 +48,38 @@ public class SpectatorListener implements Listener {
if (!anySupervisorOnline(null)) { if (!anySupervisorOnline(null)) {
event.getPlayer().kickPlayer(""); 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 @EventHandler