Add BauSystem module

Fix ci java version
Fix LinkageProcessor
This commit is contained in:
2024-08-05 13:28:50 +02:00
parent 41d31e6c9c
commit 3366a30b0c
526 changed files with 43550 additions and 149479 deletions
@@ -0,0 +1,51 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.lobby.command;
import de.steamwar.command.SWCommand;
import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.entity.Player;
public class FlyCommand extends SWCommand {
public FlyCommand() {
super("fly");
}
@Register
public void genericCommand(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!user.hasPerm(UserPerm.TEAM)) {
player.sendMessage("§cUnbekannter Befehl.");
return;
}
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
boolean newFlightState = !lobbyPlayer.isFlying();
lobbyPlayer.setFly(newFlightState);
player.setAllowFlight(newFlightState);
player.setFlying(newFlightState);
player.sendMessage("§7Du kannst jetzt " + (newFlightState ? "§afliegen§7." : "§cnicht §7mehr fliegen."));
}
}
@@ -0,0 +1,67 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.lobby.command;
import de.steamwar.command.SWCommand;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.display.Hologram;
import org.bukkit.entity.Player;
public class HologramCommand extends SWCommand {
public HologramCommand() {
super("hologram");
}
@Register(help = true)
public void genericHelp(Player player, String... args) {
if (PortalCommand.noPermissions(player)) return;
player.sendMessage("/hologram create <id> <text>");
player.sendMessage("/hologram list");
player.sendMessage("/hologram delete <id>");
}
@Register("create")
public void portalCreate(Player player, String id, String... text) {
if (PortalCommand.noPermissions(player)) return;
new Hologram(id, player.getLocation(), String.join(" ", text).replace("&", "§"), false);
LobbySystem.config().save();
}
@Register("list")
public void portalList(Player player) {
if (PortalCommand.noPermissions(player)) return;
Hologram.getHolograms().forEach(hologram -> player.sendMessage(hologram.toString()));
}
@Register("delete")
public void portalDelete(Player player, String id) {
if (PortalCommand.noPermissions(player)) return;
Hologram hologram = Hologram.getHologram(id);
if (hologram == null)
return;
hologram.delete();
LobbySystem.config().save();
}
}
@@ -0,0 +1,88 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.lobby.command;
import de.steamwar.command.SWCommand;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.PlayerSpawn;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Set;
public class ModifyCommand extends SWCommand implements Listener {
private static final Set<HumanEntity> modifying = new HashSet<>();
public static boolean modifying(HumanEntity player) {
return modifying.contains(player);
}
public ModifyCommand() {
super("modify");
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin());
}
@Register
public void modify(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!user.hasPerm(UserPerm.ADMINISTRATION)) {
return;
}
if(modifying(player)) {
modifying.remove(player);
LobbySystem.getEntityServer(true).removePlayer(player);
player.setGameMode(GameMode.ADVENTURE);
player.setOp(false);
PlayerSpawn.giveItems(player);
}else {
modifying.add(player);
LobbySystem.getEntityServer(true).addPlayer(player);
player.setGameMode(GameMode.CREATIVE);
player.setOp(true);
}
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
Player player = event.getPlayer();
modifying.remove(player);
player.setOp(false);
}
@Register("waitinghallspawn")
public void setWaitingHallSpawn(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!user.hasPerm(UserPerm.ADMINISTRATION))
return;
LobbySystem.config().setWaitingHallSpawn(player.getLocation());
}
}
@@ -0,0 +1,168 @@
package de.steamwar.lobby.command;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.RegionSelector;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.portal.*;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import lombok.Data;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class PortalCommand extends SWCommand {
public PortalCommand() {
super("portal");
}
public static boolean noPermissions(Player player) {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
return !steamwarUser.hasPerm(UserPerm.ADMINISTRATION);
}
@Register
public void genericHelp(Player player, String... args) {
if (noPermissions(player)) return;
LobbySystem.getMessage().sendPrefixless("COMMAND_HELP_HEAD", player, "portal");
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_LIST_HELP", player);
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_ADD_HELP", player);
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_REMOVE_HELP", player);
}
@Register("list")
public void portalList(Player player) {
if (noPermissions(player)) return;
LobbySystem.getMessage().sendPrefixless("COMMAND_HELP_HEAD", player, "portal list");
Portal.getPortals().forEach(portal -> {
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_LIST_SHORT_INFO", player, portal.type().name(), portal.getId(), portal.getPos1().toVector().toString(), portal.getPos2().toVector().toString());
});
}
@Register({"create", "command"})
public void portalAddCommand(Player player, String portalName, String... command) {
if (noPermissions(player)) return;
PortalLocations tuple = getSelection(player);
if (tuple == null) return;
new Portal(portalName, tuple.k, tuple.v, portal -> new CommandPortal(String.join(" ", command)));
}
@Register({"create", "fight"})
public void portalAddFightserver(Player player, String portalName, String gamemode, int order, String target) {
if (noPermissions(player)) return;
PortalLocations tuple = getSelection(player);
if (tuple == null) return;
new Portal(portalName, tuple.k, tuple.v, portal -> new FightserverPortal(portal, gamemode.toLowerCase(), order, target, new ArrayList<>(), new ArrayList<>()));
}
@Register({"create", "teleport"})
public void portalAddTeleport(Player player, String portalName, String portalDestination) {
if (noPermissions(player)) return;
PortalLocations tuple = getSelection(player);
if (tuple == null) return;
new Portal(portalName, tuple.k, tuple.v, portal -> new TeleportPortal(portal, portalDestination));
}
@Register({"create", "stack"})
public void portalAddStack(Player player, String portalName, String portalDestination, String... command) {
if (noPermissions(player)) return;
PortalLocations tuple = getSelection(player);
if (tuple == null) return;
new Portal(portalName, tuple.k, tuple.v, portal -> new StackPortal(portal, portalDestination, String.join(" ", command)));
}
@Register({"depth"})
public void portalDepth(Player player, Portal portal, double depth) {
portal.setDepth(depth);
}
@Register({"addblue"})
public void portalAddBlue(Player player, Portal portal) {
FightserverPortal handler = (FightserverPortal) portal.getHandler();
handler.addBlue(locationOfPlayer(player));
}
@Register({"addred"})
public void portalAddRed(Player player, Portal portal) {
FightserverPortal handler = (FightserverPortal) portal.getHandler();
handler.addRed(locationOfPlayer(player));
}
private Location locationOfPlayer(Player player) {
Location l = player.getLocation();
l.setYaw(((CraftPlayer)player).getHandle().cm());
return l;
}
@Register({"removeblue"})
public void portalRemoveBlue(Player player, Portal portal, int i) {
FightserverPortal handler = (FightserverPortal) portal.getHandler();
handler.removeBlue(i-1);
}
@Register({"removered"})
public void portalRemoveRed(Player player, Portal portal, int i) {
FightserverPortal handler = (FightserverPortal) portal.getHandler();
handler.removeRed(i-1);
}
@Register("remove")
public void portalRemove(Player player, Portal portal) {
if (noPermissions(player)) return;
portal.delete();
}
@ClassMapper(value = Portal.class, local = true)
public TypeMapper<Portal> portalTypeMapper() {
return new TypeMapper<Portal>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
return new ArrayList<>(Portal.getPortalNames());
}
@Override
public Portal map(CommandSender commandSender, String[] previousArguments, String s) {
return Portal.getPortal(s);
}
};
}
@Data
private static class PortalLocations {
private final Location k;
private final Location v;
}
private PortalLocations getSelection(Player player) {
RegionSelector regionSelector = WorldEdit.getInstance()
.getSessionManager()
.get(BukkitAdapter.adapt(player))
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
try {
CuboidRegion region = (CuboidRegion)regionSelector.getRegion();
return new PortalLocations(adapt(player.getWorld(), region.getPos1()), adapt(player.getWorld(), region.getPos2()));
} catch (IncompleteRegionException e) {
LobbySystem.getMessage().send("PORTAL_NO_WORLDEDIT_SELECTION", player);
return null;
}
}
private Location adapt(World world, BlockVector3 blockVector3) {
return new Location(world, blockVector3.getBlockX() + 0.5, blockVector3.getBlockY(), blockVector3.getBlockZ() + 0.5);
}
}