SteamWar/BauSystem
Archiviert
13
0

Remove Permission.build #232

Manuell gemergt
YoyoNow hat 2 Commits von Permissions nach master 2021-04-04 18:52:10 +02:00 zusammengeführt
12 geänderte Dateien mit 11 neuen und 160 gelöschten Zeilen
Nur Änderungen aus Commit 92b89775cf werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,6 +22,5 @@ package de.steamwar.bausystem;
public enum Permission { public enum Permission {
world, world,
worldedit, worldedit,
build,
member member
} }

Datei anzeigen

@ -38,7 +38,6 @@ public class CommandBau extends SWCommand {
@Register(help = true) @Register(help = true)
public void genericHelp(Player p, String... args) { public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers");
p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers");
p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers");
} }
@ -48,14 +47,6 @@ public class CommandBau extends SWCommand {
CommandInfo.sendBauInfo(p); CommandInfo.sendBauInfo(p);
} }
@Register("togglebuild")
public void toggleBuildCommand(Player p, SteamwarUser user) {
if (!permissionCheck(p)) {
return;
}
onToggleBD(p, user);
}
@Register("togglewe") @Register("togglewe")
public void toggleWECommand(Player p, SteamwarUser user) { public void toggleWECommand(Player p, SteamwarUser user) {
if (!permissionCheck(p)) { if (!permissionCheck(p)) {
@ -72,16 +63,6 @@ public class CommandBau extends SWCommand {
onToggleWorld(p, user); onToggleWorld(p, user);
} }
private void onToggleBD(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) {
return;
}
BauweltMember target = BauweltMember.getBauMember(BauSystem.getOwnerID(), id.getId());
Welt.toggleBuild(p, target);
}
private void onToggleWE(Player p, SteamwarUser id) { private void onToggleWE(Player p, SteamwarUser id) {
if (negativeToggleCheck(p, id)) { if (negativeToggleCheck(p, id)) {
return; return;

Datei anzeigen

@ -39,11 +39,7 @@ public class CommandDebugStick extends SWCommand {
@Register @Register
public void genericCommand(Player p) { public void genericCommand(Player p) {
if (Welt.noPermission(p, Permission.build)) { VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8),
p.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15));
} else {
VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8),
new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15));
}
} }
} }

Datei anzeigen

@ -111,10 +111,8 @@ public class CommandGUI extends SWCommand implements Listener {
player.performCommand("sim wand"); player.performCommand("sim wand");
}); });
ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", Permission.build, "Du hast keine Buildrechte"); ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", null, "");
inv.setItem(37, redstoneWand, clickType -> { inv.setItem(37, redstoneWand, clickType -> {
if (Welt.noPermission(player, Permission.build))
return;
player.closeInventory(); player.closeInventory();
player.performCommand("redstonetester"); player.performCommand("redstonetester");
}); });
@ -311,9 +309,7 @@ public class CommandGUI extends SWCommand implements Listener {
}); });
} }
inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.build), false, clickType -> { inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "", null), false, clickType -> {
if (Welt.noPermission(player, Permission.build))
return;
List<SWListInv.SWListEntry<String>> playerSWListEntry = new ArrayList<>(); List<SWListInv.SWListEntry<String>> playerSWListEntry = new ArrayList<>();
Bukkit.getOnlinePlayers().forEach(player1 -> { Bukkit.getOnlinePlayers().forEach(player1 -> {
if (player1.equals(player)) if (player1.equals(player))
@ -479,7 +475,6 @@ public class CommandGUI extends SWCommand implements Listener {
item.setName("§7" + user.getUserName()); item.setName("§7" + user.getUserName());
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add("§7Online: §e" + (Bukkit.getPlayer(user.getUUID()) == null ? "Offline" : "Online")); lore.add("§7Online: §e" + (Bukkit.getPlayer(user.getUUID()) == null ? "Offline" : "Online"));
lore.add("§7Bauen: §e" + (member.isBuild() ? "Ja" : "Nein"));
lore.add("§7Worldedit: §e" + (member.isWorldEdit() ? "Ja" : "Nein")); lore.add("§7Worldedit: §e" + (member.isWorldEdit() ? "Ja" : "Nein"));
lore.add("§7World: §e" + (member.isWorld() ? "Ja" : "Nein")); lore.add("§7World: §e" + (member.isWorld() ? "Ja" : "Nein"));
item.setLore(lore); item.setLore(lore);
@ -514,47 +509,35 @@ public class CommandGUI extends SWCommand implements Listener {
private static void bauweltMemberGUI(Player player, BauweltMember member) { private static void bauweltMemberGUI(Player player, BauweltMember member) {
SteamwarUser user = SteamwarUser.get(member.getMemberID()); SteamwarUser user = SteamwarUser.get(member.getMemberID());
SWInventory inv = new SWInventory(player, 9, "Member: " + user.getUserName()); SWInventory inv = new SWInventory(player, 9, "Member: " + user.getUserName());
if (member.isBuild()) {
inv.setItem(0, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Bauen", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglebuild §8[§eSpieler§8]"), false, clickType -> {
member.setBuild(false);
bauweltMemberGUI(player, member);
});
} else {
inv.setItem(0, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Bauen", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglebuild §8[§eSpieler§8]"), false, clickType -> {
member.setBuild(true);
bauweltMemberGUI(player, member);
});
}
if (member.isWorldEdit()) { if (member.isWorldEdit()) {
inv.setItem(2, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { inv.setItem(1, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(false); member.setWorldEdit(false);
bauweltMemberGUI(player, member); bauweltMemberGUI(player, member);
}); });
} else { } else {
inv.setItem(2, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> { inv.setItem(1, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(true); member.setWorldEdit(true);
bauweltMemberGUI(player, member); bauweltMemberGUI(player, member);
}); });
} }
if (member.isWorld()) { if (member.isWorld()) {
inv.setItem(4, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7World", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { inv.setItem(3, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7World", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> {
member.setWorld(false); member.setWorld(false);
bauweltMemberGUI(player, member); bauweltMemberGUI(player, member);
}); });
} else { } else {
inv.setItem(4, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> { inv.setItem(3, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> {
member.setWorld(true); member.setWorld(true);
bauweltMemberGUI(player, member); bauweltMemberGUI(player, member);
}); });
} }
inv.setItem(6, Material.BARRIER, "§7Member entfernen", clickType -> { inv.setItem(5, Material.BARRIER, "§7Member entfernen", clickType -> {
player.closeInventory(); player.closeInventory();
confirmChatMessage(player, "/bau delmember " + user.getUserName()); confirmChatMessage(player, "/bau delmember " + user.getUserName());
}); });
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player)); inv.setItem(7, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player));
inv.open(); inv.open();
} }
@ -569,7 +552,7 @@ public class CommandGUI extends SWCommand implements Listener {
} }
private static List<String> getNoPermsLore(List<String> lore, Player player, String noPerms, Permission perm) { private static List<String> getNoPermsLore(List<String> lore, Player player, String noPerms, Permission perm) {
if (Welt.noPermission(player, perm)) { if (perm != null && Welt.noPermission(player, perm)) {
lore = new ArrayList<>(lore); lore = new ArrayList<>(lore);
lore.add(noPerms); lore.add(noPerms);
} }

Datei anzeigen

@ -19,9 +19,7 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.BauweltMember;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,7 +36,6 @@ public class CommandGamemode extends SWCommand {
@Register @Register
public void genericCommand(Player p) { public void genericCommand(Player p) {
if (!permissionCheck(p)) return;
if (p.getGameMode() == GameMode.CREATIVE) { if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR); p.setGameMode(GameMode.SPECTATOR);
} else { } else {
@ -48,18 +45,6 @@ public class CommandGamemode extends SWCommand {
@Register @Register
public void gamemodeCommand(Player p, GameMode gameMode) { public void gamemodeCommand(Player p, GameMode gameMode) {
if (!permissionCheck(p)) return;
p.setGameMode(gameMode); p.setGameMode(gameMode);
} }
private boolean permissionCheck(Player p) {
if (!p.getUniqueId().equals(BauSystem.getOwner())) {
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if (member == null || !member.isBuild()) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern");
return false;
}
}
return true;
}
} }

Datei anzeigen

@ -58,7 +58,6 @@ public class CommandInfo extends SWCommand {
for (BauweltMember member : members) { for (BauweltMember member : members) {
membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8["); membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8[");
membermessage.append(member.isBuild() ? "§a" : "§c").append("B").append("§8,");
membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,"); membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,");
membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" "); membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" ");
} }

Datei anzeigen

@ -45,48 +45,34 @@ public class CommandLoader extends SWCommand {
@Register({"setup"}) @Register({"setup"})
public void setupCommand(Player p) { public void setupCommand(Player p) {
if (!permissionCheck(p)) return;
setup(p); setup(p);
} }
@Register({"undo"}) @Register({"undo"})
public void undoCommand(Player p) { public void undoCommand(Player p) {
if (!permissionCheck(p)) return;
undo(p); undo(p);
} }
@Register({"start"}) @Register({"start"})
public void startCommand(Player p) { public void startCommand(Player p) {
if (!permissionCheck(p)) return;
start(p); start(p);
} }
@Register({"stop"}) @Register({"stop"})
public void stopCommand(Player p) { public void stopCommand(Player p) {
if (!permissionCheck(p)) return;
stop(p); stop(p);
} }
@Register({"wait"}) @Register({"wait"})
public void waitCommand(Player p, int time) { public void waitCommand(Player p, int time) {
if (!permissionCheck(p)) return;
wait(p, time); wait(p, time);
} }
@Register({"speed"}) @Register({"speed"})
public void speedCommand(Player p, int time) { public void speedCommand(Player p, int time) {
if (!permissionCheck(p)) return;
speed(p, time); speed(p, time);
} }
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden");
return false;
}
return true;
}
private void setup(Player player) { private void setup(Player player) {
AutoLoader.getLoader(player).setup(); AutoLoader.getLoader(player).setup();
} }

