SteamWar/BauSystem2.0
Archiviert
12
0

Remove Permission.SPECTATOR
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2024-01-19 17:02:57 +01:00
Ursprung 2bf0b0c6e8
Commit da1ea27f61
11 geänderte Dateien mit 44 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.loader.Updater;
import de.steamwar.bausystem.utils.TickListener;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.command.AbstractValidator;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.message.Message;
import lombok.Getter;
@ -77,38 +78,27 @@ public class BauSystem extends JavaPlugin implements Listener {
new Updater(PrototypeLoader.file, PrototypeLoader::load);
new Updater(RegionLoader.file, RegionLoader::load);
SWCommandUtils.addValidator(Player.class, (player, object, messageSender) -> {
if (Permission.BUILD.hasPermission(player)) {
return true;
}
messageSender.send("NO_PERMISSION");
return false;
});
SWCommandUtils.addValidator(CommandSender.class, (commandSender, object, messageSender) -> {
if (commandSender instanceof Player) {
if (Permission.BUILD.hasPermission((Player) commandSender)) {
return true;
}
messageSender.send("NO_PERMISSION");
return false;
}
return true;
});
SWCommandUtils.addValidator("supervisor", (commandSender, object, messageSender) -> {
if (commandSender instanceof Player) {
if (Permission.SUPERVISOR.hasPermission((Player) commandSender)) {
return true;
}
messageSender.send("NO_PERMISSION");
return false;
}
return true;
});
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR));
LinkageUtils.link();
TickListener.impl.init();
}
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
return (commandSender, object, messageSender) -> {
if (commandSender instanceof Player) {
if (permission.hasPermission((Player) commandSender)) {
return true;
}
messageSender.send("NO_PERMISSION");
return false;
}
return true;
};
}
@Override
public void onDisable() {
LinkageUtils.unlink();

Datei anzeigen

@ -49,9 +49,9 @@ public enum Permission {
REAL_SPECTATOR(bauweltMember -> {
return !bauweltMember.isBuild() && !bauweltMember.isSupervisor();
}),
SPECTATOR(bauweltMember -> {
return !BUILD.permissionPredicate.test(bauweltMember);
}),
/**
* Primarily used for {@link de.steamwar.bausystem.linkage.specific.GuiItem}
*/
MEMBER(bauweltMember -> {
return true;
});
@ -87,10 +87,10 @@ public enum Permission {
public boolean hasPermission(Player member) {
if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) {
return this != SPECTATOR && this != REAL_SPECTATOR;
return this != REAL_SPECTATOR;
}
BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
if (bauweltMember == null) return this == SPECTATOR || this == REAL_SPECTATOR;
if (bauweltMember == null) return this == REAL_SPECTATOR;
return permissionPredicate.test(bauweltMember);
}
}

Datei anzeigen

@ -96,7 +96,7 @@ public class SimulatorCursor implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
calcCursor(event.getPlayer());
}, 0);
@ -104,13 +104,13 @@ public class SimulatorCursor implements Listener {
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
calcCursor(event.getPlayer());
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
calcCursor(event.getPlayer());
}, 1);
@ -159,7 +159,7 @@ public class SimulatorCursor implements Listener {
if (calculating.contains(player)) return;
calculating.add(player);
}
if (Permission.SPECTATOR.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
SWUtils.sendToActionbar(player, "");
}
@ -344,7 +344,7 @@ public class SimulatorCursor implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
return;
}

Datei anzeigen

@ -50,7 +50,7 @@ public class PistonCalculator implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (!event.hasItem() || event.getItem().getType() != Material.SLIME_BALL) return;
if (event.getClickedBlock() == null) return;

Datei anzeigen

@ -35,7 +35,7 @@ public class TNTClickListener implements Listener {
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (event.getHand() != EquipmentSlot.HAND) return;
Entity entity = event.getRightClicked();

Datei anzeigen

@ -85,7 +85,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
SPECTATORS.add(event.getPlayer());
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
showSpectatorNotice(event.getPlayer());

Datei anzeigen

@ -42,7 +42,7 @@ public class ItemFrameListener implements Listener {
return;
}
if(Permission.SPECTATOR.hasPermission((Player) event.getDamager())) return;
if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return;
event.setCancelled(true);
ItemFrame itemFrame = (ItemFrame) event.getEntity();

Datei anzeigen

@ -82,7 +82,7 @@ public class SignEditFrom20 implements Listener {
}
private void edit(Player player, Block block) {
if (Permission.SPECTATOR.hasPermission(player)) return;
if (!Permission.BUILD.hasPermission(player)) return;
Sign sign = (Sign) block.getState();
Side side = signSide(player, block);
SignSide signSide = sign.getSide(side);

Datei anzeigen

@ -69,7 +69,7 @@ public class SignEditUntil19 implements Listener {
}
private void edit(Player player, Block block) {
if (Permission.SPECTATOR.hasPermission(player)) return;
if (!Permission.BUILD.hasPermission(player)) return;
Sign sign = (org.bukkit.block.Sign) block.getState();
String[] lines = sign.getLines();
for (int i = 0; i < lines.length; i++) {

Datei anzeigen

@ -176,7 +176,7 @@ public class SpectatorListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@ -184,56 +184,56 @@ public class SpectatorListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockCanBuild(BlockCanBuildEvent event) {
if (event.getPlayer() == null) return;
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setBuildable(false);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketEntity(PlayerBucketEntityEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
event.setCancelled(true);
}
}
@ -241,7 +241,7 @@ public class SpectatorListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityPickupItem(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player)) return;
if (Permission.SPECTATOR.hasPermission((Player) event.getEntity())) {
if (!Permission.BUILD.hasPermission((Player) event.getEntity())) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -40,7 +40,7 @@ public class WorldEditListener implements Listener {
if (!isWorldEditCommand(e.getMessage().split(" ")[0])) return;
Player p = e.getPlayer();
if (Permission.SPECTATOR.hasPermission(e.getPlayer())) {
if (!Permission.BUILD.hasPermission(e.getPlayer())) {
BauSystem.MESSAGE.send("NO_PERMISSION", p);
e.setCancelled(true);
e.setMessage("/");