SteamWar/BauSystem2.0
Archiviert
12
0

Fix Permission for SignEdit and other stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-12-16 21:34:29 +01:00
Ursprung a61f1e2c8c
Commit 6305453e15
5 geänderte Dateien mit 45 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -32,10 +32,10 @@ public enum Permission {
OWNER(bauweltMember -> false), OWNER(bauweltMember -> false),
SUPERVISOR(bauweltMember -> { SUPERVISOR(bauweltMember -> {
return false; // TODO: Needs to be changed later on return bauweltMember.isWorld();
}), }),
BUILD(bauweltMember -> { BUILD(bauweltMember -> {
return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); return bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember);
}), }),
SPECTATOR(bauweltMember -> { SPECTATOR(bauweltMember -> {
return !BUILD.permissionPredicate.test(bauweltMember); return !BUILD.permissionPredicate.test(bauweltMember);

Datei anzeigen

@ -43,24 +43,27 @@ public class InfoCommand extends SWCommand {
} }
} }
List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID()); if (Permission.BUILD.hasPermission(p)) {
StringBuilder membermessage = new StringBuilder(); List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());
membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); StringBuilder membermessage = new StringBuilder();
membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size()));
for (int i = 0; i < members.size(); i++) { for (int i = 0; i < members.size(); i++) {
if (i != 0) { if (i != 0) {
membermessage.append(", "); membermessage.append("§8, ");
} }
BauweltMember member = members.get(i); BauweltMember member = members.get(i);
if (Permission.SUPERVISOR.hasPermission(member)) { if (Permission.SUPERVISOR.hasPermission(member)) {
membermessage.append("§c").append(SteamwarUser.get(member.getMemberID()).getUserName()); membermessage.append("§e");
} else if (Permission.BUILD.hasPermission(member)) { } else if (Permission.BUILD.hasPermission(member)) {
membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()); membermessage.append("§6");
} else { } else {
membermessage.append("§7").append(SteamwarUser.get(member.getMemberID()).getUserName()); membermessage.append("§7");
}
membermessage.append(SteamwarUser.get(member.getMemberID()).getUserName());
} }
p.sendMessage(membermessage.toString());
} }
p.sendMessage(membermessage.toString());
StringBuilder tpsMessage = new StringBuilder(); StringBuilder tpsMessage = new StringBuilder();
tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_TPS", p)); tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_TPS", p));

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.utils.PlaceItemUtils; import de.steamwar.bausystem.utils.PlaceItemUtils;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.MinVersion;
@ -81,6 +82,7 @@ public class SignEditFrom20 implements Listener {
} }
private void edit(Player player, Block block) { private void edit(Player player, Block block) {
if (Permission.SPECTATOR.hasPermission(player)) return;
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();
Side side = signSide(player, block); Side side = signSide(player, block);
SignSide signSide = sign.getSide(side); SignSide signSide = sign.getSide(side);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MaxVersion; import de.steamwar.linkage.MaxVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -68,6 +69,7 @@ public class SignEditUntil19 implements Listener {
} }
private void edit(Player player, Block block) { private void edit(Player player, Block block) {
if (Permission.SPECTATOR.hasPermission(player)) return;
Sign sign = (org.bukkit.block.Sign) block.getState(); Sign sign = (org.bukkit.block.Sign) block.getState();
String[] lines = sign.getLines(); String[] lines = sign.getLines();
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {

Datei anzeigen

@ -27,10 +27,11 @@ 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;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.*;
import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.entity.EntityEnterBlockEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -73,7 +74,7 @@ public class SpectatorListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
ItemStack itemStack = event.getCurrentItem(); ItemStack itemStack = event.getCurrentItem();
if (itemStack == null || !itemStack.hasItemMeta()) { if (itemStack == null || !itemStack.hasItemMeta()) {
@ -161,4 +162,19 @@ public class SpectatorListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityPickupItem(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player)) return;
if (Permission.SPECTATOR.hasPermission((Player) event.getEntity())) {
event.setCancelled(true);
}
}
} }