Datei anzeigen

@ -44,19 +44,10 @@ public class CommandRedstoneTester extends SWCommand {
VersionedRunnable.call(new VersionedRunnable(() -> { VersionedRunnable.call(new VersionedRunnable(() -> {
p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar");
}, 8), new VersionedRunnable(() -> { }, 8), new VersionedRunnable(() -> {
if (!permissionCheck(p)) return;
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
SWUtils.giveItemToPlayer(p, RedstoneListener.WAND); SWUtils.giveItemToPlayer(p, RedstoneListener.WAND);
}, 15)); }, 15));
} }
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen");
return false;
}
return true;
}
} }

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.BauweltMember;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
@ -42,15 +41,6 @@ public class CommandTeleport extends SWCommand {
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
return; return;
} }
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if (member == null || !member.isBuild()) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!");
return;
}
}
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
} }
} }

Datei anzeigen

@ -48,14 +48,6 @@ public class RedstoneListener implements Listener {
public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack(); public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack();
private static Map<Player, RedstoneTester> playerMap = new HashMap<>(); private static Map<Player, RedstoneTester> playerMap = new HashMap<>();
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen");
return false;
}
return true;
}
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (!WAND.isSimilar(event.getItem())) return; if (!WAND.isSimilar(event.getItem())) return;
@ -63,10 +55,6 @@ public class RedstoneListener implements Listener {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
event.setCancelled(true); event.setCancelled(true);
if (!permissionCheck(event.getPlayer())) {
return;
}
switch (event.getAction()) { switch (event.getAction()) {
case RIGHT_CLICK_AIR: case RIGHT_CLICK_AIR:
if (player.isSneaking()) { if (player.isSneaking()) {

Datei anzeigen

@ -59,46 +59,6 @@ public class RegionListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen");
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (Core.getVersion() == 12) return;
Player p = e.getPlayer();
try {
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
e.setBuildable(false);
}
} catch (NullPointerException ex) {
//ignored, caused by worldedit brushes
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent e) {
if (Core.getVersion() == 15) return;
Player p = e.getPlayer();
try {
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
e.setCancelled(true);
}
} catch (NullPointerException ex) {
//ignored, caused by worldedit brushes
}
}
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
private boolean isWorldEditCommand(String command) { private boolean isWorldEditCommand(String command) {

Datei anzeigen

@ -40,8 +40,6 @@ public class Welt {
return true; return true;
switch (perm) { switch (perm) {
case build:
return !member1.isBuild();
case worldedit: case worldedit:
return !member1.isWorldEdit(); return !member1.isWorldEdit();
case world: case world:
@ -69,11 +67,6 @@ public class Welt {
} }
} }
public static void toggleBuild(Player p, BauweltMember target) {
target.setBuild(!target.isBuild());
sendMessages(p, target.isBuild(), target, "bauen");
}
public static void toggleWE(Player p, BauweltMember target) { public static void toggleWE(Player p, BauweltMember target) {
target.setWorldEdit(!target.isWorldEdit()); target.setWorldEdit(!target.isWorldEdit());
sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden"); sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden");