Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
685e4e5c4b
Commit
4d9e6bbb9d
@ -35,7 +35,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
public class WorldOfColorWrapper12 implements WorldOfColorWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void setTeamColor(Team team, ChatColor color) {
|
public void setTeamColor(Team team, ChatColor color) {
|
||||||
team.setColor(color);
|
team.setColor(color);
|
||||||
|
@ -30,7 +30,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper {
|
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||||
@Override
|
@Override
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -72,7 +72,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper {
|
public class FlatteningWrapper14 implements FlatteningWrapper {
|
||||||
@Override
|
@Override
|
||||||
public DyeColor getSilver() {
|
public DyeColor getSilver() {
|
||||||
return DyeColor.LIGHT_GRAY;
|
return DyeColor.LIGHT_GRAY;
|
||||||
|
@ -40,9 +40,9 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
|||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -56,7 +56,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
|
public class WorldeditWrapper14 implements WorldeditWrapper {
|
||||||
|
|
||||||
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
|
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
World w = new BukkitWorld(Config.world);
|
||||||
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
|
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));
|
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
@ -30,7 +30,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockIdWrapper15 implements BlockIdWrapper.IBlockIdWrapper {
|
public class BlockIdWrapper15 implements BlockIdWrapper {
|
||||||
@Override
|
@Override
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -72,7 +72,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockIdWrapper18 implements BlockIdWrapper.IBlockIdWrapper {
|
public class BlockIdWrapper18 implements BlockIdWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
|
@ -35,7 +35,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
@ -65,7 +65,7 @@ public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().H().a().spliterator(), false);
|
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().H().a().spliterator(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.bukkit.block.Block;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
|
public class BlockIdWrapper8 implements BlockIdWrapper {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
|
@ -38,7 +38,7 @@ import org.bukkit.scoreboard.Team;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
public class BountifulWrapper8 implements BountifulWrapper {
|
||||||
|
|
||||||
public BountifulWrapper8() {
|
public BountifulWrapper8() {
|
||||||
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
||||||
|
@ -34,7 +34,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -68,7 +68,7 @@ public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
|
public class FlatteningWrapper8 implements FlatteningWrapper {
|
||||||
@Override
|
@Override
|
||||||
public DyeColor getSilver() {
|
public DyeColor getSilver() {
|
||||||
return DyeColor.SILVER;
|
return DyeColor.SILVER;
|
||||||
|
@ -26,7 +26,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
public class WorldOfColorWrapper8 implements WorldOfColorWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void setTeamColor(Team team, ChatColor color) {
|
public void setTeamColor(Team team, ChatColor color) {
|
||||||
team.setPrefix("§" + color.getChar());
|
team.setPrefix("§" + color.getChar());
|
||||||
|
@ -37,9 +37,9 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -55,7 +55,7 @@ import java.util.Set;
|
|||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
|
public class WorldeditWrapper8 implements WorldeditWrapper {
|
||||||
|
|
||||||
protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
||||||
protected static final Set<BaseBlock> colorBlocks = new HashSet<>();
|
protected static final Set<BaseBlock> colorBlocks = new HashSet<>();
|
||||||
@ -117,12 +117,12 @@ public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clipboard loadChar(String charName) throws IOException {
|
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(Bukkit.getWorlds().get(0)).getWorldData());
|
return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Config.world).getWorldData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
World w = new BukkitWorld(Config.world);
|
||||||
Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
|
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));
|
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE));
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
@ -45,7 +45,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
public class BountifulWrapper9 implements BountifulWrapper {
|
||||||
|
|
||||||
private static final Class<?> enumHand = Reflection.getClass("{nms.world}.EnumHand");
|
private static final Class<?> enumHand = Reflection.getClass("{nms.world}.EnumHand");
|
||||||
private static final Object mainHand = enumHand.getEnumConstants()[0];
|
private static final Object mainHand = enumHand.getEnumConstants()[0];
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void resetChunk(World world, World backup, int x, int z) {
|
public void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
||||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> tntIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.fightsystem.utils.Region;
|
|||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -30,6 +31,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -118,6 +120,7 @@ public class Config {
|
|||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
private static final int EventKampfID;
|
private static final int EventKampfID;
|
||||||
|
public static final EventFight EventKampf;
|
||||||
public static final int EventTeamBlueID;
|
public static final int EventTeamBlueID;
|
||||||
public static final int EventTeamRedID;
|
public static final int EventTeamRedID;
|
||||||
public static final boolean BothTeamsPublic;
|
public static final boolean BothTeamsPublic;
|
||||||
@ -144,7 +147,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
|
||||||
|
|
||||||
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
File worldConfigFile = new File(world.getWorldFolder(), "config.yml");
|
||||||
if(!worldConfigFile.exists()) {
|
if(!worldConfigFile.exists()) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
@ -232,8 +235,6 @@ public class Config {
|
|||||||
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
||||||
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
TeamBlueSpawn = new Location(world,
|
TeamBlueSpawn = new Location(world,
|
||||||
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
||||||
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||||
@ -332,8 +333,7 @@ public class Config {
|
|||||||
EventTeamBlueID = team1.getTeamId();
|
EventTeamBlueID = team1.getTeamId();
|
||||||
EventTeamRedID = team2.getTeamId();
|
EventTeamRedID = team2.getTeamId();
|
||||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||||
|
EventKampf = eventFight;
|
||||||
FightSystem.setEventFight(eventFight);
|
|
||||||
|
|
||||||
Event event = Event.get(eventFight.getEventID());
|
Event event = Event.get(eventFight.getEventID());
|
||||||
if(BothTeamsPublic) {
|
if(BothTeamsPublic) {
|
||||||
@ -353,6 +353,7 @@ public class Config {
|
|||||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
||||||
EventTeamBlueID = 0;
|
EventTeamBlueID = 0;
|
||||||
EventTeamRedID = 0;
|
EventTeamRedID = 0;
|
||||||
|
EventKampf = null;
|
||||||
BothTeamsPublic = true;
|
BothTeamsPublic = true;
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||||
LiveReplay = false;
|
LiveReplay = false;
|
||||||
@ -397,4 +398,10 @@ public class Config {
|
|||||||
public static boolean blueNegZ(){
|
public static boolean blueNegZ(){
|
||||||
return BlueToRedZ > 0;
|
return BlueToRedZ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isReferee(Player player) {
|
||||||
|
if(EventKampf == null)
|
||||||
|
return false;
|
||||||
|
return SteamwarUser.get(player.getUniqueId()).getId() == EventKampf.getKampfleiter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,17 +35,13 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import de.steamwar.sql.EventFight;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class FightSystem extends JavaPlugin {
|
public class FightSystem extends JavaPlugin {
|
||||||
|
|
||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
private static EventFight eventFight;
|
|
||||||
private static Player eventLeiter;
|
|
||||||
|
|
||||||
private Message message;
|
private Message message;
|
||||||
private FightTeam lastWinner;
|
private FightTeam lastWinner;
|
||||||
@ -103,17 +99,17 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new WinconditionAllDead();
|
new WinconditionAllDead();
|
||||||
new WinconditionCaptainDead();
|
new WinconditionCaptainDead();
|
||||||
new WinconditionPumpkinTechKO();
|
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
||||||
new WinconditionWaterTechKO();
|
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
|
||||||
new WinconditionPercentSystem();
|
new WinconditionPercentSystem();
|
||||||
new WinconditionBlacklistPercent();
|
new WinconditionBlacklistPercent();
|
||||||
new WinconditionWhitelistPercent();
|
new WinconditionWhitelistPercent();
|
||||||
new WinconditionPoints();
|
new WinconditionPoints();
|
||||||
new WinconditionTimeout();
|
new WinconditionTimeout();
|
||||||
new WinconditionHeartRatioTimeout();
|
|
||||||
new WinconditionTimeTechKO();
|
new WinconditionTimeTechKO();
|
||||||
new EventTeamOffWincondition();
|
new EventTeamOffWincondition();
|
||||||
new WinconditionPercentTimeout();
|
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 HellsBells();
|
||||||
new Meteor();
|
new Meteor();
|
||||||
@ -150,7 +146,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
FileSource.startReplay();
|
FileSource.startReplay();
|
||||||
|
|
||||||
if(Config.mode == ArenaMode.EVENT) {
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
setPreSchemState();
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
}else if(Config.mode == ArenaMode.CHECK){
|
}else if(Config.mode == ArenaMode.CHECK){
|
||||||
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
|
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
|
||||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||||
@ -163,26 +159,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
GlobalRecorder.getInstance().close();
|
GlobalRecorder.getInstance().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreLeaderState() {
|
|
||||||
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPreSchemState() {
|
|
||||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPostSchemState() {
|
|
||||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPreRunningState() {
|
|
||||||
FightState.setFightState(FightState.PRE_RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setRunningState() {
|
|
||||||
FightState.setFightState(FightState.RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) {
|
public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) {
|
||||||
plugin.lastWinner = winFightTeam;
|
plugin.lastWinner = winFightTeam;
|
||||||
plugin.lastWinreason = winreason;
|
plugin.lastWinreason = winreason;
|
||||||
@ -191,22 +167,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setEventLeiter(Player el){
|
|
||||||
eventLeiter = el;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Player getEventLeiter(){
|
|
||||||
return eventLeiter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EventFight getEventFight(){
|
|
||||||
return eventFight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setEventFight(EventFight ef){
|
|
||||||
eventFight = ef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightSystem getPlugin() {
|
public static FightSystem getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
@ -69,14 +69,17 @@ public class GUI {
|
|||||||
|
|
||||||
public static void state(Player p){
|
public static void state(Player p){
|
||||||
SWInventory inv = new SWInventory(p, 9, msg.parse("STATE_TITLE", p));
|
SWInventory inv = new SWInventory(p, 9, msg.parse("STATE_TITLE", p));
|
||||||
inv.setItem(0, Material.GLASS, msg.parse("STATE_PRE_LEADER_SETUP", p), (ClickType click) -> FightSystem.setPreLeaderState());
|
int i = 0;
|
||||||
inv.setItem(1, Material.GLASS, msg.parse("STATE_PRE_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPreSchemState());
|
for(FightState state : FightState.values()) {
|
||||||
inv.setItem(2, Material.GLASS, msg.parse("STATE_POST_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPostSchemState());
|
if(state == FightState.SPECTATE)
|
||||||
inv.setItem(3, Material.GLASS, msg.parse("STATE_PRE_RUNNING", p), (ClickType click) -> FightSystem.setPreRunningState());
|
continue;
|
||||||
inv.setItem(4, Material.GLASS, msg.parse("STATE_RUNNING", p), (ClickType click) -> FightSystem.setRunningState());
|
|
||||||
inv.setItem(5, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getBlueTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", "WIN_FIGHTLEADER"));
|
inv.setItem(i++, Material.GLASS, msg.parse("STATE_" + state.name(), p), click -> FightState.setFightState(state));
|
||||||
inv.setItem(6, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getRedTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", "WIN_FIGHTLEADER"));
|
}
|
||||||
inv.setItem(7, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), (ClickType click) -> FightSystem.setSpectateState(null, "operator", "WIN_FIGHTLEADER"));
|
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.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class GamemodeCommand extends BukkitCommand {
|
|||||||
|
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!(Config.test() || p == FightSystem.getEventLeiter())) {
|
if (!(Config.test() || Config.isReferee(p))) {
|
||||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -42,16 +43,18 @@ public class LeaderCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(Fight.getFightPlayer(player) == null){
|
if(Fight.getFightPlayer(player) != null) {
|
||||||
if(Fight.getBlueTeam().isLeaderless())
|
|
||||||
Fight.getBlueTeam().addMember(player);
|
|
||||||
else if(Fight.getRedTeam().isLeaderless())
|
|
||||||
Fight.getRedTeam().addMember(player);
|
|
||||||
else
|
|
||||||
FightSystem.getMessage().sendPrefixless("LEADER_FULL", player, ChatMessageType.ACTION_BAR);
|
|
||||||
}else
|
|
||||||
FightSystem.getMessage().sendPrefixless("ALREADY_IN_TEAM", player, ChatMessageType.ACTION_BAR);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -24,7 +26,7 @@ public class WinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (p != FightSystem.getEventLeiter()) {
|
if (!Config.isReferee(p)) {
|
||||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -36,10 +38,14 @@ public class WinCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("tie")){
|
if(args[0].equalsIgnoreCase("tie")){
|
||||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||||
}else if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
|
return false;
|
||||||
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "WIN_FIGHTLEADER");
|
}
|
||||||
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
|
|
||||||
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "WIN_FIGHTLEADER");
|
for(FightTeam team : Fight.teams()) {
|
||||||
|
if(args[0].equalsIgnoreCase(team.getName())){
|
||||||
|
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
@ -35,6 +34,6 @@ public class PostSchemCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.setPreRunningState();
|
FightState.setFightState(FightState.PRE_RUNNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
@ -36,6 +35,6 @@ public class PreRunningCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.setRunningState();
|
FightState.setFightState(FightState.RUNNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
@ -36,6 +35,6 @@ public class PreSchemCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.setPostSchemState();
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
@ -36,6 +35,6 @@ public class SpectateOverCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.setPreLeaderState();
|
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ import de.steamwar.fightsystem.utils.Message;
|
|||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -45,7 +43,6 @@ public class HellsBells {
|
|||||||
|
|
||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
|
|
||||||
private final World world = Bukkit.getWorlds().get(0);
|
|
||||||
private final int xLength = Config.RedExtendRegion.getMaxX() - Config.RedExtendRegion.getMinX();
|
private final int xLength = Config.RedExtendRegion.getMaxX() - Config.RedExtendRegion.getMinX();
|
||||||
private final int zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
private final int zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
||||||
private State current = State.PRE;
|
private State current = State.PRE;
|
||||||
@ -100,13 +97,13 @@ public class HellsBells {
|
|||||||
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
||||||
for (int w = 0; w < width; w++) {
|
for (int w = 0; w < width; w++) {
|
||||||
if (direction.isNorthOrWest()) {
|
if (direction.isNorthOrWest()) {
|
||||||
world.spawnEntity(redStart.addAndToLocation(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(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);
|
||||||
|
|
||||||
world.spawnEntity(blueStart.addAndToLocation(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, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
} else {
|
} else {
|
||||||
world.spawnEntity(redStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
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);
|
||||||
|
|
||||||
world.spawnEntity(blueStart.addAndToLocation(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, -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) {
|
if (length.addAndGet(-2) <= 0) {
|
||||||
|
@ -30,11 +30,9 @@ import de.steamwar.fightsystem.utils.Message;
|
|||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.entity.LargeFireball;
|
import org.bukkit.entity.LargeFireball;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -52,7 +50,6 @@ public class Meteor implements Listener {
|
|||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
|
|
||||||
private final Vector vector = new Vector(0, -1, 0);
|
private final Vector vector = new Vector(0, -1, 0);
|
||||||
private final World world = Bukkit.getWorlds().get(0);
|
|
||||||
private final int xLength = Config.RedExtendRegion.getMaxX() - Config.RedExtendRegion.getMinX();
|
private final int xLength = Config.RedExtendRegion.getMaxX() - Config.RedExtendRegion.getMinX();
|
||||||
private final int zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
private final int zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
||||||
private Meteor.State current = Meteor.State.PRE;
|
private Meteor.State current = Meteor.State.PRE;
|
||||||
@ -86,7 +83,7 @@ public class Meteor implements Listener {
|
|||||||
//@EventHandler
|
//@EventHandler
|
||||||
public void explode(ProjectileHitEvent event) {
|
public void explode(ProjectileHitEvent event) {
|
||||||
if (event.getEntity() instanceof Fireball) {
|
if (event.getEntity() instanceof Fireball) {
|
||||||
TNTPrimed tnt = world.spawn(event.getEntity().getLocation(), TNTPrimed.class);
|
TNTPrimed tnt = Config.world.spawn(event.getEntity().getLocation(), TNTPrimed.class);
|
||||||
tnt.setVelocity(new Vector(0, 0, 0));
|
tnt.setVelocity(new Vector(0, 0, 0));
|
||||||
tnt.setFuseTicks(0);
|
tnt.setFuseTicks(0);
|
||||||
tnt.setYield(((Fireball) event.getEntity()).getYield());
|
tnt.setYield(((Fireball) event.getEntity()).getYield());
|
||||||
@ -113,13 +110,13 @@ public class Meteor implements Listener {
|
|||||||
vector.setX(random.nextDouble() - 0.5);
|
vector.setX(random.nextDouble() - 0.5);
|
||||||
vector.setZ(random.nextDouble() - 0.5);
|
vector.setZ(random.nextDouble() - 0.5);
|
||||||
|
|
||||||
LargeFireball fireballRed = world.spawn(redStart.toLocation(world), LargeFireball.class);
|
LargeFireball fireballRed = Config.world.spawn(redStart.toLocation(Config.world), LargeFireball.class);
|
||||||
fireballRed.setDirection(vector);
|
fireballRed.setDirection(vector);
|
||||||
fireballRed.setBounce(false);
|
fireballRed.setBounce(false);
|
||||||
fireballRed.setIsIncendiary(false);
|
fireballRed.setIsIncendiary(false);
|
||||||
fireballRed.setYield(current.explosionSize);
|
fireballRed.setYield(current.explosionSize);
|
||||||
|
|
||||||
LargeFireball fireballBlue = world.spawn(blueStart.toLocation(world), LargeFireball.class);
|
LargeFireball fireballBlue = Config.world.spawn(blueStart.toLocation(Config.world), LargeFireball.class);
|
||||||
vector.setZ(vector.getZ() * -1);
|
vector.setZ(vector.getZ() * -1);
|
||||||
fireballBlue.setDirection(vector);
|
fireballBlue.setDirection(vector);
|
||||||
fireballBlue.setBounce(false);
|
fireballBlue.setBounce(false);
|
||||||
|
@ -33,14 +33,18 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Fight {
|
public class Fight {
|
||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||||
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 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(Player player) {
|
public static FightTeam getPlayerTeam(Player player) {
|
||||||
if(redTeam.isPlayerInTeam(player))
|
if(redTeam.isPlayerInTeam(player))
|
||||||
@ -87,6 +91,10 @@ public class Fight {
|
|||||||
return blueTeam;
|
return blueTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Collection<FightTeam> teams() {
|
||||||
|
return teams;
|
||||||
|
}
|
||||||
|
|
||||||
public static FightTeam getUnrotated() {
|
public static FightTeam getUnrotated() {
|
||||||
return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
|
return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
|
||||||
}
|
}
|
||||||
@ -117,7 +125,7 @@ public class Fight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FightSystem.getEventLeiter() == player || Config.test())
|
if(Config.test() || Config.isReferee(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
|
@ -133,7 +133,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||||
WorldeditWrapper.impl.pasteClipboard(
|
WorldeditWrapper.impl.pasteClipboard(
|
||||||
clipboard,
|
clipboard,
|
||||||
new Location(Bukkit.getWorlds().get(0), region.centerX(), region.getMinY(), region.centerZ()),
|
new Location(Config.world, region.centerX(), region.getMinY(), region.centerZ()),
|
||||||
new Vector(
|
new Vector(
|
||||||
Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX()/2.0 - dims.getBlockX() : -dims.getBlockX()/2.0,
|
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.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
||||||
@ -191,17 +191,15 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
length -= 1;
|
length -= 1;
|
||||||
AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
|
AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
|
||||||
Location base = new Location(Bukkit.getWorlds().get(0), region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
Location base = new Location(Config.world, region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
||||||
for(int i = 0; i < characters.length; i++){
|
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);
|
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceSync(Material target, Material replacement){
|
private void replaceSync(Material target, Material replacement){
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
region.forEach((x, y, z) -> {
|
region.forEach((x, y, z) -> {
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = Config.world.getBlockAt(x, y, z);
|
||||||
if(block.getType() == target)
|
if(block.getType() == target)
|
||||||
block.setType(replacement);
|
block.setType(replacement);
|
||||||
});
|
});
|
||||||
|
@ -217,8 +217,8 @@ public class FightTeam {
|
|||||||
BountifulWrapper.impl.setAttackSpeed(player);
|
BountifulWrapper.impl.setAttackSpeed(player);
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
||||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build());
|
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build());
|
||||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("RESPAWN", player)).build());
|
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributes().setDisplayName(FightSystem.getMessage().parse("RESPAWN", player)).build());
|
||||||
GlobalRecorder.getInstance().playerJoins(player);
|
GlobalRecorder.getInstance().playerJoins(player);
|
||||||
TechHider.reloadChunks(player, chunksToReload, false);
|
TechHider.reloadChunks(player, chunksToReload, false);
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class FightTeam {
|
|||||||
if(!players.isEmpty()) {
|
if(!players.isEmpty()) {
|
||||||
setLeader(players.values().iterator().next(), false);
|
setLeader(players.values().iterator().next(), false);
|
||||||
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> FightState.setFightState(FightState.PRE_LEADER_SETUP), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,22 +295,22 @@ public class FightTeam {
|
|||||||
Player player = leader.getPlayer();
|
Player player = leader.getPlayer();
|
||||||
Inventory inventory = leader.getPlayer().getInventory();
|
Inventory inventory = leader.getPlayer().getInventory();
|
||||||
if (Kit.getAvailableKits(true).size() > 1 || Config.PersonalKits)
|
if (Kit.getAvailableKits(true).size() > 1 || Config.PersonalKits)
|
||||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build());
|
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build());
|
||||||
else
|
else
|
||||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||||
|
|
||||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("INVITE_PLAYERS", player)).build());
|
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributes().setDisplayName(FightSystem.getMessage().parse("INVITE_PLAYERS", player)).build());
|
||||||
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("REMOVE_PLAYERS", player)).build());
|
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().setDisplayName(FightSystem.getMessage().parse("REMOVE_PLAYERS", player)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", player)).build());
|
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", player)).build());
|
||||||
|
|
||||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_SCHEMATIC", player, Config.GameName)).build());
|
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_SCHEMATIC", player, Config.GameName)).build());
|
||||||
|
|
||||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||||
FightSystem.setPreSchemState();
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ public class FightTeam {
|
|||||||
if(Config.test())
|
if(Config.test())
|
||||||
this.schematic.enable();
|
this.schematic.enable();
|
||||||
else if(Fight.getOpposite(this).schematic.hasSchematic()){
|
else if(Fight.getOpposite(this).schematic.hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,12 +363,12 @@ public class FightTeam {
|
|||||||
|
|
||||||
this.ready = ready;
|
this.ready = ready;
|
||||||
if(ready) {
|
if(ready) {
|
||||||
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName(FightSystem.getMessage().parse("TEAM_READY", l)).build());
|
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName(FightSystem.getMessage().parse("TEAM_READY", l)).build());
|
||||||
broadcast("TEAM_READY");
|
broadcast("TEAM_READY");
|
||||||
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
||||||
FightSystem.setPreRunningState();
|
FightState.setFightState(FightState.PRE_RUNNING);
|
||||||
} else {
|
} else {
|
||||||
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", l)).build());
|
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", l)).build());
|
||||||
broadcast("TEAM_NOT_READY");
|
broadcast("TEAM_NOT_READY");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.fight;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||||
@ -28,13 +29,11 @@ import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class FightWorld extends StateDependent {
|
public class FightWorld extends StateDependent {
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
||||||
|
|
||||||
public static boolean isPaper(){
|
public static boolean isPaper(){
|
||||||
@ -58,22 +57,21 @@ public class FightWorld extends StateDependent {
|
|||||||
|
|
||||||
public static void forceLoad(){
|
public static void forceLoad(){
|
||||||
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
||||||
world.loadChunk(cX, cZ);
|
Config.world.loadChunk(cX, cZ);
|
||||||
FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ);
|
FlatteningWrapper.impl.forceLoadChunk(Config.world, cX, cZ);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetWorld(){
|
public static void resetWorld(){
|
||||||
for(Entity entity : world.getEntities()){
|
Recording.iterateOverEntities(entity -> true, entity -> {
|
||||||
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation()))) {
|
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation())))
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||||
assert backup != null;
|
assert backup != null;
|
||||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||||
CraftbukkitWrapper.impl.resetChunk(world, backup, x, z);
|
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||||
de.steamwar.core.CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
de.steamwar.core.CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -41,10 +41,12 @@ public class ArrowStopper {
|
|||||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
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() {
|
private void run() {
|
||||||
for (Arrow arrow : Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class)) {
|
Recording.iterateOverEntities(entityArrow::isInstance, entity -> {
|
||||||
|
Arrow arrow = (Arrow) entity;
|
||||||
if (invalidEntity(arrow))
|
if (invalidEntity(arrow))
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
||||||
if (arrow.getTicksLived() == 0){
|
if (arrow.getTicksLived() == 0){
|
||||||
@ -52,12 +54,12 @@ public class ArrowStopper {
|
|||||||
if(projSource instanceof Player)
|
if(projSource instanceof Player)
|
||||||
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
|
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
|
||||||
else
|
else
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
||||||
arrow.remove();
|
arrow.remove();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBlocks(Block start, Block end) {
|
private boolean checkBlocks(Block start, Block end) {
|
||||||
@ -95,8 +97,4 @@ public class ArrowStopper {
|
|||||||
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
||||||
entity.getVelocity().equals(NULL_VECTOR);
|
entity.getVelocity().equals(NULL_VECTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IArrowStopper {
|
|
||||||
boolean isInBlock(Arrow e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class Chat implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
||||||
}
|
}
|
||||||
}else if(player == FightSystem.getEventLeiter()){
|
}else if(Config.isReferee(player)){
|
||||||
broadcastChat("FIGHTLEADER_CHAT", player.getName(), message);
|
broadcastChat("FIGHTLEADER_CHAT", player.getName(), message);
|
||||||
}else{
|
}else{
|
||||||
broadcastChat("SPECTATOR_CHAT", player.getName(), message);
|
broadcastChat("SPECTATOR_CHAT", player.getName(), message);
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -32,7 +32,7 @@ public class ClickAnalyzer {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
output = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "clicks.csv"))));
|
output = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(Config.world.getWorldFolder(), "clicks.csv"))));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class EventJoin implements Listener {
|
public class EventJoin implements Listener {
|
||||||
|
|
||||||
@ -49,7 +48,7 @@ public class EventJoin implements Listener {
|
|||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
if(user.getTeam() == Config.EventTeamBlueID ||
|
if(user.getTeam() == Config.EventTeamBlueID ||
|
||||||
user.getTeam() == Config.EventTeamRedID ||
|
user.getTeam() == Config.EventTeamRedID ||
|
||||||
user.getId() == FightSystem.getEventFight().getKampfleiter())
|
Config.isReferee(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, FightSystem.getMessage().parse("NO_PARTICIPANT", player));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, FightSystem.getMessage().parse("NO_PARTICIPANT", player));
|
||||||
@ -60,10 +59,8 @@ public class EventJoin implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
if(user.getId() == FightSystem.getEventFight().getKampfleiter()){
|
if(Config.isReferee(player))
|
||||||
FightSystem.setEventLeiter(player);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if(FightState.Setup.contains(FightState.getFightState())){
|
if(FightState.Setup.contains(FightState.getFightState())){
|
||||||
FightTeam team = null;
|
FightTeam team = null;
|
||||||
@ -93,12 +90,4 @@ public class EventJoin implements Listener {
|
|||||||
if(Config.LiveReplay)
|
if(Config.LiveReplay)
|
||||||
player.kickPlayer(FightSystem.getMessage().parse("NO_PARTICIPANT", player));
|
player.kickPlayer(FightSystem.getMessage().parse("NO_PARTICIPANT", player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerLeave(PlayerQuitEvent event){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if(player == FightSystem.getEventLeiter())
|
|
||||||
FightSystem.setEventLeiter(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
@ -39,14 +38,12 @@ public class NormalJoin implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
if (Fight.getPlayerTeam(player) != null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (fightTeam == null) {
|
FightTeam team = Fight.teams().stream().filter(t -> player.getUniqueId().equals(t.getDesignatedLeader())).findAny( // Player is designated leader of a team
|
||||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
).orElse(Fight.teams().stream().filter(t -> t.canbeLeader(player)).findAny().orElse(null)); // Else search empty team
|
||||||
Fight.getBlueTeam().addMember(player);
|
if(team != null)
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
team.addMember(player);
|
||||||
Fight.getRedTeam().addMember(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import de.steamwar.fightsystem.utils.Region;
|
|||||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -50,9 +49,8 @@ public class PrepareSchem implements Listener {
|
|||||||
public PrepareSchem() {
|
public PrepareSchem() {
|
||||||
new OneShotStateDependent(ArenaMode.Prepare, FightState.PostSchemSetup, () -> Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
new OneShotStateDependent(ArenaMode.Prepare, FightState.PostSchemSetup, () -> Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
stationaryMovingPistons.clear();
|
stationaryMovingPistons.clear();
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
Fight.getUnrotated().getSchemRegion().forEach((x, y, z) -> {
|
Fight.getUnrotated().getSchemRegion().forEach((x, y, z) -> {
|
||||||
if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z)))
|
if(FlatteningWrapper.impl.checkPistonMoving(Config.world.getBlockAt(x, y, z)))
|
||||||
stationaryMovingPistons.add(new Vector(x, y, z));
|
stationaryMovingPistons.add(new Vector(x, y, z));
|
||||||
});
|
});
|
||||||
}, 1));
|
}, 1));
|
||||||
@ -61,7 +59,6 @@ public class PrepareSchem implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
super.disable();
|
super.disable();
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
Region region = Fight.getUnrotated().getExtendRegion();
|
Region region = Fight.getUnrotated().getExtendRegion();
|
||||||
int minY = Fight.getUnrotated().getSchemRegion().getMinY();
|
int minY = Fight.getUnrotated().getSchemRegion().getMinY();
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ public class PrepareSchem implements Listener {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
region.forEach((x, y, z) -> {
|
region.forEach((x, y, z) -> {
|
||||||
if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z)) && !stationaryMovingPistons.contains(new Vector(x, y, z))){
|
if(FlatteningWrapper.impl.checkPistonMoving(Config.world.getBlockAt(x, y, z)) && !stationaryMovingPistons.contains(new Vector(x, y, z))){
|
||||||
FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON");
|
FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
@ -116,8 +113,8 @@ public class PrepareSchem implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP) {
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP) {
|
||||||
FightSystem.setPreSchemState();
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
FightSystem.setPostSchemState();
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
schemExists(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
schemExists(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||||
|
@ -34,11 +34,9 @@ import de.steamwar.fightsystem.utils.*;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -50,12 +48,13 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class Recording implements Listener {
|
public class Recording implements Listener {
|
||||||
|
|
||||||
private static final int AIR = 0;
|
private static final int AIR = 0;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
public static ItemStack disarmNull(ItemStack stack){
|
public static ItemStack disarmNull(ItemStack stack){
|
||||||
if(stack == null)
|
if(stack == null)
|
||||||
@ -68,22 +67,24 @@ public class Recording implements Listener {
|
|||||||
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final Class<?> primedTnt = Reflection.getClass("{nms.world.entity.item}.EntityTNTPrimed");
|
||||||
|
private static final Reflection.MethodInvoker getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null);
|
||||||
|
public static void iterateOverEntities(Predicate<Object> filter, Consumer<Entity> consumer) {
|
||||||
|
CraftbukkitWrapper.impl.entityIterator().filter(filter).map(entity -> (Entity) getBukkitEntity.invoke(entity)).forEach(consumer);
|
||||||
|
}
|
||||||
|
|
||||||
public Recording() {
|
public Recording() {
|
||||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, BountifulWrapper.impl.newHandSwapRecorder());
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, BountifulWrapper.impl.newHandSwapRecorder());
|
||||||
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame){
|
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> Fight.teams().forEach(Recording.this::setKitItems), 1);
|
||||||
setKitItems(Fight.getBlueTeam());
|
|
||||||
setKitItems(Fight.getRedTeam());
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
despawnTeam(Fight.getRedTeam());
|
Fight.teams().forEach(Recording.this::despawnTeam);
|
||||||
despawnTeam(Fight.getBlueTeam());
|
|
||||||
despawnTNT();
|
despawnTNT();
|
||||||
}
|
}
|
||||||
}.register();
|
}.register();
|
||||||
@ -106,14 +107,11 @@ public class Recording implements Listener {
|
|||||||
if(FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
|
if(FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CraftbukkitWrapper.impl.tntIterator().filter(primedTnt::isInstance).forEach(this::trackEntity);
|
iterateOverEntities(primedTnt::isInstance, this::trackEntity);
|
||||||
}, 1, 1);
|
}, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> primedTnt = Reflection.getClass("{nms.world.entity.item}.EntityTNTPrimed");
|
private void trackEntity(Entity entity) {
|
||||||
private static final Reflection.MethodInvoker getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null);
|
|
||||||
private void trackEntity(Object e) {
|
|
||||||
Entity entity = (Entity) getBukkitEntity.invoke(e);
|
|
||||||
GlobalRecorder.getInstance().entityMoves(entity);
|
GlobalRecorder.getInstance().entityMoves(entity);
|
||||||
GlobalRecorder.getInstance().entitySpeed(entity);
|
GlobalRecorder.getInstance().entitySpeed(entity);
|
||||||
}
|
}
|
||||||
@ -297,7 +295,6 @@ public class Recording implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void despawnTNT(){
|
private void despawnTNT(){
|
||||||
for(TNTPrimed tnt : Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class))
|
iterateOverEntities(primedTnt::isInstance, GlobalRecorder.getInstance()::entityDespawns);
|
||||||
GlobalRecorder.getInstance().entityDespawns(tnt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,11 @@ public class TeamArea implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void teamAreas(PlayerMoveEvent event) {
|
public void teamAreas(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(player == FightSystem.getEventLeiter())
|
if(Config.isReferee(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
checkInTeamRegion(event, Fight.getBlueTeam(), player, team);
|
Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
|
||||||
checkInTeamRegion(event, Fight.getRedTeam(), player, team);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -49,15 +49,15 @@ public class TestJoin implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fightTeam == null && (Fight.getRedTeam().isLeaderless() || Fight.getBlueTeam().isLeaderless())) {
|
if (fightTeam == null && Fight.teams().stream().anyMatch(team -> team.canbeLeader(player))) {
|
||||||
FightSystem.getMessage().send("TEST_BECOME_LEADER", player);
|
FightSystem.getMessage().send("TEST_BECOME_LEADER", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
|
|
||||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
||||||
FightSystem.setPreSchemState();
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
FightSystem.setPostSchemState();
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,10 @@ public class WaterRemover implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Location location = event.getLocation();
|
Location location = event.getLocation();
|
||||||
if (Config.BlueExtendRegion.inRegion(location)) {
|
Fight.teams().forEach(team -> {
|
||||||
tnt.put(event.getEntity().getEntityId(), Fight.getBlueTeam());
|
if(team.getExtendRegion().inRegion(location))
|
||||||
} else if (Config.RedExtendRegion.inRegion(location)) {
|
tnt.put(event.getEntity().getEntityId(), team);
|
||||||
tnt.put(event.getEntity().getEntityId(), Fight.getRedTeam());
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -22,14 +22,13 @@ package de.steamwar.fightsystem.record;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class FileRecorder extends StateDependent implements Recorder {
|
public class FileRecorder extends StateDependent implements Recorder {
|
||||||
|
|
||||||
private static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "recording.recording");
|
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
|
||||||
private DataOutputStream outputStream;
|
private DataOutputStream outputStream;
|
||||||
|
|
||||||
public static File getFile() {
|
public static File getFile() {
|
||||||
|
@ -39,7 +39,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -50,8 +49,6 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class PacketProcessor {
|
public class PacketProcessor {
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
private static PacketProcessor currentProcessor = null;
|
private static PacketProcessor currentProcessor = null;
|
||||||
|
|
||||||
public static PacketProcessor currentReplay() {
|
public static PacketProcessor currentReplay() {
|
||||||
@ -348,7 +345,7 @@ public class PacketProcessor {
|
|||||||
if(!Config.ArenaRegion.in2dRegion(x, z))
|
if(!Config.ArenaRegion.in2dRegion(x, z))
|
||||||
return; //Outside of the arena
|
return; //Outside of the arena
|
||||||
|
|
||||||
execSync(() -> BlockIdWrapper.impl.setBlock(world, x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
execSync(() -> BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void particle() throws IOException {
|
private void particle() throws IOException {
|
||||||
@ -364,7 +361,7 @@ public class PacketProcessor {
|
|||||||
|
|
||||||
double finalX = x;
|
double finalX = x;
|
||||||
double finalZ = z;
|
double finalZ = z;
|
||||||
execSync(() -> BountifulWrapper.impl.spawnParticle(world, particleName, finalX + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), finalZ + Config.ArenaRegion.getMinZ()));
|
execSync(() -> BountifulWrapper.impl.spawnParticle(Config.world, particleName, finalX + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), finalZ + Config.ArenaRegion.getMinZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sound() throws IOException {
|
private void sound() throws IOException {
|
||||||
@ -388,7 +385,7 @@ public class PacketProcessor {
|
|||||||
|
|
||||||
Sound sound = Sound.valueOf(soundName);
|
Sound sound = Sound.valueOf(soundName);
|
||||||
|
|
||||||
execSync(() -> WorldOfColorWrapper.impl.playSound(new Location(world, x, y, z), sound, soundCategory, volume, pitch));
|
execSync(() -> WorldOfColorWrapper.impl.playSound(new Location(Config.world, x, y, z), sound, soundCategory, volume, pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void soundAtPlayer() throws IOException {
|
private void soundAtPlayer() throws IOException {
|
||||||
|
@ -53,8 +53,7 @@ public interface Recorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arenaInfo();
|
arenaInfo();
|
||||||
enableTeam(Fight.getBlueTeam());
|
Fight.teams().forEach(this::enableTeam);
|
||||||
enableTeam(Fight.getRedTeam());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void enableTeam(FightTeam team){
|
default void enableTeam(FightTeam team){
|
||||||
|
@ -26,12 +26,9 @@ import org.bukkit.block.Block;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BlockIdWrapper {
|
public interface BlockIdWrapper {
|
||||||
private BlockIdWrapper() {}
|
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface IBlockIdWrapper {
|
|
||||||
int blockToId(Block block);
|
int blockToId(Block block);
|
||||||
void setBlock(World world, int x, int y, int z, int blockState);
|
void setBlock(World world, int x, int y, int z, int blockState);
|
||||||
|
|
||||||
@ -39,5 +36,4 @@ public class BlockIdWrapper {
|
|||||||
int getObfuscateWith();
|
int getObfuscateWith();
|
||||||
|
|
||||||
Object getPose(boolean sneaking);
|
Object getPose(boolean sneaking);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,9 @@ import org.bukkit.scoreboard.Team;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BountifulWrapper {
|
public interface BountifulWrapper {
|
||||||
private BountifulWrapper() {}
|
BountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface IBountifulWrapper {
|
|
||||||
boolean mainHand(Object packet);
|
boolean mainHand(Object packet);
|
||||||
boolean bowInHand(boolean mainHand, Player p);
|
boolean bowInHand(boolean mainHand, Player p);
|
||||||
|
|
||||||
@ -57,5 +54,4 @@ public class BountifulWrapper {
|
|||||||
void setNamedSpawnPosition(Object packet, double x, double y, double z);
|
void setNamedSpawnPosition(Object packet, double x, double y, double z);
|
||||||
|
|
||||||
void sendBar(Player player, FightTeam team, double progress, String text);
|
void sendBar(Player player, FightTeam team, double progress, String text);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class BungeeFightInfo {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
new FightInfoPacket(
|
new FightInfoPacket(
|
||||||
Bukkit.getWorlds().get(0).getName(),
|
Config.world.getName(),
|
||||||
Config.SchematicType.toDB(),
|
Config.SchematicType.toDB(),
|
||||||
"",
|
"",
|
||||||
Fight.getBlueTeam().getColoredName(),
|
Fight.getBlueTeam().getColoredName(),
|
||||||
|
@ -28,17 +28,13 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CraftbukkitWrapper {
|
public interface CraftbukkitWrapper {
|
||||||
private CraftbukkitWrapper() {}
|
CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface ICraftbukkitWrapper {
|
|
||||||
void resetChunk(World world, World backup, int x, int z);
|
void resetChunk(World world, World backup, int x, int z);
|
||||||
void sendResourcePack(Player player, String pack, String sha1);
|
void sendResourcePack(Player player, String pack, String sha1);
|
||||||
float headRotation(Entity e);
|
float headRotation(Entity e);
|
||||||
boolean hasItems(ItemStack stack);
|
boolean hasItems(ItemStack stack);
|
||||||
|
|
||||||
Stream<?> tntIterator();
|
Stream<?> entityIterator();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,12 @@ public class EnterHandler implements IStateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
registerTeam(Fight.getBlueTeam());
|
Fight.teams().forEach(this::registerTeam);
|
||||||
registerTeam(Fight.getRedTeam());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
unregisterTeam(Fight.getBlueTeam());
|
Fight.teams().forEach(this::unregisterTeam);
|
||||||
unregisterTeam(Fight.getRedTeam());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerTeam(FightTeam team){
|
private void registerTeam(FightTeam team){
|
||||||
|
@ -68,11 +68,11 @@ public class FightStatistics {
|
|||||||
|
|
||||||
private void setEventResult() {
|
private void setEventResult() {
|
||||||
if (FightSystem.getLastWinner() == null)
|
if (FightSystem.getLastWinner() == null)
|
||||||
FightSystem.getEventFight().setErgebnis(0);
|
Config.EventKampf.setErgebnis(0);
|
||||||
else if (FightSystem.getLastWinner().isBlue())
|
else if (FightSystem.getLastWinner().isBlue())
|
||||||
FightSystem.getEventFight().setErgebnis(1);
|
Config.EventKampf.setErgebnis(1);
|
||||||
else
|
else
|
||||||
FightSystem.getEventFight().setErgebnis(2);
|
Config.EventKampf.setErgebnis(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disable() {
|
private void disable() {
|
||||||
@ -110,7 +110,7 @@ public class FightStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, remainingTime,
|
int fightId = create(gameMode, Config.world.getName(), starttime, remainingTime,
|
||||||
blueLeader, redLeader, blueSchem, redSchem, win, windescription);
|
blueLeader, redLeader, blueSchem, redSchem, win, windescription);
|
||||||
|
|
||||||
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||||
@ -119,7 +119,7 @@ public class FightStatistics {
|
|||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
|
|
||||||
if (ArenaMode.Event.contains(Config.mode)) {
|
if (ArenaMode.Event.contains(Config.mode)) {
|
||||||
FightSystem.getEventFight().setFight(fightId);
|
Config.EventKampf.setFight(fightId);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -28,12 +28,9 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class FlatteningWrapper {
|
public interface FlatteningWrapper {
|
||||||
private FlatteningWrapper() {}
|
FlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface IFlatteningWrapper {
|
|
||||||
DyeColor getSilver();
|
DyeColor getSilver();
|
||||||
|
|
||||||
boolean isWater(Block block);
|
boolean isWater(Block block);
|
||||||
@ -51,5 +48,4 @@ public class FlatteningWrapper {
|
|||||||
boolean checkPistonMoving(Block block);
|
boolean checkPistonMoving(Block block);
|
||||||
|
|
||||||
void setNamedSpawnPacketDataWatcher(Object packet);
|
void setNamedSpawnPacketDataWatcher(Object packet);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class ItemBuilder {
|
|||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder removeAllAttributs() {
|
public ItemBuilder removeAllAttributes() {
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||||
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
||||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||||
|
@ -161,7 +161,7 @@ public class TechHider extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean bypass(Player p, int chunkX, int chunkZ){
|
public static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||||
if(p == FightSystem.getEventLeiter())
|
if(Config.isReferee(p))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FightTeam ft = Fight.getPlayerTeam(p);
|
FightTeam ft = Fight.getPlayerTeam(p);
|
||||||
|
@ -28,17 +28,13 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
public class WorldOfColorWrapper {
|
public interface WorldOfColorWrapper {
|
||||||
private WorldOfColorWrapper() {}
|
WorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface IWorldOfColorWrapper {
|
|
||||||
void setTeamColor(Team team, ChatColor color);
|
void setTeamColor(Team team, ChatColor color);
|
||||||
boolean isInBlock(Arrow e);
|
boolean isInBlock(Arrow e);
|
||||||
|
|
||||||
void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);
|
void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);
|
||||||
|
|
||||||
void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop);
|
void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,17 +31,13 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class WorldeditWrapper {
|
public interface WorldeditWrapper {
|
||||||
private WorldeditWrapper() {}
|
WorldeditWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
|
||||||
|
|
||||||
public interface IWorldeditWrapper {
|
|
||||||
void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;
|
void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;
|
||||||
int getWaterDepth(Clipboard clipboard);
|
int getWaterDepth(Clipboard clipboard);
|
||||||
void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
|
void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
|
||||||
Vector getDimensions(Clipboard clipboard);
|
Vector getDimensions(Clipboard clipboard);
|
||||||
Clipboard loadChar(String charName) throws IOException;
|
Clipboard loadChar(String charName) throws IOException;
|
||||||
void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException;
|
void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,33 +23,19 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
|
|
||||||
public class EventTeamOffWincondition extends Wincondition{
|
public class EventTeamOffWincondition extends Wincondition{
|
||||||
|
|
||||||
public EventTeamOffWincondition(){
|
public EventTeamOffWincondition(){
|
||||||
super("TeamOffline");
|
super("TeamOffline");
|
||||||
new StateDependent(ArenaMode.Event, FightState.PreRunning) {
|
new OneShotStateDependent(ArenaMode.Event, FightState.PreRunning, () -> {
|
||||||
@Override
|
if(Fight.teams().stream().allMatch(FightTeam::allPlayersOut)){
|
||||||
public void enable() {
|
|
||||||
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
|
|
||||||
win(null, "WIN_OFFLINE_BOTH");
|
win(null, "WIN_OFFLINE_BOTH");
|
||||||
}else{
|
}else{
|
||||||
teamOff(Fight.getBlueTeam());
|
Fight.teams().stream().filter(FightTeam::allPlayersOut).findAny(
|
||||||
teamOff(Fight.getRedTeam());
|
).ifPresent(team -> win(Fight.getOpposite(team), "WIN_OFFLINE", team.getColoredName()));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable() {
|
|
||||||
//Team off is a one time trigger
|
|
||||||
}
|
|
||||||
}.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void teamOff(FightTeam team){
|
|
||||||
if(team.allPlayersOut()){
|
|
||||||
win(Fight.getOpposite(team), "WIN_OFFLINE", team.getColoredName());
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -44,8 +42,6 @@ import java.util.function.ToIntFunction;
|
|||||||
|
|
||||||
public class PercentWincondition extends Wincondition implements PrintableWincondition {
|
public class PercentWincondition extends Wincondition implements PrintableWincondition {
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||||
|
|
||||||
protected BooleanSupplier explosionFilter = () -> !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft();
|
protected BooleanSupplier explosionFilter = () -> !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft();
|
||||||
@ -53,7 +49,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
protected ToIntFunction<FightTeam> totalBlockCalc = team -> {
|
protected ToIntFunction<FightTeam> totalBlockCalc = team -> {
|
||||||
AtomicInteger blocks = new AtomicInteger();
|
AtomicInteger blocks = new AtomicInteger();
|
||||||
team.getSchemRegion().forEach((x, y, z) -> {
|
team.getSchemRegion().forEach((x, y, z) -> {
|
||||||
if (testBlock.test(world.getBlockAt(x, y, z).getType())) {
|
if (testBlock.test(Config.world.getBlockAt(x, y, z).getType())) {
|
||||||
blocks.getAndIncrement();
|
blocks.getAndIncrement();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -74,8 +70,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
|||||||
percentWincondition = this;
|
percentWincondition = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
new TeamPercent(Fight.getBlueTeam(), wincondition);
|
Fight.teams().forEach(team -> new TeamPercent(team, wincondition));
|
||||||
new TeamPercent(Fight.getRedTeam(), wincondition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
|
@ -28,6 +28,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.ToDoubleFunction;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class Wincondition {
|
public abstract class Wincondition {
|
||||||
|
|
||||||
@ -58,4 +60,17 @@ public abstract class Wincondition {
|
|||||||
public static List<PrintableWincondition> getPrintableWinconditions(){
|
public static List<PrintableWincondition> getPrintableWinconditions(){
|
||||||
return printableWinconditions;
|
return printableWinconditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PercentWincondition getPercentWincondition() {
|
||||||
|
return percentWincondition;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
|
||||||
|
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
|
||||||
|
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());
|
||||||
|
if(teams.size() > 1)
|
||||||
|
win(null, tieMessage);
|
||||||
|
else
|
||||||
|
win(teams.get(0), winMessage, teams.get(0).getColoredName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,71 +24,69 @@ import de.steamwar.fightsystem.fight.Fight;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.World;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class WinconditionWaterTechKO extends Wincondition implements PrintableWincondition {
|
public class WinconditionBlocks extends Wincondition implements PrintableWincondition {
|
||||||
|
|
||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
public static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
||||||
|
|
||||||
private final Map<FightTeam, TeamWater> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamBlocks> teamMap = new HashMap<>();
|
||||||
|
private final String barMessage;
|
||||||
|
private final Predicate<Block> isOfType;
|
||||||
|
|
||||||
public WinconditionWaterTechKO() {
|
public WinconditionBlocks(Winconditions wincondition, String windescription, String barMessage, Predicate<Block> isOfType) {
|
||||||
super("WaterTechKO");
|
super(windescription);
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
this.barMessage = barMessage;
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
this.isOfType = isOfType;
|
||||||
|
Fight.teams().forEach(team -> teamMap.put(team, new TeamBlocks(team)));
|
||||||
|
|
||||||
new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200){
|
new StateDependentTask(wincondition, FightState.Ingame, () -> teamMap.values().forEach(TeamBlocks::check), 200, 200){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
teamMap.values().forEach(TeamWater::find);
|
teamMap.values().forEach(TeamBlocks::find);
|
||||||
super.enable();
|
super.enable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.WATER_TECH_KO)){
|
|
||||||
printableWinconditions.add(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void check() {
|
if(Config.ActiveWinconditions.contains(wincondition))
|
||||||
teamMap.values().forEach(TeamWater::check);
|
printableWinconditions.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return new Message("BAR_WATER", team.getPrefix() + teamMap.get(team).water.size());
|
return new Message(barMessage, team.getPrefix() + teamMap.get(team).blocks.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TeamWater {
|
private class TeamBlocks {
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private final List<Block> water = new ArrayList<>();
|
private final List<Block> blocks = new ArrayList<>();
|
||||||
|
|
||||||
private TeamWater(FightTeam team) {
|
private TeamBlocks(FightTeam team) {
|
||||||
this.team = team;
|
this.team = team;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void find() {
|
private void find() {
|
||||||
water.clear();
|
blocks.clear();
|
||||||
team.getExtendRegion().forEach((x, y, z) -> {
|
team.getExtendRegion().forEach((x, y, z) -> {
|
||||||
Block block = WORLD.getBlockAt(x, y, z);
|
Block block = Config.world.getBlockAt(x, y, z);
|
||||||
if (FlatteningWrapper.impl.isWater(block))
|
if (isOfType.test(block))
|
||||||
water.add(block);
|
blocks.add(block);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check() {
|
private void check() {
|
||||||
water.removeIf(block -> !FlatteningWrapper.impl.isWater(block));
|
blocks.removeIf(block -> !isOfType.test(block));
|
||||||
if(water.isEmpty()){
|
if(blocks.isEmpty())
|
||||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -21,29 +21,18 @@ package de.steamwar.fightsystem.winconditions;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class WinconditionHeartRatioTimeout extends Wincondition {
|
import java.util.function.ToDoubleFunction;
|
||||||
|
|
||||||
public WinconditionHeartRatioTimeout() {
|
public class WinconditionComparisonTimeout extends Wincondition {
|
||||||
super("HeartTimeout");
|
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.HEART_RATIO_TIMEOUT)){
|
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.HEART_RATIO_TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void timeOver() {
|
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
|
||||||
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
|
super(windescription);
|
||||||
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
|
if(Config.ActiveWinconditions.contains(wincondition)) {
|
||||||
|
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER")));
|
||||||
if(blueHeartRatio > redHeartRatio) {
|
|
||||||
win(Fight.getBlueTeam(), "WIN_MORE_HEALTH", Fight.getBlueTeam().getPrefix());
|
|
||||||
}else if(blueHeartRatio < redHeartRatio){
|
|
||||||
win(Fight.getRedTeam(), "WIN_MORE_HEALTH", Fight.getRedTeam().getPrefix());
|
|
||||||
}else{
|
|
||||||
win(null, "WIN_TIME_OVER");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
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.winconditions;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
|
||||||
|
|
||||||
public class WinconditionPercentTimeout extends Wincondition {
|
|
||||||
|
|
||||||
public WinconditionPercentTimeout() {
|
|
||||||
super("PercentTimeout");
|
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.PERCENT_TIMEOUT)) {
|
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.PERCENT_TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void timeOver() {
|
|
||||||
double bluePercent = Wincondition.percentWincondition.getPercent(Fight.getBlueTeam());
|
|
||||||
double redPercent = Wincondition.percentWincondition.getPercent(Fight.getRedTeam());
|
|
||||||
|
|
||||||
if(bluePercent > redPercent) {
|
|
||||||
win(Fight.getRedTeam(), "WIN_LESS_DAMAGE", Fight.getRedTeam().getColoredName());
|
|
||||||
}else if(bluePercent < redPercent){
|
|
||||||
win(Fight.getBlueTeam(), "WIN_LESS_DAMAGE", Fight.getBlueTeam().getColoredName());
|
|
||||||
}else{
|
|
||||||
win(null, "WIN_TIME_OVER");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -46,8 +46,7 @@ public class WinconditionPoints extends PercentWincondition implements Listener
|
|||||||
checkWin = team -> {};
|
checkWin = team -> {};
|
||||||
postEnable = this::pointInit;
|
postEnable = this::pointInit;
|
||||||
|
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
Fight.teams().forEach(team -> teamMap.put(team, new TeamPoints(team)));
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
|
||||||
|
|
||||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||||
|
|
||||||
@ -57,16 +56,7 @@ public class WinconditionPoints extends PercentWincondition implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void timeOver() {
|
private void timeOver() {
|
||||||
int redPoints = teamMap.get(Fight.getRedTeam()).getPoints();
|
comparisonWin(team -> teamMap.get(team).getPoints(), "WIN_POINTS", "WIN_POINTS_EQUAL");
|
||||||
int bluePoints = teamMap.get(Fight.getBlueTeam()).getPoints();
|
|
||||||
|
|
||||||
if(bluePoints < redPoints) {
|
|
||||||
win(Fight.getRedTeam(), "WIN_POINTS", Fight.getRedTeam().getPrefix());
|
|
||||||
}else if(bluePoints > redPoints){
|
|
||||||
win(Fight.getBlueTeam(), "WIN_POINTS", Fight.getBlueTeam().getPrefix());
|
|
||||||
}else{
|
|
||||||
win(null, "WIN_POINTS_EQUAL");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
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.winconditions;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class WinconditionPumpkinTechKO extends Wincondition implements PrintableWincondition {
|
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
|
||||||
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPumpkin> teamMap = new HashMap<>();
|
|
||||||
|
|
||||||
public WinconditionPumpkinTechKO(){
|
|
||||||
super("PumpkinTechKO");
|
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
|
||||||
|
|
||||||
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.PUMPKIN_TECH_KO)){
|
|
||||||
printableWinconditions.add(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void check(){
|
|
||||||
teamMap.values().forEach(TeamPumpkin::check);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Message getDisplay(FightTeam team) {
|
|
||||||
return new Message("BAR_CANNONS", team.getPrefix() + teamMap.get(team).pumpkins);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TeamPumpkin {
|
|
||||||
private final FightTeam team;
|
|
||||||
|
|
||||||
private int pumpkins;
|
|
||||||
|
|
||||||
private TeamPumpkin (FightTeam team) {
|
|
||||||
this.team = team;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void check(){
|
|
||||||
pumpkins = 0;
|
|
||||||
team.getSchemRegion().forEach((x, y, z) -> {
|
|
||||||
if (world.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
|
|
||||||
pumpkins++;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(pumpkins == 0) {
|
|
||||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,20 +23,17 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
|
|
||||||
public class WinconditionTimeTechKO extends Wincondition {
|
public class WinconditionTimeTechKO extends Wincondition {
|
||||||
|
|
||||||
private static final int TECH_KO_TIME_IN_S = 90;
|
private static final int TECH_KO_TIME_IN_S = 90;
|
||||||
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
|
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
|
||||||
|
|
||||||
private final World world = Bukkit.getWorlds().get(0);
|
|
||||||
private final double toggle = Config.SpecSpawn.getZ();
|
private final double toggle = Config.SpecSpawn.getZ();
|
||||||
private final FightTeam smallerZteam;
|
private final FightTeam smallerZteam;
|
||||||
private final FightTeam biggerZteam;
|
private final FightTeam biggerZteam;
|
||||||
@ -77,7 +74,7 @@ public class WinconditionTimeTechKO extends Wincondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run(){
|
private void run(){
|
||||||
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
Recording.iterateOverEntities(Recording.primedTnt::isInstance, tnt -> {
|
||||||
double z = tnt.getLocation().getZ();
|
double z = tnt.getLocation().getZ();
|
||||||
boolean smallerZ = z < toggle;
|
boolean smallerZ = z < toggle;
|
||||||
boolean wasSmallerZ = z - tnt.getVelocity().getZ() < toggle;
|
boolean wasSmallerZ = z - tnt.getVelocity().getZ() < toggle;
|
||||||
@ -94,7 +91,7 @@ public class WinconditionTimeTechKO extends Wincondition {
|
|||||||
biggerZcountdown = null;
|
biggerZcountdown = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if(smallerZtime == 0)
|
if(smallerZtime == 0)
|
||||||
smallerZcountdown = new TechKOCountdown(smallerZteam, TECH_KO_HALF_TIME / 20);
|
smallerZcountdown = new TechKOCountdown(smallerZteam, TECH_KO_HALF_TIME / 20);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren