Wake AFK solo leaders with sound on opponent join #347
@ -35,7 +35,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entityList.stream();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||
public class WorldOfColorWrapper12 implements WorldOfColorWrapper {
|
||||
@Override
|
||||
public void setTeamColor(Team team, ChatColor color) {
|
||||
team.setColor(color);
|
||||
|
@ -30,7 +30,7 @@ import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper {
|
||||
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
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.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
||||
@ -72,7 +72,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper {
|
||||
public class FlatteningWrapper14 implements FlatteningWrapper {
|
||||
@Override
|
||||
public DyeColor getSilver() {
|
||||
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.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -56,7 +56,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
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<>();
|
||||
|
||||
@ -123,7 +123,7 @@ public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
|
||||
|
||||
@Override
|
||||
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());
|
||||
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||
|
@ -30,7 +30,7 @@ import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockIdWrapper15 implements BlockIdWrapper.IBlockIdWrapper {
|
||||
public class BlockIdWrapper15 implements BlockIdWrapper {
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
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.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||
@ -72,7 +72,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockIdWrapper18 implements BlockIdWrapper.IBlockIdWrapper {
|
||||
public class BlockIdWrapper18 implements BlockIdWrapper {
|
||||
|
||||
@Override
|
||||
public int blockToId(Block block) {
|
||||
|
@ -35,7 +35,7 @@ import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
||||
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
@ -65,7 +65,7 @@ public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
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.Set;
|
||||
|
||||
public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
|
||||
public class BlockIdWrapper8 implements BlockIdWrapper {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int blockToId(Block block) {
|
||||
|
@ -38,7 +38,7 @@ import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
public class BountifulWrapper8 implements BountifulWrapper {
|
||||
|
||||
public BountifulWrapper8() {
|
||||
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
||||
|
@ -34,7 +34,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper8 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
||||
@ -68,7 +68,7 @@ public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
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.meta.ItemMeta;
|
||||
|
||||
public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
|
||||
public class FlatteningWrapper8 implements FlatteningWrapper {
|
||||
@Override
|
||||
public DyeColor getSilver() {
|
||||
return DyeColor.SILVER;
|
||||
|
@ -26,7 +26,7 @@ import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||
public class WorldOfColorWrapper8 implements WorldOfColorWrapper {
|
||||
@Override
|
||||
public void setTeamColor(Team team, ChatColor color) {
|
||||
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.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -55,7 +55,7 @@ import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@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 Set<BaseBlock> colorBlocks = new HashSet<>();
|
||||
@ -117,12 +117,12 @@ public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
|
||||
|
||||
@Override
|
||||
public Clipboard loadChar(String charName) throws IOException {
|
||||
return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(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
|
||||
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());
|
||||
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||
|
@ -45,7 +45,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
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 Object mainHand = enumHand.getEnumConstants()[0];
|
||||
|
@ -35,7 +35,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
|
||||
@Override
|
||||
public void resetChunk(World world, World backup, int x, int z) {
|
||||
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
||||
@ -71,7 +71,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<?> tntIterator() {
|
||||
public Stream<?> entityIterator() {
|
||||
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.sql.Event;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -30,6 +31,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
@ -118,6 +120,7 @@ public class Config {
|
||||
|
||||
//event parameter
|
||||
private static final int EventKampfID;
|
||||
public static final EventFight EventKampf;
|
||||
public static final int EventTeamBlueID;
|
||||
public static final int EventTeamRedID;
|
||||
public static final boolean BothTeamsPublic;
|
||||
@ -144,7 +147,7 @@ public class Config {
|
||||
}
|
||||
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()) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||
Bukkit.shutdown();
|
||||
@ -232,8 +235,6 @@ public class Config {
|
||||
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
||||
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
TeamBlueSpawn = new Location(world,
|
||||
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
||||
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||
@ -332,8 +333,7 @@ public class Config {
|
||||
EventTeamBlueID = team1.getTeamId();
|
||||
EventTeamRedID = team2.getTeamId();
|
||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||
|
||||
FightSystem.setEventFight(eventFight);
|
||||
EventKampf = eventFight;
|
||||
|
||||
Event event = Event.get(eventFight.getEventID());
|
||||
if(BothTeamsPublic) {
|
||||
@ -353,6 +353,7 @@ public class Config {
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
||||
EventTeamBlueID = 0;
|
||||
EventTeamRedID = 0;
|
||||
EventKampf = null;
|
||||
BothTeamsPublic = true;
|
||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
LiveReplay = false;
|
||||
@ -397,4 +398,10 @@ public class Config {
|
||||
public static boolean blueNegZ(){
|
||||
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.winconditions.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
|
||||
private static FightSystem plugin;
|
||||
private static EventFight eventFight;
|
||||
private static Player eventLeiter;
|
||||
|
||||
private Message message;
|
||||
private FightTeam lastWinner;
|
||||
@ -103,17 +99,17 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
new WinconditionAllDead();
|
||||
new WinconditionCaptainDead();
|
||||
new WinconditionPumpkinTechKO();
|
||||
new WinconditionWaterTechKO();
|
||||
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
||||
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
|
||||
new WinconditionPercentSystem();
|
||||
new WinconditionBlacklistPercent();
|
||||
new WinconditionWhitelistPercent();
|
||||
new WinconditionPoints();
|
||||
new WinconditionTimeout();
|
||||
new WinconditionHeartRatioTimeout();
|
||||
new WinconditionTimeTechKO();
|
||||
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 Meteor();
|
||||
@ -150,7 +146,7 @@ public class FightSystem extends JavaPlugin {
|
||||
FileSource.startReplay();
|
||||
|
||||
if(Config.mode == ArenaMode.EVENT) {
|
||||
setPreSchemState();
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
}else if(Config.mode == ArenaMode.CHECK){
|
||||
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
|
||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||
@ -163,26 +159,6 @@ public class FightSystem extends JavaPlugin {
|
||||
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) {
|
||||
plugin.lastWinner = winFightTeam;
|
||||
plugin.lastWinreason = winreason;
|
||||
@ -191,22 +167,6 @@ public class FightSystem extends JavaPlugin {
|
||||
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() {
|
||||
return plugin;
|
||||
}
|
||||
|
@ -69,14 +69,17 @@ public class GUI {
|
||||
|
||||
public static void state(Player 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());
|
||||
inv.setItem(1, Material.GLASS, msg.parse("STATE_PRE_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPreSchemState());
|
||||
inv.setItem(2, Material.GLASS, msg.parse("STATE_POST_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPostSchemState());
|
||||
inv.setItem(3, Material.GLASS, msg.parse("STATE_PRE_RUNNING", p), (ClickType click) -> FightSystem.setPreRunningState());
|
||||
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(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"));
|
||||
int i = 0;
|
||||
for(FightState state : FightState.values()) {
|
||||
if(state == FightState.SPECTATE)
|
||||
continue;
|
||||
|
||||
inv.setItem(i++, Material.GLASS, msg.parse("STATE_" + state.name(), p), click -> FightState.setFightState(state));
|
||||
}
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
inv.setItem(i++, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, team.getColoredName()), click -> FightSystem.setSpectateState(team, "operator", "WIN_FIGHTLEADER"));
|
||||
}
|
||||
inv.setItem(i, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), click -> FightSystem.setSpectateState(null, "operator", "WIN_FIGHTLEADER"));
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class GamemodeCommand extends BukkitCommand {
|
||||
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -42,16 +43,18 @@ public class LeaderCommand implements CommandExecutor {
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
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
|
||||
if(Fight.getFightPlayer(player) != null) {
|
||||
FightSystem.getMessage().sendPrefixless("ALREADY_IN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(team.canbeLeader(player)) {
|
||||
team.addMember(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
FightSystem.getMessage().sendPrefixless("LEADER_FULL", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -24,7 +26,7 @@ public class WinCommand implements CommandExecutor {
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (p != FightSystem.getEventLeiter()) {
|
||||
if (!Config.isReferee(p)) {
|
||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
@ -36,10 +38,14 @@ public class WinCommand implements CommandExecutor {
|
||||
|
||||
if(args[0].equalsIgnoreCase("tie")){
|
||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||
}else if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
|
||||
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "WIN_FIGHTLEADER");
|
||||
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
|
||||
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(args[0].equalsIgnoreCase(team.getName())){
|
||||
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
@ -35,6 +34,6 @@ public class PostSchemCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
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.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
@ -36,6 +35,6 @@ public class PreRunningCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
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.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
@ -36,6 +35,6 @@ public class PreSchemCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
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.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
@ -36,6 +35,6 @@ public class SpectateOverCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
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.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -45,7 +43,6 @@ public class HellsBells {
|
||||
|
||||
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 zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
||||
private State current = State.PRE;
|
||||
@ -100,13 +97,13 @@ public class HellsBells {
|
||||
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
||||
for (int w = 0; w < width; w++) {
|
||||
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 {
|
||||
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) {
|
||||
|
@ -30,11 +30,9 @@ import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LargeFireball;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -52,7 +50,6 @@ public class Meteor implements Listener {
|
||||
public static final Random random = new Random();
|
||||
|
||||
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 zLength = Config.RedExtendRegion.getMaxZ() - Config.RedExtendRegion.getMinZ();
|
||||
private Meteor.State current = Meteor.State.PRE;
|
||||
@ -86,7 +83,7 @@ public class Meteor implements Listener {
|
||||
//@EventHandler
|
||||
public void explode(ProjectileHitEvent event) {
|
||||
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.setFuseTicks(0);
|
||||
tnt.setYield(((Fireball) event.getEntity()).getYield());
|
||||
@ -113,13 +110,13 @@ public class Meteor implements Listener {
|
||||
vector.setX(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.setBounce(false);
|
||||
fireballRed.setIsIncendiary(false);
|
||||
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);
|
||||
fireballBlue.setDirection(vector);
|
||||
fireballBlue.setBounce(false);
|
||||
|
@ -33,14 +33,18 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class 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 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) {
|
||||
if(redTeam.isPlayerInTeam(player))
|
||||
@ -87,6 +91,10 @@ public class Fight {
|
||||
return blueTeam;
|
||||
}
|
||||
|
||||
public static Collection<FightTeam> teams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static FightTeam getUnrotated() {
|
||||
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;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
|
@ -133,7 +133,7 @@ public class FightSchematic extends StateDependent {
|
||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||
WorldeditWrapper.impl.pasteClipboard(
|
||||
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(
|
||||
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,
|
||||
@ -191,17 +191,15 @@ public class FightSchematic extends StateDependent {
|
||||
|
||||
length -= 1;
|
||||
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++){
|
||||
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceSync(Material target, Material replacement){
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
region.forEach((x, y, z) -> {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
Block block = Config.world.getBlockAt(x, y, z);
|
||||
if(block.getType() == target)
|
||||
block.setType(replacement);
|
||||
});
|
||||
|
@ -217,8 +217,8 @@ public class FightTeam {
|
||||
BountifulWrapper.impl.setAttackSpeed(player);
|
||||
player.teleport(spawn);
|
||||
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(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("RESPAWN", 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).removeAllAttributes().setDisplayName(FightSystem.getMessage().parse("RESPAWN", player)).build());
|
||||
GlobalRecorder.getInstance().playerJoins(player);
|
||||
TechHider.reloadChunks(player, chunksToReload, false);
|
||||
|
||||
@ -268,7 +268,7 @@ public class FightTeam {
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.values().iterator().next(), false);
|
||||
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), 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();
|
||||
Inventory inventory = leader.getPlayer().getInventory();
|
||||
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
|
||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||
|
||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().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(2, new ItemBuilder(Material.PAPER).removeAllAttributes().setDisplayName(FightSystem.getMessage().parse("INVITE_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)
|
||||
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()){
|
||||
FightSystem.setPreSchemState();
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ public class FightTeam {
|
||||
if(Config.test())
|
||||
this.schematic.enable();
|
||||
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;
|
||||
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");
|
||||
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
||||
FightSystem.setPreRunningState();
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
@ -28,13 +29,11 @@ import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FightWorld extends StateDependent {
|
||||
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
||||
|
||||
public static boolean isPaper(){
|
||||
@ -58,22 +57,21 @@ public class FightWorld extends StateDependent {
|
||||
|
||||
public static void forceLoad(){
|
||||
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
||||
world.loadChunk(cX, cZ);
|
||||
FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ);
|
||||
Config.world.loadChunk(cX, cZ);
|
||||
FlatteningWrapper.impl.forceLoadChunk(Config.world, cX, cZ);
|
||||
});
|
||||
}
|
||||
|
||||
public static void resetWorld(){
|
||||
for(Entity entity : world.getEntities()){
|
||||
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation()))) {
|
||||
Recording.iterateOverEntities(entity -> true, entity -> {
|
||||
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation())))
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
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()) {
|
||||
de.steamwar.core.CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -41,10 +41,12 @@ public class ArrowStopper {
|
||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
private static final Class<?> entityArrow = Reflection.getClass("{nms.world.entity.projectile}.EntityArrow");
|
||||
private void run() {
|
||||
for (Arrow arrow : Bukkit.getWorlds().get(0).getEntitiesByClass(Arrow.class)) {
|
||||
Recording.iterateOverEntities(entityArrow::isInstance, entity -> {
|
||||
Arrow arrow = (Arrow) entity;
|
||||
if (invalidEntity(arrow))
|
||||
continue;
|
||||
return;
|
||||
|
||||
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
||||
if (arrow.getTicksLived() == 0){
|
||||
@ -52,12 +54,12 @@ public class ArrowStopper {
|
||||
if(projSource instanceof Player)
|
||||
prevLocation = ((Player) arrow.getShooter()).getEyeLocation();
|
||||
else
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (checkBlocks(arrow.getLocation().getBlock(), prevLocation.getBlock())) {
|
||||
arrow.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkBlocks(Block start, Block end) {
|
||||
@ -95,8 +97,4 @@ public class ArrowStopper {
|
||||
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
||||
entity.getVelocity().equals(NULL_VECTOR);
|
||||
}
|
||||
|
||||
public interface IArrowStopper {
|
||||
boolean isInBlock(Arrow e);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class Chat implements Listener {
|
||||
} else {
|
||||
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
||||
}
|
||||
}else if(player == FightSystem.getEventLeiter()){
|
||||
}else if(Config.isReferee(player)){
|
||||
broadcastChat("FIGHTLEADER_CHAT", player.getName(), message);
|
||||
}else{
|
||||
broadcastChat("SPECTATOR_CHAT", player.getName(), message);
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
@ -32,7 +32,7 @@ public class ClickAnalyzer {
|
||||
|
||||
static {
|
||||
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) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class EventJoin implements Listener {
|
||||
|
||||
@ -49,7 +48,7 @@ public class EventJoin implements Listener {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(user.getTeam() == Config.EventTeamBlueID ||
|
||||
user.getTeam() == Config.EventTeamRedID ||
|
||||
user.getId() == FightSystem.getEventFight().getKampfleiter())
|
||||
Config.isReferee(player))
|
||||
return;
|
||||
|
||||
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();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
if(user.getId() == FightSystem.getEventFight().getKampfleiter()){
|
||||
FightSystem.setEventLeiter(player);
|
||||
if(Config.isReferee(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if(FightState.Setup.contains(FightState.getFightState())){
|
||||
FightTeam team = null;
|
||||
@ -93,12 +90,4 @@ public class EventJoin implements Listener {
|
||||
if(Config.LiveReplay)
|
||||
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;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -39,14 +38,12 @@ public class NormalJoin implements Listener {
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if (Fight.getPlayerTeam(player) != null)
|
||||
return;
|
||||
|
||||
if (fightTeam == null) {
|
||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||
Fight.getBlueTeam().addMember(player);
|
||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||
Fight.getRedTeam().addMember(player);
|
||||
}
|
||||
}
|
||||
FightTeam team = Fight.teams().stream().filter(t -> player.getUniqueId().equals(t.getDesignatedLeader())).findAny( // Player is designated leader of a team
|
||||
).orElse(Fight.teams().stream().filter(t -> t.canbeLeader(player)).findAny().orElse(null)); // Else search empty team
|
||||
if(team != null)
|
||||
team.addMember(player);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -50,9 +49,8 @@ public class PrepareSchem implements Listener {
|
||||
public PrepareSchem() {
|
||||
new OneShotStateDependent(ArenaMode.Prepare, FightState.PostSchemSetup, () -> Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
stationaryMovingPistons.clear();
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
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));
|
||||
});
|
||||
}, 1));
|
||||
@ -61,7 +59,6 @@ public class PrepareSchem implements Listener {
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Region region = Fight.getUnrotated().getExtendRegion();
|
||||
int minY = Fight.getUnrotated().getSchemRegion().getMinY();
|
||||
|
||||
@ -76,7 +73,7 @@ public class PrepareSchem implements Listener {
|
||||
|
||||
try{
|
||||
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");
|
||||
Bukkit.shutdown();
|
||||
throw new IllegalStateException();
|
||||
@ -116,8 +113,8 @@ public class PrepareSchem implements Listener {
|
||||
}
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP) {
|
||||
FightSystem.setPreSchemState();
|
||||
FightSystem.setPostSchemState();
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
|
||||
schemExists(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
|
@ -34,11 +34,9 @@ import de.steamwar.fightsystem.utils.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -50,12 +48,13 @@ import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Recording implements Listener {
|
||||
|
||||
private static final int AIR = 0;
|
||||
private static final Random random = new Random();
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
public static ItemStack disarmNull(ItemStack stack){
|
||||
if(stack == null)
|
||||
@ -68,22 +67,24 @@ public class Recording implements Listener {
|
||||
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() {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, BountifulWrapper.impl.newHandSwapRecorder());
|
||||
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame){
|
||||
@Override
|
||||
public void enable() {
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
setKitItems(Fight.getBlueTeam());
|
||||
setKitItems(Fight.getRedTeam());
|
||||
}, 1);
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> Fight.teams().forEach(Recording.this::setKitItems), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
despawnTeam(Fight.getRedTeam());
|
||||
despawnTeam(Fight.getBlueTeam());
|
||||
Fight.teams().forEach(Recording.this::despawnTeam);
|
||||
despawnTNT();
|
||||
}
|
||||
}.register();
|
||||
@ -106,14 +107,11 @@ public class Recording implements Listener {
|
||||
if(FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
|
||||
return;
|
||||
|
||||
CraftbukkitWrapper.impl.tntIterator().filter(primedTnt::isInstance).forEach(this::trackEntity);
|
||||
iterateOverEntities(primedTnt::isInstance, this::trackEntity);
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private 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);
|
||||
private void trackEntity(Object e) {
|
||||
Entity entity = (Entity) getBukkitEntity.invoke(e);
|
||||
private void trackEntity(Entity entity) {
|
||||
GlobalRecorder.getInstance().entityMoves(entity);
|
||||
GlobalRecorder.getInstance().entitySpeed(entity);
|
||||
}
|
||||
@ -297,7 +295,6 @@ public class Recording implements Listener {
|
||||
}
|
||||
|
||||
private void despawnTNT(){
|
||||
for(TNTPrimed tnt : Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class))
|
||||
GlobalRecorder.getInstance().entityDespawns(tnt);
|
||||
iterateOverEntities(primedTnt::isInstance, GlobalRecorder.getInstance()::entityDespawns);
|
||||
}
|
||||
}
|
||||
|
@ -54,12 +54,11 @@ public class TeamArea implements Listener {
|
||||
@EventHandler
|
||||
public void teamAreas(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(player == FightSystem.getEventLeiter())
|
||||
if(Config.isReferee(player))
|
||||
return;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
checkInTeamRegion(event, Fight.getBlueTeam(), player, team);
|
||||
checkInTeamRegion(event, Fight.getRedTeam(), player, team);
|
||||
Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -49,15 +49,15 @@ public class TestJoin implements Listener {
|
||||
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);
|
||||
}
|
||||
|
||||
player.setOp(true);
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
||||
FightSystem.setPreSchemState();
|
||||
FightSystem.setPostSchemState();
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,11 +60,10 @@ public class WaterRemover implements Listener {
|
||||
return;
|
||||
|
||||
Location location = event.getLocation();
|
||||
if (Config.BlueExtendRegion.inRegion(location)) {
|
||||
tnt.put(event.getEntity().getEntityId(), Fight.getBlueTeam());
|
||||
} else if (Config.RedExtendRegion.inRegion(location)) {
|
||||
tnt.put(event.getEntity().getEntityId(), Fight.getRedTeam());
|
||||
}
|
||||
Fight.teams().forEach(team -> {
|
||||
if(team.getExtendRegion().inRegion(location))
|
||||
tnt.put(event.getEntity().getEntityId(), team);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -22,14 +22,13 @@ package de.steamwar.fightsystem.record;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
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;
|
||||
|
||||
public static File getFile() {
|
||||
|
@ -39,7 +39,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -50,8 +49,6 @@ import java.util.logging.Level;
|
||||
|
||||
public class PacketProcessor {
|
||||
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
private static PacketProcessor currentProcessor = null;
|
||||
|
||||
public static PacketProcessor currentReplay() {
|
||||
@ -348,7 +345,7 @@ public class PacketProcessor {
|
||||
if(!Config.ArenaRegion.in2dRegion(x, z))
|
||||
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 {
|
||||
@ -364,7 +361,7 @@ public class PacketProcessor {
|
||||
|
||||
double finalX = x;
|
||||
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 {
|
||||
@ -388,7 +385,7 @@ public class PacketProcessor {
|
||||
|
||||
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 {
|
||||
|
@ -53,8 +53,7 @@ public interface Recorder {
|
||||
}
|
||||
|
||||
arenaInfo();
|
||||
enableTeam(Fight.getBlueTeam());
|
||||
enableTeam(Fight.getRedTeam());
|
||||
Fight.teams().forEach(this::enableTeam);
|
||||
}
|
||||
|
||||
default void enableTeam(FightTeam team){
|
||||
|
@ -26,12 +26,9 @@ import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockIdWrapper {
|
||||
private BlockIdWrapper() {}
|
||||
public interface BlockIdWrapper {
|
||||
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public interface IBlockIdWrapper {
|
||||
int blockToId(Block block);
|
||||
void setBlock(World world, int x, int y, int z, int blockState);
|
||||
|
||||
@ -39,5 +36,4 @@ public class BlockIdWrapper {
|
||||
int getObfuscateWith();
|
||||
|
||||
Object getPose(boolean sneaking);
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,9 @@ import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BountifulWrapper {
|
||||
private BountifulWrapper() {}
|
||||
public interface BountifulWrapper {
|
||||
BountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public interface IBountifulWrapper {
|
||||
boolean mainHand(Object packet);
|
||||
boolean bowInHand(boolean mainHand, Player p);
|
||||
|
||||
@ -57,5 +54,4 @@ public class BountifulWrapper {
|
||||
void setNamedSpawnPosition(Object packet, double x, double y, double z);
|
||||
|
||||
void sendBar(Player player, FightTeam team, double progress, String text);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class BungeeFightInfo {
|
||||
return;
|
||||
|
||||
new FightInfoPacket(
|
||||
Bukkit.getWorlds().get(0).getName(),
|
||||
Config.world.getName(),
|
||||
Config.SchematicType.toDB(),
|
||||
"",
|
||||
Fight.getBlueTeam().getColoredName(),
|
||||
|
@ -28,17 +28,13 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CraftbukkitWrapper {
|
||||
private CraftbukkitWrapper() {}
|
||||
public interface 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 sendResourcePack(Player player, String pack, String sha1);
|
||||
float headRotation(Entity e);
|
||||
boolean hasItems(ItemStack stack);
|
||||
|
||||
Stream<?> tntIterator();
|
||||
}
|
||||
Stream<?> entityIterator();
|
||||
}
|
||||
|
@ -43,14 +43,12 @@ public class EnterHandler implements IStateDependent {
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
registerTeam(Fight.getBlueTeam());
|
||||
registerTeam(Fight.getRedTeam());
|
||||
Fight.teams().forEach(this::registerTeam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
unregisterTeam(Fight.getBlueTeam());
|
||||
unregisterTeam(Fight.getRedTeam());
|
||||
Fight.teams().forEach(this::unregisterTeam);
|
||||
}
|
||||
|
||||
private void registerTeam(FightTeam team){
|
||||
|
@ -68,11 +68,11 @@ public class FightStatistics {
|
||||
|
||||
private void setEventResult() {
|
||||
if (FightSystem.getLastWinner() == null)
|
||||
FightSystem.getEventFight().setErgebnis(0);
|
||||
Config.EventKampf.setErgebnis(0);
|
||||
else if (FightSystem.getLastWinner().isBlue())
|
||||
FightSystem.getEventFight().setErgebnis(1);
|
||||
Config.EventKampf.setErgebnis(1);
|
||||
else
|
||||
FightSystem.getEventFight().setErgebnis(2);
|
||||
Config.EventKampf.setErgebnis(2);
|
||||
}
|
||||
|
||||
private void disable() {
|
||||
@ -110,7 +110,7 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||
@ -119,7 +119,7 @@ public class FightStatistics {
|
||||
savePlayerStats(fp, fightId);
|
||||
|
||||
if (ArenaMode.Event.contains(Config.mode)) {
|
||||
FightSystem.getEventFight().setFight(fightId);
|
||||
Config.EventKampf.setFight(fightId);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -28,12 +28,9 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class FlatteningWrapper {
|
||||
private FlatteningWrapper() {}
|
||||
public interface FlatteningWrapper {
|
||||
FlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
public interface IFlatteningWrapper {
|
||||
DyeColor getSilver();
|
||||
|
||||
boolean isWater(Block block);
|
||||
@ -51,5 +48,4 @@ public class FlatteningWrapper {
|
||||
boolean checkPistonMoving(Block block);
|
||||
|
||||
void setNamedSpawnPacketDataWatcher(Object packet);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ItemBuilder {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
public ItemBuilder removeAllAttributs() {
|
||||
public ItemBuilder removeAllAttributes() {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
|
@ -161,7 +161,7 @@ public class TechHider extends StateDependent {
|
||||
}
|
||||
|
||||
public static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||
if(p == FightSystem.getEventLeiter())
|
||||
if(Config.isReferee(p))
|
||||
return true;
|
||||
|
||||
FightTeam ft = Fight.getPlayerTeam(p);
|
||||
|
@ -28,17 +28,13 @@ import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper {
|
||||
private WorldOfColorWrapper() {}
|
||||
public interface 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);
|
||||
boolean isInBlock(Arrow e);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -31,17 +31,13 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class WorldeditWrapper {
|
||||
private WorldeditWrapper() {}
|
||||
public interface 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;
|
||||
int getWaterDepth(Clipboard clipboard);
|
||||
void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
|
||||
Vector getDimensions(Clipboard clipboard);
|
||||
Clipboard loadChar(String charName) throws IOException;
|
||||
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.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
|
||||
public class EventTeamOffWincondition extends Wincondition{
|
||||
|
||||
public EventTeamOffWincondition(){
|
||||
super("TeamOffline");
|
||||
new StateDependent(ArenaMode.Event, FightState.PreRunning) {
|
||||
@Override
|
||||
public void enable() {
|
||||
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
|
||||
new OneShotStateDependent(ArenaMode.Event, FightState.PreRunning, () -> {
|
||||
if(Fight.teams().stream().allMatch(FightTeam::allPlayersOut)){
|
||||
win(null, "WIN_OFFLINE_BOTH");
|
||||
}else{
|
||||
teamOff(Fight.getBlueTeam());
|
||||
teamOff(Fight.getRedTeam());
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
Fight.teams().stream().filter(FightTeam::allPlayersOut).findAny(
|
||||
).ifPresent(team -> 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.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -44,8 +42,6 @@ import java.util.function.ToIntFunction;
|
||||
|
||||
public class PercentWincondition extends Wincondition implements PrintableWincondition {
|
||||
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||
|
||||
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 -> {
|
||||
AtomicInteger blocks = new AtomicInteger();
|
||||
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();
|
||||
}
|
||||
});
|
||||
@ -74,8 +70,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
|
||||
percentWincondition = this;
|
||||
}
|
||||
|
||||
new TeamPercent(Fight.getBlueTeam(), wincondition);
|
||||
new TeamPercent(Fight.getRedTeam(), wincondition);
|
||||
Fight.teams().forEach(team -> new TeamPercent(team, wincondition));
|
||||
}
|
||||
|
||||
public Message getDisplay(FightTeam team) {
|
||||
|
@ -28,6 +28,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class Wincondition {
|
||||
|
||||
@ -58,4 +60,17 @@ public abstract class Wincondition {
|
||||
public static List<PrintableWincondition> getPrintableWinconditions(){
|
||||
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.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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() {
|
||||
super("WaterTechKO");
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
||||
public WinconditionBlocks(Winconditions wincondition, String windescription, String barMessage, Predicate<Block> isOfType) {
|
||||
super(windescription);
|
||||
this.barMessage = barMessage;
|
||||
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
|
||||
public void enable() {
|
||||
teamMap.values().forEach(TeamWater::find);
|
||||
teamMap.values().forEach(TeamBlocks::find);
|
||||
super.enable();
|
||||
}
|
||||
};
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.WATER_TECH_KO)){
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void check() {
|
||||
teamMap.values().forEach(TeamWater::check);
|
||||
if(Config.ActiveWinconditions.contains(wincondition))
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 List<Block> water = new ArrayList<>();
|
||||
private final List<Block> blocks = new ArrayList<>();
|
||||
|
||||
private TeamWater(FightTeam team) {
|
||||
private TeamBlocks(FightTeam team) {
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
private void find() {
|
||||
water.clear();
|
||||
blocks.clear();
|
||||
team.getExtendRegion().forEach((x, y, z) -> {
|
||||
Block block = WORLD.getBlockAt(x, y, z);
|
||||
if (FlatteningWrapper.impl.isWater(block))
|
||||
water.add(block);
|
||||
Block block = Config.world.getBlockAt(x, y, z);
|
||||
if (isOfType.test(block))
|
||||
blocks.add(block);
|
||||
});
|
||||
}
|
||||
|
||||
private void check() {
|
||||
water.removeIf(block -> !FlatteningWrapper.impl.isWater(block));
|
||||
if(water.isEmpty()){
|
||||
blocks.removeIf(block -> !isOfType.test(block));
|
||||
if(blocks.isEmpty())
|
||||
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.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.StateDependentCountdown;
|
||||
|
||||
public class WinconditionHeartRatioTimeout extends Wincondition {
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
public WinconditionHeartRatioTimeout() {
|
||||
super("HeartTimeout");
|
||||
if(Config.ActiveWinconditions.contains(Winconditions.HEART_RATIO_TIMEOUT)){
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.HEART_RATIO_TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
}
|
||||
}
|
||||
public class WinconditionComparisonTimeout extends Wincondition {
|
||||
|
||||
protected void timeOver() {
|
||||
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
|
||||
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
|
||||
|
||||
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");
|
||||
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
|
||||
super(windescription);
|
||||
if(Config.ActiveWinconditions.contains(wincondition)) {
|
||||
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "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 -> {};
|
||||
postEnable = this::pointInit;
|
||||
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
||||
Fight.teams().forEach(team -> teamMap.put(team, new TeamPoints(team)));
|
||||
|
||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||
|
||||
@ -57,16 +56,7 @@ public class WinconditionPoints extends PercentWincondition implements Listener
|
||||
}
|
||||
|
||||
private void timeOver() {
|
||||
int redPoints = teamMap.get(Fight.getRedTeam()).getPoints();
|
||||
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");
|
||||
}
|
||||
comparisonWin(team -> teamMap.get(team).getPoints(), "WIN_POINTS", "WIN_POINTS_EQUAL");
|
||||
}
|
||||
|
||||
@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.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
public class WinconditionTimeTechKO extends Wincondition {
|
||||
|
||||
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 final World world = Bukkit.getWorlds().get(0);
|
||||
private final double toggle = Config.SpecSpawn.getZ();
|
||||
private final FightTeam smallerZteam;
|
||||
private final FightTeam biggerZteam;
|
||||
@ -77,7 +74,7 @@ public class WinconditionTimeTechKO extends Wincondition {
|
||||
}
|
||||
|
||||
private void run(){
|
||||
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
||||
Recording.iterateOverEntities(Recording.primedTnt::isInstance, tnt -> {
|
||||
double z = tnt.getLocation().getZ();
|
||||
boolean smallerZ = z < toggle;
|
||||
boolean wasSmallerZ = z - tnt.getVelocity().getZ() < toggle;
|
||||
@ -94,7 +91,7 @@ public class WinconditionTimeTechKO extends Wincondition {
|
||||
biggerZcountdown = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(smallerZtime == 0)
|
||||
smallerZcountdown = new TechKOCountdown(smallerZteam, TECH_KO_HALF_TIME / 20);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren