forked from SteamWar/SteamWar
Add FightSystem module
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.10")
|
||||
compileOnly("de.steamwar:worldedit:1.12")
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import net.minecraft.server.v1_10_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||
if (!FightWorld.isPAPER()) {
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
}
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.12")
|
||||
compileOnly("de.steamwar:worldedit:1.12")
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import net.minecraft.server.v1_12_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||
if (!FightWorld.isPAPER()) {
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
}
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper12 implements WorldOfColorWrapper {
|
||||
@Override
|
||||
public void setTeamColor(Team team, ChatColor color) {
|
||||
team.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInBlock(Projectile e) {
|
||||
if(e instanceof Arrow)
|
||||
return ((Arrow) e).isInBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
|
||||
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
|
||||
player.sendTitle(title, subtitle, start, hold, stop);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class WorldeditWrapper12 extends WorldeditWrapper8 {
|
||||
|
||||
static {
|
||||
colorBlocks.add(new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE));
|
||||
colorBlocks.add(new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
||||
compileOnly(project(":FightSystem:FightSystem_9"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.14")
|
||||
compileOnly("de.steamwar:worldedit:1.15")
|
||||
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.6")
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||
|
||||
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
|
||||
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
||||
private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
|
||||
private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
|
||||
private static final Reflection.FieldAccessor<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
|
||||
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
|
||||
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
|
||||
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||
|
||||
private final Map trackers;
|
||||
public BlockIdWrapper14() {
|
||||
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
||||
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
return (int) getCombinedId.invoke(null, getNMS.invoke(block));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
||||
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
||||
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
||||
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
||||
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
||||
@Override
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
Object blockData = getByCombinedId.invoke(null, blockState);
|
||||
Object nworld = getWorldHandle.invoke(world);
|
||||
Object pos = newBlockPosition.invoke(x, y, z);
|
||||
|
||||
removeTileEntity.invoke(nworld, pos);
|
||||
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
||||
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
||||
}
|
||||
|
||||
private static final Class<?> entityTracker = Reflection.getClass("{nms.server.level}.PlayerChunkMap$EntityTracker");
|
||||
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
|
||||
@Override
|
||||
public void trackEntity(Player player, int entity) {
|
||||
Object tracker = trackers.get(entity);
|
||||
if(tracker != null)
|
||||
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
|
||||
@Override
|
||||
public void untrackEntity(Player player, int entity) {
|
||||
Object tracker = trackers.get(entity);
|
||||
if(tracker != null)
|
||||
clearPlayer.invoke(tracker, getPlayer.invoke(player));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
|
||||
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
||||
@Override
|
||||
public Material idToMaterial(int blockState) {
|
||||
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import net.minecraft.server.v1_14_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||
if (!FightWorld.isPAPER()) {
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
}
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
chunk.heightMap.clear();
|
||||
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Pose;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FlatteningWrapper14 implements FlatteningWrapper {
|
||||
@Override
|
||||
public DyeColor getSilver() {
|
||||
return DyeColor.LIGHT_GRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWater(Block block) {
|
||||
if(block.getType() == Material.WATER)
|
||||
return true;
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if(!(data instanceof Waterlogged))
|
||||
return false;
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWater(Block block) {
|
||||
Material type = block.getType();
|
||||
if(type == Material.WATER || type == Material.LAVA){
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if(!(data instanceof Waterlogged))
|
||||
return false;
|
||||
|
||||
Waterlogged waterlogged = (Waterlogged) data;
|
||||
if(waterlogged.isWaterlogged()){
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsBlockMeta(ItemMeta meta) {
|
||||
return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttributeModifier(ItemStack stack) {
|
||||
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doRecord(BlockPhysicsEvent e) {
|
||||
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceLoadChunk(World world, int cX, int cZ) {
|
||||
world.setChunkForceLoaded(cX, cZ, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPistonMoving(Block block) {
|
||||
return block.getType() == Material.MOVING_PISTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFacingWater(Block dispenser) {
|
||||
return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCrouching(Player player) {
|
||||
return player.getPose() == Pose.SWIMMING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockChange(Player player, Block block, Material type) {
|
||||
player.sendBlockChange(block.getLocation(), type.createBlockData());
|
||||
}
|
||||
}
|
||||
@@ -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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class SWSound14 implements SWSound.ISWSound {
|
||||
@Override
|
||||
public Sound getSound(SWSound sound) {
|
||||
switch(sound){
|
||||
case ENTITY_WITHER_DEATH:
|
||||
return Sound.ENTITY_WITHER_DEATH;
|
||||
case BLOCK_NOTE_BASS:
|
||||
return Sound.BLOCK_NOTE_BLOCK_BASS;
|
||||
case BLOCK_NOTE_PLING:
|
||||
return Sound.BLOCK_NOTE_BLOCK_PLING;
|
||||
case ENTITY_GENERIC_EXPLODE:
|
||||
return Sound.ENTITY_GENERIC_EXPLODE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class WorldeditWrapper14 implements WorldeditWrapper {
|
||||
|
||||
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
|
||||
|
||||
static {
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder");
|
||||
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
|
||||
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
||||
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
|
||||
colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock()));
|
||||
|
||||
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
||||
BlockVector3 pos = minimum.add(x, y, z);
|
||||
BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
|
||||
if(replacement != null)
|
||||
clipboard.setBlock(pos, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterDepth(Clipboard clipboard) {
|
||||
BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1);
|
||||
int depth = 0;
|
||||
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
|
||||
depth++;
|
||||
it = it.add(0, 1, 0);
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) {
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
|
||||
aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
|
||||
).toBlockPoint()).build());
|
||||
e.flushSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDimensions(Clipboard clipboard) {
|
||||
BlockVector3 dims = clipboard.getDimensions();
|
||||
return new Vector(dims.getX(), dims.getY(), dims.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard loadChar(String charName) throws IOException {
|
||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
||||
World w = new BukkitWorld(Config.world);
|
||||
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
|
||||
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||
|
||||
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
|
||||
);
|
||||
forwardExtentCopy.setCopyingEntities(false);
|
||||
Operations.complete(forwardExtentCopy);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
|
||||
writer.write(clipboard);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.15")
|
||||
compileOnly("de.steamwar:worldedit:1.15")
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import net.minecraft.server.v1_15_R1.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||
if (!FightWorld.isPAPER()) {
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
}
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
chunk.heightMap.clear();
|
||||
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:fastasyncworldedit:1.18")
|
||||
compileOnly("de.steamwar:spigot:1.18")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
compileOnly("com.mojang:datafixerupper:4.0.26")
|
||||
compileOnly("io.netty:netty-all:4.1.68.Final")
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.6")
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.ChunkSection;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
||||
|
||||
private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle");
|
||||
private static final Reflection.MethodInvoker getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
|
||||
private static final Reflection.MethodInvoker getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
|
||||
private ChunkSection[] getChunkSections(World world, int x, int z) {
|
||||
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
ChunkSection[] sections = getChunkSections(world, x, z);
|
||||
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getEntity = Reflection.getTypedMethod(Reflection.getClass("{obc}.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
|
||||
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
|
||||
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).ce();
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
|
||||
private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.SectionPosition;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class HullHiderWrapper18 implements HullHiderWrapper {
|
||||
|
||||
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
|
||||
@Override
|
||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||
List<Object> blockdata = new ArrayList<>(changes.size());
|
||||
|
||||
changes.removeIf(change -> {
|
||||
BlockData data = Config.world.getBlockData(change.getX(), change.getY(), change.getZ());
|
||||
boolean unchanged = data.getMaterial() == Config.ObfuscateWith || Config.HiddenBlocks.contains(data.getMaterial());
|
||||
if(!unchanged)
|
||||
blockdata.add(getState.invoke(data));
|
||||
return unchanged;
|
||||
});
|
||||
|
||||
if(changes.isEmpty())
|
||||
return null;
|
||||
|
||||
return generateBlockChangePacket(changes, blockdata.toArray());
|
||||
}
|
||||
|
||||
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
|
||||
if(changes.size() > 1) {
|
||||
Hull.IntVector section = changes.get(0);
|
||||
section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
|
||||
int xOffset = 16*section.getX();
|
||||
int yOffset = 16*section.getY();
|
||||
int zOffset = 16*section.getZ();
|
||||
|
||||
short[] pos = new short[changes.size()];
|
||||
for(int i = 0; i < changes.size(); i++) {
|
||||
Hull.IntVector change = changes.get(i);
|
||||
|
||||
pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset));
|
||||
}
|
||||
|
||||
return constructMultiBlockChange(section, pos, blockdata);
|
||||
} else {
|
||||
Hull.IntVector pos = changes.get(0);
|
||||
return new PacketPlayOutBlockChange(new BlockPosition(pos.getX(), pos.getY(), pos.getZ()), (IBlockData) blockdata[0]);
|
||||
}
|
||||
}
|
||||
|
||||
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
|
||||
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length), false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":FightSystem:FightSystem_18"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:worldedit:1.15")
|
||||
compileOnly("de.steamwar:spigot:1.19")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
|
||||
compileOnly("com.mojang:brigadier:1.0.18")
|
||||
compileOnly("com.mojang:datafixerupper:4.0.26")
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 {
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).ck();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":FightSystem:FightSystem_18"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.20")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.6")
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class CraftbukkitWrapper20 extends CraftbukkitWrapper18 {
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).cm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||
import net.minecraft.core.SectionPosition;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
|
||||
|
||||
public class HullHiderWrapper20 extends HullHiderWrapper18 {
|
||||
|
||||
@Override
|
||||
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
|
||||
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.8")
|
||||
compileOnly("de.steamwar:worldedit:1.12")
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockIdWrapper8 implements BlockIdWrapper {
|
||||
|
||||
private static final Class<?> entityTracker = Reflection.getClass("{nms}.EntityTracker");
|
||||
private static final Reflection.FieldAccessor<?> getEntityTracker = Reflection.getField(worldServer, entityTracker, 0);
|
||||
private static final Class<?> intHashMap = Reflection.getClass("{nms}.IntHashMap");
|
||||
private static final Reflection.FieldAccessor<?> getTrackedEntities = Reflection.getField(entityTracker, intHashMap, 0);
|
||||
|
||||
private final Object trackers;
|
||||
public BlockIdWrapper8() {
|
||||
trackers = getTrackedEntities.get(getEntityTracker.get(getWorldHandle.invoke(Config.world)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int blockToId(Block block) {
|
||||
return block.getTypeId() << 4 + block.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
|
||||
blockState = 0;
|
||||
|
||||
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
||||
}
|
||||
|
||||
private static final Class<?> entityTrackerEntry = Reflection.getClass("{nms}.EntityTrackerEntry");
|
||||
private static final Reflection.MethodInvoker get = Reflection.getTypedMethod(intHashMap, "get", Object.class, int.class);
|
||||
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer);
|
||||
@Override
|
||||
public void trackEntity(Player player, int entity) {
|
||||
Object tracker = get.invoke(trackers, entity);
|
||||
if(tracker != null)
|
||||
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
||||
}
|
||||
|
||||
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer);
|
||||
@Override
|
||||
public void untrackEntity(Player player, int entity) {
|
||||
Object tracker = get.invoke(trackers, entity);
|
||||
if(tracker != null)
|
||||
clearPlayer.invoke(tracker, getPlayer.invoke(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Material idToMaterial(int blockState) {
|
||||
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
|
||||
blockState = 0;
|
||||
|
||||
return Material.getMaterial(blockState >> 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class BountifulWrapper8 implements BountifulWrapper {
|
||||
|
||||
public BountifulWrapper8() {
|
||||
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
||||
dragon.setLocation(Config.ArenaRegion.centerX(), -100, Config.ArenaRegion.centerZ(), 0, 0);
|
||||
this.spawnDragonId = dragon.getId();
|
||||
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainHand(Object packet) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bowInHand(boolean mainHand, Player p) {
|
||||
return p.getInventory().getItemInHand().getType() == Material.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttackSpeed(Player player) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNametagVisibility(Team team) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newDenyArrowPickupListener() {
|
||||
return new Listener() {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newDenyHandSwapListener() {
|
||||
return new Listener() {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordHandItems(Player player) {
|
||||
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInHand()), "MAINHAND");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newHandSwapRecorder() {
|
||||
return new Listener() {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(World world, String particleName, double x, double y, double z) {
|
||||
world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1);
|
||||
}
|
||||
|
||||
private final Set<Player> seesDragon = new HashSet<>();
|
||||
private final PacketPlayOutSpawnEntityLiving spawnDragon;
|
||||
private final int spawnDragonId;
|
||||
@Override
|
||||
public void sendBar(Player player, FightTeam team, double progress, String text) {
|
||||
seesDragon.removeIf(p -> !p.isOnline());
|
||||
|
||||
if(!seesDragon.contains(player)) {
|
||||
((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon);
|
||||
seesDragon.add(player);
|
||||
}
|
||||
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(0, (byte) 0x20);
|
||||
watcher.a(2, text);
|
||||
watcher.a(3, (byte) 1);
|
||||
watcher.a(4, (byte) 1);
|
||||
watcher.a(6, (float)(progress * 200));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true));
|
||||
}
|
||||
}
|
||||
@@ -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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import net.minecraft.server.v1_8_R3.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true;
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class FlatteningWrapper8 implements FlatteningWrapper {
|
||||
@Override
|
||||
public DyeColor getSilver() {
|
||||
return DyeColor.SILVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWater(Block block) {
|
||||
Material type = block.getType();
|
||||
return type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWater(Block block) {
|
||||
if(isWater(block)){
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsBlockMeta(ItemMeta meta) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttributeModifier(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doRecord(BlockPhysicsEvent e) {
|
||||
return e.getChangedType() != e.getBlock().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceLoadChunk(World world, int cX, int cZ) {
|
||||
world.setKeepSpawnInMemory(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPistonMoving(Block block) {
|
||||
return block.getType() == Material.PISTON_MOVING_PIECE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFacingWater(Block dispenser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCrouching(Player player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void sendBlockChange(Player player, Block block, Material type) {
|
||||
player.sendBlockChange(block.getLocation(), type, (byte)0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HullHiderWrapper8 implements HullHiderWrapper {
|
||||
|
||||
private static final Reflection.ConstructorInvoker newMultiBlockChange = Reflection.getConstructor("{nms}.PacketPlayOutMultiBlockChange", int.class, short[].class, Reflection.getClass("{nms}.Chunk"));
|
||||
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
|
||||
@Override
|
||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||
changes.removeIf(change -> {
|
||||
Material material = Config.world.getBlockAt(change.getX(), change.getY(), change.getZ()).getType();
|
||||
return material == Config.ObfuscateWith || Config.HiddenBlocks.contains(material);
|
||||
});
|
||||
|
||||
if(changes.isEmpty())
|
||||
return null;
|
||||
|
||||
Hull.IntVector chunk = changes.get(0);
|
||||
chunk = new Hull.IntVector(chunk.getX() >> 4, chunk.getY() >> 4, chunk.getZ() >> 4);
|
||||
int xOffset = 16*chunk.getX();
|
||||
int zOffset = 16*chunk.getZ();
|
||||
short[] pos = new short[changes.size()];
|
||||
|
||||
for(int i = 0; i < changes.size(); i++) {
|
||||
Hull.IntVector change = changes.get(i);
|
||||
pos[i] = (short) (((change.getX()-xOffset) << 12) + ((change.getZ()-zOffset) << 8) + change.getY());
|
||||
}
|
||||
|
||||
return newMultiBlockChange.invoke(pos.length, pos, getHandle.invoke(Config.world.getChunkAt(chunk.getX(), chunk.getZ())));
|
||||
}
|
||||
}
|
||||
@@ -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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class SWSound8 implements SWSound.ISWSound {
|
||||
@Override
|
||||
public Sound getSound(SWSound sound) {
|
||||
switch(sound){
|
||||
case ENTITY_WITHER_DEATH:
|
||||
return Sound.WITHER_DEATH;
|
||||
case BLOCK_NOTE_BASS:
|
||||
return Sound.NOTE_BASS;
|
||||
case BLOCK_NOTE_PLING:
|
||||
return Sound.NOTE_PLING;
|
||||
case ENTITY_GENERIC_EXPLODE:
|
||||
return Sound.EXPLODE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper8 implements WorldOfColorWrapper {
|
||||
@Override
|
||||
public void setTeamColor(Team team, ChatColor color) {
|
||||
team.setPrefix("§" + color.getChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInBlock(Projectile e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
|
||||
location.getWorld().playSound(location, sound, volume, pitch);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
|
||||
player.sendTitle(title, subtitle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class WorldeditWrapper8 implements WorldeditWrapper {
|
||||
|
||||
protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
||||
protected static final Set<BaseBlock> colorBlocks = new HashSet<>();
|
||||
|
||||
static {
|
||||
colorBlocks.add(new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE));
|
||||
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE));
|
||||
colorBlocks.add(new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE));
|
||||
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE));
|
||||
colorBlocks.add(new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
|
||||
Vector minimum = clipboard.getRegion().getMinimumPoint();
|
||||
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
|
||||
colorBlocks.forEach(base -> replaceMap.put(base, new BaseBlock(base.getId(), c.getWoolData())));
|
||||
|
||||
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
||||
Vector pos = minimum.add(x, y, z);
|
||||
BaseBlock replacement = replaceMap.get(clipboard.getBlock(pos));
|
||||
if(replacement != null)
|
||||
clipboard.setBlock(pos, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterDepth(Clipboard clipboard) {
|
||||
Vector it = clipboard.getMinimumPoint().add(0, 0, 1);
|
||||
int depth = 0;
|
||||
while(!clipboard.getBlock(it).isAir()) {
|
||||
depth++;
|
||||
it = it.add(0, 1, 0);
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteClipboard(Clipboard clipboard, Location position, org.bukkit.util.Vector offset, AffineTransform aT) {
|
||||
World w = new BukkitWorld(position.getWorld());
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add(
|
||||
aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()))
|
||||
).toBlockPoint()).build());
|
||||
e.flushQueue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.util.Vector getDimensions(Clipboard clipboard) {
|
||||
Vector dims = clipboard.getDimensions();
|
||||
return new org.bukkit.util.Vector(dims.getBlockX(), dims.getBlockY(), dims.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard loadChar(String charName) throws IOException {
|
||||
return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Config.world).getWorldData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
||||
World w = new BukkitWorld(Config.world);
|
||||
Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
|
||||
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||
|
||||
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
|
||||
);
|
||||
Operations.complete(forwardExtentCopy);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
|
||||
writer.write(clipboard, w.getWorldData());
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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(":FightSystem:FightSystem_Core"))
|
||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly("de.steamwar:spigot:1.9")
|
||||
compileOnly("de.steamwar:worldedit:1.12")
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BountifulWrapper9 implements BountifulWrapper {
|
||||
|
||||
private static final Class<?> enumHand = Reflection.getClass("{nms.world}.EnumHand");
|
||||
private static final Object mainHand = enumHand.getEnumConstants()[0];
|
||||
private static final Reflection.FieldAccessor<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0);
|
||||
|
||||
@Override
|
||||
public boolean mainHand(Object packet) {
|
||||
return blockPlaceHand.get(packet) == mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bowInHand(boolean mainHand, Player p) {
|
||||
return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttackSpeed(Player player) {
|
||||
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
attribute.setBaseValue(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNametagVisibility(Team team) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newDenyArrowPickupListener() {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlayerPickupArrowEvent e){
|
||||
if(Fight.fighting(e.getPlayer()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newDenyHandSwapListener() {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
if(Fight.fighting(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordHandItems(Player player) {
|
||||
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
|
||||
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener newHandSwapRecorder() {
|
||||
return new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onItemSwap(PlayerSwapHandItemsEvent e){
|
||||
if(Recording.isNotSent(e.getPlayer()))
|
||||
return;
|
||||
|
||||
Player player = e.getPlayer();
|
||||
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND");
|
||||
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(World world, String particleName, double x, double y, double z) {
|
||||
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
|
||||
}
|
||||
|
||||
private final Map<Player, BossBar> barMap = new HashMap<>();
|
||||
@Override
|
||||
public void sendBar(Player player, FightTeam team, double progress, String text) {
|
||||
barMap.keySet().removeIf(p -> !p.isOnline());
|
||||
|
||||
if(!barMap.containsKey(player)) {
|
||||
BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID);
|
||||
barMap.put(player, bar);
|
||||
bar.addPlayer(player);
|
||||
}
|
||||
|
||||
BossBar bar = barMap.get(player);
|
||||
BarColor color = chat2bar(team.getColor());
|
||||
if(bar.getColor() != color)
|
||||
bar.setColor(color);
|
||||
|
||||
if(bar.getProgress() != progress)
|
||||
bar.setProgress(progress);
|
||||
|
||||
if(!bar.getTitle().equals(text))
|
||||
bar.setTitle(text);
|
||||
}
|
||||
|
||||
private BarColor chat2bar(ChatColor color) {
|
||||
switch(color) {
|
||||
case DARK_BLUE:
|
||||
case DARK_AQUA:
|
||||
case BLUE:
|
||||
case AQUA:
|
||||
return BarColor.BLUE;
|
||||
case GREEN:
|
||||
case DARK_GREEN:
|
||||
return BarColor.GREEN;
|
||||
case DARK_RED:
|
||||
case RED:
|
||||
return BarColor.RED;
|
||||
case DARK_PURPLE:
|
||||
return BarColor.PURPLE;
|
||||
case GOLD:
|
||||
case YELLOW:
|
||||
return BarColor.YELLOW;
|
||||
case LIGHT_PURPLE:
|
||||
return BarColor.PINK;
|
||||
case BLACK:
|
||||
case WHITE:
|
||||
case GRAY:
|
||||
case DARK_GRAY:
|
||||
default:
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import net.minecraft.server.v1_9_R2.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
||||
Chunk chunk = w.getChunkAt(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||
if (!FightWorld.isPAPER()) {
|
||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||
}
|
||||
chunk.tileEntities.clear();
|
||||
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
@@ -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.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class SWSound9 implements SWSound.ISWSound {
|
||||
@Override
|
||||
public Sound getSound(SWSound sound){
|
||||
switch(sound){
|
||||
case ENTITY_WITHER_DEATH:
|
||||
return Sound.ENTITY_WITHER_DEATH;
|
||||
case BLOCK_NOTE_BASS:
|
||||
return Sound.BLOCK_NOTE_BASS;
|
||||
case BLOCK_NOTE_PLING:
|
||||
return Sound.BLOCK_NOTE_PLING;
|
||||
case ENTITY_GENERIC_EXPLODE:
|
||||
return Sound.ENTITY_GENERIC_EXPLODE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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")
|
||||
}
|
||||
|
||||
group = "de.steamwar"
|
||||
version = ""
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
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("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.6")
|
||||
compileOnly("io.netty:netty-all:4.1.68.Final")
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
Server:
|
||||
# Base server folder
|
||||
Folder: ""
|
||||
# Server java archive
|
||||
ServerJar: ""
|
||||
# Available arenas
|
||||
Maps: []
|
||||
# Names to address the game mode in the chat interface
|
||||
ChatNames: []
|
||||
# If the game mode should be marked as a historic game mode
|
||||
Historic: false # defaults to false if missing
|
||||
# If ranked matches should be available for the game mode
|
||||
Ranked: false # defaults to false if missing
|
||||
|
||||
# The questions that have to be answered to accept the schematic
|
||||
CheckQuestions: [] # Disables check schem type if missing
|
||||
|
||||
# The available schematic ranks
|
||||
Ranks: [] # Disables ranks for this schematic type if missing
|
||||
|
||||
Times:
|
||||
# Time in seconds the server stops after starting if nobody joins
|
||||
NoPlayersOnlineDuration: 300 # defaults to 300 if missing
|
||||
# Time in seconds the team leaders have to choose their schematic
|
||||
PreSchemPasteDuration: 120 # defaults to 120 if missing
|
||||
# Time in seconds for preparing
|
||||
SetupDuration: 300 # defaults to 300 if missing
|
||||
# Time in seconds the final countdown is long
|
||||
PreFightDuration: 30 # defaults to 30 if missing
|
||||
# Time in seconds to spectate the arena after the fight
|
||||
SpectatorDuration: 30 # defaults to 30 if missing
|
||||
|
||||
Arena:
|
||||
# The amount of blocks the schematics should be pasted under the surface
|
||||
WaterDepth: 0 # defaults to 0 if missing
|
||||
# The outer border of the arena, measured in blocks around the schematic areas
|
||||
Schem2Border:
|
||||
x: 24 # defaults to 24 if missing
|
||||
z: 24 # defaults to 24 if missing
|
||||
# The offset the teams spawn relative to the center of their area
|
||||
SpawnOffset:
|
||||
x: 0 # defaults to 0 if missing
|
||||
y: 0 # defaults to Schematic.Size.y if missing
|
||||
z: 0 # defaults to 0 if missing
|
||||
# The size of the team areas are expanded around the schematics
|
||||
BorderFromSchematic: 12 # defaults to 12 if missing
|
||||
# If ground walkable, teams can walk below the lower arena border during setup
|
||||
GroundWalkable: true # defaults to true if missing
|
||||
# Disable snow and ice melting
|
||||
DisableSnowMelt: false # defaults to false if missing
|
||||
# Allow leaving the arena area as spectator
|
||||
Leaveable: false # defaults to false if missing
|
||||
# Allow missiles to fly to the enemy and not stop at the schem border.
|
||||
AllowMissiles: false # defaults to true if EnterStages are present otherwise 'false'
|
||||
|
||||
Schematic:
|
||||
# The size of the schematics
|
||||
Size:
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
# The schematic type that can be chosen in this arena
|
||||
Type: Normal # defaults to Normal if missing
|
||||
# The schematic types that are also allowed to be chosen in this arena
|
||||
SubTypes: [] # defaults to empty List
|
||||
# Shortcut of the schematic type
|
||||
Shortcut: "" # defaults to "" if missing
|
||||
# Spigot (1.8) material for GUIs
|
||||
Material: STONE_BUTTON # defaults to STONE_BUTTON if missing
|
||||
# Manual check of schematic necessary
|
||||
ManualCheck: true # defaults to true if missing
|
||||
# If the schematics should be rotated during pasting
|
||||
Rotate: true # defaults to true if missing
|
||||
# If the schematics should be pasted aligned to the borders instead of centered
|
||||
PasteAligned: false # defaults to false if missing
|
||||
# If only public schematics are allowed
|
||||
OnlyPublicSchematics: false # defaults to false if missing
|
||||
# If the public only force should be completely disabled
|
||||
IgnorePublicOnly: false # defaults to false if missing
|
||||
# If obsidian and bedrock should be replaced during PRE_RUNNING
|
||||
ReplaceObsidianBedrock: false # defaults to false if missing
|
||||
# If the replacement should happen with block updates
|
||||
ReplaceWithBlockupdates: false # defaults to false if missing
|
||||
# If the schematic perparation arena mode is time limited
|
||||
UnlimitedPrepare: false # defaults to false if missing
|
||||
# Maximal amount of blocks allowed in the schematic
|
||||
MaxBlocks: 0 # defaults to 0 (ignored) if missing
|
||||
# Maximal amount of items per dispenser
|
||||
MaxDispenserItems: 128 # defaults to 128 if missing
|
||||
# List of limited material (combinations)
|
||||
# List contains tags Amount (integer) and Materials (List of material names in Spigot 1.12 AND Spigot 1.15 format)
|
||||
Limited:
|
||||
- Materials: []
|
||||
Amount: 0
|
||||
|
||||
# The name of the game mode presented to the players
|
||||
GameName: WarGear # defaults to WarGear if missing
|
||||
# The prefix used for team chats
|
||||
TeamChatPrefix: + # defaults to + if missing
|
||||
Blue:
|
||||
Name: Blau # defaults to Blue if missing
|
||||
Prefix: '§3' # defaults to '§3' if missing
|
||||
Red:
|
||||
Name: Rot # defaults to Red if missing
|
||||
Prefix: '§c' # defaults to '§c' if missing
|
||||
|
||||
# The list of active win conditions
|
||||
WinConditions: # defaults to none if missing
|
||||
- TIMEOUT
|
||||
# - HEART_RATIO_TIMEOUT
|
||||
# - PERCENT_TIMEOUT
|
||||
|
||||
- ALL_DEAD
|
||||
# - CAPTAIN_DEAD
|
||||
|
||||
# - PERCENT_SYSTEM
|
||||
# - POINTS
|
||||
# - POINTS_AIRSHIP
|
||||
|
||||
# - WATER_TECH_KO
|
||||
# - TIME_TECH_KO
|
||||
# - PUMPKIN_TECH_KO
|
||||
|
||||
# - HELLS_BELLS
|
||||
# - METEOR
|
||||
# - PERSISTENT_DAMAGE
|
||||
# - TNT_DISTRIBUTION
|
||||
|
||||
WinConditionParams:
|
||||
# The time of any of the timeout win conditions in seconds
|
||||
TimeoutTime: 1200 # defaults to 1200 if missing
|
||||
# The percentage when any of the percent win conditions limits or triggers a win
|
||||
PercentWin: 7.0 # defaults to 7.0 if missing
|
||||
# Does the percentage still change after the start of the enter phase
|
||||
PercentEntern: true # defaults to true if missing
|
||||
# Is Blocks a whitelist (true) or blacklist (false)
|
||||
BlocksWhitelist: false # defaults to false if missing
|
||||
# Special Blocks (Valid spigot material values) used by the percent win conditions
|
||||
Blocks: [] # defaults to none if missing
|
||||
|
||||
Kits:
|
||||
# The kit file for this configuration
|
||||
File: kits.yml # defaults to kits.yml if missing
|
||||
# The default kit for team members
|
||||
MemberDefault: default # defaults to default if missing
|
||||
# The default kit for team leaders
|
||||
LeaderDefault: default # defaults to default if missing
|
||||
# If the personal kit system is active
|
||||
PersonalKits: false # defaults to false if missing
|
||||
# Items (Valid spigot material values) that are not allowed in the personal kit
|
||||
ForbiddenItems: [] # defaults to none if missing
|
||||
|
||||
# A list of integers containing the waiting time of this enter stage in the fight
|
||||
EnterStages: [] # defaults to no enter stages (empty list) if missing
|
||||
|
||||
Techhider:
|
||||
# The tech hider blocks/materials have to be valid lowercase minecraft material names
|
||||
# Activates the tech hider
|
||||
Active: false # defaults to false if missing
|
||||
# Which block the tech hider replaces to.
|
||||
ObfuscateWith: end_stone # defaults to end_stone if missing
|
||||
# A list of all hidden blocks. "water" results in the hiding of all waterlogged blocks as well.
|
||||
HiddenBlocks: [] # defaults to none if missing
|
||||
# The block entity contents that are hidden (here with minecraft:nametag)
|
||||
HiddenBlockEntites: [] # defaults to none if missing
|
||||
|
||||
# The following configuration must be in the world folder/config.yml
|
||||
#
|
||||
# # The lower arena border under which players get damage
|
||||
# UnderBorder: 0 # defaults to BlueCorner.y if missing
|
||||
# # The lowest corner in all axis of the blue team schematic area
|
||||
# BlueCorner:
|
||||
# x: 0
|
||||
# y: 0
|
||||
# z: 0
|
||||
# # The offset between the lowest corner of the blue area and the lowest corner of the red area
|
||||
# BlueToRed:
|
||||
# x: 0 # defaults to 0 if missing
|
||||
# y: 0 # defaults to 0 if missing
|
||||
# z: 0 # defaults to Schematic.Size.z + 50 if missing
|
||||
@@ -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.fightsystem;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum ArenaMode {
|
||||
NORMAL,
|
||||
EVENT,
|
||||
TEST,
|
||||
CHECK,
|
||||
PREPARE,
|
||||
REPLAY;
|
||||
|
||||
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
||||
|
||||
public static final Set<ArenaMode> Normal = Collections.unmodifiableSet(EnumSet.of(NORMAL));
|
||||
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
|
||||
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
|
||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||
|
||||
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||
public static final Set<ArenaMode> AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
|
||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY, CHECK)));
|
||||
public static final Set<ArenaMode> ManualTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
|
||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST));
|
||||
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
||||
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||
public static final Set<ArenaMode> SeriousFight = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY)));
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
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.fightsystem;
|
||||
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Config {
|
||||
|
||||
private Config(){}
|
||||
|
||||
public static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
//Fight sequence
|
||||
public static final int NoPlayerOnlineDuration;
|
||||
public static final int PreSchemPasteDuration;
|
||||
public static final int SetupDuration;
|
||||
public static final int PreFightDuration;
|
||||
public static final int SpectatorDuration;
|
||||
|
||||
// entern parameter
|
||||
public static final List<Integer> EnterStages;
|
||||
|
||||
//arena parameter
|
||||
public static final Region BluePasteRegion;
|
||||
public static final Region RedPasteRegion;
|
||||
public static final Region BlueExtendRegion;
|
||||
public static final Region RedExtendRegion;
|
||||
public static final Region ArenaRegion;
|
||||
public static final Region PlayerRegion;
|
||||
|
||||
public static final Location TeamBlueSpawn;
|
||||
public static final Location TeamRedSpawn;
|
||||
public static final Location SpecSpawn;
|
||||
|
||||
public static final int BlueToRedX;
|
||||
private static final int BlueToRedY;
|
||||
public static final int BlueToRedZ;
|
||||
|
||||
public static final int PreperationArea;
|
||||
public static final int WaterDepth;
|
||||
public static final boolean GroundWalkable;
|
||||
public static final boolean DisableSnowMelt;
|
||||
public static final boolean ArenaLeaveable;
|
||||
public static final boolean AllowMissiles;
|
||||
|
||||
//schematic parameter
|
||||
public static final boolean RanksEnabled;
|
||||
public static final boolean OnlyPublicSchematics;
|
||||
public static final boolean IgnorePublicOnly;
|
||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
||||
public static final List<de.steamwar.sql.SchematicType> SubTypes;
|
||||
public static final boolean RedRotate;
|
||||
public static final boolean BlueRotate;
|
||||
public static final boolean PasteAligned;
|
||||
public static final boolean ReplaceObsidianBedrock;
|
||||
public static final boolean ReplaceWithBlockupdates;
|
||||
public static final boolean UnlimitedPrepare;
|
||||
|
||||
//team parameter
|
||||
public static final String TeamRedName;
|
||||
public static final String TeamBlueName;
|
||||
public static final String TeamRedColor;
|
||||
public static final String TeamBlueColor;
|
||||
public static final String GameName;
|
||||
public static final String TeamChatDetection;
|
||||
public static final UUID BlueLeader;
|
||||
public static final UUID RedLeader;
|
||||
|
||||
//Active win conditions
|
||||
public static final Set<Winconditions> ActiveWinconditions;
|
||||
|
||||
//win condition parameters
|
||||
public static final int TimeoutTime;
|
||||
public static final double PercentWin;
|
||||
public static final boolean PercentEntern;
|
||||
public static final boolean PercentBlocksWhitelist;
|
||||
public static final Set<Material> PercentBlocks;
|
||||
|
||||
//default kits
|
||||
public static final String MemberDefault;
|
||||
public static final String LeaderDefault;
|
||||
public static final boolean PersonalKits;
|
||||
public static final Set<Material> ForbiddenItems;
|
||||
public static final String KitFile;
|
||||
|
||||
//tech hider parameter
|
||||
public static final boolean TechhiderActive;
|
||||
public static final Set<Material> HiddenBlocks;
|
||||
public static final Set<String> HiddenBlockEntities;
|
||||
public static final Material ObfuscateWith;
|
||||
|
||||
//event parameter
|
||||
public static final EventFight EventKampf;
|
||||
private static final Set<Integer> Referees;
|
||||
public static final int EventTeamBlueID;
|
||||
public static final int EventTeamRedID;
|
||||
public static final boolean BothTeamsPublic;
|
||||
public static final int MaximumTeamMembers;
|
||||
public static final boolean LiveReplay;
|
||||
|
||||
//check parameter
|
||||
public static final int CheckSchemID;
|
||||
public static final int PrepareSchemID;
|
||||
|
||||
public static final ArenaMode mode;
|
||||
|
||||
//replay system parameter
|
||||
public static final String spectateIP = "127.0.0.1";
|
||||
public static final int SpectatePort;
|
||||
public static final int ReplayID;
|
||||
|
||||
static{
|
||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||
|
||||
String configFile = System.getProperty("config", "config.yml");
|
||||
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
||||
FightSystem.getPlugin().saveDefaultConfig();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
|
||||
|
||||
File worldConfigFile = new File(world.getWorldFolder(), "config.yml");
|
||||
if(!worldConfigFile.exists()) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
||||
|
||||
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 300);
|
||||
PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120);
|
||||
SetupDuration = config.getInt("Times.SetupDuration", 300);
|
||||
PreFightDuration = config.getInt("Times.PreFightDuration", 30);
|
||||
SpectatorDuration = config.getInt("Times.SpectatorDuration", 30);
|
||||
|
||||
int blueCornerX = worldconfig.getInt("BlueCorner.x");
|
||||
int blueCornerY = worldconfig.getInt("BlueCorner.y");
|
||||
int blueCornerZ = worldconfig.getInt("BlueCorner.z");
|
||||
int underBorder = worldconfig.getInt("UnderBorder", blueCornerY);
|
||||
|
||||
WaterDepth = config.getInt("Arena.WaterDepth", 0);
|
||||
int schem2BorderX = config.getInt("Arena.Schem2Border.x", 24);
|
||||
int schem2BorderZ = config.getInt("Arena.Schem2Border.z", 24);
|
||||
PreperationArea = config.getInt("Arena.BorderFromSchematic", 12);
|
||||
GroundWalkable = config.getBoolean("Arena.GroundWalkable", true);
|
||||
DisableSnowMelt = config.getBoolean("Arena.DisableSnowMelt", false);
|
||||
ArenaLeaveable = config.getBoolean("Arena.Leaveable", false);
|
||||
|
||||
int schemsizeX = config.getInt("Schematic.Size.x");
|
||||
int schemsizeY = config.getInt("Schematic.Size.y");
|
||||
int schemsizeZ = config.getInt("Schematic.Size.z");
|
||||
RanksEnabled = !config.getStringList("Ranks").isEmpty();
|
||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
|
||||
SubTypes = config.getStringList("Schematic.SubTypes").stream().map(de.steamwar.sql.SchematicType::fromDB).collect(Collectors.toList());
|
||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
|
||||
boolean rotate = config.getBoolean("Schematic.Rotate", true);
|
||||
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
|
||||
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false);
|
||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
|
||||
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
|
||||
|
||||
GameName = config.getString("GameName", "WarGear");
|
||||
TeamChatDetection = config.getString("TeamChatPrefix", "+");
|
||||
|
||||
ActiveWinconditions = Collections.unmodifiableSet(config.getStringList("WinConditions").stream().map(Winconditions::valueOf).collect(Collectors.toSet()));
|
||||
|
||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime", 1200);
|
||||
PercentWin = config.getDouble("WinConditionParams.PercentWin", 7.0);
|
||||
PercentEntern = config.getBoolean("WinConditionParams.PercentEntern", true);
|
||||
PercentBlocksWhitelist = config.getBoolean("WinConditionParams.BlocksWhitelist", false);
|
||||
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||
|
||||
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
||||
AllowMissiles = config.getBoolean("Arena.AllowMissiles", !EnterStages.isEmpty());
|
||||
|
||||
KitFile = config.getString("Kits.File", "kits.yml");
|
||||
MemberDefault = config.getString("Kits.MemberDefault", "default");
|
||||
LeaderDefault = config.getString("Kits.LeaderDefault", "default");
|
||||
PersonalKits = config.getBoolean("Kits.PersonalKits", false);
|
||||
ForbiddenItems = Collections.unmodifiableSet(config.getStringList("Kits.ForbiddenItems").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||
|
||||
TechhiderActive = config.getBoolean("Techhider.Active", false);
|
||||
ObfuscateWith = Material.getMaterial(config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase());
|
||||
HiddenBlocks = config.getStringList("Techhider.HiddenBlocks").stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet());
|
||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||
|
||||
if(schemsizeX < 0){
|
||||
schemsizeX = -schemsizeX;
|
||||
blueCornerX = blueCornerX - schemsizeX;
|
||||
}
|
||||
if(schemsizeY < 0){
|
||||
schemsizeY = -schemsizeY;
|
||||
blueCornerY = blueCornerY - schemsizeY;
|
||||
}
|
||||
if(schemsizeZ < 0){
|
||||
schemsizeZ = -schemsizeZ;
|
||||
blueCornerZ = blueCornerZ - schemsizeZ;
|
||||
}
|
||||
|
||||
BlueToRedX = worldconfig.getInt("BlueToRed.x", 0);
|
||||
BlueToRedY = worldconfig.getInt("BlueToRed.y", 0);
|
||||
BlueToRedZ = worldconfig.getInt("BlueToRed.z", schemsizeZ + 50);
|
||||
double teamBlueSpawnOffsetX = config.getDouble("Arena.SpawnOffset.x", 0);
|
||||
double teamBlueSpawnOffsetY = config.getDouble("Arena.SpawnOffset.y", schemsizeY);
|
||||
double teamBlueSpawnOffsetZ = config.getDouble("Arena.SpawnOffset.z", 0);
|
||||
|
||||
int teamRedCornerX = BlueToRedX + blueCornerX;
|
||||
int teamRedCornerY = BlueToRedY + blueCornerY;
|
||||
int teamRedCornerZ = BlueToRedZ + blueCornerZ;
|
||||
|
||||
int teamBluePasteX = blueCornerX + schemsizeX / 2;
|
||||
int teamBluePasteZ = blueCornerZ + schemsizeZ / 2;
|
||||
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
||||
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
||||
|
||||
TeamBlueSpawn = new Location(world,
|
||||
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
||||
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
||||
|
||||
TeamRedSpawn = new Location(world,
|
||||
teamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
||||
teamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||
teamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
||||
|
||||
SpecSpawn = new Location(world,
|
||||
teamBluePasteX + BlueToRedX /2.0,
|
||||
blueCornerY + BlueToRedY /2.0 + schemsizeY/2.0,
|
||||
teamBluePasteZ + BlueToRedZ /2.0);
|
||||
|
||||
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
||||
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
|
||||
double yaw = Math.toDegrees(v1.clone().setY(0).angle(new Vector(0, 0, 1)));
|
||||
|
||||
TeamBlueSpawn.setYaw((float) yaw + 180);
|
||||
TeamBlueSpawn.setPitch((float) pitch);
|
||||
|
||||
TeamRedSpawn.setYaw((float) yaw);
|
||||
TeamRedSpawn.setPitch((float) pitch * -1);
|
||||
|
||||
|
||||
boolean teamRedRotate;
|
||||
boolean teamBlueRotate;
|
||||
int arenaMinX;
|
||||
int arenaMaxX;
|
||||
int arenaMinZ;
|
||||
int arenaMaxZ;
|
||||
if(BlueToRedX > 0){
|
||||
arenaMinX = blueCornerX - schem2BorderX;
|
||||
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
|
||||
teamRedRotate = true;
|
||||
teamBlueRotate = false;
|
||||
}else{
|
||||
arenaMinX = teamRedCornerX - schem2BorderX;
|
||||
arenaMaxX = blueCornerX + schemsizeX + schem2BorderX;
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = true;
|
||||
}
|
||||
if(BlueToRedZ > 0){
|
||||
arenaMinZ = blueCornerZ - schem2BorderZ;
|
||||
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
|
||||
teamRedRotate = true;
|
||||
teamBlueRotate = false;
|
||||
}else{
|
||||
arenaMinZ = teamRedCornerZ - schem2BorderZ;
|
||||
arenaMaxZ = blueCornerZ + schemsizeZ + schem2BorderZ;
|
||||
if(BlueToRedZ != 0){
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = true;
|
||||
}
|
||||
}
|
||||
if(!rotate){
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = false;
|
||||
}
|
||||
RedRotate = teamRedRotate;
|
||||
BlueRotate = teamBlueRotate;
|
||||
|
||||
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||
|
||||
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
||||
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
||||
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
||||
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
||||
|
||||
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(eventKampfID >= 1){
|
||||
EventKampf = EventFight.get(eventKampfID);
|
||||
if(EventKampf == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
|
||||
assert EventKampf != null;
|
||||
Team team1 = Team.get(EventKampf.getTeamBlue());
|
||||
Team team2 = Team.get(EventKampf.getTeamRed());
|
||||
|
||||
if(team1 == null || team2 == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
|
||||
assert team1 != null;
|
||||
assert team2 != null;
|
||||
TeamBlueName = team1.getTeamKuerzel();
|
||||
TeamRedName = team2.getTeamKuerzel();
|
||||
TeamBlueColor = "§" + team1.getTeamColor();
|
||||
TeamRedColor = "§" + team2.getTeamColor();
|
||||
EventTeamBlueID = team1.getTeamId();
|
||||
EventTeamRedID = team2.getTeamId();
|
||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||
SpectatePort = EventKampf.getSpectatePort();
|
||||
LiveReplay = SpectatePort != 0;
|
||||
Referees = Referee.get(Config.EventKampf.getEventID());
|
||||
|
||||
Event event = Event.get(EventKampf.getEventID());
|
||||
if(BothTeamsPublic) {
|
||||
OnlyPublicSchematics = true;
|
||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
}else{
|
||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||
}
|
||||
}else{
|
||||
//No event
|
||||
TeamRedColor = config.getString("Red.Prefix", "§c");
|
||||
TeamBlueColor = config.getString("Blue.Prefix", "§3");
|
||||
TeamRedName = config.getString("Red.Name", "Rot");
|
||||
TeamBlueName = config.getString("Blue.Name", "Blau");
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
||||
EventTeamBlueID = 0;
|
||||
EventTeamRedID = 0;
|
||||
EventKampf = null;
|
||||
BothTeamsPublic = true;
|
||||
Referees = Collections.emptySet();
|
||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
LiveReplay = false;
|
||||
SpectatePort = -ReplayID;
|
||||
}
|
||||
|
||||
String blueLeader = System.getProperty("blueLeader", null);
|
||||
String redLeader = System.getProperty("redLeader", null);
|
||||
if(blueLeader != null)
|
||||
BlueLeader = UUID.fromString(blueLeader);
|
||||
else
|
||||
BlueLeader = null;
|
||||
if(redLeader != null)
|
||||
RedLeader = UUID.fromString(redLeader);
|
||||
else
|
||||
RedLeader = null;
|
||||
|
||||
if(CheckSchemID != 0){
|
||||
mode = ArenaMode.CHECK;
|
||||
}else if(PrepareSchemID != 0){
|
||||
mode = ArenaMode.PREPARE;
|
||||
}else if(eventKampfID >= 1){
|
||||
mode = ArenaMode.EVENT;
|
||||
}else if(eventKampfID == -1){
|
||||
mode = ArenaMode.TEST;
|
||||
}else if(ReplayID != 0){
|
||||
mode = ArenaMode.REPLAY;
|
||||
}else{
|
||||
mode = ArenaMode.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean test(){
|
||||
return ArenaMode.Test.contains(mode);
|
||||
}
|
||||
public static boolean replayserver(){
|
||||
return ReplayID < 0;
|
||||
}
|
||||
public static boolean blueNegZ(){
|
||||
return BlueToRedZ > 0;
|
||||
}
|
||||
|
||||
public static boolean isReferee(Player player) {
|
||||
return Referees.contains(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
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.fightsystem;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.commands.*;
|
||||
import de.steamwar.fightsystem.countdown.*;
|
||||
import de.steamwar.fightsystem.event.HellsBells;
|
||||
import de.steamwar.fightsystem.event.Meteor;
|
||||
import de.steamwar.fightsystem.event.PersistentDamage;
|
||||
import de.steamwar.fightsystem.event.TNTDistributor;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.fight.HotbarKit;
|
||||
import de.steamwar.fightsystem.listener.Shutdown;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.record.FileRecorder;
|
||||
import de.steamwar.fightsystem.record.FileSource;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.record.LiveRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.winconditions.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static FightSystem plugin;
|
||||
|
||||
private Message message;
|
||||
private FightTeam lastWinner;
|
||||
private String lastWinreason;
|
||||
private TechHiderWrapper techHider;
|
||||
private HullHider hullHider;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if(Core.getInstance() == null) {
|
||||
Core.setInstance(this);
|
||||
TinyProtocol.init();
|
||||
}
|
||||
|
||||
message = new Message("de.steamwar.fightsystem.FightSystem", FightSystem.class.getClassLoader());
|
||||
|
||||
new EntityDamage();
|
||||
new WaterRemover();
|
||||
new Permanent();
|
||||
new PistonListener(ArenaMode.AntiTestCheckPrepare, e -> e.setCancelled(true));
|
||||
new PistonListener(ArenaMode.Test, e -> getMessage().broadcastActionbar("PISTON_PUSHED_OUTSIDE"));
|
||||
new PistonListener(ArenaMode.Prepare, e -> {
|
||||
getMessage().broadcast("PISTON_PUSHED_OUTSIDE");
|
||||
shutdown();
|
||||
});
|
||||
new Chat();
|
||||
new ArenaBorder();
|
||||
new IngameDeath();
|
||||
new InFightDamage();
|
||||
new InFightInventory();
|
||||
new DenyWorldInteraction();
|
||||
new DenyInventoryMovement();
|
||||
new EventJoin();
|
||||
new Recording();
|
||||
new Check();
|
||||
new Shutdown();
|
||||
new SetupQuit();
|
||||
new PrepareSchem();
|
||||
new TestJoin();
|
||||
new NormalJoin();
|
||||
new RunningWorldInteraction();
|
||||
new PersonalKitCreator();
|
||||
new ArrowStopper();
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
||||
new BlockFadeListener();
|
||||
new LeaveableArena();
|
||||
new ClickAnalyzer();
|
||||
new BlockPlaceCollision();
|
||||
new HotbarKit.HotbarKitListener();
|
||||
new JoinRequestListener();
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||
|
||||
new EnterHandler();
|
||||
techHider = new TechHiderWrapper();
|
||||
hullHider = new HullHider();
|
||||
new FightWorld();
|
||||
new FightUI();
|
||||
new FightStatistics();
|
||||
new BungeeFightInfo();
|
||||
|
||||
new WinconditionAllDead();
|
||||
new WinconditionCaptainDead();
|
||||
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
||||
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
|
||||
new WinconditionPercent(Winconditions.PERCENT_SYSTEM, "Percent");
|
||||
new WinconditionPoints();
|
||||
new WinconditionPointsAirShip();
|
||||
new WinconditionTimeout();
|
||||
new WinconditionTimeTechKO();
|
||||
new EventTeamOffWincondition();
|
||||
new WinconditionComparisonTimeout(Winconditions.HEART_RATIO_TIMEOUT, "HeartTimeout", "WIN_MORE_HEALTH", FightTeam::getHeartRatio);
|
||||
new WinconditionComparisonTimeout(Winconditions.PERCENT_TIMEOUT, "PercentTimeout", "WIN_LESS_DAMAGE", team -> -Wincondition.getPercentWincondition().getPercent(team));
|
||||
|
||||
new HellsBells();
|
||||
new Meteor();
|
||||
new PersistentDamage();
|
||||
new TNTDistributor();
|
||||
new WinconditionAmongUs();
|
||||
|
||||
new NoPlayersOnlineCountdown();
|
||||
new PreSchemCountdown();
|
||||
new PostSchemCountdown();
|
||||
new PreRunningCountdown();
|
||||
new SpectateOverCountdown();
|
||||
new EventSpectateCountdown();
|
||||
|
||||
new LeaveCommand();
|
||||
new KitCommand();
|
||||
new RemoveCommand();
|
||||
new RequestsCommand();
|
||||
new InfoCommand();
|
||||
new WGCommand();
|
||||
new TBCommand();
|
||||
new GamemodeCommand();
|
||||
new ReadyCommand();
|
||||
new AkCommand();
|
||||
new LeaderCommand();
|
||||
new LockschemCommand();
|
||||
new StateCommand();
|
||||
new SkipCommand();
|
||||
new TPSWarpCommand();
|
||||
new UnrankCommand();
|
||||
new WinCommand();
|
||||
|
||||
new LiveRecorder();
|
||||
new FileRecorder();
|
||||
|
||||
FileSource.startReplay();
|
||||
|
||||
if(Config.mode == ArenaMode.EVENT) {
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
}else if(Config.mode == ArenaMode.CHECK){
|
||||
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
|
||||
Fight.getBlueTeam().setSchem(checkSchematicNode);
|
||||
|
||||
if (checkSchematicNode.getName().endsWith("-prepared")) {
|
||||
SchematicNode unpreparedSchematicNode = SchematicNode.getSchematicNode(checkSchematicNode.getOwner(), checkSchematicNode.getName().substring(0, checkSchematicNode.getName().length() - 9), checkSchematicNode.getParent());
|
||||
if (unpreparedSchematicNode != null) {
|
||||
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
|
||||
}
|
||||
}
|
||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GlobalRecorder.getInstance().close();
|
||||
ClickAnalyzer.close();
|
||||
}
|
||||
|
||||
public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) {
|
||||
plugin.lastWinner = winFightTeam;
|
||||
plugin.lastWinreason = winreason;
|
||||
FightUI.printWin(winFightTeam, subtitle, params);
|
||||
|
||||
FightState.setFightState(FightState.SPECTATE);
|
||||
}
|
||||
|
||||
public static Message getMessage() {
|
||||
return plugin.message;
|
||||
}
|
||||
|
||||
public static FightTeam getLastWinner() {
|
||||
return plugin.lastWinner;
|
||||
}
|
||||
|
||||
public static String getLastWinreason() {
|
||||
return plugin.lastWinreason;
|
||||
}
|
||||
|
||||
public static TechHiderWrapper getTechHider() {
|
||||
return plugin.techHider;
|
||||
}
|
||||
|
||||
public static HullHider getHullHider() {
|
||||
return plugin.hullHider;
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
//Staggered kick to prevent lobby overloading
|
||||
if(Bukkit.getOnlinePlayers().isEmpty()){
|
||||
Bukkit.shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
|
||||
Bukkit.getScheduler().runTaskLater(plugin, FightSystem::shutdown, 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
PREFIX=§eArena§8»
|
||||
|
||||
# Commands
|
||||
NO_TEAM=§cYou are in no team
|
||||
FIGHT_ALREADY_STARTED=§cThe fight already started
|
||||
NOT_LEADER=§cYou aren't a leader
|
||||
PLAYER_UNAVAILABLE=§cThe player is not in an arena
|
||||
|
||||
NOT_IN_TEAM=§e{0} §cis not in your team
|
||||
|
||||
KIT_UNAVAILABLE=§cThis kit does not exist
|
||||
KIT_CHOSEN=§7Selected kit §e{0}
|
||||
|
||||
GAMEMODE_NOT_ALLOWED=§cChanging gamemode is not permitted
|
||||
GAMEMODE_UNKNOWN=§cUnknown gamemode {0}
|
||||
GAMEMODE_HELP=§8/§7gm §8[§egamemode§8]
|
||||
|
||||
LEADER_FULL=§cAll teams already have a leader
|
||||
ALREADY_IN_TEAM=§cYou are already in a team
|
||||
|
||||
LOCKSCHEM_HELP=§8/§7lockschem §8[§eteam§8]
|
||||
UNKNOWN_TEAM=§cThis team does not exist
|
||||
LOCKSCHEM_LOCKED=§7Schematic locked
|
||||
LOCKSCHEM_LOCKED_BY=§cThe schematic was locked by §e{0}
|
||||
|
||||
REMOVE_HELP=§8/§eremove §8[§eplayer§8]
|
||||
|
||||
NOT_FIGHTLEADER=§cYou are not the fight leader
|
||||
WIN_HELP=§8/§7win §8[§eteam §8or §etie§8]
|
||||
|
||||
INFO_RANKED=§7Ranked§8: §e{0}
|
||||
INFO_LEADER=§7Leader {0}§8: {1}
|
||||
INFO_SCHEMATIC=§7Schematic {0}§8: §e{1} §7from {2}, Rank: {3}
|
||||
|
||||
TPSWARP_HELP=§8/§7tpswarp §8[§eticks per second§8]
|
||||
TPSWARP_SET=§7TPS set to §e{0}
|
||||
|
||||
|
||||
# GUI
|
||||
STATE_TITLE=Fight state
|
||||
STATE_PRE_LEADER_SETUP=§7Team leader waiting phase
|
||||
STATE_PRE_SCHEM_SETUP=§7Schematic selection phase
|
||||
STATE_POST_SCHEM_SETUP=§7Preparation phase
|
||||
STATE_PRE_RUNNING=§eKit distribution
|
||||
STATE_RUNNING=§eFighting phase
|
||||
STATE_SPECTATE_WIN=§7Victory {0}
|
||||
STATE_SPECTATE_TIE=§7Draw
|
||||
|
||||
REMOVE_TITLE=Kick player
|
||||
|
||||
KIT_SELECTION_TITLE=Kit selection
|
||||
KIT_NO_KITS=§cNo kits found
|
||||
KIT_CREATE=§eNew kit
|
||||
KITNAME_TITLE=Input kit name
|
||||
KITNAME_IN_USE=§cThis kit name is already in use
|
||||
KIT_SEARCH=§eSearch
|
||||
KITSEARCH_TITLE=Search for kit
|
||||
|
||||
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
||||
SCHEM_TITLE={0} selection
|
||||
SCHEM_PUBLIC=§ePublic {0}
|
||||
SCHEM_UNCHECKED=§eUnchecked {0}
|
||||
SCHEM_PRIVATE=§ePrivate {0}
|
||||
SCHEM_NO_PRIVATE=§7No private {0} present
|
||||
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
|
||||
|
||||
|
||||
# Countdowns
|
||||
COUNTDOWN_MINUTES=§e{0} §7Minutes {1}
|
||||
COUNTDOWN_SECONDS=§e{0} §7Seconds {1}
|
||||
COUNTDOWN_SECOND=§eOne §7second {1}
|
||||
|
||||
ENTERN_COUNTDOWN=until boarding is allowed
|
||||
ENTERN_ALLOWED=§eBoarding §7is now allowed
|
||||
|
||||
SHUTDOWN_COUNTDOWN=until the server is stopped
|
||||
PRE_SCHEM_COUNTDOWN=until a public schematic is chosen
|
||||
POST_SCHEM_COUNTDOWN=until the kits are distributed
|
||||
PRE_RUNNING_COUNTDOWN=until the fight starts
|
||||
RUNNING_COUNTDOWN=until the fight ends
|
||||
SPECTATE_COUNTDOWN=until the arena is reset
|
||||
|
||||
|
||||
# Fight
|
||||
SCHEMATIC_UNLOADABLE=§cUnable to load schematic
|
||||
SCHEMATIC_CHOSEN=§7{0} §e{1} §7chosen
|
||||
SCHEMATIC_UNCHECKED=§7Team {0} §7has chosen an §eunchecked §7schematic§8!
|
||||
TEAM_READY=§aTeam ready
|
||||
TEAM_NOT_READY=§c§mTeam ready
|
||||
SKIP_READY=§aSkipping to next event
|
||||
SKIP_NOT_READY=§c§mSkipping to next event
|
||||
TEAM_CHAT={0}{1}§8» {0}{2}
|
||||
CHOOSE_KIT=§eChoose kit
|
||||
RESPAWN=§eRespawn
|
||||
REMOVE_PLAYERS=§cKick player
|
||||
CHOOSE_SCHEMATIC=§eChoose {0}
|
||||
SCHEMATIC_REQUIRED=§cChoose a schematic first
|
||||
|
||||
KIT_PREVIEW_EDIT=§7Edit kit
|
||||
KIT_PREVIEW_CHOOSE=§aSelect kit
|
||||
KIT_PREVIEW_BACK=§cBack
|
||||
KIT_PREVIEW_DELETE=§cDelete kit
|
||||
KIT_DELETION_CONFIRMATION=Are you sure you want to delete the kit?
|
||||
KIT_DELETION_ABORT=§cCancel
|
||||
KIT_DELETION_DELETE=§aDelete
|
||||
|
||||
|
||||
# Listener
|
||||
NO_ARENA_LEAVING=§cYou may not leave the arena
|
||||
CHECK_JOIN_DENIED=§cThere is a schematic in review on this server!
|
||||
CHECK_COMMAND_LOCKED=§cThis command is locked during review! Admin will be notified.
|
||||
NO_BLOCK_BREAK=§cYou are currently not allowed to break blocks here
|
||||
NO_BLOCK_PLACE=§cYou are currently not allowed to place blocks here
|
||||
NO_BOW_USAGE=§cYou can only use your bow after the fight has started
|
||||
NO_PARTICIPANT=§cYou are no fight participant
|
||||
NO_FRIENDLY_FIRE=§cNo friendly fire allowed
|
||||
NO_TNT_PLACE=§cYou are not allowed to place tnt
|
||||
NO_TELEPORT=§cYou are not allowed to use this teleport function
|
||||
OPEN_INVENTORY_TO_CUSTOMIZE=§eOpen inventory to customize your kit
|
||||
NO_ENTERN=§cYou may not board
|
||||
NO_TEAMAREA=§cYou are not allowed in the team area
|
||||
TEST_BECOME_LEADER=§7Become a team leader with §8/§eleader
|
||||
PREPARE_SCHEM_DELETED=§cApparently the schematic to be submitted was deleted. submission aborted.
|
||||
PREPARE_SCHEM_EXISTS=§cThere is already a schematic with the suffix -prepared, please rename or delete it, submission aborted.
|
||||
PREPARE_ACTIVE_PISTON=§cMoving pistons were found in the team area, submission aborted.
|
||||
PREPARE_FAILED_SAVING=§cThe schematic could not be saved, submission aborted.
|
||||
PREPARE_SENT_IN=§aA team member will review the schematic soon
|
||||
PARTICIPANT_CHAT={0} {1}§8» §7{2}
|
||||
FIGHTLEADER_CHAT=§e{0}§8» §e{1}
|
||||
SPECTATOR_CHAT=§7{0}§8» §7{1}
|
||||
PISTON_PUSHED_OUTSIDE=§cA piston pushed a block outside the allowed area!
|
||||
|
||||
|
||||
# Replay
|
||||
REPLAY_ENDS=§cReplay ended
|
||||
OLD_STRING={0}
|
||||
|
||||
|
||||
# States
|
||||
COMMAND_CURRENTLY_UNAVAILABLE=§cThis command is unavailable at this time of the fight
|
||||
|
||||
|
||||
# Utils
|
||||
TPS_WARNING=§c{0} §7TPS
|
||||
|
||||
UI_PRE_RUNNING=§7Kits distributed
|
||||
UI_RUNNING=§aFight started
|
||||
UI_SKIP=§7Skipping to next event
|
||||
UI_UNRANKED=§7Unranked match
|
||||
UI_PLAYER_JOINS=§a§l» {0}{1}
|
||||
UI_PLAYER_LEAVES=§c§l« {0}{1}
|
||||
UI_LEADER_JOINS=§a§l» {0}Leader {1}
|
||||
UI_PLAYER_DEATH={0}{1} §7died
|
||||
UI_PLAYER_LEAVE={0}{1} §7left the fight
|
||||
UI_WIN={0}Victory {1}
|
||||
UI_DRAW=§7Draw
|
||||
|
||||
BAR_PRE_LEADER=§7Waiting for team leader
|
||||
BAR_PRE_SCHEM={1} §7Schematic selection {0} {2}
|
||||
BAR_PREPARE={1} {3} §7Preparation {0} {4} {2}
|
||||
BAR_PRE_RUNNING={1} {3} §7Start of fight in {0} {4} {2}
|
||||
BAR_RUNNING0={1} {3} {0} {4} {2}
|
||||
BAR_RUNNING1={1} {3} {5} {0} {6} {4} {2}
|
||||
BAR_RUNNING2={1} {3} {5} {7} {0} {6} {8} {4} {2}
|
||||
BAR_RUNNING3={1} {3} {5} {7} {9} {0} {6} {8} {10} {4} {2}
|
||||
BAR_TIE={1} §7Draw {0} {2}
|
||||
BAR_WIN={1} §7Victory {3} {0} {2}
|
||||
BAR_POINTS={0} §8Points
|
||||
BAR_POINTS_OF={0}§8/§7{1} §8Points
|
||||
BAR_PERCENT={0}§8%
|
||||
BAR_CANNONS={0} §8Cannons
|
||||
BAR_WATER={0} §8Water
|
||||
|
||||
|
||||
# Winconditions
|
||||
HELLS_BELLS_COUNTDOWN=until the bombs start dropping
|
||||
HELLS_BELLS_START_1=§c!!Careful!! Bombers arriving in about a minute.
|
||||
HELLS_BELLS_START_2=§cBombers approaching, arrival in about a minute.
|
||||
HELLS_BELLS_START_3=§cBombers spotted on the radar, ETA: one minute.
|
||||
HELLS_BELLS_START_4=§cUnknown flying object spotted, arriving in about a minute.
|
||||
HELLS_BELLS_START_5=§cFlying object spotted. ETA: one minute.
|
||||
HELLS_BELLS_START_6=§cWild bombers appeared, arrival in about a minute.
|
||||
HELLS_BELLS_SWAP_1=§aThe bombs are starting to fall more quickly.
|
||||
HELLS_BELLS_SWAP_2=§aMore bombers arriving.
|
||||
HELLS_BELLS_SWAP_3=§aAdditional bombers sighted.
|
||||
HELLS_BELLS_SWAP_4=§aThe bombardement is increasing.
|
||||
|
||||
METEOR_COUNTDOWN=until meteors start falling
|
||||
METEOR_START_1=§cA meteor shower was detected
|
||||
METEOR_START_2=§cShooting starts are 100% more likely to appear during this fight
|
||||
METEOR_START_3=§cMeteors sighted, seek shelter immediately!
|
||||
METEOR_START_4=§cThe end is near! The meteors will hit us in about a minute.
|
||||
METEOR_START_5=§fNEWS §cThere will be multiple meteor showers this afternoon!
|
||||
METEOR_START_6=§cAirships still flying are doomed to crash.
|
||||
METEOR_SWAP_1=§aIt doesn't stop, the meteors appear to be increasing.
|
||||
METEOR_SWAP_2=§aThis was only the beginning, the meteors are arriving faster and more powerful.
|
||||
METEOR_SWAP_3=§aIt seems like it won't stop, the meteors are starting to arrive more quickly!
|
||||
METEOR_SWAP_4=§aAnother shower has been detected, get to safety!
|
||||
|
||||
TECHKO_COUNTDOWN=must have fired a shot by {0}
|
||||
|
||||
WIN_FIGHTLEADER=§7Referee decision
|
||||
WIN_PERCENT={0} §7is too badly damaged
|
||||
WIN_OFFLINE_BOTH=§7Both teams offline
|
||||
WIN_OFFLINE={0} §7offline
|
||||
WIN_ALL_DEAD={0}All players neutralised
|
||||
WIN_LEADER_DEAD={0} neutralised
|
||||
WIN_TIME_OVER=§7Time is up!
|
||||
WIN_MORE_HEALTH={0} with more remaining health
|
||||
WIN_LESS_DAMAGE={0} §7less damaged
|
||||
WIN_POINTS={0} has more points
|
||||
WIN_POINTS_EQUAL=§7Equal points
|
||||
WIN_TECHKO={0} §7is tech K.O.
|
||||
WIN_IMPOSTER_DEAD={0} §7killed the imposter
|
||||
WIN_CREWMATE_DEAD={0} §7killed all team mates
|
||||
|
||||
AMONG_US_IMPOSTER_MESSAGE = §4You are the Imposter§8! §7Kill all your team mates to win the game!
|
||||
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill him to win the game!
|
||||
|
||||
|
||||
# Invites
|
||||
JOIN_REQUEST=§7Request join
|
||||
JOIN_REQUEST_TITLE=Request join
|
||||
JOIN_REQUEST_ALREADY=§cYou have already sent a join request
|
||||
JOIN_REQUEST_TEAM=§7Join {0}
|
||||
JOIN_REQUEST_CONFIRMATION=§7Join request submitted
|
||||
JOIN_REQUEST_NOTIFICATION=§e{0} §7requests joining team {1}§8. §7Accept or decline using §8/§erequests
|
||||
|
||||
REQUESTS=§7Open join requests
|
||||
REQUESTS_TITLE=Open join requests
|
||||
REQUEST_DECLINED=§cJoin of {0} declined
|
||||
REQUEST_YOUR_DECLINED=§cYour join request was declined
|
||||
REQUESTS_LEFT_CLICK=§eLeft click §7to §eaccept§8!
|
||||
REQUESTS_RIGHT_CLICK=§eRight click §7to §edecline§8!
|
||||
|
||||
NO_JOIN_REQUEST=§cThe player did not request joining
|
||||
NO_CONFIRMATION=§cNo confirmation necessary
|
||||
@@ -0,0 +1,236 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
# Commands
|
||||
NO_TEAM=§cDu bist in keinem Team
|
||||
FIGHT_ALREADY_STARTED=§cDer Kampf hat bereits begonnen
|
||||
NOT_LEADER=§cDu bist kein Leader
|
||||
PLAYER_UNAVAILABLE=§cDer Spieler ist nicht in der Arena
|
||||
|
||||
NOT_IN_TEAM=§e{0} §cist nicht in deinem Team
|
||||
|
||||
KIT_UNAVAILABLE=§cDieses Kit gibt es nicht
|
||||
KIT_CHOSEN=§7Kit §e{0} §7gew§hlt
|
||||
|
||||
GAMEMODE_NOT_ALLOWED=§cSpielmodusänderung verboten
|
||||
GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus {0}
|
||||
GAMEMODE_HELP=§8/§7gm §8[§eSpielmodus§8]
|
||||
|
||||
LEADER_FULL=§cAlle Teams haben bereits einen Leader
|
||||
ALREADY_IN_TEAM=§cDu bist bereits in einem Team
|
||||
|
||||
LOCKSCHEM_HELP=§8/§7lockschem §8[§eTeam§8]
|
||||
UNKNOWN_TEAM=§cDieses Team existiert nicht
|
||||
LOCKSCHEM_LOCKED=§7Schematic gesperrt
|
||||
LOCKSCHEM_LOCKED_BY=§cDie Schematic wurde von §e{0} §cgesperrt
|
||||
|
||||
REMOVE_HELP=§8/§eremove §8[§eSpieler§8]
|
||||
|
||||
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
|
||||
WIN_HELP=§8/§7win §8[§eTeam §8oder §etie§8]
|
||||
|
||||
TPSWARP_HELP=§8/§7tpswarp §8[§eTicks pro Sekunde§8]
|
||||
TPSWARP_SET=§7TPS auf §e{0} §7gesetzt
|
||||
|
||||
|
||||
# GUI
|
||||
STATE_TITLE=Kampfstatus
|
||||
STATE_PRE_LEADER_SETUP=§7Teamleaderwartephase
|
||||
STATE_PRE_SCHEM_SETUP=§7Schemauswahlphase
|
||||
STATE_POST_SCHEM_SETUP=§7Vorbereitungsphase
|
||||
STATE_PRE_RUNNING=§eKitausgabe
|
||||
STATE_RUNNING=§eKampfphase
|
||||
STATE_SPECTATE_WIN=§7Sieg {0}
|
||||
STATE_SPECTATE_TIE=§7Unentschieden
|
||||
|
||||
REMOVE_TITLE=Spieler rauswerfen
|
||||
|
||||
KIT_SELECTION_TITLE=Kitauswahl
|
||||
KIT_NO_KITS=§cKeine Kits gefunden
|
||||
KIT_CREATE=§eNeues Kit
|
||||
KITNAME_TITLE=Kitname eingeben
|
||||
KITNAME_IN_USE=§cDieser Kitname wird bereits genutzt
|
||||
KIT_SEARCH=§eSuchen
|
||||
KITSEARCH_TITLE=Nach Kit suchen
|
||||
|
||||
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
||||
SCHEM_TITLE={0}-Auswahl
|
||||
SCHEM_PUBLIC=§eÖffentliches {0}
|
||||
SCHEM_UNCHECKED=§eUngeprüftes {0}
|
||||
SCHEM_PRIVATE=§ePrivates {0}
|
||||
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
|
||||
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
|
||||
|
||||
|
||||
# Countdowns
|
||||
COUNTDOWN_MINUTES=§e{0} §7Minuten {1}
|
||||
COUNTDOWN_SECONDS=§e{0} §7Sekunden {1}
|
||||
COUNTDOWN_SECOND=§eEine §7Sekunde {1}
|
||||
|
||||
ENTERN_COUNTDOWN=bis Entern erlaubt ist
|
||||
ENTERN_ALLOWED=§eEntern §7ist nun erlaubt
|
||||
|
||||
SHUTDOWN_COUNTDOWN=bis der Server gestoppt wird
|
||||
PRE_SCHEM_COUNTDOWN=bis eine Public-Schematic gewählt wird
|
||||
POST_SCHEM_COUNTDOWN=bis die Kits verteilt werden
|
||||
PRE_RUNNING_COUNTDOWN=bis die Arena freigegeben ist
|
||||
RUNNING_COUNTDOWN=bis der Kampf vorbei ist
|
||||
SPECTATE_COUNTDOWN=bis die Arena zurückgesetzt wird
|
||||
|
||||
|
||||
# Fight
|
||||
SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden
|
||||
SCHEMATIC_CHOSEN=§7{0} §e{1} §7gewählt
|
||||
SCHEMATIC_UNCHECKED=§7Team {0} §7hat eine §eungeprüfte §7Schematic gewählt§8!
|
||||
TEAM_READY=§aTeam bereit
|
||||
TEAM_NOT_READY=§c§mTeam bereit
|
||||
SKIP_READY=§aBeschleunigung zum nächsten Event
|
||||
SKIP_NOT_READY=§c§mBeschleunigung zum nächsten Event
|
||||
CHOOSE_KIT=§eKit wählen
|
||||
RESPAWN=§eRespawn
|
||||
REMOVE_PLAYERS=§cSpieler rauswerfen
|
||||
CHOOSE_SCHEMATIC=§e{0} wählen
|
||||
SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein
|
||||
|
||||
KIT_PREVIEW_EDIT=§7Kit bearbeiten
|
||||
KIT_PREVIEW_CHOOSE=§aKit wählen
|
||||
KIT_PREVIEW_BACK=§cZurück
|
||||
KIT_PREVIEW_DELETE=§cKit löschen
|
||||
KIT_DELETION_CONFIRMATION=Kit wirklich löschen?
|
||||
KIT_DELETION_ABORT=§cAbbrechen
|
||||
KIT_DELETION_DELETE=§aLöschen
|
||||
|
||||
|
||||
# Listener
|
||||
NO_ARENA_LEAVING=§cDu darfst die Arena nicht verlassen
|
||||
CHECK_JOIN_DENIED=§cAuf diesem Server wird momentan eine Schematic geprüft!
|
||||
CHECK_COMMAND_LOCKED=§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt.
|
||||
NO_BLOCK_BREAK=§cDu darfst hier derzeit keine Blöcke abbauen
|
||||
NO_BLOCK_PLACE=§cDu darfst hier derzeit keine Blöcke setzen
|
||||
NO_BOW_USAGE=§cDu darfst den Bogen erst nach Kampfbeginn nutzen
|
||||
NO_PARTICIPANT=§cDu bist kein Kampfteilnehmer
|
||||
NO_FRIENDLY_FIRE=§cDu darfst deinen Teamkollegen keinen Schaden zufügen
|
||||
NO_TNT_PLACE=§cDu darfst kein TNT setzen
|
||||
NO_TELEPORT=§cDu darfst diese Teleportfunktion nicht benutzen
|
||||
OPEN_INVENTORY_TO_CUSTOMIZE=§eInventar zum Anpassen des Kits öffnen
|
||||
NO_ENTERN=§cDu darfst nicht entern
|
||||
NO_TEAMAREA=§cDu darfst nicht zu den Teams
|
||||
TEST_BECOME_LEADER=§7Werde zum Teamleader mit §8/§eleader
|
||||
PREPARE_SCHEM_DELETED=§cAnscheinend wurde die auszufahrende Schematic gelöscht, Einsenden wird abgebrochen.
|
||||
PREPARE_SCHEM_EXISTS=§cEs existiert bereits eine Schem mit Namenszusatz -prepared, diese bitte umbenennen oder löschen, Einsenden wird abgebrochen.
|
||||
PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen.
|
||||
PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen.
|
||||
PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft
|
||||
PISTON_PUSHED_OUTSIDE=§cEin Kolben hat einen Block aus dem erlaubten Bereich geschoben!
|
||||
|
||||
|
||||
# Replay
|
||||
REPLAY_ENDS=§cReplay beendet
|
||||
|
||||
|
||||
# States
|
||||
COMMAND_CURRENTLY_UNAVAILABLE=§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar
|
||||
|
||||
|
||||
# Utils
|
||||
UI_PRE_RUNNING=§7Kits verteilt
|
||||
UI_RUNNING=§aArena freigegeben
|
||||
UI_SKIP=§7Sprung zum nächsten Ereignis
|
||||
UI_UNRANKED=§7Ungewerteter Kampf
|
||||
UI_LEADER_JOINS=§a§l» {0}Leader {1}
|
||||
UI_PLAYER_DEATH={0}{1} §7ist gestorben
|
||||
UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen
|
||||
UI_WIN={0}Sieg {1}
|
||||
UI_DRAW=§7Unentschieden
|
||||
|
||||
BAR_PRE_LEADER=§7Warten auf Teamleader
|
||||
BAR_PRE_SCHEM={1} §7Schemauswahl {0} {2}
|
||||
BAR_PREPARE={1} {3} §7Vorbereitung {0} {4} {2}
|
||||
BAR_PRE_RUNNING={1} {3} §7Kampfbeginn in {0} {4} {2}
|
||||
BAR_TIE={1} §7Unentschieden {0} {2}
|
||||
BAR_WIN={1} §7Sieg {3} {0} {2}
|
||||
BAR_POINTS={0} §8Punkte
|
||||
BAR_POINTS_OF={0}§8/§7{1} §8Punkte
|
||||
BAR_PERCENT={0}§8%
|
||||
BAR_CANNONS={0} §8Kanonen
|
||||
BAR_WATER={0} §8Wasser
|
||||
|
||||
|
||||
# Winconditions
|
||||
HELLS_BELLS_COUNTDOWN=bis die Bomben fallen
|
||||
HELLS_BELLS_START_1=§c!!Achtung!! Bomber im Anflug, noch ca. eine Minute bis zur Ankunft.
|
||||
HELLS_BELLS_START_2=§cBomber im Anflug, ca. eine Minute bis zur Ankunft.
|
||||
HELLS_BELLS_START_3=§cBomber auf dem Radar gesichtet, geschätzte Ankunftszeit: eine Minute.
|
||||
HELLS_BELLS_START_4=§cUnbekanntes Flugobjekt gesichtet, trifft in ca. einer Minute ein.
|
||||
HELLS_BELLS_START_5=§cFlugobjekt gesichtet. Ankunft in ca. einer Minute.
|
||||
HELLS_BELLS_START_6=§cBomber erschienen, Ankunft ca. eine Minute.
|
||||
HELLS_BELLS_SWAP_1=§aDie Bomben fallen nun schneller.
|
||||
HELLS_BELLS_SWAP_2=§aMehr Bomber im Anflug.
|
||||
HELLS_BELLS_SWAP_3=§aZusätzliche Bomber gesichtet.
|
||||
HELLS_BELLS_SWAP_4=§aDas Bombardement scheint sich zu erhöhen.
|
||||
|
||||
METEOR_COUNTDOWN=bis es Meteore regnet
|
||||
METEOR_START_1=§cEin Meteorschauer wurden am Himmel entdeckt
|
||||
METEOR_START_2=§cSternschnuppen sind diesen Fight 100% wahrscheinlicher
|
||||
METEOR_START_3=§cEs wurden Meteoriten am Himmel entdeckt, begeben sie sich umgehend in Sicherheit!
|
||||
METEOR_START_4=§cDer Untergang steht nahe! Die Meteoriten werden uns in etwa einer Minute treffen.
|
||||
METEOR_START_5=§fNEWS §cHeute Nachmittag wird es größere Meteoriten Schauer geben!
|
||||
METEOR_START_6=§cNoch fliegende Airships sind dem Absturz geweiht.
|
||||
METEOR_SWAP_1=§aEs hört nicht auf, die Meteoriten scheinen mehr zu werden.
|
||||
METEOR_SWAP_2=§aDas war erst der Anfang, die Meteoriten kommen immer schneller und machen mehr Schaden.
|
||||
METEOR_SWAP_3=§aEs scheint als würde es nicht aufhören, die Meteoriten kommen nur schneller!
|
||||
METEOR_SWAP_4=§aEin weiterer Schauer ist entdeckt worden, begebt euch in Sicherheit!
|
||||
|
||||
TECHKO_COUNTDOWN=bis {0} §7einen Schuss abgegeben haben muss
|
||||
|
||||
WIN_FIGHTLEADER=§7Kampfleiterentscheidung
|
||||
WIN_PERCENT={0} §7zu beschädigt
|
||||
WIN_OFFLINE_BOTH=§7Beide Teams offline
|
||||
WIN_OFFLINE={0} §7offline
|
||||
WIN_ALL_DEAD={0}Alle Spieler kampfunfähig
|
||||
WIN_LEADER_DEAD={0} kampfunfähig
|
||||
WIN_TIME_OVER=§7Zeit abgelaufen
|
||||
WIN_MORE_HEALTH={0} mit mehr verbleibenden Leben
|
||||
WIN_LESS_DAMAGE={0} §7weniger beschädigt
|
||||
WIN_POINTS={0} hat mehr Punkte
|
||||
WIN_POINTS_EQUAL=§7Gleicher Punktestand
|
||||
WIN_TECHKO={0} §7ist Tech K.O.
|
||||
WIN_IMPOSTER_DEAD={0} §7 hat den Imposter getötet
|
||||
WIN_CREWMATE_DEAD={0} §7 hat alle Kameraden getötet
|
||||
|
||||
AMONG_US_IMPOSTER_MESSAGE = §4Du bist ein Imposter§8! §7Du musst alle Kameraden töten, um zu gewinnen.
|
||||
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4Es ist ein Imposter unter uns§8! §7Tötet ihn, um das Spiel zu gewinnen!
|
||||
|
||||
# Invites
|
||||
JOIN_REQUEST=§7Teambeitritt anfragen
|
||||
JOIN_REQUEST_TITLE=Teambeitritt anfragen
|
||||
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
|
||||
JOIN_REQUEST_TEAM={0} §7beitreten
|
||||
JOIN_REQUEST_CONFIRMATION=§7Teambeitritt angefragt
|
||||
JOIN_REQUEST_NOTIFICATION=§e{0} §7möchte Team {1} §7beitreten§8. §7Akzeptiere oder lehne ab mit §8/§erequests
|
||||
|
||||
REQUESTS=§7Offene Beitrittsanfragen
|
||||
REQUESTS_TITLE=Offene Beitrittsanfragen
|
||||
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
|
||||
REQUEST_YOUR_DECLINED=§cDeine Betrittsanfrage wurde abgelehnt
|
||||
REQUESTS_LEFT_CLICK=§eLinksklick §7um §eanzunehmen§8!
|
||||
REQUESTS_RIGHT_CLICK=§eRechtsklick §7um §eabzulehnen§8!
|
||||
|
||||
NO_JOIN_REQUEST=§cDer Spieler hat noch keinen Beitritt angefragt
|
||||
NO_CONFIRMATION=§cKeine Zustimmung nötig
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* 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.fightsystem.ai;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Chat;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Lectern;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Openable;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class AI {
|
||||
|
||||
private static final Map<UUID, AI> ais = new HashMap<>();
|
||||
|
||||
static {
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
|
||||
ais.values().forEach(AI::stop);
|
||||
ais.clear();
|
||||
});
|
||||
}
|
||||
|
||||
public static AI getAI(UUID uuid) {
|
||||
return ais.get(uuid);
|
||||
}
|
||||
|
||||
private final FightTeam team;
|
||||
private final LivingEntity entity;
|
||||
private final BukkitTask task;
|
||||
private final Queue<Action> queue = new ArrayDeque<>();
|
||||
|
||||
protected AI(FightTeam team, SteamwarUser user) {
|
||||
this.team = team;
|
||||
|
||||
entity = (LivingEntity) Config.world.spawnEntity(Config.SpecSpawn, EntityType.VILLAGER);
|
||||
entity.setCustomName(user.getUserName());
|
||||
((Villager)entity).setAware(false);
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
ais.put(entity.getUniqueId(), this);
|
||||
team.addMember(entity, user);
|
||||
}
|
||||
|
||||
public abstract SchematicNode chooseSchematic();
|
||||
|
||||
public boolean acceptJoinRequest(Player player, FightTeam team) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void plan();
|
||||
|
||||
public void stop() {
|
||||
if(!entity.isDead())
|
||||
entity.remove();
|
||||
|
||||
if(!task.isCancelled())
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
public LivingEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected void setReady() {
|
||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
return;
|
||||
|
||||
if(team.getLeader().getEntity() != entity)
|
||||
return;
|
||||
|
||||
team.setReady(true);
|
||||
}
|
||||
|
||||
protected void chat(String message) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
|
||||
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
||||
}
|
||||
|
||||
protected Vector getPosition() {
|
||||
Location location = entity.getLocation();
|
||||
Region extend = team.getExtendRegion();
|
||||
if(Fight.getUnrotated() == team)
|
||||
return new Vector(
|
||||
location.getX() - extend.getMinX(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
location.getZ() - extend.getMinZ()
|
||||
);
|
||||
else
|
||||
return new Vector(
|
||||
extend.getMaxX() - location.getX(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
extend.getMaxZ() - location.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
protected Material getBlock(Vector pos) {
|
||||
queue.add(new Action(1));
|
||||
return translate(pos, true).getBlock().getType();
|
||||
}
|
||||
|
||||
protected boolean isPowered(Vector pos) {
|
||||
queue.add(new Action(1));
|
||||
return translate(pos, true).getBlock().isBlockPowered();
|
||||
}
|
||||
|
||||
protected void setTNT(Vector pos) {
|
||||
queue.add(new Action(1) {
|
||||
@Override
|
||||
public void run() {
|
||||
if(FightState.getFightState() != FightState.RUNNING)
|
||||
return;
|
||||
|
||||
Location location = translate(pos, true);
|
||||
if(interactionDistanceViolation(location))
|
||||
return;
|
||||
|
||||
Block block = location.getBlock();
|
||||
if(block.getType() == Material.AIR)
|
||||
block.setType(Material.TNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void interact(Vector pos) {
|
||||
queue.add(new Action(1) {
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = translate(pos, true);
|
||||
if(interactionDistanceViolation(location))
|
||||
return;
|
||||
|
||||
interact(location.getBlock());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void interact(Vector pos, int n) {
|
||||
queue.add(new Action(1) {
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = translate(pos, true);
|
||||
if (interactionDistanceViolation(location))
|
||||
return;
|
||||
Block block = location.getBlock();
|
||||
BlockData data = block.getBlockData();
|
||||
if (data instanceof Repeater) {
|
||||
Repeater repeater = (Repeater) data;
|
||||
repeater.setDelay(n);
|
||||
} else if (data instanceof Lectern) {
|
||||
Lectern lectern = (Lectern) data;
|
||||
lectern.setPage(n);
|
||||
}
|
||||
block.setBlockData(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void move(Vector pos) {
|
||||
queue.add(new Action(2) {
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = entity.getLocation();
|
||||
Location target = translate(pos, false);
|
||||
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
|
||||
return;
|
||||
|
||||
entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean interactionDistanceViolation(Location location) {
|
||||
return location.distance(entity.getEyeLocation()) > 5;
|
||||
}
|
||||
|
||||
private void interact(Block block) {
|
||||
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
|
||||
if (data instanceof NoteBlock) {
|
||||
NoteBlock noteBlock = (NoteBlock) data;
|
||||
Note note = noteBlock.getNote();
|
||||
noteBlock.setNote(note.isSharped() ? note.flattened() : note.sharped());
|
||||
} else if (data instanceof Openable) {
|
||||
Openable openable = (Openable) data;
|
||||
openable.setOpen(!openable.isOpen());
|
||||
} else if (data instanceof Comparator) {
|
||||
Comparator comparator = (Comparator) data;
|
||||
comparator.setMode(Comparator.Mode.values()[1 - comparator.getMode().ordinal()]);
|
||||
} else if (data instanceof Powerable) {
|
||||
Material type = block.getType();
|
||||
Powerable powerable = (Powerable) data;
|
||||
boolean isPowered = powerable.isPowered();
|
||||
|
||||
if(type.name().endsWith("BUTTON")) {
|
||||
if(isPowered)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
if(!block.getType().name().endsWith("BUTTON"))
|
||||
return;
|
||||
|
||||
powerable.setPowered(false);
|
||||
block.setBlockData(powerable);
|
||||
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
|
||||
}
|
||||
|
||||
powerable.setPowered(!isPowered);
|
||||
}
|
||||
block.setBlockData(data);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
if(queue.isEmpty())
|
||||
plan();
|
||||
|
||||
if(!queue.isEmpty() && --queue.peek().delay == 0)
|
||||
queue.poll().run();
|
||||
}
|
||||
|
||||
private Location translate(Vector pos, boolean blockPos) {
|
||||
Region extend = team.getExtendRegion();
|
||||
if(Fight.getUnrotated() == team)
|
||||
return new Location(
|
||||
Config.world,
|
||||
pos.getX() + extend.getMinX(),
|
||||
pos.getY() + team.getSchemRegion().getMinY(),
|
||||
pos.getZ() + extend.getMinZ()
|
||||
);
|
||||
else
|
||||
return new Location(
|
||||
Config.world,
|
||||
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
|
||||
pos.getY() + team.getSchemRegion().getMinY(),
|
||||
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
private static class Action {
|
||||
private int delay;
|
||||
public Action(int delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public void run() {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.fightsystem.ai;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class LixfelAI extends AI {
|
||||
|
||||
private final Random random = new Random();
|
||||
private LixfelPathplanner pathplanner;
|
||||
|
||||
public LixfelAI(FightTeam team, String user) {
|
||||
super(team, SteamwarUser.get(user));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SchematicNode chooseSchematic() {
|
||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
||||
SchematicNode schem = publics.get(new Random().nextInt(publics.size()));
|
||||
pathplanner = new LixfelPathplanner(schem);
|
||||
return schem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void plan() {
|
||||
setReady();
|
||||
Vector destination = pathplanner.getWalkable().get(random.nextInt(pathplanner.getWalkable().size()));
|
||||
List<Vector> path = pathplanner.plan(getPosition(), destination);
|
||||
if(!path.isEmpty())
|
||||
chat("Path size: " + path.size());
|
||||
for(Vector p : path) {
|
||||
move(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.fightsystem.ai;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class LixfelPathplanner {
|
||||
|
||||
private static BlockType getBlockType(Clipboard clipboard, BlockVector3 vector) {
|
||||
return clipboard.getBlock(vector).getBlockType();
|
||||
}
|
||||
|
||||
private static boolean nonsolid(Clipboard clipboard, BlockVector3 vector) {
|
||||
return !getBlockType(clipboard, vector).getMaterial().isSolid();
|
||||
}
|
||||
|
||||
private static Vector toBukkit(BlockVector3 vector) {
|
||||
return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
|
||||
}
|
||||
|
||||
private final List<Vector> walkable = new ArrayList<>();
|
||||
private final Map<Vector, Vector[]> neighbours = new HashMap<>();
|
||||
|
||||
public LixfelPathplanner(SchematicNode schem) {
|
||||
try {
|
||||
fillWalkable(new SchematicData(schem).load());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Vector> getWalkable() {
|
||||
return walkable;
|
||||
}
|
||||
|
||||
private void fillWalkable(Clipboard clipboard) {
|
||||
BlockVector3 min = clipboard.getRegion().getMinimumPoint().subtract(Config.PreperationArea, 0, Config.PreperationArea); //TODO assumes nonextended Schematic with maximal size
|
||||
Region region = clipboard.getRegion();
|
||||
clipboard.getRegion().forEach(vector -> {
|
||||
BlockVector3 below = vector.subtract(0, 1, 0);
|
||||
if(!region.contains(below))
|
||||
return;
|
||||
|
||||
BlockType belowMaterial = getBlockType(clipboard, below);
|
||||
BlockVector3 above = vector.add(0, 1, 0);
|
||||
if(nonsolid(clipboard, vector)) {
|
||||
if(
|
||||
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
|
||||
(!region.contains(above) || nonsolid(clipboard, above))
|
||||
)
|
||||
walkable.add(toBukkit(vector.subtract(min)));
|
||||
} else {
|
||||
if(!region.contains(above))
|
||||
walkable.add(toBukkit(above.subtract(min)));
|
||||
}
|
||||
});
|
||||
|
||||
for(Vector vector : walkable) {
|
||||
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Vector> planToAnywhere(Vector start, Vector destination) {
|
||||
Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null);
|
||||
|
||||
if(intermediate == null)
|
||||
return Collections.emptyList();
|
||||
|
||||
List<Vector> plan = plan(start, intermediate);
|
||||
plan.add(destination);
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
public List<Vector> plan(Vector start, Vector destination) {
|
||||
if(neighbouring(start, destination))
|
||||
return Collections.singletonList(destination);
|
||||
|
||||
Map<Vector, Vector> approach = new HashMap<>();
|
||||
Set<Vector> checking = Collections.singleton(destination);
|
||||
|
||||
while(!checking.isEmpty()) {
|
||||
Set<Vector> toCheck = new HashSet<>();
|
||||
for(Vector current : checking) {
|
||||
Vector firstStep = Arrays.stream(neighbours.get(current))
|
||||
.filter(vector -> !approach.containsKey(vector))
|
||||
.filter(next -> {
|
||||
approach.put(next, current);
|
||||
toCheck.add(next);
|
||||
return neighbouring(next, start);
|
||||
})
|
||||
.findAny().orElse(null);
|
||||
|
||||
if(firstStep != null) {
|
||||
List<Vector> path = new ArrayList<>();
|
||||
path.add(firstStep);
|
||||
|
||||
while(path.get(path.size()-1) != destination) {
|
||||
path.add(approach.get(path.get(path.size()-1)));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
checking = toCheck;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private boolean neighbouring(Vector a, Vector b) {
|
||||
return Math.abs(a.getX() - b.getX()) <= 1 && Math.abs(a.getY() - b.getY()) <= 1 && Math.abs(a.getZ() - b.getZ()) <= 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AkCommand implements CommandExecutor {
|
||||
|
||||
public AkCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(!player.isOp())
|
||||
return false;
|
||||
|
||||
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()){
|
||||
return false;
|
||||
}
|
||||
|
||||
Kit.createKit(args[0], player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@UtilityClass
|
||||
public class Commands {
|
||||
|
||||
private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
|
||||
public static void injectCommand(Command cmd) {
|
||||
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
|
||||
}
|
||||
|
||||
private static void errNoTeam(Player p){
|
||||
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
|
||||
static boolean checkSetup(Player p){
|
||||
if(!FightState.setup()){
|
||||
FightSystem.getMessage().sendPrefixless("FIGHT_ALREADY_STARTED", p, ChatMessageType.ACTION_BAR);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static FightPlayer checkGetPlayer(Player p){
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||
if(fightPlayer == null){
|
||||
errNoTeam(p);
|
||||
}
|
||||
return fightPlayer;
|
||||
}
|
||||
|
||||
public static FightPlayer checkGetLeader(Player p){
|
||||
FightPlayer fightPlayer = checkGetPlayer(p);
|
||||
if(fightPlayer != null && !fightPlayer.isLeader()){
|
||||
FightSystem.getMessage().sendPrefixless("NOT_LEADER", p, ChatMessageType.ACTION_BAR);
|
||||
fightPlayer = null;
|
||||
}
|
||||
return fightPlayer;
|
||||
}
|
||||
|
||||
public static FightTeam checkGetTeam(Player p){
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null){
|
||||
errNoTeam(p);
|
||||
}
|
||||
return fightTeam;
|
||||
}
|
||||
|
||||
private static Player checkGetPlayer(Player p, String t){
|
||||
Player target = Bukkit.getPlayer(t);
|
||||
if(target == null) {
|
||||
FightSystem.getMessage().sendPrefixless("PLAYER_UNAVAILABLE", p, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
static void toggleReady(Player p){
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null || checkGetLeader(p) == null)
|
||||
return;
|
||||
|
||||
fightTeam.setReady(!fightTeam.isReady());
|
||||
}
|
||||
|
||||
static void toggleSkip(Player p){
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null || checkGetLeader(p) == null)
|
||||
return;
|
||||
|
||||
fightTeam.skip();
|
||||
}
|
||||
|
||||
static void leaveTeam(Player p){
|
||||
if(checkSetup(p))
|
||||
return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
fightTeam.removePlayer(p);
|
||||
}
|
||||
|
||||
static void kick(Player p, String kicked){
|
||||
if(checkSetup(p))
|
||||
return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
FightPlayer fightPlayer = checkGetLeader(p);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
Player target = checkGetPlayer(p, kicked);
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
if(!fightTeam.isPlayerInTeam(target)){
|
||||
FightSystem.getMessage().sendPrefixless("NOT_IN_TEAM", p, ChatMessageType.ACTION_BAR, target.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
fightTeam.removePlayer(target);
|
||||
}
|
||||
|
||||
public static void kit(Player p, String kitName){
|
||||
if(checkSetup(p))
|
||||
return;
|
||||
|
||||
FightPlayer fightPlayer = checkGetPlayer(p);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
Kit k = null;
|
||||
if(Config.PersonalKits){
|
||||
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
||||
if(kit != null){
|
||||
kit.setInUse();
|
||||
k = new Kit(kit);
|
||||
}
|
||||
}else{
|
||||
k = Kit.getKitByName(kitName);
|
||||
}
|
||||
|
||||
if(k == null || !k.canUseKit(fightPlayer.isLeader())){
|
||||
FightSystem.getMessage().sendPrefixless("KIT_UNAVAILABLE", p, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
FightSystem.getMessage().sendPrefixless("KIT_CHOSEN", p, ChatMessageType.ACTION_BAR, kitName);
|
||||
fightPlayer.setKit(k);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.*;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GUI {
|
||||
private GUI(){}
|
||||
|
||||
private static final Message msg = FightSystem.getMessage();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
|
||||
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
|
||||
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
|
||||
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
|
||||
p.closeInventory();
|
||||
new JoinRequest(p, team);
|
||||
});
|
||||
}
|
||||
|
||||
public static void joinRequest(Player p) {
|
||||
if(JoinRequest.get(p) != null) {
|
||||
msg.sendPrefixless("JOIN_REQUEST_ALREADY", p, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
SWInventory inv = new SWInventory(p, 9, msg.parse("JOIN_REQUEST_TITLE", p));
|
||||
FightTeam team = Fight.getPlayerTeam(p);
|
||||
if(team != Fight.getRedTeam())
|
||||
addTeamRequest(p, inv, team == null ? 0 : 4, Fight.getBlueTeam());
|
||||
if(team != Fight.getBlueTeam())
|
||||
addTeamRequest(p, inv, team == null ? 8 : 4, Fight.getRedTeam());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void state(Player p){
|
||||
SWInventory inv = new SWInventory(p, 9, msg.parse("STATE_TITLE", p));
|
||||
int i = 0;
|
||||
for(FightState state : FightState.values()) {
|
||||
if(state == FightState.SPECTATE)
|
||||
continue;
|
||||
|
||||
inv.setItem(i++, Material.GLASS, msg.parse("STATE_" + state.name(), p), click -> FightState.setFightState(state));
|
||||
}
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
inv.setItem(i++, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, team.getColoredName()), click -> FightSystem.setSpectateState(team, "operator", "WIN_FIGHTLEADER"));
|
||||
}
|
||||
inv.setItem(i, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), click -> FightSystem.setSpectateState(null, "operator", "WIN_FIGHTLEADER"));
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void chooseJoinRequests(Player p){
|
||||
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p));
|
||||
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> {
|
||||
p.closeInventory();
|
||||
RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void chooseRemove(Player p){
|
||||
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
|
||||
FightTeam team = Fight.getPlayerTeam(p);
|
||||
if(team == null)
|
||||
return;
|
||||
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getObject()))));
|
||||
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("REMOVE_TITLE", p), players, (ClickType click, UUID player) -> {
|
||||
Commands.kick(p, SteamwarUser.get(player).getUserName());
|
||||
p.closeInventory();
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void kitSelection(Player p, String query){
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
List<SWListInv.SWListEntry<Kit>> entries = new ArrayList<>();
|
||||
|
||||
if(Config.PersonalKits){
|
||||
List<PersonalKit> kits = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB());
|
||||
kits.forEach(kit -> entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName(), new ArrayList<>(), kit.isInUse(), clickType -> {}), new Kit(kit))));
|
||||
}else{
|
||||
List<Kit> kitList = Kit.getAvailableKits(fightPlayer.isLeader());
|
||||
for(Kit k : kitList){
|
||||
entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, k.leaderExclusive(), null), k));
|
||||
}
|
||||
}
|
||||
|
||||
entries.removeIf(entry -> !entry.getObject().getName().toLowerCase().contains(query.toLowerCase()));
|
||||
|
||||
SWListInv<Kit> inv = new SWListInv<>(p, msg.parse("KIT_SELECTION_TITLE", p), false, entries, (clickType, kit) -> kit.preview(p));
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
if(entries.isEmpty()) {
|
||||
inv.setItem(22, new SWItem(Material.BARRIER, msg.parse("KIT_NO_KITS", p)));
|
||||
}
|
||||
if(Config.PersonalKits){
|
||||
inv.setItem(48, Material.NETHER_STAR, msg.parse("KIT_CREATE", p), clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITNAME_TITLE", p));
|
||||
anvilInv.setItem(Material.LEATHER_CHESTPLATE);
|
||||
anvilInv.setCallback(s -> {
|
||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||
if(PersonalKit.get(user.getId(), Config.SchematicType.toDB(), s) != null) {
|
||||
msg.sendPrefixless("KITNAME_IN_USE", p, ChatMessageType.ACTION_BAR);
|
||||
p.closeInventory();
|
||||
return;
|
||||
}
|
||||
Kit prototype = Kit.getAvailableKits(Fight.getFightPlayer(p).isLeader()).get(0);
|
||||
PersonalKit kit = PersonalKit.create(user.getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor());
|
||||
PersonalKitCreator.openKitCreator(p, kit);
|
||||
});
|
||||
anvilInv.open();
|
||||
});
|
||||
}
|
||||
inv.setItem(50, Material.NAME_TAG, msg.parse("KIT_SEARCH", p), clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITSEARCH_TITLE", p));
|
||||
anvilInv.setItem(Material.PAPER);
|
||||
anvilInv.setCallback(s -> kitSelection(p, s));
|
||||
anvilInv.open();
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void preSchemDialog(Player p){
|
||||
if(!Config.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP){
|
||||
msg.sendPrefixless("SCHEM_NO_ENEMY", p, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
int invSize = (Config.SubTypes.size() + 1) * 9;
|
||||
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
|
||||
setupSchemTypeRow(p, inv, Config.SchematicType, 0);
|
||||
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
||||
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
||||
}
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) {
|
||||
inv.setItem(row * 9 + 8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, type.name()), (ClickType click) -> {
|
||||
p.closeInventory();
|
||||
schemDialog(p, type, true, false);
|
||||
});
|
||||
|
||||
if (Fight.publicOnly()) {
|
||||
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, type.name()), (ClickType click)->{});
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(Config.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
|
||||
inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, type.name()), (ClickType click) -> {
|
||||
p.closeInventory();
|
||||
schemDialog(p, type, false, true);
|
||||
});
|
||||
}
|
||||
|
||||
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) {
|
||||
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click)->{});
|
||||
return;
|
||||
}
|
||||
|
||||
inv.setItem(row * 9, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, type.name()), (ClickType click) -> {
|
||||
p.closeInventory();
|
||||
schemDialog(p, type, false, false);
|
||||
});
|
||||
}
|
||||
|
||||
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
|
||||
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
});
|
||||
selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY);
|
||||
selector.open();
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import de.steamwar.core.CommandRemover;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class GamemodeCommand extends BukkitCommand {
|
||||
|
||||
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
||||
"spectator");
|
||||
|
||||
public GamemodeCommand() {
|
||||
super("gamemode");
|
||||
List<String> aliases = new ArrayList<>();
|
||||
aliases.add("gm");
|
||||
this.setAliases(aliases);
|
||||
|
||||
try {
|
||||
CommandRemover.removeAll("gamemode");
|
||||
} catch (Exception e) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||
}
|
||||
Commands.injectCommand(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}else if (args.length == 0) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (!(Config.test() || Config.isReferee(p))) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameMode mode = createMode(args[0]);
|
||||
|
||||
if(mode == null){
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_UNKNOWN", p, ChatMessageType.ACTION_BAR, args[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
p.setGameMode(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private GameMode createMode(String modeArg){
|
||||
try {
|
||||
return GameMode.getByValue(Integer.parseInt(modeArg));
|
||||
} catch (NumberFormatException ignored) {
|
||||
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c")))
|
||||
return GameMode.CREATIVE;
|
||||
else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a")))
|
||||
return GameMode.ADVENTURE;
|
||||
else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp")))
|
||||
return GameMode.SPECTATOR;
|
||||
else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s")))
|
||||
return GameMode.SURVIVAL;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length == 1)
|
||||
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.fightsystem.utils.FightStatistics;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InfoCommand implements CommandExecutor {
|
||||
|
||||
public InfoCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
|
||||
Player player = (Player) sender;
|
||||
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK))
|
||||
return false;
|
||||
|
||||
FightSystem.getMessage().send("INFO_RANKED", player, !FightStatistics.isUnranked());
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(!team.isLeaderless())
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||
|
||||
if(team.getSchematic() != 0) {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(team.getSchematic());
|
||||
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getRank());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KitCommand implements CommandExecutor {
|
||||
|
||||
public KitCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length != 1)
|
||||
GUI.kitSelection(player, "");
|
||||
else{
|
||||
Commands.kit(player, args[0]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LeaderCommand implements CommandExecutor {
|
||||
|
||||
public LeaderCommand() {
|
||||
new StateDependentCommand(ArenaMode.ManualTeams, FightState.Setup, "leader", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(Fight.getFightPlayer(player) != null) {
|
||||
FightSystem.getMessage().sendPrefixless("ALREADY_IN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(team.canbeLeader(player)) {
|
||||
team.addMember(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
FightSystem.getMessage().sendPrefixless("LEADER_FULL", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LeaveCommand implements CommandExecutor {
|
||||
|
||||
public LeaveCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
Commands.leaveTeam(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LockschemCommand implements CommandExecutor {
|
||||
|
||||
public LockschemCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK))
|
||||
return false;
|
||||
|
||||
if(args.length != 1) {
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
String teamName = args[0];
|
||||
FightTeam fightTeam = Fight.getTeamByName(teamName);
|
||||
|
||||
if(fightTeam == null) {
|
||||
FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
|
||||
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ReadyCommand implements CommandExecutor {
|
||||
|
||||
public ReadyCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
Commands.toggleReady(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RemoveCommand implements CommandExecutor {
|
||||
|
||||
public RemoveCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length != 1){
|
||||
FightSystem.getMessage().sendPrefixless("REMOVE_HELP", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
Commands.kick(player, args[0]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class RequestsCommand implements CommandExecutor {
|
||||
|
||||
public RequestsCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
if(fp == null || !(fp.isLeader() || fp.isLiving())) {
|
||||
GUI.joinRequest(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Commands.checkGetLeader(player) == null)
|
||||
return false;
|
||||
|
||||
GUI.chooseJoinRequests(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||
JoinRequest request = JoinRequest.get(target);
|
||||
if(request == null) {
|
||||
FightSystem.getMessage().send("NO_JOIN_REQUEST", player);
|
||||
return;
|
||||
}
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if(!request.required(team)) {
|
||||
FightSystem.getMessage().send("NO_CONFIRMATION", player);
|
||||
return;
|
||||
}
|
||||
|
||||
handleJoinRequest.accept(request, team);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SkipCommand implements CommandExecutor {
|
||||
|
||||
public SkipCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(PacketProcessor.isReplaying() && player.getUniqueId().equals(Fight.getBlueTeam().getDesignatedLeader())) {
|
||||
PacketProcessor.currentReplay().skipToSubtitle();
|
||||
} else {
|
||||
Commands.toggleSkip(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StateCommand implements CommandExecutor {
|
||||
|
||||
public StateCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GUI.state((Player) sender);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TBCommand implements CommandExecutor {
|
||||
|
||||
public TBCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resettb", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.core.TPSWarpUtils;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class TPSWarpCommand implements CommandExecutor {
|
||||
|
||||
public TPSWarpCommand() {
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
double tps;
|
||||
try {
|
||||
tps = Double.parseDouble(args[0]);
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
||||
FightSystem.getMessage().send("TPSWARP_HELP", sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
TPSWarpUtils.warp(tps);
|
||||
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.fightsystem.utils.FightStatistics;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UnrankCommand implements CommandExecutor {
|
||||
|
||||
public UnrankCommand () {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "unrank", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(Commands.checkGetLeader(player) == null)
|
||||
return false;
|
||||
|
||||
FightStatistics.unrank();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WGCommand implements CommandExecutor {
|
||||
|
||||
public WGCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resetwg", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Fight.getBlueTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WinCommand implements CommandExecutor {
|
||||
|
||||
public WinCommand() {
|
||||
new StateDependentCommand(ArenaMode.Event, FightState.Ingame, "win", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (!Config.isReferee(p)) {
|
||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.length == 0){
|
||||
FightSystem.getMessage().sendPrefixless("WIN_HELP", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("tie")){
|
||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(args[0].equalsIgnoreCase(team.getName())){
|
||||
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Countdown {
|
||||
|
||||
private static final List<Countdown> currentCountdowns = new ArrayList<>();
|
||||
|
||||
protected final Message appendix;
|
||||
|
||||
private final int totalTime;
|
||||
protected final Sound sound;
|
||||
private final boolean level;
|
||||
|
||||
protected int time;
|
||||
private BukkitTask task = null;
|
||||
|
||||
public abstract void countdownFinished();
|
||||
|
||||
protected Countdown(int time, Message appendix, SWSound sound, boolean level) {
|
||||
this.totalTime = time;
|
||||
this.time = time;
|
||||
this.appendix = appendix;
|
||||
this.sound = sound != null ? sound.getSound() : null;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
time = totalTime;
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
||||
currentCountdowns.add(this);
|
||||
show();
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
if(task != null){
|
||||
task.cancel();
|
||||
currentCountdowns.remove(this);
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void skip(){
|
||||
if(currentCountdowns.isEmpty())
|
||||
return;
|
||||
|
||||
int smallestTime = currentCountdowns.get(0).time;
|
||||
for(Countdown countdown : currentCountdowns){
|
||||
if(countdown.time < smallestTime)
|
||||
smallestTime = countdown.time;
|
||||
}
|
||||
|
||||
for(Countdown countdown : new ArrayList<>(currentCountdowns)) {
|
||||
countdown.time -= smallestTime;
|
||||
countdown.show();
|
||||
}
|
||||
|
||||
FightUI.addSubtitle("UI_SKIP");
|
||||
}
|
||||
|
||||
public static void sendCountdownMessage(Player p, String message, int displaytime, Message appendix) {
|
||||
FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix.getMsg(), p, appendix.getParams()));
|
||||
}
|
||||
|
||||
protected void broadcast(String message, int divisor){
|
||||
if(this.sound != null && divisor == 1)
|
||||
Fight.playSound(this.sound, 100.0F, 1.0F);
|
||||
|
||||
GlobalRecorder.getInstance().countdown(message, time / divisor, appendix);
|
||||
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
|
||||
}
|
||||
|
||||
public int getTimeLeft(){
|
||||
return time;
|
||||
}
|
||||
|
||||
private void count() {
|
||||
time--;
|
||||
show();
|
||||
}
|
||||
|
||||
private void show(){
|
||||
switch (time) {
|
||||
case 900: case 600: case 300: case 180: case 120:
|
||||
broadcast("COUNTDOWN_MINUTES", 60);
|
||||
break;
|
||||
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
|
||||
broadcast("COUNTDOWN_SECONDS", 1);
|
||||
break;
|
||||
case 1:
|
||||
broadcast("COUNTDOWN_SECOND", 1);
|
||||
break;
|
||||
case 0:
|
||||
if(this.sound != null)
|
||||
Fight.playSound(this.sound, 100.0F, 2.0F);
|
||||
|
||||
disable();
|
||||
countdownFinished();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if(this.level)
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(time));
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.techhider.ProtocolUtils;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnternCountdown extends Countdown {
|
||||
|
||||
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
||||
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
|
||||
|
||||
if(countdown != null) {
|
||||
time -= Config.TimeoutTime - countdown.getTimeLeft();
|
||||
|
||||
if(time < 0)
|
||||
time = 0;
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
private List<ProtocolUtils.ChunkPos> chunkPos;
|
||||
|
||||
public EnternCountdown(FightPlayer fp, Countdown countdown) {
|
||||
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
fightPlayer = fp;
|
||||
enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
|
||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
FightSystem.getHullHider().updatePlayer(player);
|
||||
FightSystem.getTechHider().reloadChunks(player, Fight.getOpposite(fightPlayer.getTeam()).getExtendRegion(), Region.EMPTY);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcast(String message, int divisor) {
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
|
||||
sendCountdownMessage(player, message, time / divisor, appendix);
|
||||
});
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
|
||||
public class EventSpectateCountdown extends Countdown {
|
||||
|
||||
public EventSpectateCountdown() {
|
||||
super(Config.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightSystem.shutdown();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NoPlayersOnlineCountdown extends Countdown {
|
||||
|
||||
public NoPlayersOnlineCountdown() {
|
||||
super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
|
||||
|
||||
if (!Config.ArenaLeaveable)
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
|
||||
public class PostSchemCountdown extends Countdown {
|
||||
|
||||
public PostSchemCountdown() {
|
||||
super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
|
||||
if(Config.mode == ArenaMode.PREPARE && Config.UnlimitedPrepare)
|
||||
return;
|
||||
|
||||
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
|
||||
public class PreRunningCountdown extends Countdown {
|
||||
|
||||
public PreRunningCountdown() {
|
||||
super(Config.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true);
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightState.setFightState(FightState.RUNNING);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
|
||||
public class PreSchemCountdown extends Countdown {
|
||||
|
||||
public PreSchemCountdown() {
|
||||
super(Config.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
|
||||
public class SpectateOverCountdown extends Countdown {
|
||||
|
||||
public SpectateOverCountdown() {
|
||||
super(Config.test() ? 3600 : Config.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
new StateDependentCountdown(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
|
||||
public class TimeOverCountdown extends Countdown {
|
||||
|
||||
private final Runnable timeOver;
|
||||
|
||||
public TimeOverCountdown(Runnable timeOver) {
|
||||
super(Config.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false);
|
||||
this.timeOver = timeOver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
timeOver.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
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.fightsystem.event;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class HellsBells {
|
||||
|
||||
public static final Random random = new Random();
|
||||
|
||||
private final int xLength = Config.BlueExtendRegion.getSizeX();
|
||||
private final int zLength = Config.BlueExtendRegion.getSizeZ();
|
||||
private State current = State.PRE;
|
||||
private int currentDrops = 0;
|
||||
private HellsBellsCountdown currentCountdown;
|
||||
private BukkitTask currentDropping;
|
||||
|
||||
private final List<String> startMessages = Arrays.asList("HELLS_BELLS_START_1", "HELLS_BELLS_START_2",
|
||||
"HELLS_BELLS_START_3", "HELLS_BELLS_START_4", "HELLS_BELLS_START_5", "HELLS_BELLS_START_6");
|
||||
private final List<String> stateSwapMessages = Arrays.asList("HELLS_BELLS_SWAP_1", "HELLS_BELLS_SWAP_2",
|
||||
"HELLS_BELLS_SWAP_3", "HELLS_BELLS_SWAP_4");
|
||||
|
||||
public void startCountdown() {
|
||||
if (current == HellsBells.State.PRE || current == HellsBells.State.FIRST) {
|
||||
String startMessage = startMessages.get(random.nextInt(startMessages.size()));
|
||||
GlobalRecorder.getInstance().system(startMessage);
|
||||
FightSystem.getMessage().broadcast(startMessage);
|
||||
current = current.getNext();
|
||||
} else if (current != HellsBells.State.LAST && currentDrops >= current.SWITCH_AFTER) {
|
||||
String stateSwapMessage = stateSwapMessages.get(random.nextInt(stateSwapMessages.size()));
|
||||
GlobalRecorder.getInstance().system(stateSwapMessage);
|
||||
FightSystem.getMessage().broadcast(stateSwapMessage);
|
||||
currentDrops = 0;
|
||||
current = current.getNext();
|
||||
}
|
||||
|
||||
currentDrops++;
|
||||
currentCountdown = new HellsBellsCountdown(current.MIN_TIME + random.nextInt(current.MAX_TIME - current.MIN_TIME));
|
||||
currentCountdown.enable();
|
||||
}
|
||||
|
||||
public void drop() {
|
||||
Direction direction = Direction.getRandom();
|
||||
|
||||
AtomicInteger length = new AtomicInteger(20 + random.nextInt(direction.getLength(zLength, xLength) - 20));
|
||||
int width = 5 + random.nextInt(5);
|
||||
int xOffset = getStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width));
|
||||
int zOffset = getStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get()));
|
||||
int yOffset = getHeightStart();
|
||||
|
||||
Point redStart;
|
||||
Point blueStart;
|
||||
|
||||
if (direction.isNorthOrWest()) {
|
||||
redStart = new Point(Config.RedExtendRegion.getMaxX() - xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedExtendRegion.getMaxZ() - zOffset);
|
||||
blueStart = new Point(Config.BlueExtendRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BlueExtendRegion.getMinZ() + zOffset);
|
||||
} else {
|
||||
redStart = new Point(Config.RedExtendRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedExtendRegion.getMinZ() + zOffset);
|
||||
blueStart = new Point(Config.BlueExtendRegion.getMaxX() - xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BlueExtendRegion.getMaxZ() - zOffset);
|
||||
}
|
||||
|
||||
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
||||
for (int w = 0; w < width; w++) {
|
||||
if (direction.isNorthOrWest()) {
|
||||
Config.world.spawnEntity(redStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT);
|
||||
|
||||
Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||
} else {
|
||||
Config.world.spawnEntity(redStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||
|
||||
Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT);
|
||||
}
|
||||
}
|
||||
if (length.addAndGet(-2) <= 0) {
|
||||
currentDropping.cancel();
|
||||
}
|
||||
}, 0L, 4L);
|
||||
}
|
||||
|
||||
private int getStart(int regionSize, int length) {
|
||||
double randomNumber = (Math.max(Math.min(random.nextGaussian(), -2), 2) + 2) / 4;
|
||||
Bukkit.getLogger().log(Level.INFO, "Calculated Start: " + (int) (randomNumber * (regionSize - length)));
|
||||
return Math.max(Math.min((int) (randomNumber * (regionSize - length)), regionSize - length), 0);
|
||||
}
|
||||
|
||||
private int getHeightStart() {
|
||||
return 5 + random.nextInt(15);
|
||||
}
|
||||
|
||||
public HellsBells() {
|
||||
new StateDependent(Winconditions.HELLS_BELLS, FightState.Running) {
|
||||
@Override
|
||||
public void enable() {
|
||||
current = State.PRE;
|
||||
currentDrops = 0;
|
||||
startCountdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
currentCountdown.disable();
|
||||
}
|
||||
}.register();
|
||||
}
|
||||
|
||||
private class HellsBellsCountdown extends Countdown {
|
||||
|
||||
public HellsBellsCountdown(int time) {
|
||||
super(time, new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
drop();
|
||||
startCountdown();
|
||||
}
|
||||
}
|
||||
|
||||
private enum State {
|
||||
|
||||
PRE(60, 80, 1),
|
||||
FIRST(40, 60, 3),
|
||||
SECOND(30, 40, 4),
|
||||
THIRD(20, 30, 4),
|
||||
FOURTH(10, 20, 5),
|
||||
LAST(5, 10, 0);
|
||||
|
||||
|
||||
State(int minTime, int maxTime, int switchAfter) {
|
||||
this.MIN_TIME = minTime;
|
||||
this.MAX_TIME = maxTime;
|
||||
this.SWITCH_AFTER = switchAfter;
|
||||
}
|
||||
|
||||
private final int MIN_TIME; //NOSONAR
|
||||
private final int MAX_TIME; //NOSONAR
|
||||
private final int SWITCH_AFTER; //NOSONAR
|
||||
|
||||
|
||||
public State getNext() {
|
||||
switch (this) {
|
||||
case PRE:
|
||||
return FIRST;
|
||||
case FIRST:
|
||||
return SECOND;
|
||||
case SECOND:
|
||||
return THIRD;
|
||||
case THIRD:
|
||||
return FOURTH;
|
||||
case FOURTH:
|
||||
case LAST:
|
||||
return LAST;
|
||||
default:
|
||||
return PRE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum Direction {
|
||||
NORTH(0, 0, 1),
|
||||
SOUTH(0, 0, -1),
|
||||
EAST(1, 0, 0),
|
||||
WEST(-1, 0, 0);
|
||||
|
||||
|
||||
int dx;
|
||||
int dy;
|
||||
int dz;
|
||||
|
||||
Direction(int dx, int dy, int dz) {
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.dz = dz;
|
||||
}
|
||||
|
||||
public static Direction getRandom() {
|
||||
return Direction.values()[random.nextInt(Direction.values().length)];
|
||||
}
|
||||
|
||||
Direction other() {
|
||||
switch (this) {
|
||||
case NORTH:
|
||||
return EAST;
|
||||
case SOUTH:
|
||||
return WEST;
|
||||
case EAST:
|
||||
return NORTH;
|
||||
case WEST:
|
||||
return SOUTH;
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength(int length1, int length2) {
|
||||
return isNorthOrSouth() ? length1 : length2;
|
||||
}
|
||||
|
||||
public boolean isNorthOrSouth() {
|
||||
return this == NORTH || this == SOUTH;
|
||||
}
|
||||
|
||||
public boolean isNorthOrWest() {
|
||||
return this == NORTH || this == WEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
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.fightsystem.event;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LargeFireball;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class Meteor implements Listener {
|
||||
|
||||
public static final Random random = new Random();
|
||||
|
||||
private final Vector vector = new Vector(0, -1, 0);
|
||||
private final int xLength = Config.RedExtendRegion.getMaxX() - Config.RedExtendRegion.getMinX();
|
||||
private final int zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
||||
private Meteor.State current = Meteor.State.PRE;
|
||||
private int currentDrops = 0;
|
||||
private Meteor.MeteorCountdown currentCountdown;
|
||||
private final AtomicInteger amount = new AtomicInteger(0);
|
||||
private BukkitTask currentDropping;
|
||||
|
||||
private final List<String> startMessages = Arrays.asList("METEOR_START_1", "METEOR_START_2", "METEOR_START_3", "METEOR_START_4", "METEOR_START_5", "METEOR_START_6");
|
||||
private final List<String> stateSwapMessages = Arrays.asList("METEOR_SWAP_1", "METEOR_SWAP_2", "METEOR_SWAP_3", "METEOR_SWAP_4");
|
||||
|
||||
public void startCountdown() {
|
||||
if (current == Meteor.State.PRE || current == Meteor.State.FIRST) {
|
||||
String startMessage = startMessages.get(random.nextInt(startMessages.size()));
|
||||
GlobalRecorder.getInstance().system(startMessage);
|
||||
FightSystem.getMessage().broadcast(startMessage);
|
||||
current = current.getNext();
|
||||
} else if (current != Meteor.State.LAST && currentDrops >= current.SWITCH_AFTER) {
|
||||
String stateSwapMessage = stateSwapMessages.get(random.nextInt(stateSwapMessages.size()));
|
||||
GlobalRecorder.getInstance().system(stateSwapMessage);
|
||||
FightSystem.getMessage().broadcast(stateSwapMessage);
|
||||
currentDrops = 0;
|
||||
current = current.getNext();
|
||||
}
|
||||
|
||||
currentDrops++;
|
||||
currentCountdown = new Meteor.MeteorCountdown(current.MIN_TIME + random.nextInt(current.MAX_TIME - current.MIN_TIME));
|
||||
currentCountdown.enable();
|
||||
}
|
||||
|
||||
//@EventHandler
|
||||
public void explode(ProjectileHitEvent event) {
|
||||
if (event.getEntity() instanceof Fireball) {
|
||||
TNTPrimed tnt = Config.world.spawn(event.getEntity().getLocation(), TNTPrimed.class);
|
||||
tnt.setVelocity(new Vector(0, 0, 0));
|
||||
tnt.setFuseTicks(0);
|
||||
tnt.setYield(((Fireball) event.getEntity()).getYield());
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void drop() {
|
||||
int randomAmount = current.minAmount + random.nextInt(current.maxAmount - current.minAmount);
|
||||
if (amount.get() > 0) {
|
||||
amount.set(amount.get() + randomAmount);
|
||||
return;
|
||||
}
|
||||
amount.set(randomAmount);
|
||||
|
||||
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
||||
int xOffset = getStart(xLength);
|
||||
int zOffset = getStart(zLength);
|
||||
int yOffset = getHeightStart();
|
||||
|
||||
Point redStart = new Point(Config.RedExtendRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedExtendRegion.getMaxZ() - zOffset);
|
||||
Point blueStart = new Point(Config.BlueExtendRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BlueExtendRegion.getMinZ() + zOffset);
|
||||
|
||||
vector.setX(random.nextDouble() - 0.5);
|
||||
vector.setZ(random.nextDouble() - 0.5);
|
||||
|
||||
LargeFireball fireballRed = Config.world.spawn(redStart.toLocation(Config.world), LargeFireball.class);
|
||||
fireballRed.setDirection(vector);
|
||||
fireballRed.setBounce(false);
|
||||
fireballRed.setIsIncendiary(false);
|
||||
fireballRed.setYield(current.explosionSize);
|
||||
|
||||
LargeFireball fireballBlue = Config.world.spawn(blueStart.toLocation(Config.world), LargeFireball.class);
|
||||
vector.setZ(vector.getZ() * -1);
|
||||
fireballBlue.setDirection(vector);
|
||||
fireballBlue.setBounce(false);
|
||||
fireballBlue.setIsIncendiary(false);
|
||||
fireballBlue.setYield(current.explosionSize);
|
||||
|
||||
if (amount.decrementAndGet() <= 0) {
|
||||
currentDropping.cancel();
|
||||
}
|
||||
}, 0L, 4L);
|
||||
}
|
||||
|
||||
private int getStart(int regionSize) {
|
||||
double randomNumber = (random.nextDouble() - random.nextDouble()) / 2 + 0.5;
|
||||
Bukkit.getLogger().log(Level.INFO, "Calculated Start: " + (int) (randomNumber * (regionSize - 1)));
|
||||
return Math.max(Math.min((int) (randomNumber * (regionSize - 1)), regionSize - 1), 0);
|
||||
}
|
||||
|
||||
private int getHeightStart() {
|
||||
return 5 + random.nextInt(15);
|
||||
}
|
||||
|
||||
public Meteor() {
|
||||
new StateDependentListener(Winconditions.METEOR, FightState.Running, this);
|
||||
|
||||
new StateDependent(Winconditions.METEOR, FightState.Running) {
|
||||
@Override
|
||||
public void enable() {
|
||||
startCountdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
currentCountdown.disable();
|
||||
}
|
||||
}.register();
|
||||
}
|
||||
|
||||
private class MeteorCountdown extends Countdown {
|
||||
|
||||
public MeteorCountdown(int time) {
|
||||
super(time, new Message("METEOR_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
drop();
|
||||
startCountdown();
|
||||
}
|
||||
}
|
||||
|
||||
private enum State {
|
||||
|
||||
PRE(60, 80, 1, 0, 0, 0),
|
||||
FIRST(25, 35, 6, 2, 3, 6),
|
||||
SECOND(20, 30, 7, 4, 4, 8),
|
||||
THIRD(15, 25, 7, 4, 5, 10),
|
||||
FOURTH(10, 20, 8, 6, 7, 14),
|
||||
LAST(5, 10, 0, 6, 9, 18);
|
||||
|
||||
|
||||
State(int minTime, int maxTime, int switchAfter, int explosionSize, int minAmount, int maxAmount) {
|
||||
this.MIN_TIME = minTime;
|
||||
this.MAX_TIME = maxTime;
|
||||
this.SWITCH_AFTER = switchAfter;
|
||||
this.explosionSize = explosionSize;
|
||||
this.minAmount = minAmount;
|
||||
this.maxAmount = maxAmount;
|
||||
}
|
||||
|
||||
private final int MIN_TIME; //NOSONAR
|
||||
private final int MAX_TIME; //NOSONAR
|
||||
private final int SWITCH_AFTER; //NOSONAR
|
||||
private final int explosionSize; //NOSONAR
|
||||
private final int minAmount;
|
||||
private final int maxAmount;
|
||||
|
||||
|
||||
public Meteor.State getNext() {
|
||||
switch (this) {
|
||||
case PRE:
|
||||
return FIRST;
|
||||
case FIRST:
|
||||
return SECOND;
|
||||
case SECOND:
|
||||
return THIRD;
|
||||
case THIRD:
|
||||
return FOURTH;
|
||||
case FOURTH:
|
||||
case LAST:
|
||||
return LAST;
|
||||
default:
|
||||
return PRE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.fightsystem.event;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PersistentDamage {
|
||||
|
||||
public PersistentDamage() {
|
||||
if(!ArenaMode.SeriousFight.contains(Config.mode))
|
||||
return;
|
||||
|
||||
new OneShotStateDependent(Winconditions.PERSISTENT_DAMAGE, FightState.Spectate, () -> Fight.teams().forEach(team -> {
|
||||
try{
|
||||
WorldeditWrapper.impl.saveSchem(SchematicNode.getSchematicNode(team.getSchematic()), team.getExtendRegion(), team.getSchemRegion().getMinY());
|
||||
}catch(WorldEditException e){
|
||||
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not persist schematic state", e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.fightsystem.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
class Point {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public Point(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, this.x, this.y, this.z); //NOSONAR
|
||||
}
|
||||
|
||||
public Location addAndToLocation(World world, int x, int y, int z) {
|
||||
return new Location(world, this.x + x, this.y + y, this.z + z); //NOSONAR
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.fightsystem.event;
|
||||
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class TNTDistributor {
|
||||
|
||||
public TNTDistributor() {
|
||||
new StateDependentTask(Winconditions.TNT_DISTRIBUTION, FightState.Running, () -> Fight.teams().forEach(team -> team.getPlayers().forEach(fp -> {
|
||||
if(!fp.isLiving())
|
||||
return;
|
||||
|
||||
fp.ifPlayer(player -> player.getInventory().addItem(new ItemStack(Material.TNT, 20)));
|
||||
})), 300, 300);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.events;
|
||||
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class BoardingEvent extends Event {
|
||||
@Getter
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.events;
|
||||
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TeamDeathEvent extends Event {
|
||||
@Getter
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.events;
|
||||
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TeamLeaveEvent extends Event {
|
||||
@Getter
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.events;
|
||||
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TeamSpawnEvent extends Event {
|
||||
@Getter
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class Fight {
|
||||
private Fight(){}
|
||||
|
||||
@Getter
|
||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||
@Getter
|
||||
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
||||
private static final Collection<FightTeam> teams = new HashSet<>();
|
||||
static {
|
||||
teams.add(redTeam);
|
||||
teams.add(blueTeam);
|
||||
}
|
||||
|
||||
public static FightTeam getPlayerTeam(LivingEntity player) {
|
||||
if(redTeam.isPlayerInTeam(player))
|
||||
return redTeam;
|
||||
if(blueTeam.isPlayerInTeam(player))
|
||||
return blueTeam;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FightTeam getOpposite(FightTeam fightTeam) {
|
||||
if(fightTeam == redTeam)
|
||||
return blueTeam;
|
||||
else if(fightTeam == blueTeam)
|
||||
return redTeam;
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public static FightPlayer getFightPlayer(LivingEntity player) {
|
||||
if(redTeam.isPlayerInTeam(player))
|
||||
return redTeam.getFightPlayer(player);
|
||||
if(blueTeam.isPlayerInTeam(player))
|
||||
return blueTeam.getFightPlayer(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean fighting(LivingEntity player) {
|
||||
return getPlayerTeam(player) != null;
|
||||
}
|
||||
|
||||
public static Collection<FightTeam> teams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static FightTeam getUnrotated() {
|
||||
return Config.blueNegZ() ? Fight.getBlueTeam() : Fight.getRedTeam();
|
||||
}
|
||||
|
||||
public static void playSound(Sound sound, float volume, float pitch) {
|
||||
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
||||
//volume: max. 100, pitch: max. 2
|
||||
if(Core.getVersion() >= 18)
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
|
||||
else
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||
}
|
||||
|
||||
public static FightTeam getTeamByName(String name) {
|
||||
if(redTeam.getName().equalsIgnoreCase(name))
|
||||
return redTeam;
|
||||
if(blueTeam.getName().equalsIgnoreCase(name))
|
||||
return blueTeam;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setPlayerGamemode(Player player, GameMode gameMode) {
|
||||
player.setGameMode(gameMode);
|
||||
|
||||
if(gameMode == GameMode.SPECTATOR) {
|
||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||
currentPlayer.hidePlayer(player);
|
||||
player.hidePlayer(currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
if(Config.test() || Config.isReferee(player))
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
if(!player.isOnline())
|
||||
return;
|
||||
pseudoSpectator(player, true);
|
||||
}, 1);
|
||||
}else if(gameMode == GameMode.SURVIVAL) {
|
||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||
currentPlayer.showPlayer(player);
|
||||
player.showPlayer(currentPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void pseudoSpectator(Player player, boolean enable) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
|
||||
}
|
||||
|
||||
public static boolean publicOnly() {
|
||||
if (Config.OnlyPublicSchematics) {
|
||||
return true;
|
||||
}
|
||||
if (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
|
||||
return false;
|
||||
}
|
||||
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
|
||||
return false;
|
||||
}
|
||||
return redTeam.isPublicsOnly() || blueTeam.isPublicsOnly();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ai.AI;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class FightPlayer {
|
||||
|
||||
private final int id;
|
||||
private LivingEntity entity;
|
||||
@Getter
|
||||
private final FightTeam team;
|
||||
private boolean isOut;
|
||||
@Setter
|
||||
@Getter
|
||||
private Kit kit;
|
||||
@Getter
|
||||
private int kills;
|
||||
private EnternCountdown enternCountdown = null;
|
||||
|
||||
FightPlayer(LivingEntity entity, SteamwarUser user, FightTeam team) {
|
||||
this.id = user.getId();
|
||||
this.entity = entity;
|
||||
this.team = team;
|
||||
this.isOut = false;
|
||||
kit = Kit.getKitByName(Config.MemberDefault);
|
||||
if(Config.PersonalKits){
|
||||
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.SchematicType.toDB());
|
||||
if(personalKit != null){
|
||||
kit = new Kit(personalKit);
|
||||
}
|
||||
}
|
||||
kills = 0;
|
||||
}
|
||||
|
||||
public void revive() {
|
||||
isOut = false;
|
||||
}
|
||||
|
||||
public void setOut() {
|
||||
isOut = true;
|
||||
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
|
||||
stopEnternCountdown();
|
||||
ifAI(AI::stop);
|
||||
}
|
||||
|
||||
public void startEnternCountdown(Countdown countdown) {
|
||||
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
|
||||
enternCountdown = new EnternCountdown(this, countdown);
|
||||
}
|
||||
|
||||
public void stopEnternCountdown(){
|
||||
if(enternCountdown != null){
|
||||
enternCountdown.disable();
|
||||
}
|
||||
enternCountdown = null;
|
||||
}
|
||||
|
||||
public LivingEntity getEntity() {
|
||||
LivingEntity bukkit = Bukkit.getPlayer(entity.getUniqueId());
|
||||
if(bukkit != null)
|
||||
entity = bukkit;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public SteamwarUser getUser() {
|
||||
return SteamwarUser.get(id);
|
||||
}
|
||||
|
||||
public void ifAI(Consumer<AI> function) {
|
||||
if(entity instanceof Player)
|
||||
return;
|
||||
AI ai = AI.getAI(entity.getUniqueId());
|
||||
if(ai != null)
|
||||
function.accept(ai);
|
||||
}
|
||||
|
||||
public void ifPlayer(Consumer<Player> function) {
|
||||
if(entity instanceof Player)
|
||||
function.accept((Player) entity);
|
||||
}
|
||||
|
||||
public boolean isLiving() {
|
||||
return !this.isOut;
|
||||
}
|
||||
|
||||
public boolean isLeader() {
|
||||
FightPlayer leader = team.getLeader();
|
||||
return leader != null && leader.getEntity() == entity;
|
||||
}
|
||||
|
||||
public void addKill(){
|
||||
kills++;
|
||||
}
|
||||
|
||||
public boolean canEntern(){
|
||||
if(enternCountdown == null)
|
||||
return false;
|
||||
return enternCountdown.getTimeLeft() == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FightSchematic extends StateDependent {
|
||||
|
||||
private final FightTeam team;
|
||||
private final Region region;
|
||||
private final boolean rotate;
|
||||
|
||||
private Clipboard clipboard = null;
|
||||
private int schematic = 0;
|
||||
|
||||
public FightSchematic(FightTeam team, boolean rotate) {
|
||||
super(ArenaMode.All, FightState.PostSchemSetup);
|
||||
this.team = team;
|
||||
this.region = team.getSchemRegion();
|
||||
this.rotate = rotate;
|
||||
register();
|
||||
}
|
||||
|
||||
public boolean hasSchematic() {
|
||||
return clipboard != null;
|
||||
}
|
||||
|
||||
public int getId(){
|
||||
return schematic;
|
||||
}
|
||||
|
||||
public void setSchematic(SchematicNode schem) {
|
||||
schematic = schem.getId();
|
||||
try {
|
||||
clipboard = new SchematicData(schem).load();
|
||||
|
||||
if(schem.replaceColor())
|
||||
replaceTeamColor(clipboard);
|
||||
} catch (IOException e) {
|
||||
team.broadcastSystem("SCHEMATIC_UNLOADABLE");
|
||||
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void setSchematic(int schemId, Clipboard clipboard) {
|
||||
this.schematic = schemId;
|
||||
this.clipboard = clipboard;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
schematic = 0;
|
||||
clipboard = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if(FightState.getFightState() == FightState.SPECTATE)
|
||||
return;
|
||||
|
||||
if(clipboard == null){
|
||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
||||
if(publics.isEmpty()) {
|
||||
for (SchematicType type : Config.SubTypes) {
|
||||
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
||||
if (!publics.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (publics.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||
}
|
||||
|
||||
if(ArenaMode.AntiReplay.contains(Config.mode)) {
|
||||
if(team.isBlue())
|
||||
GlobalRecorder.getInstance().blueSchem(schematic);
|
||||
else
|
||||
GlobalRecorder.getInstance().redSchem(schematic);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||
}
|
||||
|
||||
private void replaceTeamColor(Clipboard clipboard) {
|
||||
try {
|
||||
WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK);
|
||||
} catch (WorldEditException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Could not recolor schematic", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void paste(){
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
|
||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||
WorldeditWrapper.impl.pasteClipboard(
|
||||
clipboard,
|
||||
new Location(Config.world, region.centerX(), region.getMinY(), region.centerZ()),
|
||||
new Vector(
|
||||
Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX()/2.0 - dims.getBlockX() : -dims.getBlockX()/2.0,
|
||||
Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
||||
Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ()/2.0 - dims.getBlockZ() : -dims.getBlockZ()/2.0
|
||||
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
|
||||
new AffineTransform().rotateY(rotate ? 180 : 0)
|
||||
);
|
||||
FightSystem.getHullHider().initialize(team);
|
||||
if(ArenaMode.Check.contains(Config.mode) && !team.isBlue())
|
||||
replaceSync(Material.TNT, Material.OBSIDIAN);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if(!Config.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE)
|
||||
return;
|
||||
|
||||
FreezeWorld freezer = null;
|
||||
if(!Config.ReplaceWithBlockupdates)
|
||||
freezer = new FreezeWorld();
|
||||
|
||||
replaceSync(Material.OBSIDIAN, Material.TNT);
|
||||
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
||||
|
||||
if(!Config.ReplaceWithBlockupdates)
|
||||
freezer.disable();
|
||||
}
|
||||
|
||||
public void pasteTeamName(){
|
||||
char[] chars = team.getName().toCharArray();
|
||||
Clipboard[] characters = new Clipboard[chars.length];
|
||||
|
||||
int length = 0;
|
||||
int[] offsets = new int[chars.length];
|
||||
|
||||
for(int i = 0; i < chars.length; i++){
|
||||
Clipboard character;
|
||||
try {
|
||||
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
||||
try {
|
||||
character = WorldeditWrapper.impl.loadChar("");
|
||||
}catch (IOException ex) {
|
||||
throw new SecurityException("Could not load text", ex);
|
||||
}
|
||||
}
|
||||
|
||||
replaceTeamColor(character);
|
||||
|
||||
characters[i] = character;
|
||||
offsets[i] = length;
|
||||
length += WorldeditWrapper.impl.getDimensions(character).getBlockX() + 1; // 1 is the distance between characters
|
||||
}
|
||||
|
||||
length -= 1;
|
||||
AffineTransform aT = new AffineTransform().rotateY(((team == Fight.getRedTeam()) == (Config.BlueToRedZ > 0)) ? 180 : 0);
|
||||
Location base = new Location(Config.world, region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
||||
for(int i = 0; i < characters.length; i++){
|
||||
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceSync(Material target, Material replacement){
|
||||
region.forEach((x, y, z) -> {
|
||||
Block block = Config.world.getBlockAt(x, y, z);
|
||||
if(block.getType() == target)
|
||||
block.setType(replacement);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
import de.steamwar.fightsystem.listener.Permanent;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.listener.TeamArea;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.NameTagVisibility;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public class FightTeam {
|
||||
|
||||
private static void setKitButton(HotbarKit kit, boolean leader) {
|
||||
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
|
||||
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
|
||||
else
|
||||
kit.setItem(1, null, null, null);
|
||||
}
|
||||
|
||||
private static final HotbarKit memberKit = new HotbarKit();
|
||||
static {
|
||||
setKitButton(memberKit, false);
|
||||
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
|
||||
}
|
||||
private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
|
||||
static {
|
||||
setKitButton(notReadyKit, true);
|
||||
|
||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
|
||||
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
|
||||
}
|
||||
|
||||
if(Config.test())
|
||||
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
|
||||
|
||||
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
|
||||
}
|
||||
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
|
||||
static {
|
||||
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
|
||||
}
|
||||
private static final HotbarKit readyKit = new HotbarKit(memberKit);
|
||||
static {
|
||||
readyKit.setItem(1, null, null, null);
|
||||
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
|
||||
}
|
||||
|
||||
@Getter
|
||||
private UUID designatedLeader;
|
||||
@Getter
|
||||
private FightPlayer leader;
|
||||
@Getter
|
||||
private boolean publicsOnly;
|
||||
|
||||
private final Map<UUID, FightPlayer> players = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private String name;
|
||||
@Getter
|
||||
private String prefix;
|
||||
@Getter
|
||||
private ChatColor color;
|
||||
private final FightSchematic schematic;
|
||||
private final Team team;
|
||||
@Getter
|
||||
private final boolean blue;
|
||||
|
||||
@Getter
|
||||
private boolean ready;
|
||||
private boolean skip;
|
||||
|
||||
@Getter
|
||||
private final Location spawn;
|
||||
@Getter
|
||||
private final Region schemRegion;
|
||||
@Getter
|
||||
private final Region extendRegion;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public FightTeam(String name, String prefix, Location spawn, Region schemRegion, Region extendRegion, boolean rotate, boolean blue, UUID designatedLeader) { //TODO: Static TeamConfig object
|
||||
this.spawn = spawn;
|
||||
this.schemRegion = schemRegion;
|
||||
this.extendRegion = extendRegion;
|
||||
this.publicsOnly = false;
|
||||
this.ready = false;
|
||||
this.skip = false;
|
||||
this.blue = blue;
|
||||
this.designatedLeader = designatedLeader;
|
||||
setPrefixAndName(prefix, name);
|
||||
this.schematic = new FightSchematic(this, rotate);
|
||||
new KitLoader();
|
||||
new SpectateHandler();
|
||||
new TeamArea(this);
|
||||
|
||||
team = FightScoreboard.getBukkitTeam(name);
|
||||
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
||||
BountifulWrapper.impl.setNametagVisibility(team);
|
||||
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
||||
if (!Config.ActiveWinconditions.contains(Winconditions.AMONG_US)) {
|
||||
team.setAllowFriendlyFire(false);
|
||||
}
|
||||
|
||||
new OneShotStateDependent(ArenaMode.Restartable, FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
|
||||
new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
|
||||
if(leader != null)
|
||||
leader.ifPlayer(notReadyKit::loadToPlayer);
|
||||
});
|
||||
}
|
||||
|
||||
public void setPrefixAndName(String prefix, String name){
|
||||
this.name = name;
|
||||
this.prefix = prefix;
|
||||
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||
}
|
||||
|
||||
public boolean canbeLeader(Player p){
|
||||
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||
}
|
||||
|
||||
public void teleportToSpawn(){
|
||||
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
|
||||
}
|
||||
|
||||
public FightPlayer getFightPlayer(LivingEntity player) {
|
||||
return players.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean allPlayersOut() {
|
||||
for(FightPlayer fightPlayer : players.values()) {
|
||||
if(fightPlayer.isLiving())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPlayerInTeam(LivingEntity player) {
|
||||
return players.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean canPlayerEntern(LivingEntity player) {
|
||||
return getFightPlayer(player).canEntern();
|
||||
}
|
||||
|
||||
public boolean isPlayerLeader(LivingEntity player) {
|
||||
if(leader != null)
|
||||
return leader.getEntity().equals(player);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
skip = false;
|
||||
ready = false;
|
||||
schematic.reset();
|
||||
|
||||
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
||||
playerSet.removeIf(uuid -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
removePlayer(players.get(uuid).getEntity());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
FightPlayer leaderBackup = leader;
|
||||
players.clear();
|
||||
leader = null;
|
||||
|
||||
if(leaderBackup != null){
|
||||
playerSet.remove(leaderBackup.getEntity().getUniqueId());
|
||||
addMember(leaderBackup.getEntity(), leaderBackup.getUser(), true);
|
||||
}
|
||||
|
||||
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true));
|
||||
|
||||
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
|
||||
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
Collections.shuffle(onlinePlayers);
|
||||
for(Player player : onlinePlayers) {
|
||||
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
|
||||
addMember(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcast(String message, Object... params) {
|
||||
broadcast(player -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params));
|
||||
}
|
||||
|
||||
public void broadcastSystem(String message, Object... params) {
|
||||
broadcast(player -> FightSystem.getMessage().send(message, player, params));
|
||||
}
|
||||
|
||||
public void broadcastChat(Player sender, String message) {
|
||||
broadcast(player -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message));
|
||||
}
|
||||
|
||||
private void broadcast(Consumer<Player> f) {
|
||||
players.forEach((uuid, fightPlayer) -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null)
|
||||
f.accept(player);
|
||||
});
|
||||
}
|
||||
|
||||
public void addMember(Player player) {
|
||||
addMember(player, SteamwarUser.get(player.getUniqueId()), false);
|
||||
}
|
||||
|
||||
public void addMember(LivingEntity entity, SteamwarUser user) {
|
||||
addMember(entity, user, false);
|
||||
}
|
||||
|
||||
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) {
|
||||
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
|
||||
fightPlayer.revive();
|
||||
players.put(entity.getUniqueId(), fightPlayer);
|
||||
Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer));
|
||||
|
||||
Permanent.getSpectatorTeam().removeEntry(entity.getName());
|
||||
team.addEntry(entity.getName());
|
||||
|
||||
entity.setHealth(20);
|
||||
entity.teleport(spawn);
|
||||
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
BountifulWrapper.impl.setAttackSpeed(player);
|
||||
player.setFoodLevel(20);
|
||||
player.getInventory().clear();
|
||||
FightSystem.getHullHider().updatePlayer(player);
|
||||
|
||||
if(FightState.Spectate.contains(FightState.getFightState())) {
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
} else {
|
||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
|
||||
}
|
||||
});
|
||||
|
||||
if(FightState.Running.contains(FightState.getFightState()))
|
||||
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
|
||||
|
||||
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, fightPlayer.canEntern() ? Region.EMPTY : Fight.getOpposite(this).getExtendRegion()));
|
||||
|
||||
if(isLeaderless())
|
||||
setLeader(fightPlayer, silent);
|
||||
else if(!silent)
|
||||
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, entity.getName());
|
||||
}
|
||||
|
||||
public void removePlayer(LivingEntity entity) {
|
||||
FightPlayer fightPlayer = getFightPlayer(entity);
|
||||
Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
|
||||
|
||||
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
players.remove(entity.getUniqueId());
|
||||
team.removeEntry(entity.getName());
|
||||
Permanent.getSpectatorTeam().addEntry(entity.getName());
|
||||
|
||||
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, entity.getName());
|
||||
|
||||
if(fightPlayer.equals(leader))
|
||||
removeLeader();
|
||||
|
||||
entity.teleport(Config.SpecSpawn);
|
||||
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
player.getInventory().clear();
|
||||
|
||||
if(player.isOnline()){
|
||||
FightSystem.getHullHider().updatePlayer(player);
|
||||
FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, Fight.getOpposite(this).getExtendRegion());
|
||||
|
||||
if(ArenaMode.VariableTeams.contains(Config.mode))
|
||||
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isLeaderless() {
|
||||
return leader == null;
|
||||
}
|
||||
|
||||
private void removeLeader() {
|
||||
this.leader = null;
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.values().iterator().next(), false);
|
||||
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> FightState.setFightState(FightState.PRE_LEADER_SETUP), 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLeader(FightPlayer leader, boolean silent) {
|
||||
leader.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
|
||||
this.leader = leader;
|
||||
designatedLeader = null;
|
||||
if(ready)
|
||||
setReady(false);
|
||||
|
||||
if(!silent)
|
||||
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
||||
|
||||
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty();
|
||||
|
||||
if(!Config.PersonalKits)
|
||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||
|
||||
leader.ifPlayer(player -> {
|
||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
chooseSchemKit.loadToPlayer(player);
|
||||
else
|
||||
notReadyKit.loadToPlayer(player);
|
||||
});
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
}
|
||||
|
||||
leader.ifAI(ai -> pasteSchem(ai.chooseSchematic()));
|
||||
}
|
||||
|
||||
public Collection<FightPlayer> getPlayers() {
|
||||
return players.values();
|
||||
}
|
||||
|
||||
public void pasteSchem() {
|
||||
testPasteAction();
|
||||
}
|
||||
|
||||
public void pasteSchem(SchematicNode schematic){
|
||||
if(schematic.getSchemtype().check()) {
|
||||
FightStatistics.unrank();
|
||||
FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName());
|
||||
}
|
||||
|
||||
setSchem(schematic);
|
||||
testPasteAction();
|
||||
}
|
||||
|
||||
public void pasteSchem(int schemId, Clipboard clipboard){
|
||||
this.schematic.setSchematic(schemId, clipboard);
|
||||
testPasteAction();
|
||||
}
|
||||
|
||||
private void testPasteAction(){
|
||||
if(Config.test())
|
||||
this.schematic.enable();
|
||||
else if(Fight.getOpposite(this).schematic.hasSchematic()){
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
}
|
||||
|
||||
public void pasteTeamName(){
|
||||
schematic.pasteTeamName();
|
||||
}
|
||||
|
||||
public void setSchem(SchematicNode schematic){
|
||||
this.schematic.setSchematic(schematic);
|
||||
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getName());
|
||||
}
|
||||
|
||||
public void setReady(boolean ready) {
|
||||
LivingEntity l = leader.getEntity();
|
||||
|
||||
if(!schematic.hasSchematic()){
|
||||
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
this.ready = ready;
|
||||
if(ready) {
|
||||
broadcast("TEAM_READY");
|
||||
leader.ifPlayer(readyKit::loadToPlayer);
|
||||
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
} else {
|
||||
broadcast("TEAM_NOT_READY");
|
||||
leader.ifPlayer(notReadyKit::loadToPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void skip(){
|
||||
this.skip = !skip;
|
||||
if(skip){
|
||||
broadcast("SKIP_READY");
|
||||
if(Fight.getOpposite(this).skip || Config.test()){
|
||||
skip = false;
|
||||
Fight.getOpposite(this).skip = false;
|
||||
Countdown.skip();
|
||||
}
|
||||
}else{
|
||||
broadcast("SKIP_NOT_READY");
|
||||
}
|
||||
}
|
||||
|
||||
public String getColoredName() {
|
||||
return prefix + name;
|
||||
}
|
||||
|
||||
public int getSchematic() {
|
||||
return schematic.getId();
|
||||
}
|
||||
|
||||
public double getCurrentHearts() {
|
||||
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
||||
}
|
||||
|
||||
public double getHeartRatio(){
|
||||
int maximumHearts = players.size() * 20;
|
||||
return maximumHearts != 0 ? getCurrentHearts() / maximumHearts : 0;
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
public int getAlivePlayers() {
|
||||
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private class KitLoader extends StateDependent {
|
||||
private KitLoader() {
|
||||
super(ArenaMode.AntiReplay, FightState.Ingame);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
for(FightPlayer fightPlayer : players.values()) {
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
PersonalKitCreator.closeIfInKitCreator(player);
|
||||
|
||||
player.closeInventory();
|
||||
fightPlayer.getKit().loadToPlayer(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(p -> p.getInventory().clear()));
|
||||
}
|
||||
}
|
||||
|
||||
private class SpectateHandler extends StateDependent {
|
||||
private SpectateHandler() {
|
||||
super(ArenaMode.AntiReplay, FightState.Spectate);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
players.values().forEach(fightPlayer -> {
|
||||
fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
|
||||
fightPlayer.getEntity().teleport(FightTeam.this.spawn);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FightWorld extends StateDependent {
|
||||
|
||||
@Getter
|
||||
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
|
||||
|
||||
public FightWorld() {
|
||||
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
//unused
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightWorld::resetWorld); //Delay to prevent raceconditions with techhider and hullhider
|
||||
}
|
||||
|
||||
public static void forceLoad(){
|
||||
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
||||
Config.world.loadChunk(cX, cZ);
|
||||
FlatteningWrapper.impl.forceLoadChunk(Config.world, cX, cZ);
|
||||
});
|
||||
}
|
||||
|
||||
public static void resetWorld(){
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation())))
|
||||
entities.add(entity);
|
||||
});
|
||||
entities.forEach(Entity::remove);
|
||||
entities.clear();
|
||||
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
de.steamwar.core.CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||
}
|
||||
});
|
||||
Bukkit.unloadWorld(backup, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FreezeWorld implements Listener {
|
||||
|
||||
private final Listener denyHandSwap = BountifulWrapper.impl.newDenyHandSwapListener();
|
||||
|
||||
public FreezeWorld(){
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
Bukkit.getPluginManager().registerEvents(denyHandSwap, FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
public void disable(){
|
||||
HandlerList.unregisterAll(this);
|
||||
HandlerList.unregisterAll(denyHandSwap);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||
e.setNewCurrent(e.getOldCurrent());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDispense(BlockDispenseEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockExplosion(BlockExplodeEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockExplosion(ItemSpawnEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
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.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class HotbarKit extends Kit {
|
||||
|
||||
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
|
||||
static {
|
||||
for(int i = 0; i < 9; i++)
|
||||
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest);
|
||||
}
|
||||
|
||||
private static final int HOTBAR_SIZE = 9;
|
||||
|
||||
private final String[] nameTags;
|
||||
private final Consumer<Player>[] onClicks;
|
||||
|
||||
protected HotbarKit(String name, ItemStack[] inventory, ItemStack[] armor, Collection<PotionEffect> effects, String[] nameTags, Consumer<Player>[] onClicks) {
|
||||
super(name, inventory, armor, effects);
|
||||
this.nameTags = nameTags;
|
||||
this.onClicks = onClicks;
|
||||
}
|
||||
|
||||
public HotbarKit() {
|
||||
this(null, new ItemStack[HOTBAR_SIZE], null, null, new String[HOTBAR_SIZE], new Consumer[HOTBAR_SIZE]);
|
||||
}
|
||||
|
||||
public HotbarKit(HotbarKit kit) {
|
||||
this(kit.getName(), kit.getInventory().clone(), kit.getArmor() != null ? kit.getArmor().clone() : null, kit.getEffects(), kit.nameTags.clone(), kit.onClicks.clone());
|
||||
}
|
||||
|
||||
public void setItem(int id, String nameTag, ItemStack stack, Consumer<Player> onClick) {
|
||||
super.setItem(id, stack);
|
||||
nameTags[id] = nameTag;
|
||||
onClicks[id] = onClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void loadToPlayer(Player player) {
|
||||
for(int i = 0; i < HOTBAR_SIZE; i++) {
|
||||
if(nameTags[i] != null) {
|
||||
ItemMeta meta = Objects.requireNonNull(getInventory()[i].getItemMeta());
|
||||
meta.setDisplayName(FightSystem.getMessage().parse(nameTags[i], player, Config.GameName));
|
||||
getInventory()[i].setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
super.loadToPlayer(player);
|
||||
}
|
||||
|
||||
public static class HotbarKitListener implements Listener {
|
||||
|
||||
private static final Set<Player> clicked = new HashSet<>();
|
||||
|
||||
public HotbarKitListener() {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, clicked::clear, 10, 10);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
if(event.getAction() == Action.PHYSICAL || (Core.getVersion() > 8 && event.getHand() != EquipmentSlot.HAND))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(!clicked.add(player))
|
||||
return;
|
||||
|
||||
((HotbarKit)activeKit).onClicks[slot].accept(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JoinRequest {
|
||||
|
||||
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
|
||||
|
||||
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
|
||||
return activeRequests.values().stream().filter(
|
||||
request -> request.waitOnApproval.contains(team)
|
||||
).map(request -> {
|
||||
SWItem item = SWItem.getPlayerSkull(request.player);
|
||||
item.setLore(Arrays.asList(
|
||||
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
|
||||
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
|
||||
));
|
||||
return new SWListInv.SWListEntry<>(item, request.player);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void clearRequests() {
|
||||
activeRequests.clear();
|
||||
}
|
||||
|
||||
public static JoinRequest get(Player player) {
|
||||
return activeRequests.get(player);
|
||||
}
|
||||
|
||||
private final Player player;
|
||||
private final FightTeam team;
|
||||
private final Set<FightTeam> waitOnApproval;
|
||||
|
||||
public JoinRequest(Player player, FightTeam team) {
|
||||
this.player = player;
|
||||
this.team = team;
|
||||
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
|
||||
Set<FightTeam> alreadyAccepted = new HashSet<>();
|
||||
|
||||
activeRequests.put(player, this);
|
||||
for(FightTeam t : waitOnApproval) {
|
||||
FightPlayer leader = t.getLeader();
|
||||
if(leader == null)
|
||||
continue;
|
||||
|
||||
if(leader.getEntity() == null)
|
||||
continue;
|
||||
|
||||
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
|
||||
leader.ifAI(ai -> {
|
||||
if(ai.acceptJoinRequest(player, team))
|
||||
alreadyAccepted.add(t);
|
||||
});
|
||||
}
|
||||
|
||||
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR);
|
||||
alreadyAccepted.forEach(this::accept);
|
||||
}
|
||||
|
||||
public boolean required(FightTeam decider) {
|
||||
return waitOnApproval.contains(decider);
|
||||
}
|
||||
|
||||
public void accept(FightTeam acceptor) {
|
||||
waitOnApproval.remove(acceptor);
|
||||
|
||||
if(waitOnApproval.isEmpty()) {
|
||||
team.addMember(player);
|
||||
activeRequests.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void decline(FightTeam declinor) {
|
||||
FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR);
|
||||
waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", player.getName()));
|
||||
silentDecline();
|
||||
}
|
||||
|
||||
public void silentDecline() {
|
||||
activeRequests.remove(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
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.fightsystem.fight;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.commands.Commands;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Kit {
|
||||
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.KitFile);
|
||||
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
||||
|
||||
protected static final Map<Player, Kit> activeKits = new HashMap<>();
|
||||
|
||||
public static Kit getActiveKit(Player player) {
|
||||
return activeKits.get(player);
|
||||
}
|
||||
|
||||
static {
|
||||
if(!kits.exists()) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Kitconfig fehlend!" + kits.getAbsolutePath());
|
||||
}
|
||||
|
||||
FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits);
|
||||
ConfigurationSection kitSection = kitData.getConfigurationSection("Kits");
|
||||
|
||||
for(String key : Objects.requireNonNull(kitSection).getKeys(false)) {
|
||||
loadedKits.add(new Kit(Objects.requireNonNull(kitSection.getConfigurationSection(key))));
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter
|
||||
private final ItemStack[] inventory;
|
||||
@Getter
|
||||
private final ItemStack[] armor;
|
||||
@Getter
|
||||
private final Collection<PotionEffect> effects;
|
||||
/* In which stage is entern allowed? */
|
||||
@Getter
|
||||
private final int enterStage;
|
||||
/* Is this kit allowed to set/handle tnt? */
|
||||
@Getter
|
||||
private final boolean tnt;
|
||||
private final boolean leaderAllowed;
|
||||
private final boolean memberAllowed;
|
||||
|
||||
protected Kit(String name, ItemStack[] inventory, ItemStack[] armor, Collection<PotionEffect> effects) {
|
||||
this.name = name;
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
this.effects = effects;
|
||||
this.leaderAllowed = true;
|
||||
this.memberAllowed = true;
|
||||
this.enterStage = 0;
|
||||
this.tnt = true;
|
||||
}
|
||||
|
||||
protected Kit(Kit kit) {
|
||||
this(kit.name, kit.inventory.clone(), kit.armor, kit.effects);
|
||||
}
|
||||
|
||||
public Kit(String name, Player player) {
|
||||
this(name, player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getActivePotionEffects());
|
||||
}
|
||||
|
||||
public Kit(PersonalKit kit){
|
||||
this(kit.getName(), kit.getInventory(), kit.getArmor(), Collections.emptyList());
|
||||
}
|
||||
|
||||
public Kit(ConfigurationSection kit){
|
||||
name = kit.getName();
|
||||
inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[0]);
|
||||
if(kit.isList("Armor"))
|
||||
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]);
|
||||
else
|
||||
armor = null;
|
||||
leaderAllowed = kit.getBoolean("LeaderAllowed");
|
||||
memberAllowed = kit.getBoolean("MemberAllowed");
|
||||
if(kit.isList("Effects"))
|
||||
effects = (List<PotionEffect>) kit.getList("Effects");
|
||||
else
|
||||
effects = null;
|
||||
enterStage = kit.getInt("EnterStage", 0);
|
||||
tnt = kit.getBoolean("TNT", true);
|
||||
}
|
||||
|
||||
protected void setItem(int id, ItemStack stack) {
|
||||
inventory[id] = stack;
|
||||
}
|
||||
|
||||
public static Kit getKitByName(String kitName) {
|
||||
for(Kit kit : loadedKits) {
|
||||
if(kit.getName().equalsIgnoreCase(kitName))
|
||||
return kit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Kit> getAvailableKits(boolean leader){
|
||||
List<Kit> kits = new ArrayList<>();
|
||||
for (Kit k : loadedKits) {
|
||||
if (k.canUseKit(leader)){
|
||||
kits.add(k);
|
||||
}
|
||||
}
|
||||
return kits;
|
||||
}
|
||||
|
||||
public boolean canUseKit(boolean leader){
|
||||
if (leader) {
|
||||
return leaderAllowed;
|
||||
} else {
|
||||
return memberAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean leaderExclusive() {
|
||||
return !memberAllowed;
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack stack) {
|
||||
for(ItemStack i : inventory) {
|
||||
if(similar(i, stack))
|
||||
return true;
|
||||
}
|
||||
for(ItemStack i : armor) {
|
||||
if(similar(i, stack))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void toPersonalKit(PersonalKit kit) {
|
||||
kit.setContainer(inventory, armor);
|
||||
}
|
||||
|
||||
public void removeBadItems(){
|
||||
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
||||
assert normal != null;
|
||||
|
||||
for(int i = 0; i < inventory.length; i++){
|
||||
if(isBadItem(inventory[i]))
|
||||
inventory[i] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isBadItem(ItemStack stack){
|
||||
if(stack == null)
|
||||
return false;
|
||||
|
||||
//Check for forbidden item
|
||||
if(Config.ForbiddenItems.contains(stack.getType()))
|
||||
return true;
|
||||
|
||||
//Check for attribute modifiers
|
||||
if(FlatteningWrapper.impl.hasAttributeModifier(stack)){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(stack.hasItemMeta()){
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if(FlatteningWrapper.impl.containsBlockMeta(meta))
|
||||
return true; //Blocks always upwards slabs etc.
|
||||
|
||||
if(hasItems(stack))
|
||||
return true; //Blocks prefilled inventories
|
||||
}
|
||||
|
||||
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
||||
assert normal != null;
|
||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||
}
|
||||
|
||||
private static final Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
|
||||
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
|
||||
private static final Class<?> nbtTagCompound = Reflection.getClass("{nms.nbt}.NBTTagCompound");
|
||||
private static final Reflection.MethodInvoker getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound);
|
||||
private static final Reflection.MethodInvoker getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class);
|
||||
public static boolean hasItems(ItemStack stack) {
|
||||
Set<String> keys = new HashSet<>((Set<String>) getKeys.invoke(getTag.invoke(asNMSCopy.invoke(null, stack))));
|
||||
keys.remove("Enchantments");
|
||||
keys.remove("Damage");
|
||||
return !keys.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isEnchantmentInKit(ItemStack stack){
|
||||
for(ItemStack is : inventory){
|
||||
if(similar(stack, is))
|
||||
return true;
|
||||
}
|
||||
if(armor != null){
|
||||
for(ItemStack is : armor){
|
||||
if(similar(stack, is))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean similar(ItemStack stack, ItemStack stack2){
|
||||
if(stack == null || stack2 == null)
|
||||
return false;
|
||||
if(stack.getType() != stack2.getType())
|
||||
return false;
|
||||
if(stack.hasItemMeta() != stack2.hasItemMeta())
|
||||
return false;
|
||||
if(stack.getItemMeta() == null || stack2.getItemMeta() == null)
|
||||
return true;
|
||||
|
||||
//Enchantment Map comparison used for default similarity check does not work
|
||||
Map<Enchantment, Integer> en = stack.getItemMeta().getEnchants();
|
||||
Map<Enchantment, Integer> en2 = new HashMap<>(stack.getItemMeta().getEnchants());
|
||||
|
||||
for(Map.Entry<Enchantment, Integer> e : en.entrySet()){
|
||||
if(!en2.remove(e.getKey(), e.getValue()))
|
||||
return false;
|
||||
}
|
||||
return en2.isEmpty();
|
||||
}
|
||||
|
||||
public void loadToPlayer(Player player) {
|
||||
activeKits.put(player, this);
|
||||
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setContents(inventory);
|
||||
if(armor != null)
|
||||
player.getInventory().setArmorContents(armor);
|
||||
player.updateInventory();
|
||||
if(effects != null)
|
||||
player.addPotionEffects(effects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a kit preview with the options to go back to kit selection or to select the kit.
|
||||
*/
|
||||
public void preview(Player player){
|
||||
SWInventory inv = new SWInventory(player, 54, name);
|
||||
|
||||
//36 = Inventargröße
|
||||
for(int i = 0; i < 36; i++){
|
||||
if(inventory[i] == null)
|
||||
continue;
|
||||
SWItem item = new SWItem();
|
||||
item.setItemStack(inventory[i]);
|
||||
inv.setItem(i, item);
|
||||
}
|
||||
|
||||
if(armor != null){
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(armor[i] == null)
|
||||
continue;
|
||||
SWItem item = new SWItem();
|
||||
item.setItemStack(armor[i]);
|
||||
inv.setItem(36 + i, item);
|
||||
}
|
||||
}
|
||||
|
||||
if(effects != null){
|
||||
Iterator<PotionEffect> it = effects.iterator();
|
||||
int pos = 44;
|
||||
while(it.hasNext()){
|
||||
PotionEffect effect = it.next();
|
||||
SWItem item = new SWItem(SWItem.getMaterial("POTION"), effect.getType().getName());
|
||||
inv.setItem(pos, item);
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
inv.setCallback(-999, click -> player.closeInventory());
|
||||
if(Config.PersonalKits){
|
||||
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), FightSystem.getMessage().parse("KIT_PREVIEW_EDIT", player), clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), name)));
|
||||
inv.setItem(53, Material.BARRIER, FightSystem.getMessage().parse("KIT_PREVIEW_DELETE", player), clickType -> {
|
||||
player.closeInventory();
|
||||
SWInventory conf = new SWInventory(player, 9, FightSystem.getMessage().parse("KIT_DELETION_CONFIRMATION", player));
|
||||
conf.setItem(8, SWItem.getDye(1), FightSystem.getMessage().parse("KIT_DELETION_ABORT", player), click -> player.closeInventory());
|
||||
conf.setItem(0, SWItem.getDye(10), FightSystem.getMessage().parse("KIT_DELETION_DELETE", player), click -> {
|
||||
player.closeInventory();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
PersonalKit kit = PersonalKit.get(user.getId(), Config.SchematicType.toDB(), name);
|
||||
if(kit.isInUse()) {
|
||||
List<PersonalKit> kits = PersonalKit.get(user.getId(), Config.SchematicType.toDB());
|
||||
if(!kits.isEmpty()){
|
||||
PersonalKit kit1 = kits.get(0);
|
||||
kit1.setInUse();
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||
assert fightPlayer != null;
|
||||
fightPlayer.setKit(new Kit(kit1));
|
||||
}
|
||||
}
|
||||
kit.delete();
|
||||
});
|
||||
conf.open();
|
||||
});
|
||||
}
|
||||
inv.setItem(45, SWItem.getDye(10), (byte)10, FightSystem.getMessage().parse("KIT_PREVIEW_CHOOSE", player), click -> {
|
||||
Commands.kit(player, name);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setItem(53, SWItem.getDye(1), (byte)1, FightSystem.getMessage().parse("KIT_PREVIEW_BACK", player), click -> GUI.kitSelection(player, ""));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void createKit(String kitName, Player player){
|
||||
loadedKits.add(new Kit(kitName, player));
|
||||
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||
for(Kit k : loadedKits){
|
||||
ConfigurationSection section = yamlConfiguration.createSection("Kits." + k.getName());
|
||||
section.set("Items", k.inventory);
|
||||
if(k.armor != null)
|
||||
section.set("Armor", k.armor);
|
||||
section.set("LeaderAllowed", k.leaderAllowed);
|
||||
section.set("MemberAllowed", k.memberAllowed);
|
||||
section.set("Effects", k.effects);
|
||||
section.set("EnterStage", k.enterStage);
|
||||
section.set("TNT", k.tnt);
|
||||
}
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(kits);
|
||||
}catch(IOException e){
|
||||
throw new SecurityException("Failed to save kits.data", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class ArenaBorder implements Listener {
|
||||
|
||||
private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING", "ArenaBorder.spectatorBorder");
|
||||
private final Border playerBorder = new Border(Config.PlayerRegion.to2d(), true, 5, "NO_ARENA_LEAVING", "ArenaBorder.playerBorder");
|
||||
|
||||
public ArenaBorder() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
|
||||
new StateDependentListener(!Config.GroundWalkable, FightState.AntiRunning, new Listener() {
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if(e.getTo().getY() <= Config.PlayerRegion.getMinY() && playerBorder.contains(player))
|
||||
player.teleport(Fight.getPlayerTeam(player).getSpawn());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
addToSpectator(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeamJoin(TeamSpawnEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
spectatorBorder.removePlayer(player);
|
||||
playerBorder.addPlayer(player);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeamDeath(TeamDeathEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
playerBorder.removePlayer(player);
|
||||
addToSpectator(player);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeamLeave(TeamLeaveEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
playerBorder.removePlayer(player);
|
||||
addToSpectator(player);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
spectatorBorder.removePlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
private void damage() {
|
||||
Fight.teams().forEach(team -> {
|
||||
for(FightPlayer fp : team.getPlayers()) {
|
||||
LivingEntity entity = fp.getEntity();
|
||||
if(fp.isLiving() && entity.getLocation().getY() <= Config.PlayerRegion.getMinY())
|
||||
entity.damage(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addToSpectator(Player player) {
|
||||
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
|
||||
return;
|
||||
|
||||
spectatorBorder.addPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArrowStopper {
|
||||
|
||||
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
|
||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
|
||||
public ArrowStopper() {
|
||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
private static final Class<?> entityArrow = Reflection.getClass("{nms.world.entity.projectile}.EntityArrow");
|
||||
private void run() {
|
||||
Recording.iterateOverEntities(entityArrow::isInstance, entity -> {
|
||||
Projectile arrow = (Projectile) entity;
|
||||
if (invalidEntity(arrow))
|
||||
return;
|
||||
|
||||
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
||||
if (arrow.getTicksLived() == 0){
|
||||
ProjectileSource projSource = arrow.getShooter();
|
||||
if(projSource instanceof Player)
|
||||
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
|
||||
else
|
||||
return;
|
||||
}
|
||||
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
||||
arrow.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkBlocks(Block start, Block end) {
|
||||
Block cursor = start;
|
||||
|
||||
while (!cursor.getLocation().equals(end.getLocation())) {
|
||||
BlockFace nearest = BlockFace.SELF;
|
||||
double nearestDistance = cursor.getLocation().distance(end.getLocation());
|
||||
for (BlockFace face : BLOCK_FACES) {
|
||||
Block relative = cursor.getRelative(face);
|
||||
double distance = relative.getLocation().distance(end.getLocation());
|
||||
if(distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
nearest = face;
|
||||
}
|
||||
}
|
||||
cursor = cursor.getRelative(nearest);
|
||||
if(checkBlock(cursor))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkBlock(Block block) {
|
||||
return Config.HiddenBlocks.contains(block.getType());
|
||||
}
|
||||
|
||||
private boolean invalidEntity(Projectile entity) {
|
||||
Location location = entity.getLocation();
|
||||
boolean teamFrom = entity.getVelocity().getZ() > 0;
|
||||
boolean overMid = location.getZ() > Config.SpecSpawn.getZ();
|
||||
boolean otherSide = teamFrom == overMid;
|
||||
return otherSide || !Config.ArenaRegion.inRegion(location) ||
|
||||
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
||||
entity.getVelocity().equals(NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
|
||||
public class BlockFadeListener implements Listener {
|
||||
|
||||
public BlockFadeListener() {
|
||||
new StateDependentListener(Config.DisableSnowMelt, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
if (Config.ArenaRegion.inRegion(event.getBlock()) && (event.getBlock().getType() == Material.SNOW_BLOCK || event.getBlock().getType() == Material.SNOW || event.getBlock().getType() == Material.ICE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class BlockPlaceCollision implements Listener {
|
||||
|
||||
public BlockPlaceCollision() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Block block = event.getBlock();
|
||||
if(!block.getType().isSolid())
|
||||
return;
|
||||
|
||||
// Hitbox size: 0.6xz, 1.8y, 1.5y when sneaking
|
||||
Player player = event.getPlayer();
|
||||
Location min = player.getLocation().add(-0.3, 0, -0.3);
|
||||
Location max = player.getLocation().add(0.3, FlatteningWrapper.impl.isCrouching(player) ? 0.6 : (player.isSneaking() ? 1.5 : 1.8), 0.3);
|
||||
|
||||
Location blockmin = block.getLocation();
|
||||
Location blockmax = block.getLocation().add(1.0, 1.0, 1.0);
|
||||
if(
|
||||
max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() ||
|
||||
max.getY() <= blockmin.getY() || min.getY() >= blockmax.getY() ||
|
||||
max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ()
|
||||
)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Border {
|
||||
|
||||
private final Map<UUID, Set<Block>> ghostBarriers = new HashMap<>();
|
||||
private final Map<UUID, Location> lastLocation = new HashMap<>();
|
||||
private final boolean contain;
|
||||
private final String resetMessage;
|
||||
private final String name;
|
||||
private final Region region;
|
||||
private final int ghostRange;
|
||||
private final int ghostSize;
|
||||
|
||||
public Border(Region region, boolean contain, int ghostRange, String resetMessage, String name) {
|
||||
this.contain = contain;
|
||||
this.resetMessage = resetMessage;
|
||||
this.name = name;
|
||||
this.region = region;
|
||||
this.ghostRange = ghostRange;
|
||||
this.ghostSize = 2*ghostRange + 1;
|
||||
|
||||
new StateDependentTask(ArenaMode.All, FightState.All, this::run, 1, 1);
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
if(ghostBarriers.containsKey(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
|
||||
lastLocation.put(player.getUniqueId(), player.getLocation());
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
|
||||
}
|
||||
|
||||
public boolean contains(Player player) {
|
||||
return ghostBarriers.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
|
||||
lastLocation.remove(player.getUniqueId());
|
||||
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
|
||||
if(blocks == null || !player.isOnline())
|
||||
return;
|
||||
|
||||
for(Block block : blocks)
|
||||
sendChange(player, block, Material.AIR);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
List<UUID> offline = new ArrayList<>();
|
||||
for(Map.Entry<UUID, Set<Block>> entry : ghostBarriers.entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
offline.add(uuid);
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = player.getLocation();
|
||||
if(region.playerInRegion(location) != contain) {
|
||||
player.teleport(lastLocation.get(uuid));
|
||||
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Block> ghostBlocks = entry.getValue();
|
||||
Region ghostRegion = Region.fromSize(location.getBlockX() - ghostRange, location.getBlockY() - ghostRange, location.getBlockZ() - ghostRange, ghostSize, ghostSize, ghostSize);
|
||||
ghostBlocks.removeIf(block -> {
|
||||
if(!ghostRegion.inRegion(block)) {
|
||||
sendChange(player, block, Material.AIR);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if(contain) {
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||
} else {
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
|
||||
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
|
||||
}
|
||||
|
||||
lastLocation.put(entry.getKey(), location);
|
||||
}
|
||||
|
||||
offline.forEach(uuid -> FightSystem.getPlugin().getLogger().log(Level.INFO, () -> uuid + " was removed from border " + name));
|
||||
offline.forEach(ghostBarriers::remove);
|
||||
offline.forEach(lastLocation::remove);
|
||||
}
|
||||
|
||||
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {
|
||||
border.forEach((x, y, z) -> {
|
||||
Block block = Config.world.getBlockAt(x, y, z);
|
||||
if(ghostBlocks.add(block))
|
||||
sendChange(player, block, Material.BARRIER);
|
||||
});
|
||||
}
|
||||
|
||||
private void sendChange(Player player, Block block, Material type) {
|
||||
if(block.getType() == Material.AIR)
|
||||
FlatteningWrapper.impl.sendBlockChange(player, block, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Chat implements Listener {
|
||||
|
||||
public Chat(){
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String message = event.getMessage();
|
||||
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, player.getName() + "» " + message);
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam != null) {
|
||||
String teamName = fightTeam.getColoredName();
|
||||
if(message.startsWith(Config.TeamChatDetection)) {
|
||||
fightTeam.broadcastChat(player, message.substring(1));
|
||||
} else {
|
||||
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
||||
}
|
||||
}else if(Config.isReferee(player)){
|
||||
broadcastChat("FIGHTLEADER_CHAT", player.getName(), message);
|
||||
}else{
|
||||
broadcastChat("SPECTATOR_CHAT", player.getName(), message);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public static void broadcastChat(String message, Object... params) {
|
||||
GlobalRecorder.getInstance().chat(message, params);
|
||||
FightSystem.getMessage().chat(message, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Check implements Listener {
|
||||
|
||||
public Check() {
|
||||
new StateDependentListener(ArenaMode.Check, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e){
|
||||
Player player = e.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
if(user.hasPerm(UserPerm.CHECK))
|
||||
return;
|
||||
|
||||
SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID);
|
||||
if(user.getId() == schem.getOwner())
|
||||
return;
|
||||
|
||||
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);
|
||||
player.kickPlayer("");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player);
|
||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class ClickAnalyzer {
|
||||
|
||||
private static final PrintStream output;
|
||||
|
||||
static {
|
||||
try {
|
||||
output = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(Config.world.getWorldFolder(), "clicks.csv"))));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ClickAnalyzer() {
|
||||
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
|
||||
if(Core.getVersion() > 8)
|
||||
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"), this::onBlockPlace);
|
||||
}
|
||||
|
||||
public Object onBlockPlace(Player player, Object packet) {
|
||||
synchronized(output) {
|
||||
output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
public class DenyInventoryMovement implements Listener {
|
||||
|
||||
public DenyInventoryMovement() {
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiIngame, this);
|
||||
|
||||
Listener listener = BountifulWrapper.impl.newDenyHandSwapListener();
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiIngame, listener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemPickup(PlayerPickupItemEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user