Add Teamserver module

This commit is contained in:
2024-08-05 09:42:55 +02:00
parent 2bdd23d04a
commit 5887f1703a
14 changed files with 1042 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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/>.
*/
plugins {
id("java")
id("base")
id("com.github.johnrengelman.shadow")
}
group = "de.steamwar"
version = ""
tasks.compileJava {
options.encoding = "UTF-8"
}
tasks.build {
finalizedBy(tasks.shadowJar)
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
main {
java {
srcDirs("src/")
}
resources {
srcDirs("src/")
exclude("**/*.java", "**/*.kt")
}
}
}
dependencies {
compileOnly("org.projectlombok:lombok:1.18.32")
annotationProcessor("org.projectlombok:lombok:1.18.32")
compileOnly(project(":SpigotCore"))
compileOnly("de.steamwar:worldedit:1.15")
compileOnly("de.steamwar:axiompaper:RELEASE")
compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
}
@@ -0,0 +1,71 @@
/*
* 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.teamserver;
import de.steamwar.message.Message;
import de.steamwar.teamserver.command.*;
import de.steamwar.teamserver.listener.AxiomHandshakeListener;
import de.steamwar.teamserver.listener.FreezeListener;
import de.steamwar.teamserver.listener.PlayerChange;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.plugin.java.JavaPlugin;
public final class Builder extends JavaPlugin {
// This should be treated as final!
public static Message MESSAGE;
private static Builder instance;
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
MESSAGE = new Message("de.steamwar.teamserver.Teamserver", getClassLoader());
new GamemodeCommand();
new SpeedCommand();
new FreezeCommand();
new ArenaconfigCommand();
if (Bukkit.getPluginManager().getPlugin("AxiomPaper") != null) {
Bukkit.getPluginManager().registerEvents(new AxiomHandshakeListener(), this);
}
Bukkit.getPluginManager().registerEvents(new PlayerChange(), this);
Bukkit.getPluginManager().registerEvents(new FreezeListener(), this);
MaterialCommand materialCommand = new MaterialCommand();
Bukkit.getPluginManager().registerEvents(materialCommand, this);
Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, false);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public static Builder getInstance() {
return instance;
}
}
@@ -0,0 +1,61 @@
#
# This file is a part of the SteamWar software.
#
# Copyright (C) 2023 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/>.
#
PREFIX = §eBuilder§8»
TIME = HH:mm:ss
# Freeze
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
REGION_FREEZE_ENABLED=§cRegion eingefroren
REGION_FREEZE_DISABLED=§aRegion aufgetaut
# Material
MATERIAL_INV_NAME=§eMaterial {0}/{1}
MATERIAL_SEARCH=§eSuchen
MATERIAL_BACK=§eZurück
MATERIAL_SEARCH_NAME=§eName
MATERIAL_SEARCH_TRANSPARENT=§eTransparent
MATERIAL_SEARCH_SOLID=§eSolide
MATERIAL_SEARCH_GRAVITY=§eFallend
MATERIAL_SEARCH_OCCLUDING=§eOccluding
MATERIAL_SEARCH_INTERACTEABLE=§eInterargierbar
MATERIAL_SEARCH_FLAMMABLE=§eFlammbar
MATERIAL_SEARCH_BURNABLE=§eBrennbar
MATERIAL_SEARCH_WATERLOGGABLE=§eWasserspeicherbar
MATERIAL_SEARCH_BLASTRESISTANCE=§eBlast Resistance
MATERIAL_SEARCH_BLASTRESISTANCE_MIN=§eBlast Resistance mindestens
MATERIAL_SEARCH_BLASTRESISTANCE_MAX=§eBlast Resistance maximal
MATERIAL_SEARCH_BLASTRESISTANCE_EXACT=§eBlast Resistance
MATERIAL_SEARCH_VALUE=§8: §e{0}
MATERIAL_BLAST-RESISTANCE=§8- §eBlast Resistance§8: §7{0}
MATERIAL_HARDNESS=§8- §eHärte§8: §7{0}
MATERIAL_TNT_BREAKABLE=§8- §eZerstörbar durch TNT
MATERIAL_TNT_UNBREAKABLE=§8- §eNicht Zerstörbar durch TNT
MATERIAL_TRANSPARENT=§8- §eTransparenter Block
MATERIAL_SOLID=§8- §eSolider Block
MATERIAL_GRAVITY=§8- §eFallender Block
MATERIAL_OCCLUDING=§8- §eOccluding Block
MATERIAL_INTERACT-ABLE=§8- §eInterargierbarer Block
MATERIAL_FLAMMABLE=§8- §eFlammbarer Block
MATERIAL_BURNABLE=§8- §eBrennbarer Block
MATERIAL_WATERLOGGABLE=§8- §eWasserspeicherbarer Block
ARENACONFIG_HELP=§8/§7arenaconfig §8[§eUntere Spielergrenze§8] (WE-Pos1: Kleinste blaue Schemkoordinate, WE-Pos2: Kleinste Rote Schemkoordinate)
ARENACONFIG_SELECTION=§cKeine WE-SAuswahl,
@@ -0,0 +1,84 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.teamserver.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.teamserver.Builder;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
public class ArenaconfigCommand extends SWCommand {
public ArenaconfigCommand() {
super("arenaconfig");
}
@Register
public void genericHelp(Player p, String... args) {
Builder.MESSAGE.send("ARENACONFIG_HELP", p);
}
@Register
public void config(Player p, int lowerPlayerBorder) throws IOException {
CuboidRegion region = getSelection(p);
if(region == null)
return;
BlockVector3 pos1 = region.getPos1();
BlockVector3 pos2 = region.getPos2();
File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
config.set("UnderBorder", lowerPlayerBorder);
config.set("BlueCorner.x", pos1.getX());
config.set("BlueCorner.y", pos1.getY());
config.set("BlueCorner.z", pos1.getZ());
config.set("BlueToRed.x", pos2.getX() - pos1.getX());
config.set("BlueToRed.y", pos2.getY() - pos1.getY());
config.set("BlueToRed.z", pos2.getZ() - pos1.getZ());
config.save(file);
}
private CuboidRegion getSelection(Player player) {
RegionSelector regionSelector = WorldEdit.getInstance()
.getSessionManager()
.get(BukkitAdapter.adapt(player))
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
try {
return (CuboidRegion)regionSelector.getRegion();
} catch (IncompleteRegionException e) {
Builder.MESSAGE.send("ARENACONFIG_SELECTION", player);
return null;
}
}
}
@@ -0,0 +1,56 @@
/*
* 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.teamserver.command;
import de.steamwar.command.SWCommand;
import de.steamwar.teamserver.Builder;
import de.steamwar.teamserver.listener.FreezeListener;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class FreezeCommand extends SWCommand {
public FreezeCommand() {
super("freeze", "stoplag");
}
@Register(description = "REGION_FREEZE_HELP")
public void toggleCommand(Player p) {
if (toggle()) {
Bukkit.getOnlinePlayers().forEach(player -> {
Builder.MESSAGE.sendPrefixless("REGION_FREEZE_ENABLED", player, ChatMessageType.ACTION_BAR);
});
} else {
Bukkit.getOnlinePlayers().forEach(player -> {
Builder.MESSAGE.sendPrefixless("REGION_FREEZE_DISABLED", player, ChatMessageType.ACTION_BAR);
});
}
}
private boolean toggle() {
if (FreezeListener.freeze) {
FreezeListener.freeze = false;
} else {
FreezeListener.freeze = true;
}
return FreezeListener.freeze;
}
}
@@ -0,0 +1,45 @@
/*
* 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.teamserver.command;
import de.steamwar.command.SWCommand;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class GamemodeCommand extends SWCommand {
public GamemodeCommand() {
super("gamemode", "gm", "g");
}
@Register
public void genericCommand(final Player p) {
if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR);
} else {
p.setGameMode(GameMode.CREATIVE);
}
}
@Register
public void gamemodeCommand(final Player p, final GameMode gameMode) {
p.setGameMode(gameMode);
}
}
@@ -0,0 +1,311 @@
/*
* 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.teamserver.command;
import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.teamserver.Builder;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class MaterialCommand extends SWCommand implements Listener {
public MaterialCommand() {
super("material");
}
private List<MaterialData> materialData = new ArrayList<>();
private Map<Player, Search> searchMap = new HashMap<>();
{
for (Material value : Material.values()) {
if (!value.isBlock()) {
continue;
}
if (value.isLegacy()) {
continue;
}
materialData.add(new MaterialData(value));
}
}
private static class MaterialData {
private Material material;
private Material originalMaterial;
private String name;
private double blastResistance;
private double hardness;
private boolean transparent;
private boolean solid;
private boolean gravity;
private boolean occluding;
private boolean interacteable;
private boolean flammable;
private boolean burnable;
private boolean waterloggable;
public MaterialData(Material material) {
this.originalMaterial = material;
name = material.name();
blastResistance = material.getBlastResistance();
hardness = material.getHardness();
transparent = material.isTransparent();
solid = material.isSolid();
gravity = material.hasGravity();
occluding = material.isOccluding();
interacteable = material.isInteractable();
flammable = material.isFlammable();
burnable = material.isBurnable();
BlockData blockData = material.createBlockData();
waterloggable = blockData instanceof Waterlogged;
if (material.isItem() && material != Material.AIR) {
this.material = material;
} else {
this.material = Material.GHAST_TEAR;
}
}
public SWListInv.SWListEntry<Material> toSWItem(Player p) {
List<String> lore = new ArrayList<>();
lore.add(Builder.MESSAGE.parse("MATERIAL_BLAST-RESISTANCE", p, blastResistance));
lore.add(Builder.MESSAGE.parse(blastResistance > 9 ? "MATERIAL_TNT_UNBREAKABLE" : "MATERIAL_TNT_BREAKABLE", p));
lore.add(Builder.MESSAGE.parse("MATERIAL_HARDNESS", p, hardness));
if (transparent) {
lore.add(Builder.MESSAGE.parse("MATERIAL_TRANSPARENT", p));
}
if (solid) {
lore.add(Builder.MESSAGE.parse("MATERIAL_SOLID", p));
}
if (gravity) {
lore.add(Builder.MESSAGE.parse("MATERIAL_GRAVITY", p));
}
if (occluding) {
lore.add(Builder.MESSAGE.parse("MATERIAL_OCCLUDING", p));
}
if (interacteable) {
lore.add(Builder.MESSAGE.parse("MATERIAL_INTERACT-ABLE", p));
}
if (flammable) {
lore.add(Builder.MESSAGE.parse("MATERIAL_FLAMMABLE", p));
}
if (burnable) {
lore.add(Builder.MESSAGE.parse("MATERIAL_BURNABLE", p));
}
if (waterloggable) {
lore.add(Builder.MESSAGE.parse("MATERIAL_WATERLOGGABLE", p));
}
return new SWListInv.SWListEntry<>(new SWItem(material, "§e" + name, lore, false, clickType -> {
}), originalMaterial);
}
public boolean is(Search search) {
boolean result = true;
if (search.transparent) {
result &= transparent;
}
if (search.solid) {
result &= solid;
}
if (search.gravity) {
result &= gravity;
}
if (search.occluding) {
result &= occluding;
}
if (search.interacteable) {
result &= interacteable;
}
if (search.flammable) {
result &= flammable;
}
if (search.burnable) {
result &= burnable;
}
if (search.waterloggable) {
result &= waterloggable;
}
if (!result) {
return false;
}
if (!(blastResistance >= search.blastResistanceMin && blastResistance < search.blastResistanceMax)) {
return false;
}
if (search.name.isEmpty()) {
return true;
}
return Pattern.compile(".*" + search.name.toLowerCase().replace(' ', '.') + ".*").asPredicate().test(name.toLowerCase());
}
}
private static class Search {
private boolean transparent = false;
private boolean solid = false;
private boolean gravity = false;
private boolean occluding = false;
private boolean interacteable = false;
private boolean flammable = false;
private boolean burnable = false;
private boolean waterloggable = false;
private double blastResistanceMin = 0;
private double blastResistanceMax = 5000000;
private String name = "";
}
@Register
public void materialGUI(Player p) {
List<SWListInv.SWListEntry<Material>> swListEntries = new ArrayList<>();
materialData.forEach(data -> {
if (data.is(searchMap.get(p))) {
swListEntries.add(data.toSWItem(p));
}
});
SWListInv<Material> materialSWListInv = new SWListInv<>(p, Builder.MESSAGE.parse("MATERIAL_INV_NAME", p, swListEntries.size(), materialData.size()), false, swListEntries, (clickType, material) -> {
});
materialSWListInv.setItem(49, new SWItem(Material.NAME_TAG, Builder.MESSAGE.parse("MATERIAL_SEARCH", p), clickType -> {
searchGUI(p);
}));
materialSWListInv.open();
}
private void searchGUI(Player p) {
SWInventory swInventory = new SWInventory(p, 54, Builder.MESSAGE.parse("MATERIAL_SEARCH", p));
Search search = searchMap.get(p);
swInventory.setItem(45, new SWItem(Material.ARROW, Builder.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
materialGUI(p);
}));
swInventory.setItem(10, new SWItem(Material.NAME_TAG, Builder.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, Builder.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
swAnvilInv.setCallback(s -> {
search.name = s;
searchGUI(p);
});
swAnvilInv.open();
}));
swInventory.setItem(19, new SWItem(Material.GLASS, Builder.MESSAGE.parse("MATERIAL_SEARCH_TRANSPARENT", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.transparent), clickType -> {
search.transparent = !search.transparent;
searchGUI(p);
}));
swInventory.setItem(20, new SWItem(Material.BRICK, Builder.MESSAGE.parse("MATERIAL_SEARCH_SOLID", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.solid), clickType -> {
search.solid = !search.solid;
searchGUI(p);
}));
swInventory.setItem(21, new SWItem(Material.BLACK_CONCRETE_POWDER, Builder.MESSAGE.parse("MATERIAL_SEARCH_GRAVITY", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.gravity), clickType -> {
search.gravity = !search.gravity;
searchGUI(p);
}));
swInventory.setItem(22, new SWItem(Material.BIRCH_LOG, Builder.MESSAGE.parse("MATERIAL_SEARCH_OCCLUDING", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.occluding), clickType -> {
search.occluding = !search.occluding;
searchGUI(p);
}));
swInventory.setItem(23, new SWItem(Material.OAK_BUTTON, Builder.MESSAGE.parse("MATERIAL_SEARCH_INTERACTEABLE", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.interacteable), clickType -> {
search.interacteable = !search.interacteable;
searchGUI(p);
}));
swInventory.setItem(24, new SWItem(Material.FLINT_AND_STEEL, Builder.MESSAGE.parse("MATERIAL_SEARCH_FLAMMABLE", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.flammable), clickType -> {
search.flammable = !search.flammable;
searchGUI(p);
}));
swInventory.setItem(25, new SWItem(Material.LAVA_BUCKET, Builder.MESSAGE.parse("MATERIAL_SEARCH_BURNABLE", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.burnable), clickType -> {
search.burnable = !search.burnable;
searchGUI(p);
}));
swInventory.setItem(28, new SWItem(Material.WATER_BUCKET, Builder.MESSAGE.parse("MATERIAL_SEARCH_WATERLOGGABLE", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.waterloggable), clickType -> {
search.waterloggable = !search.waterloggable;
searchGUI(p);
}));
swInventory.setItem(30, new SWItem(Material.FIRE_CHARGE, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_MIN", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMin), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMin + "");
swAnvilInv.setCallback(s -> {
try {
search.blastResistanceMin = Double.parseDouble(s);
if (search.blastResistanceMin < 0) search.blastResistanceMin = 0;
if (search.blastResistanceMin > 5000000) search.blastResistanceMin = 5000000;
if (search.blastResistanceMin > search.blastResistanceMax)
search.blastResistanceMin = search.blastResistanceMax;
} catch (NumberFormatException e) {
// Ignored
}
searchGUI(p);
});
swAnvilInv.open();
}));
swInventory.setItem(31, new SWItem(Material.TNT, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_MAX", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMax), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMax + "");
swAnvilInv.setCallback(s -> {
try {
search.blastResistanceMax = Double.parseDouble(s);
if (search.blastResistanceMax > 5000000) search.blastResistanceMax = 5000000;
if (search.blastResistanceMax < 0) search.blastResistanceMax = 0;
if (search.blastResistanceMax < search.blastResistanceMin)
search.blastResistanceMax = search.blastResistanceMin;
} catch (NumberFormatException e) {
// Ignored
}
searchGUI(p);
});
swAnvilInv.open();
}));
swInventory.setItem(32, new SWItem(Material.NETHER_BRICK, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_EXACT", p) + Builder.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMin + "-" + search.blastResistanceMax), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, Builder.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMax + "");
swAnvilInv.setCallback(s -> {
try {
search.blastResistanceMax = Double.parseDouble(s);
if (search.blastResistanceMax > 5000000) search.blastResistanceMax = 5000000;
if (search.blastResistanceMax < 0) search.blastResistanceMax = 0;
search.blastResistanceMin = search.blastResistanceMax;
} catch (NumberFormatException e) {
// Ignored
}
searchGUI(p);
});
swAnvilInv.open();
}));
swInventory.open();
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
searchMap.put(event.getPlayer(), new Search());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
searchMap.remove(event.getPlayer());
}
}
@@ -0,0 +1,55 @@
/*
* 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.teamserver.command;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class SpeedCommand extends SWCommand {
public SpeedCommand() {
super("speed");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("/speed [1-10] - Setzte deine Flug- und Laufgeschindigkeit.");
p.sendMessage("Aktuelle geschwindigkeit: " + (p.getFlySpeed() * 10F));
}
@Register
public void speedCommand(Player p, float speed) {
speed = speed / 10F;
if (speed < -1F) {
p.sendMessage("§7" + speed + " ist zu klein");
} else if (speed > 1F) {
p.sendMessage("§7" + speed + " ist zu hoch");
} else {
p.setFlySpeed(speed);
p.setWalkSpeed(Math.min(speed + 0.1F, 1F));
p.sendMessage("Aktuelle geschwindigkeit: " + (p.getFlySpeed() * 10F));
}
}
@Register({"default"})
public void speedCommand(Player p) {
speedCommand(p, 1);
}
}
@@ -0,0 +1,32 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.teamserver.listener;
import com.moulberry.axiom.event.AxiomHandshakeEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class AxiomHandshakeListener implements Listener {
@EventHandler
public void onAxiomHandshake(AxiomHandshakeEvent event) {
event.setMaxBufferSize(Short.MAX_VALUE);
}
}
@@ -0,0 +1,212 @@
/*
* 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.teamserver.listener;
import de.steamwar.core.Core;
import de.steamwar.teamserver.Builder;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class FreezeListener implements Listener {
public static boolean freeze = true;
public FreezeListener() {
Bukkit.getScheduler().runTaskTimer(Builder.getInstance(), () -> {
if (!freeze) return;
Bukkit.getOnlinePlayers().forEach(player -> {
Builder.MESSAGE.sendPrefixless("REGION_FREEZE_ENABLED", player, ChatMessageType.ACTION_BAR);
});
}, 1, 1);
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
if (!freeze) return;
e.setCancelled(true);
if (e.getEntityType() == EntityType.PRIMED_TNT) {
Bukkit.getScheduler().runTaskLater(Builder.getInstance(), () -> {
e.getLocation().getBlock().setType(Material.TNT, false);
}, 1L);
}
}
@EventHandler
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (!e.isBuildable()) return;
if (freeze) return;
if (e.getMaterial() == Material.TNT) {
e.setBuildable(false);
e.getBlock().setType(Material.TNT, false);
}
}
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onPhysicsEvent(BlockPhysicsEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockGrow(BlockGrowEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent e) {
if (freeze) {
e.setNewCurrent(e.getOldCurrent());
}
}
@EventHandler
public void onBlockDispense(BlockDispenseEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
if (e.getDestination().getLocation() != null && freeze) {
e.setCancelled(true);
} else if (e.getSource().getLocation() != null && freeze) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent e) {
if (Core.getVersion() < 19) return;
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
if (freeze) {
if (e.isCancelled()) return;
e.setCancelled(true);
e.getBlock().setType(Material.AIR, false);
}
}
/*
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
if (Core.getVersion() < 19) return;
if (!e.getItemInHand().getType().isBlock()) return;
if (freeze) {
e.setCancelled(true);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
e.getBlock().setType(e.getItemInHand().getType(), false);
}, 1L);
}
}
*/
@EventHandler
public void onFluidLevelChange(FluidLevelChangeEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockSpread(BlockSpreadEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockFromTo(BlockFromToEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockForm(BlockFormEvent e) {
if (freeze) {
e.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (freeze) {
Block block = e.getClickedBlock();
if (block.getType() == Material.LEVER) {
Switch data = ((Switch) block.getBlockData());
data.setPowered(!data.isPowered());
block.setBlockData(data, false);
}
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
if (freeze) {
event.setCancelled(true);
}
}
}
@@ -0,0 +1,40 @@
/*
* 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.teamserver.listener;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerChange implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().setOp(true);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
Bukkit.shutdown();
}
}
+8
View File
@@ -0,0 +1,8 @@
name: Teamserver
version: 1.0
main: de.steamwar.teamserver.Builder
api-version: 1.15
prefix: Teamserver
depend: [SpigotCore, WorldEdit]
authors: [ YoyoNow ]
description: Teamserver