SteamWar/BauSystem
Archiviert
13
0

CannonSimulator #164

Manuell gemergt
YoyoNow hat 37 Commits von CanonSimulator nach master 2021-03-07 10:47:37 +01:00 zusammengeführt
15 geänderte Dateien mit 808 neuen und 39 gelöschten Zeilen
Nur Änderungen aus Commit ab8f0db420 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.PlayerUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -27,9 +28,6 @@ class CommandDebugStick_15 {
private CommandDebugStick_15(){}
static void giveStick(Player player){
if(player.getInventory().getItemInMainHand().getType() == Material.AIR)
player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK));
else
player.getInventory().addItem(new ItemStack(Material.DEBUG_STICK));
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
}
}

Datei anzeigen

@ -0,0 +1,36 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class PlayerUtils {
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
ItemStack current = player.getInventory().getItemInMainHand();
player.getInventory().setItemInMainHand(itemStack);
if (current.getType() != Material.AIR) {
player.getInventory().addItem(current);
}
}
}

Datei anzeigen

@ -100,6 +100,7 @@ public class BauSystem extends JavaPlugin implements Listener {
getCommand("script").setExecutor(new CommandScript());
getCommand("simulator").setExecutor(new CommandSimulator());
getCommand("simulator").setTabCompleter(new CommandSimulatorTabCompleter());
getCommand("gui").setExecutor(new CommandGUI());
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
@ -107,6 +108,7 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this);
Bukkit.getPluginManager().registerEvents(new TNTSimulatorListener(), this);
Bukkit.getPluginManager().registerEvents(new CommandGUI(), this);
new AFKStopper();
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);

Datei anzeigen

@ -21,9 +21,9 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.PlayerUtils;
import de.steamwar.bausystem.world.Detonator;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -63,10 +63,7 @@ public class CommandDetonator implements CommandExecutor {
case "wand":
case "detonator":
case "item":
if(player.getInventory().getItemInMainHand().getType() == Material.AIR)
player.getInventory().setItemInMainHand(Detonator.WAND);
else
player.getInventory().addItem(Detonator.WAND);
PlayerUtils.giveItemToPlayer(player, Detonator.WAND);
player.updateInventory();
Detonator.getDetonator(player);
break;

Datei anzeigen

@ -0,0 +1,603 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.PlayerUtils;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.world.*;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class CommandGUI implements CommandExecutor, Listener {
private static final Set<Player> OPEN_INVS = new HashSet<>();
private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>();
private static final Set<Player> LAST_F_PLAYER = new HashSet<>();
private static boolean isRefreshing = false;
public CommandGUI() {
Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20);
}
public static void openBauGui(Player player) {
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Kannst du bitte eine Utility Methode zu den Utility Methoden tun?

Kannst du bitte eine Utility Methode zu den Utility Methoden tun?
Region region = Region.getRegion(player.getLocation());
SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau");
inv.setCallback(-1, clickType -> {
if (!isRefreshing)
OPEN_INVS.remove(player);
});
inv.setItem(37, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(38, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> {
player.closeInventory();
player.performCommand("gui item");
});
ItemStack dtWand = Detonator.WAND.clone();
ItemMeta meta = dtWand.getItemMeta();
List<String> lore = meta.getLore();
lore.add("§8/§7dt wand");
if (Welt.noPermission(player, Permission.world))
lore.add("§cDu hast keine Worldrechte");
meta.setLore(lore);
dtWand.setItemMeta(meta);
inv.setItem(39, dtWand, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.closeInventory();
player.performCommand("dt wand");
});
inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.worldedit), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.closeInventory();
player.performCommand("/wand");
});
inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.world), Core.getVersion() < 13, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.closeInventory();
player.performCommand("debugstick");
});
inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren");
anvilInv.setItem(Material.COMPASS);
anvilInv.setCallback(s -> player.performCommand("tpslimit " + s));
anvilInv.open();
});
inv.setItem(5, Material.FEATHER, "§7Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + player.getFlySpeed() * 10, "§8/§7speed §8[§e1 - 10§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Geschwindigkeit");
anvilInv.setItem(Material.FEATHER);
anvilInv.setCallback(s -> player.performCommand("speed " + s));
anvilInv.open();
});
if (player.getUniqueId().equals(BauSystem.getOwner())) {
SWItem skull = SWItem.getPlayerSkull(player.getName());
skull.setName("§7Bau verwalten");
List<String> skullLore = new ArrayList<>();
skullLore.add("§7TNT: §e" + region.getTntMode().getName());
skullLore.add("§7StopLag: §e" + (region.isFreeze() ? "Eingeschaltet" : "Ausgeschaltet"));
skullLore.add("§7Fire: §e" + (region.isFire() ? "Ausgeschaltet" : "Eingeschaltet"));
skullLore.add("§7Members: §e" + (BauweltMember.getMembers(BauSystem.getOwnerID()).size() - 1));
skull.setLore(skullLore);
skull.setCallback(clickType -> {
player.closeInventory();
bauManagementGUI(player);
});
inv.setItem(4, skull);
}
inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + PredefinedBook.getBookCount() + " §7Bücher"), true, clickType -> {
player.closeInventory();
scriptBooksGUI(player);
});
inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.closeInventory();
OPEN_TRACER_INVS.add(player);
traceGUI(player);
});
inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.closeInventory();
autoLoaderGUI(player);
});
inv.setItem(17, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe");
anvilInv.setItem(Material.NAME_TAG);
anvilInv.setCallback(s -> player.performCommand("skull " + s));
anvilInv.open();
});
if (Region.GlobalRegion.isGlobalRegion(region)) {
inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> {
});
inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> {
});
inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> {
});
} else {
inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player));
});
if (region.hasProtection()) {
inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player));
});
} else {
inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {
});
}
if (region.hasTestblock()) {
inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player));
});
} else {
inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {
});
}
}
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
inv.setItem(26, Material.POTION, "§7Nightvision: §eEingeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player);
openBauGui(player);
});
} else {
inv.setItem(26, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player);
openBauGui(player);
});
}
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
inv.setItem(35, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player);
openBauGui(player);
});
} else {
inv.setItem(35, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player);
openBauGui(player);
});
}
boolean isBuildArea = region.hasBuildRegion();
List<String> tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.world);
switch (region.getTntMode()) {
case OFF:
inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("tnt " + (isBuildArea ? "tb" : "on"));
updateInventories();
});
break;
case ONLY_TB:
inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("tnt on");
updateInventories();
});
break;
default:
inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("tnt off");
updateInventories();
});
}
if (region.isFreeze()) {
inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("freeze");
updateInventories();
});
} else {
inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("freeze");
updateInventories();
});
}
if (region.isFire()) {
inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("fire");
updateInventories();
});
} else {
inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world))
return;
player.performCommand("fire");
updateInventories();
});
}
inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.build), false, clickType -> {
if (Welt.noPermission(player, Permission.build))
return;
List<SWListInv.SWListEntry<String>> playerSWListEntry = new ArrayList<>();
Bukkit.getOnlinePlayers().forEach(player1 -> {
if (player1.equals(player))
return;
playerSWListEntry.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(player1.getName()), player1.getName()));
});
SWListInv<String> playerSWListInv = new SWListInv<>(player, "Teleporter", playerSWListEntry, (clickType1, player1) -> {
player.closeInventory();
player.performCommand("tp " + player1);
});
playerSWListInv.open();
});
inv.open();
}
private static void traceGUI(Player player) {
SWInventory inv = new SWInventory(player, 9, "Tracer");
inv.setCallback(-1, clickType -> {
if (!isRefreshing)
OPEN_TRACER_INVS.remove(player);
});
List<String> stateLore = Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName(), "§8/§7trace §8[§estart§8, stop §8oder §eauto§8]");
switch (RecordStateMachine.getRecordStatus()) {
case IDLE:
inv.setItem(0, getMaterial("SNOWBALL", "SNOW_BALL"), "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandAuto();
updateInventories();
});
break;
case IDLE_AUTO:
inv.setItem(0, Material.ENDER_PEARL, "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandStart();
updateInventories();
});
break;
case RECORD:
case RECORD_AUTO:
inv.setItem(0, getMaterial("ENDER_EYE", "EYE_OF_ENDER"), "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandStop();
updateInventories();
});
}
if (TraceShowManager.hasActiveShow(player)) {
inv.setItem(2, Material.TNT, "§7Showstatus", Arrays.asList("§7Aktuell: §eGezeigt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
player.performCommand("trace hide");
traceGUI(player);
});
} else {
inv.setItem(2, Material.GLASS, "§7Showstatus", Arrays.asList("§7Aktuell: §eVersteckt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
player.performCommand("trace show");
traceGUI(player);
});
}
inv.setItem(4, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7Trace GUI", Collections.singletonList("§8/§7trace show gui"), false, clickType -> {
player.closeInventory();
player.performCommand("trace show gui");
});
inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {
}));
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
player.closeInventory();
openBauGui(player);
OPEN_INVS.add(player);
});
inv.open();
}
private static void scriptBooksGUI(Player player) {
List<SWListInv.SWListEntry<PredefinedBook>> entries = new ArrayList<>();
List<PredefinedBook> books = PredefinedBook.getBooks();
books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {
}), predefinedBook)));
SWListInv<PredefinedBook> inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> {
player.closeInventory();
player.getInventory().addItem(predefinedBook.toItemStack());
});
inv.open();
}
private static void autoLoaderGUI(Player player) {
SWInventory inv = new SWInventory(player, 9, "Autoloader");
boolean hasLoader = AutoLoader.hasLoader(player);
if (hasLoader) {
AutoLoader loader = AutoLoader.getLoader(player);
if (loader.isSetup()) {
inv.setItem(0, Material.DROPPER, "§7Loader Starten", Collections.singletonList("§8/§7loader start"), false, clickType -> {
loader.start();
autoLoaderGUI(player);
});
inv.setItem(2, Material.ARROW, "§7Letzte Aktion entfernen", Collections.singletonList("§8/§7loader undo"), false, clickType -> {
});
} else {
inv.setItem(0, Material.BLAZE_ROD, "§7Loader Bearbeiten", Collections.singletonList("§8/§7loader setup"), false, clickType -> {
loader.setup();
autoLoaderGUI(player);
});
}
inv.setItem(4, Material.COMPASS, "§7Schuss Delay", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenShots(), "§8/§7loader wait §8[§eTicks§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Schuss Delay", loader.getTicksBetweenShots() + "");
anvilInv.setItem(Material.STONE);
anvilInv.setCallback(s -> {
player.performCommand("loader wait " + s);
autoLoaderGUI(player);
});
anvilInv.open();
});
inv.setItem(6, getMaterial("CLOCK", "WATCH"), "§7Block platzier Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenBlocks(), "§8/§7loader speed §8[§eTicks§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Platzier Geschwindigkeit", loader.getTicksBetweenBlocks() + "");
anvilInv.setItem(Material.STONE);
anvilInv.setCallback(s -> {
player.performCommand("loader speed " + s);
autoLoaderGUI(player);
});
anvilInv.open();
});
inv.setItem(8, Material.BARRIER, "§7Loader löschen", Collections.singletonList("§8/§7loader stop"), false, clickType -> confirmationInventory(player, "Loader löschen?", () -> {
loader.stop();
autoLoaderGUI(player);
}, () -> autoLoaderGUI(player)));
} else {
inv.setItem(4, Material.GOLD_NUGGET, "§eNeuer Autoloader", clickType -> {
AutoLoader.getLoader(player);
player.closeInventory();
});
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
player.closeInventory();
openBauGui(player);
OPEN_INVS.add(player);
});
}
inv.open();
}
private static void bauManagementGUI(Player player) {
bauManagementGUI(player, "");
}
private static void bauManagementGUI(Player player, String search) {
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
List<SWListInv.SWListEntry<BauweltMember>> items = new ArrayList<>();
members.forEach(member -> {
if (member.getMemberID() == BauSystem.getOwnerID())
return;
SteamwarUser user = SteamwarUser.get(member.getMemberID());
if (!user.getUserName().toLowerCase().contains(search.toLowerCase()))
return;
SWItem item = SWItem.getPlayerSkull(user.getUserName());
item.setName("§7" + user.getUserName());
List<String> lore = new ArrayList<>();
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("§7World: §e" + (member.isWorld() ? "Ja" : "Nein"));
item.setLore(lore);
items.add(new SWListInv.SWListEntry<>(item, member));
});
SWListInv<BauweltMember> inv = new SWListInv<>(player, "Bauweltmembers", false, items, (clickType, member) -> bauweltMemberGUI(player, member));
inv.setItem(48, Material.NETHER_STAR, "§7Member hinzufühgen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Member hinzufühgen");
anvilInv.setItem(Material.NAME_TAG);
anvilInv.setCallback(s -> {
player.closeInventory();
confirmChatMessage(player, "/bau addmember " + s);
});
anvilInv.open();
});
inv.setItem(50, Material.NAME_TAG, "§7Suchen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Member suchen");
anvilInv.setItem(Material.PAPER);
anvilInv.setCallback(s -> {
player.closeInventory();
bauManagementGUI(player, s);
});
anvilInv.open();
});
inv.open();
}
private static void bauweltMemberGUI(Player player, BauweltMember member) {
SteamwarUser user = SteamwarUser.get(member.getMemberID());
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()) {
inv.setItem(2, getMaterial("GREEN_WOOL", "WOOL"), (byte) 13, "§7Worldedit", Arrays.asList("§7Aktuell: §eJa", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(false);
bauweltMemberGUI(player, member);
});
} else {
inv.setItem(2, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7Worldedit", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau togglewe §8[§eSpieler§8]"), false, clickType -> {
member.setWorldEdit(true);
bauweltMemberGUI(player, member);
});
}
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 -> {
member.setWorld(false);
bauweltMemberGUI(player, member);
});
} else {
inv.setItem(4, getMaterial("RED_WOOL", "WOOL"), (byte) 14, "§7World", Arrays.asList("§7Aktuell: §eNein", "§8/§7bau toggleworld §8[§eSpieler§8]"), false, clickType -> {
member.setWorld(true);
bauweltMemberGUI(player, member);
});
}
inv.setItem(6, Material.BARRIER, "§7Member entfernen", clickType -> {
player.closeInventory();
confirmChatMessage(player, "/bau delmember " + user.getUserName());
});
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> bauManagementGUI(player));
inv.open();
}
private static void confirmChatMessage(Player player, String command) {
player.sendMessage(BauSystem.PREFIX + "§7Klicke auf die Nachricht zum bestätigen");
TextComponent t = new TextComponent();
t.setText("[Hier]");
t.setColor(ChatColor.YELLOW);
t.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
t.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§7" + command)));
player.spigot().sendMessage(t);
}
private static List<String> getNoPermsLore(List<String> lore, Player player, String noPerms, Permission perm) {
if (Welt.noPermission(player, perm)) {
lore = new ArrayList<>(lore);
lore.add(noPerms);
}
return lore;
}
private static void updateInventories() {
isRefreshing = true;
OPEN_INVS.forEach(CommandGUI::openBauGui);
OPEN_TRACER_INVS.forEach(CommandGUI::traceGUI);
isRefreshing = false;
}
private static void confirmationInventory(Player player, String title, Runnable confirm, Runnable decline) {
SWInventory inv = new SWInventory(player, 9, title);
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§cAbbrechen", clickType -> {
player.closeInventory();
decline.run();
});
inv.setItem(8, SWItem.getDye(10), (byte) 10, "§aBestätigen", clickType -> {
player.closeInventory();
confirm.run();
});
inv.open();
}
private static Material getMaterial(String... names) {
for (String name : names) {
try {
return Material.valueOf(name);
} catch (IllegalArgumentException ignored) {
//Ignored /\
}
}
return null;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player))
return false;
Player player = ((Player) commandSender);
if (strings.length == 0) {
openBauGui(player);
OPEN_INVS.add(player);
} else if ("item".equalsIgnoreCase(strings[0])) {
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR));
}
return true;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getItem() == null || event.getItem().getType() != Material.NETHER_STAR)
return;
openBauGui(event.getPlayer());
OPEN_INVS.add(event.getPlayer());
}
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (LAST_F_PLAYER.contains(event.getPlayer())) {
openBauGui(event.getPlayer());
OPEN_INVS.add(event.getPlayer());
} else {
LAST_F_PLAYER.add(event.getPlayer());
}
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -26,8 +27,6 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import de.steamwar.bausystem.BauSystem;
public class CommandGills implements CommandExecutor {
@Override
@ -35,16 +34,17 @@ public class CommandGills implements CommandExecutor {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
toggleGills(player);
return false;
}
for(PotionEffect effect : player.getActivePotionEffects()){
if(effect.getType().equals(PotionEffectType.WATER_BREATHING)){
player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert");
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
return false;
}
public static void toggleGills(Player player) {
if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert");
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false));
player.sendMessage(BauSystem.PREFIX + "Wassersicht aktiviert");
return false;
}
}

Datei anzeigen

@ -34,16 +34,18 @@ public class CommandNV implements CommandExecutor {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
for(PotionEffect effect : player.getActivePotionEffects()){
if(effect.getType().equals(PotionEffectType.NIGHT_VISION)){
player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert");
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
return false;
}
}
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false));
player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert");
toggleNightvision(player);
return false;
}
public static void toggleNightvision(Player player) {
if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert");
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false));
player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert");
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class CommandReset implements CommandExecutor {
}
Region region = Region.getRegion(player.getLocation());
if (region == null) {
if (region == Region.GlobalRegion.getInstance()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;
}

Datei anzeigen

@ -21,6 +21,7 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.PlayerUtils;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -67,7 +68,7 @@ public class CommandScript implements CommandExecutor {
if (!(sender instanceof Player)) {
return false;
}
((Player) sender).getInventory().setItemInMainHand(BOOK);
PlayerUtils.giveItemToPlayer((Player) sender, BOOK);
return false;
}

Datei anzeigen

@ -20,8 +20,8 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.PlayerUtils;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -47,10 +47,7 @@ public class CommandSkull implements CommandExecutor {
assert sm != null;
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
is.setItemMeta(sm);
if(p.getInventory().getItemInMainHand().getType() == Material.AIR)
p.getInventory().setItemInMainHand(is);
else
p.getInventory().addItem(is);
PlayerUtils.giveItemToPlayer(p, is);
return false;
}

Datei anzeigen

@ -46,7 +46,7 @@ public class CommandTestblock implements CommandExecutor {
}
Region region = Region.getRegion(player.getLocation());
if (region == null || !region.hasTestblock()) {
if (!region.hasTestblock()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;
}

Datei anzeigen

@ -139,6 +139,14 @@ public class AutoLoader extends IAutoLoader implements Listener {
ticksBetweenBlocks = time;
}
public int getTicksBetweenShots() {
return ticksBetweenShots;
}
public int getTicksBetweenBlocks() {
return ticksBetweenBlocks;
}
public boolean isSetup() {
return setup;
}

Datei anzeigen

@ -48,10 +48,10 @@ public class Detonator implements Listener {
static {
WAND = new ItemStack(Material.TRIPWIRE_HOOK, 1);
WAND = new ItemStack(Material.BLAZE_ROD, 1);
ItemMeta im = WAND.getItemMeta();
im.setDisplayName("§6Fernzünder");
im.setDisplayName("§eFernzünder");
List<String> lorelist = Arrays.asList("§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren",
"§eLinks Klick + Shift §8- §7Füge einen Punkt hinzu", "§eRechts Klick §8- §7Löse alle Punkte aus");

Datei anzeigen

@ -0,0 +1,124 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class PredefinedBook {
private static final FileConfiguration configuration;
private static List<PredefinedBook> bookCache;
static {
configuration = YamlConfiguration.loadConfiguration(new File(BauSystem.getPlugin().getDataFolder(), "books.yml"));
}
public static List<PredefinedBook> getBooks() {
if(bookCache != null)
return bookCache;
List<PredefinedBook> books = new ArrayList<>();
for (String book:configuration.getKeys(false)) {
ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book));
books.add(new PredefinedBook(section));
}
bookCache = books;
return books;
}
public static int getBookCount() {
return configuration.getKeys(false).size();
}
private List<String> lines;
private List<String> lore;
private String author;
private String name;
private ItemStack finishedBook;
PredefinedBook(ConfigurationSection section) {
this.lines = section.getStringList("lines");
this.lore = section.getStringList("lore");
this.author = section.getString("author", "§8Steam§eWar");
this.name = section.getName();
}
public ItemStack toItemStack() {
if(finishedBook != null)
return finishedBook;
ItemStack book = new ItemStack(getBookMat());
BookMeta meta = (BookMeta) book.getItemMeta();
meta.setPages(getPages());
meta.setDisplayName(name);
meta.setTitle(name);
meta.setAuthor(author);
meta.setGeneration(BookMeta.Generation.ORIGINAL);
meta.setLore(lore);
book.setItemMeta(meta);
finishedBook = book;
return book;
}
public Material getBookMat() {
return Material.WRITTEN_BOOK;
}
public List<String> getLines() {
return lines;
}
public String getAuthor() {
return author;
}
public String getName() {
return name;
}
public List<String> getLore() {
return lore;
}
private String[] getPages() {
List<StringBuilder> pages = new ArrayList<>();
pages.add(0, new StringBuilder());
int charsPerLine = 19;
int currentLine = 0;
int currentpage = 0;
boolean first = true;
for (String line:lines) {
int linesPlus = (int) Math.ceil((double) line.length() / charsPerLine);
currentLine += linesPlus;
if(currentLine >= 14 || line.equals("!")) {
currentLine = linesPlus;
currentpage++;
if(currentpage > 50)
throw new IllegalStateException("Book " + name + " has more pages than 50");
pages.add(currentpage, new StringBuilder());
first = true;
if(line.equals("!"))
continue;
}
if(!first) {
pages.get(currentpage).append("\n");
}else {
first = false;
}
pages.get(currentpage).append(line);
}
String[] finalPages = new String[pages.size()];
for (int i = 0; i < pages.size(); i++) {
finalPages[i] = pages.get(i).toString();
}
return finalPages;
}
}

Datei anzeigen

@ -37,4 +37,5 @@ commands:
aliases: dt
script:
simulator:
aliases: sim
aliases: sim
gui: