Full resettable + config simplification
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
9098a26aa9
Commit
9b65277c66
@ -24,7 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -54,10 +54,9 @@ class FightTeam_12 {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
FightTeam_8.replaceTeamColor(e, c, r);
|
||||||
Vector corner = new Vector(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
|
||||||
|
@ -33,6 +33,7 @@ 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.Config;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -61,10 +62,8 @@ class FightTeam_14 {
|
|||||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(BlockVector3.at(r.getMinX(), r.getMinY(), r.getMinZ()), BlockVector3.at(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ);
|
|
||||||
CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock());
|
e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock());
|
||||||
e.replaceBlocks(region, CARPET_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock());
|
e.replaceBlocks(region, CARPET_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock());
|
||||||
|
@ -32,6 +32,7 @@ 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.Config;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -72,9 +73,8 @@ class FightTeam_8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
Vector corner = new Vector(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
|
||||||
|
@ -54,39 +54,20 @@ public class Config {
|
|||||||
public static final Region BluePasteRegion;
|
public static final Region BluePasteRegion;
|
||||||
public static final Region RedPasteRegion;
|
public static final Region RedPasteRegion;
|
||||||
public static final Region BlueExtendRegion;
|
public static final Region BlueExtendRegion;
|
||||||
public static final Region RedExetendRegion;
|
public static final Region RedExtendRegion;
|
||||||
public static final Region ArenaRegion;
|
public static final Region ArenaRegion;
|
||||||
|
|
||||||
public static final int SchemsizeX;
|
|
||||||
public static final int SchemsizeY;
|
|
||||||
public static final int SchemsizeZ;
|
|
||||||
public static final int TeamBlueCornerX;
|
|
||||||
public static final int TeamBlueCornerY;
|
|
||||||
public static final int TeamBlueCornerZ;
|
|
||||||
private static final int TeamBluePasteX;
|
|
||||||
private static final int TeamBluePasteZ;
|
|
||||||
public static final Location TeamBlueSpawn;
|
public static final Location TeamBlueSpawn;
|
||||||
public static final int TeamRedCornerX;
|
|
||||||
public static final int TeamRedCornerY;
|
|
||||||
public static final int TeamRedCornerZ;
|
|
||||||
private static final int TeamRedPasteX;
|
|
||||||
private static final int TeamRedPasteZ;
|
|
||||||
public static final Location TeamRedSpawn;
|
public static final Location TeamRedSpawn;
|
||||||
|
public static final Location SpecSpawn;
|
||||||
|
|
||||||
private static final int TeamBluetoReddistanceX;
|
private static final int TeamBluetoReddistanceX;
|
||||||
private static final int TeamBluetoReddistanceY;
|
private static final int TeamBluetoReddistanceY;
|
||||||
public static final int TeamBluetoReddistanceZ;
|
public static final int TeamBluetoReddistanceZ;
|
||||||
public static final Location SpecSpawn;
|
|
||||||
public static final int underArenaBorder;
|
|
||||||
public static final int BorderFromSchematic;
|
public static final int BorderFromSchematic;
|
||||||
public static final int upperArenaBorder;
|
|
||||||
public static final boolean AlignWater;
|
public static final boolean AlignWater;
|
||||||
public static final int WaterDepth;
|
public static final int WaterDepth;
|
||||||
private static final int Schem2BorderX;
|
|
||||||
private static final int Schem2BorderZ;
|
|
||||||
public static final int ArenaMinX;
|
|
||||||
public static final int ArenaMinZ;
|
|
||||||
public static final int ArenaMaxX;
|
|
||||||
public static final int ArenaMaxZ;
|
|
||||||
public static final boolean GroundWalkable;
|
public static final boolean GroundWalkable;
|
||||||
|
|
||||||
//schematic parameter
|
//schematic parameter
|
||||||
@ -94,10 +75,9 @@ public class Config {
|
|||||||
public static final boolean OnlyPublicSchematics;
|
public static final boolean OnlyPublicSchematics;
|
||||||
public static final boolean IgnorePublicOnly;
|
public static final boolean IgnorePublicOnly;
|
||||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
public static final de.steamwar.sql.SchematicType SchematicType;
|
||||||
public static final boolean TeamRedRotate;
|
public static final boolean RedRotate;
|
||||||
public static final boolean TeamBlueRotate;
|
public static final boolean BlueRotate;
|
||||||
public static final boolean ReplaceObsidian;
|
public static final boolean ReplaceObsidianBedrock;
|
||||||
public static final boolean ReplaceBedrock;
|
|
||||||
public static final boolean ReplaceWithBlockupdates;
|
public static final boolean ReplaceWithBlockupdates;
|
||||||
|
|
||||||
//team parameter
|
//team parameter
|
||||||
@ -180,9 +160,9 @@ public class Config {
|
|||||||
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
|
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
|
||||||
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
|
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
|
||||||
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
|
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
|
||||||
Schem2BorderX = config.getInt("Arena.Schem2Border.x");
|
int schem2BorderX = config.getInt("Arena.Schem2Border.x");
|
||||||
Schem2BorderZ = config.getInt("Arena.Schem2Border.z");
|
int schem2BorderZ = config.getInt("Arena.Schem2Border.z");
|
||||||
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
|
int underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
|
||||||
BorderFromSchematic = config.getInt("Arena.BorderFromSchematic");
|
BorderFromSchematic = config.getInt("Arena.BorderFromSchematic");
|
||||||
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
|
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
|
||||||
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
|
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
|
||||||
@ -195,14 +175,13 @@ public class Config {
|
|||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
||||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
||||||
boolean rotate = config.getBoolean("Schematic.Rotate");
|
boolean rotate = config.getBoolean("Schematic.Rotate");
|
||||||
ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian");
|
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock");
|
||||||
ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock");
|
|
||||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
|
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
|
||||||
|
|
||||||
GameName = config.getString("Output.GameName");
|
GameName = config.getString("Output.GameName");
|
||||||
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||||
|
|
||||||
ActiveWinconditions = config.getStringList("WinConditions").stream().map(Winconditions::valueOf).collect(Collectors.toSet());
|
ActiveWinconditions = Collections.unmodifiableSet(config.getStringList("WinConditions").stream().map(Winconditions::valueOf).collect(Collectors.toSet()));
|
||||||
|
|
||||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||||
@ -214,7 +193,7 @@ public class Config {
|
|||||||
MemberDefault = config.getString("Kits.MemberDefault");
|
MemberDefault = config.getString("Kits.MemberDefault");
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||||
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
||||||
ForbiddenItems = config.getStringList("Kits.ForbiddenItems");
|
ForbiddenItems = Collections.unmodifiableList(config.getStringList("Kits.ForbiddenItems"));
|
||||||
|
|
||||||
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||||
@ -222,88 +201,81 @@ public class Config {
|
|||||||
TechhiderActive = config.getBoolean("Techhider.Active");
|
TechhiderActive = config.getBoolean("Techhider.Active");
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
SchemsizeX = -schemsizeX;
|
schemsizeX = -schemsizeX;
|
||||||
TeamBlueCornerX = teamBlueCornerX - SchemsizeX;
|
teamBlueCornerX = teamBlueCornerX - schemsizeX;
|
||||||
}else{
|
|
||||||
SchemsizeX = schemsizeX;
|
|
||||||
TeamBlueCornerX = teamBlueCornerX;
|
|
||||||
}
|
}
|
||||||
if(schemsizeY < 0){
|
if(schemsizeY < 0){
|
||||||
SchemsizeY = -schemsizeY;
|
schemsizeY = -schemsizeY;
|
||||||
TeamBlueCornerY = teamBlueCornerY - SchemsizeY;
|
teamBlueCornerY = teamBlueCornerY - schemsizeY;
|
||||||
}else{
|
|
||||||
SchemsizeY = schemsizeY;
|
|
||||||
TeamBlueCornerY = teamBlueCornerY;
|
|
||||||
}
|
}
|
||||||
if(schemsizeZ < 0){
|
if(schemsizeZ < 0){
|
||||||
SchemsizeZ = -schemsizeZ;
|
schemsizeZ = -schemsizeZ;
|
||||||
TeamBlueCornerZ = teamBlueCornerZ - SchemsizeZ;
|
teamBlueCornerZ = teamBlueCornerZ - schemsizeZ;
|
||||||
}else{
|
|
||||||
SchemsizeZ = schemsizeZ;
|
|
||||||
TeamBlueCornerZ = teamBlueCornerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
|
|
||||||
|
|
||||||
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
|
int teamRedCornerX = TeamBluetoReddistanceX + teamBlueCornerX;
|
||||||
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
int teamRedCornerY = TeamBluetoReddistanceY + teamBlueCornerY;
|
||||||
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
int teamRedCornerZ = TeamBluetoReddistanceZ + teamBlueCornerZ;
|
||||||
|
|
||||||
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
int teamBluePasteX = teamBlueCornerX + schemsizeX / 2;
|
||||||
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
int teamBluePasteZ = teamBlueCornerZ + schemsizeZ / 2;
|
||||||
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
|
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
|
||||||
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
|
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
TeamBlueSpawn = new Location(world,
|
TeamBlueSpawn = new Location(world,
|
||||||
TeamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
||||||
TeamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
teamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||||
TeamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
||||||
|
|
||||||
TeamRedSpawn = new Location(world,
|
TeamRedSpawn = new Location(world,
|
||||||
TeamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
teamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
||||||
TeamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
teamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||||
TeamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
teamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
||||||
|
|
||||||
|
SpecSpawn = new Location(world,
|
||||||
|
teamBluePasteX + TeamBluetoReddistanceX/2.0,
|
||||||
|
teamBlueCornerY + TeamBluetoReddistanceY/2.0 + schemsizeY/2.0,
|
||||||
|
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
||||||
|
|
||||||
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
||||||
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
|
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
|
||||||
double yaw = Math.toDegrees(v1.clone().setY(0).angle(new Vector(0, 0, 1)));
|
double yaw = Math.toDegrees(v1.clone().setY(0).angle(new Vector(0, 0, 1)));
|
||||||
double pitchInverted = pitch * -1;
|
|
||||||
double yawInverted = yaw + 180;
|
|
||||||
|
|
||||||
TeamBlueSpawn.setYaw((float) yawInverted);
|
TeamBlueSpawn.setYaw((float) yaw + 180);
|
||||||
TeamBlueSpawn.setPitch((float) pitch);
|
TeamBlueSpawn.setPitch((float) pitch);
|
||||||
|
|
||||||
TeamRedSpawn.setYaw((float) yaw);
|
TeamRedSpawn.setYaw((float) yaw);
|
||||||
TeamRedSpawn.setPitch((float) pitchInverted);
|
TeamRedSpawn.setPitch((float) pitch * -1);
|
||||||
|
|
||||||
SpecSpawn = new Location(world,
|
|
||||||
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
|
||||||
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
|
||||||
TeamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
|
||||||
|
|
||||||
boolean teamRedRotate;
|
boolean teamRedRotate;
|
||||||
boolean teamBlueRotate;
|
boolean teamBlueRotate;
|
||||||
|
int arenaMinX;
|
||||||
|
int arenaMaxX;
|
||||||
|
int arenaMinZ;
|
||||||
|
int arenaMaxZ;
|
||||||
if(TeamBluetoReddistanceX > 0){
|
if(TeamBluetoReddistanceX > 0){
|
||||||
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
|
arenaMinX = teamBlueCornerX - schem2BorderX;
|
||||||
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
|
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
ArenaMinX = TeamRedCornerX - Schem2BorderX;
|
arenaMinX = teamRedCornerX - schem2BorderX;
|
||||||
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
|
arenaMaxX = teamBlueCornerX + schemsizeX + schem2BorderX;
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
}
|
}
|
||||||
if(TeamBluetoReddistanceZ > 0){
|
if(TeamBluetoReddistanceZ > 0){
|
||||||
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
|
arenaMinZ = teamBlueCornerZ - schem2BorderZ;
|
||||||
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
|
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
|
arenaMinZ = teamRedCornerZ - schem2BorderZ;
|
||||||
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
|
arenaMaxZ = teamBlueCornerZ + schemsizeZ + schem2BorderZ;
|
||||||
if(TeamBluetoReddistanceZ != 0){
|
if(TeamBluetoReddistanceZ != 0){
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
@ -313,14 +285,16 @@ public class Config {
|
|||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}
|
}
|
||||||
TeamRedRotate = teamRedRotate;
|
RedRotate = teamRedRotate;
|
||||||
TeamBlueRotate = teamBlueRotate;
|
BlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
RedPasteRegion = new Region(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ, SchemsizeX, SchemsizeY, SchemsizeZ);
|
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
BluePasteRegion = new Region(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ, SchemsizeX, SchemsizeY, SchemsizeZ);
|
BluePasteRegion = new Region(teamBlueCornerX, teamBlueCornerY, teamBlueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
RedExetendRegion = new Region(TeamRedCornerX, underArenaBorder, TeamRedCornerZ, SchemsizeX, upperArenaBorder, SchemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
|
||||||
BlueExtendRegion = new Region(TeamBlueCornerX, underArenaBorder, TeamBlueCornerZ, SchemsizeX, upperArenaBorder, SchemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
RedExtendRegion = new Region(teamRedCornerX, underArenaBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
||||||
ArenaRegion = new Region(ArenaMinX, underArenaBorder, ArenaMinZ, ArenaMaxX - ArenaMinX, upperArenaBorder - underArenaBorder, ArenaMaxZ - ArenaMinZ);
|
BlueExtendRegion = new Region(teamBlueCornerX, underArenaBorder, teamBlueCornerZ, schemsizeX, schemsizeY, schemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
||||||
|
int upperArenaBorder = teamBlueCornerY + schemsizeY + BorderFromSchematic;
|
||||||
|
ArenaRegion = new Region(arenaMinX, underArenaBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underArenaBorder, arenaMaxZ - arenaMinZ);
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(EventKampfID >= 1){
|
if(EventKampfID >= 1){
|
||||||
|
@ -19,39 +19,19 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import de.steamwar.fightsystem.fight.IFight;
|
import de.steamwar.fightsystem.fight.IFight;
|
||||||
import de.steamwar.fightsystem.fight.IFightTeam;
|
import de.steamwar.fightsystem.fight.IFightTeam;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ITechHider {
|
public class ITechHider {
|
||||||
private ITechHider (){}
|
private ITechHider (){}
|
||||||
|
|
||||||
static final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
|
||||||
static final Material obfuscateMaterial;
|
|
||||||
static final int threadMultiplier;
|
|
||||||
|
|
||||||
static{
|
|
||||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
|
||||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
|
||||||
|
|
||||||
if(Config.mode == ArenaMode.EVENT)
|
|
||||||
threadMultiplier = 4;
|
|
||||||
else
|
|
||||||
threadMultiplier = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean bypass(Player p, int chunkX, int chunkZ){
|
static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||||
if(p == IFightSystem.getEventLeiter())
|
if(p == IFightSystem.getEventLeiter())
|
||||||
return true;
|
return true;
|
||||||
@ -62,7 +42,7 @@ public class ITechHider {
|
|||||||
}else if(ft.isBlue()){
|
}else if(ft.isBlue()){
|
||||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
}else{
|
}else{
|
||||||
return ft.canPlayerEntern(p) || Config.RedExetendRegion.chunkOutside(chunkX, chunkZ);
|
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.util.TriConsumer;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
@ -79,6 +80,28 @@ public class Region {
|
|||||||
executor.accept(x, z);
|
executor.accept(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forEach(TriConsumer<Integer, Integer, Integer> executor) {
|
||||||
|
for(int x = minX; x < maxX; x++) {
|
||||||
|
for(int y = minY; y < maxY; y++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
executor.accept(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int volume(){
|
||||||
|
return (maxX - minX) * (maxY - minY) * (maxZ - minZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int centerX() {
|
||||||
|
return (maxX - minX) / 2 + minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int centerZ() {
|
||||||
|
return (maxZ - minZ) / 2 + minZ;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean in2dRegion(Location location){
|
public boolean in2dRegion(Location location){
|
||||||
return minX <= location.getX() && location.getX() < maxX && minZ <= location.getZ() && location.getZ() <= maxZ;
|
return minX <= location.getX() && location.getX() < maxX && minZ <= location.getZ() && location.getZ() <= maxZ;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ import de.steamwar.core.Core;
|
|||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
|
import de.steamwar.fightsystem.listener.Shutdown;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.record.Recorder;
|
import de.steamwar.fightsystem.record.Recorder;
|
||||||
@ -38,7 +38,6 @@ import de.steamwar.fightsystem.winconditions.*;
|
|||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -144,10 +143,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Recorder.closeAll();
|
Recorder.closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void setPreLeaderState() {
|
public static void setPreLeaderState() {
|
||||||
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||||
|
|
||||||
|
Fight.getBlueTeam().reset();
|
||||||
|
Fight.getRedTeam().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreSchemState() {
|
public static void setPreSchemState() {
|
||||||
@ -161,12 +161,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static void setPreRunningState() {
|
public static void setPreRunningState() {
|
||||||
FightState.setFightState(FightState.PRE_RUNNING);
|
FightState.setFightState(FightState.PRE_RUNNING);
|
||||||
|
|
||||||
Fight.getBlueTeam().loadKits();
|
|
||||||
Fight.getRedTeam().loadKits();
|
|
||||||
setAllPlayersGM(GameMode.SURVIVAL);
|
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
||||||
|
|
||||||
Fight.replaceSync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRunningState() {
|
public static void setRunningState() {
|
||||||
@ -179,11 +174,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
|
|
||||||
setAllPlayersGM(GameMode.SPECTATOR);
|
|
||||||
Fight.getBlueTeam().teleportToSpawn();
|
|
||||||
Fight.getRedTeam().teleportToSpawn();
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(winFightTeam != null) {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
||||||
} else {
|
} else {
|
||||||
@ -223,14 +213,4 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static void shutdown(String reason){
|
public static void shutdown(String reason){
|
||||||
IFightSystem.shutdown(reason);
|
IFightSystem.shutdown(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setAllPlayersGM(GameMode gm) {
|
|
||||||
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
|
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
|
||||||
}
|
|
||||||
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
|
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ public class LeaderCommand implements CommandExecutor {
|
|||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
if(Fight.getFightPlayer(player) == null){
|
if(Fight.getFightPlayer(player) == null){
|
||||||
if(Fight.getBlueTeam().isLeaderless())
|
if(Fight.getBlueTeam().isLeaderless())
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
else if(Fight.getRedTeam().isLeaderless())
|
else if(Fight.getRedTeam().isLeaderless())
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
else
|
else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
||||||
}else
|
}else
|
||||||
|
@ -42,8 +42,8 @@ import java.util.logging.Level;
|
|||||||
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.RedExetendRegion, Config.TeamRedRotate, 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.TeamBlueRotate, 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);
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
IFight.init(redTeam, blueTeam);
|
IFight.init(redTeam, blueTeam);
|
||||||
@ -106,11 +106,6 @@ public class Fight {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceSync() {
|
|
||||||
redTeam.replaceSync();
|
|
||||||
blueTeam.replaceSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPlayerGamemode(Player player, GameMode gameMode) {
|
public static void setPlayerGamemode(Player player, GameMode gameMode) {
|
||||||
player.setGameMode(gameMode);
|
player.setGameMode(gameMode);
|
||||||
|
|
||||||
|
@ -54,9 +54,7 @@ public class FightPlayer {
|
|||||||
|
|
||||||
public void setOut() {
|
public void setOut() {
|
||||||
isOut = true;
|
isOut = true;
|
||||||
if(enternCountdown != null){
|
stopEnternCountdown();
|
||||||
enternCountdown.disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnternCountdown(EnternCountdown countdown){
|
public void setEnternCountdown(EnternCountdown countdown){
|
||||||
|
@ -30,6 +30,7 @@ import de.steamwar.fightsystem.record.RecordSystem;
|
|||||||
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.ColorConverter;
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -48,26 +49,16 @@ import java.util.logging.Level;
|
|||||||
public class FightSchematic extends StateDependent {
|
public class FightSchematic extends StateDependent {
|
||||||
|
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private final int pasteX;
|
private final Region region;
|
||||||
private final int pasteY;
|
|
||||||
private final int pasteZ;
|
|
||||||
private final int cornerX;
|
|
||||||
private final int cornerY;
|
|
||||||
private final int cornerZ;
|
|
||||||
private final boolean rotate;
|
private final boolean rotate;
|
||||||
|
|
||||||
private Clipboard clipboard = null;
|
private Clipboard clipboard = null;
|
||||||
private int schematic = 0;
|
private int schematic = 0;
|
||||||
|
|
||||||
public FightSchematic(FightTeam team, int pasteX, int pasteY, int pasteZ, int cornerX, int cornerY, int cornerZ, boolean rotate) {
|
public FightSchematic(FightTeam team, boolean rotate) {
|
||||||
super(ArenaMode.All, FightState.Schem);
|
super(ArenaMode.All, FightState.PostSchemSetup);
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.pasteX = pasteX;
|
this.region = team.getSchemRegion();
|
||||||
this.pasteY = pasteY;
|
|
||||||
this.pasteZ = pasteZ;
|
|
||||||
this.cornerX = cornerX;
|
|
||||||
this.cornerY = cornerY;
|
|
||||||
this.cornerZ = cornerZ;
|
|
||||||
this.rotate = rotate;
|
this.rotate = rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +80,11 @@ public class FightSchematic extends StateDependent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset(){
|
||||||
|
schematic = 0;
|
||||||
|
clipboard = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if(FightState.getFightState() == FightState.SPECTATE)
|
if(FightState.getFightState() == FightState.SPECTATE)
|
||||||
@ -119,22 +115,22 @@ public class FightSchematic extends StateDependent {
|
|||||||
try {
|
try {
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
EditSession e = FightTeam_8.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
|
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
|
||||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
FightTeam_8.replaceTeamColor(e, c, region);
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
}
|
}
|
||||||
}, 8), new VersionedRunnable(() -> {
|
}, 8), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
EditSession e = FightTeam_8.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
|
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
|
||||||
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
FightTeam_12.replaceTeamColor(e, c, region);
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
}
|
}
|
||||||
}, 12), new VersionedRunnable(() -> {
|
}, 12), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
EditSession e = FightTeam_14.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
|
EditSession e = FightTeam_14.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
|
||||||
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
FightTeam_14.replaceTeamColor(e, c, region);
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
}
|
}
|
||||||
@ -148,35 +144,30 @@ public class FightSchematic extends StateDependent {
|
|||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceSync(boolean replace, Material target, Material replacement){
|
@Override
|
||||||
if(!replace)
|
public void disable() {
|
||||||
|
if(!Config.ReplaceObsidianBedrock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
Location minPoint = new Location(world,cornerX, cornerY, cornerZ);
|
|
||||||
Location maxPoint = new Location(world, (cornerX + Config.SchemsizeX), (cornerY + Config.SchemsizeY), (cornerZ + Config.SchemsizeZ));
|
|
||||||
|
|
||||||
FreezeWorld freezer = null;
|
FreezeWorld freezer = null;
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
if(!Config.ReplaceWithBlockupdates)
|
||||||
freezer = new FreezeWorld();
|
freezer = new FreezeWorld();
|
||||||
|
|
||||||
for(int x = minPoint.getBlockX(); x < maxPoint.getBlockX(); x++) {
|
replaceSync(Material.OBSIDIAN, Material.TNT);
|
||||||
for(int z = minPoint.getBlockZ(); z < maxPoint.getBlockZ(); z++) {
|
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
||||||
for(int y = minPoint.getBlockY(); y < maxPoint.getBlockY(); y++) {
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if(block.getType() == target)
|
|
||||||
block.setType(replacement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
if(!Config.ReplaceWithBlockupdates)
|
||||||
HandlerList.unregisterAll(freezer);
|
HandlerList.unregisterAll(freezer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void replaceSync(Material target, Material replacement){
|
||||||
public void disable() {
|
World world = Bukkit.getWorlds().get(0);
|
||||||
team.teleportToSpawn();
|
|
||||||
|
region.forEach((x, y, z) -> {
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
if(block.getType() == target)
|
||||||
|
block.setType(replacement);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FreezeWorld implements Listener {
|
private static class FreezeWorld implements Listener {
|
||||||
|
@ -29,6 +29,7 @@ import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
|||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
@ -48,14 +49,14 @@ import java.util.*;
|
|||||||
public class FightTeam implements IFightTeam{
|
public class FightTeam implements IFightTeam{
|
||||||
|
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
private final UUID designatedLeader;
|
private UUID designatedLeader;
|
||||||
private final Map<Player, FightPlayer> players = new HashMap<>();
|
private final Map<Player, FightPlayer> players = new HashMap<>();
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
private final Set<Player> invited = new HashSet<>();
|
private final Set<Player> invited = new HashSet<>();
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
private FightSchematic schematic;
|
private final FightSchematic schematic;
|
||||||
private final Team team;
|
private final Team team;
|
||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
|
|
||||||
@ -67,16 +68,16 @@ public class FightTeam implements IFightTeam{
|
|||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.schemRegion = schemRegion;
|
this.schemRegion = schemRegion;
|
||||||
this.extendRegion = extendRegion;
|
this.extendRegion = extendRegion;
|
||||||
int pasteX = schemRegion.getMinX() + Config.SchemsizeX / 2;
|
|
||||||
int pasteY = schemRegion.getMinY();
|
|
||||||
int pasteZ = schemRegion.getMinZ() + Config.SchemsizeZ / 2;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.schematic = new FightSchematic(this, pasteX, pasteY, pasteZ, schemRegion.getMinX(), schemRegion.getMinY(), schemRegion.getMinZ(), rotate);
|
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.designatedLeader = designatedLeader;
|
this.designatedLeader = designatedLeader;
|
||||||
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
|
this.schematic = new FightSchematic(this, rotate);
|
||||||
|
new KitLoader();
|
||||||
|
new SpectateHandler();
|
||||||
|
|
||||||
if(FightScoreboard.getScoreboard().getTeam(name) == null)
|
if(FightScoreboard.getScoreboard().getTeam(name) == null)
|
||||||
team = FightScoreboard.getScoreboard().registerNewTeam(name);
|
team = FightScoreboard.getScoreboard().registerNewTeam(name);
|
||||||
else
|
else
|
||||||
@ -96,18 +97,6 @@ public class FightTeam implements IFightTeam{
|
|||||||
return extendRegion;
|
return extendRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCornerX() {
|
|
||||||
return schemRegion.getMinX();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getCornerY() {
|
|
||||||
return schemRegion.getMinY();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getCornerZ() {
|
|
||||||
return schemRegion.getMinZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canbeLeader(Player p){
|
public boolean canbeLeader(Player p){
|
||||||
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
@ -145,11 +134,41 @@ public class FightTeam implements IFightTeam{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset(){
|
||||||
|
schematic.reset();
|
||||||
|
invited.clear();
|
||||||
|
Set<Player> playerSet = new HashSet<>(players.keySet());
|
||||||
|
for(Player player : playerSet){
|
||||||
|
if(!player.isOnline())
|
||||||
|
removePlayer(player);
|
||||||
|
}
|
||||||
|
FightPlayer leaderBackup = leader;
|
||||||
|
playerSet.removeIf(player -> !player.isOnline());
|
||||||
|
players.clear();
|
||||||
|
leader = null;
|
||||||
|
|
||||||
|
if(leaderBackup != null){
|
||||||
|
playerSet.remove(leaderBackup.getPlayer());
|
||||||
|
addMember(leaderBackup.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSet.forEach(this::addMember);
|
||||||
|
|
||||||
|
if(isLeaderless()){
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
|
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
|
||||||
|
addMember(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcast(String message) {
|
public void broadcast(String message) {
|
||||||
players.forEach((player, fp) -> player.sendMessage(message));
|
players.forEach((player, fp) -> player.sendMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightPlayer addMember(Player player) {
|
public void addMember(Player player) {
|
||||||
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
||||||
FightPlayer fightPlayer = new FightPlayer(player, this);
|
FightPlayer fightPlayer = new FightPlayer(player, this);
|
||||||
players.put(player, fightPlayer);
|
players.put(player, fightPlayer);
|
||||||
@ -168,7 +187,9 @@ public class FightTeam implements IFightTeam{
|
|||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
||||||
RecordSystem.playerJoins(player);
|
RecordSystem.playerJoins(player);
|
||||||
TechHider.reloadChunks(player, chunksToReload);
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
return fightPlayer;
|
|
||||||
|
if(isLeaderless())
|
||||||
|
setLeader(fightPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
public void removePlayer(Player player) {
|
||||||
@ -181,14 +202,17 @@ public class FightTeam implements IFightTeam{
|
|||||||
if(fightPlayer.equals(leader))
|
if(fightPlayer.equals(leader))
|
||||||
setLeader(null);
|
setLeader(null);
|
||||||
|
|
||||||
|
RecordSystem.entityDespawns(player);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
if(player.isOnline()){
|
||||||
if(!ArenaMode.Test.contains(Config.mode))
|
if(!ArenaMode.Test.contains(Config.mode))
|
||||||
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
||||||
RecordSystem.entityDespawns(player);
|
|
||||||
TechHider.reloadChunks(player, chunksToReload);
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLeaderless() {
|
public boolean isLeaderless() {
|
||||||
return leader == null;
|
return leader == null;
|
||||||
@ -203,9 +227,11 @@ public class FightTeam implements IFightTeam{
|
|||||||
return leader;
|
return leader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeader(FightPlayer leader) {
|
private void setLeader(FightPlayer leader) {
|
||||||
if (leader == null){
|
if (leader == null) {
|
||||||
if(!players.isEmpty()) {
|
if (FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
||||||
|
this.leader = null;
|
||||||
|
}else if(!players.isEmpty()) {
|
||||||
setLeader(players.values().iterator().next());
|
setLeader(players.values().iterator().next());
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||||
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
@ -213,10 +239,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PersonalKitCreator.notInKitCreator(leader.getPlayer()))
|
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
|
||||||
leader.getPlayer().closeInventory();
|
|
||||||
|
|
||||||
this.leader = leader;
|
this.leader = leader;
|
||||||
|
designatedLeader = null;
|
||||||
if(ready)
|
if(ready)
|
||||||
setReady(false);
|
setReady(false);
|
||||||
|
|
||||||
@ -328,18 +354,6 @@ public class FightTeam implements IFightTeam{
|
|||||||
return currentHearts / maximumHearts;
|
return currentHearts / maximumHearts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKits(){
|
|
||||||
for(FightPlayer fightPlayer : players.values()) {
|
|
||||||
fightPlayer.getPlayer().getInventory().clear();
|
|
||||||
fightPlayer.getKit().loadToPlayer(fightPlayer.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void replaceSync() {
|
|
||||||
schematic.replaceSync(Config.ReplaceObsidian, Material.OBSIDIAN, Material.TNT);
|
|
||||||
schematic.replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTeamColor(Team team, ChatColor color){
|
private void setTeamColor(Team team, ChatColor color){
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
|
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
|
||||||
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
|
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
|
||||||
@ -350,4 +364,43 @@ public class FightTeam implements IFightTeam{
|
|||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class KitLoader extends StateDependent {
|
||||||
|
private KitLoader() {
|
||||||
|
super(ArenaMode.All, FightState.Ingame);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
for(FightPlayer fightPlayer : players.values()) {
|
||||||
|
Player player = fightPlayer.getPlayer();
|
||||||
|
PersonalKitCreator.closeIfInKitCreator(player);
|
||||||
|
|
||||||
|
player.getInventory().clear();
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||||
|
fightPlayer.getKit().loadToPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
players.values().forEach(fightPlayer -> fightPlayer.getPlayer().getInventory().clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SpectateHandler extends StateDependent {
|
||||||
|
private SpectateHandler() {
|
||||||
|
super(ArenaMode.All, FightState.Spectate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SURVIVAL));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,12 @@ public class ArenaBorder implements Listener {
|
|||||||
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
|
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(to.getY() <= Config.underArenaBorder) {
|
if(to.getY() <= Config.ArenaRegion.getMinY()) {
|
||||||
if(FightState.infight())
|
if(FightState.infight())
|
||||||
player.damage(2);
|
player.damage(2);
|
||||||
else if(!Config.GroundWalkable)
|
else if(!Config.GroundWalkable)
|
||||||
player.teleport(team.getSpawn());
|
player.teleport(team.getSpawn());
|
||||||
}else if(to.getY() + 1.8 <= Config.upperArenaBorder){
|
}else if(to.getY() + 1.8 <= Config.ArenaRegion.getMaxY()){
|
||||||
reset(event);
|
reset(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.Config;
|
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.FightPlayer;
|
|
||||||
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.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
@ -80,9 +79,7 @@ public class EventJoin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
||||||
FightPlayer fp = team.addMember(player);
|
team.addMember(player);
|
||||||
if(team.isLeaderless())
|
|
||||||
team.setLeader(fp);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ public class NormalJoin implements Listener {
|
|||||||
|
|
||||||
if (fightTeam == null) {
|
if (fightTeam == null) {
|
||||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,7 @@ public class PersonalKitCreator implements Listener {
|
|||||||
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
|
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
|
||||||
|
|
||||||
public PersonalKitCreator(){
|
public PersonalKitCreator(){
|
||||||
new StateDependentListener(Config.PersonalKits, FightState.Setup, this){
|
new StateDependentListener(Config.PersonalKits, FightState.Setup, this);
|
||||||
@Override
|
|
||||||
public void disable(){
|
|
||||||
while(!openKitCreators.isEmpty()){
|
|
||||||
openKitCreators.values().iterator().next().close();
|
|
||||||
}
|
|
||||||
super.disable();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openKitCreator(Player player, PersonalKit kit){
|
public static void openKitCreator(Player player, PersonalKit kit){
|
||||||
@ -73,6 +65,14 @@ public class PersonalKitCreator implements Listener {
|
|||||||
return !openKitCreators.containsKey(player);
|
return !openKitCreators.containsKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void closeIfInKitCreator(HumanEntity player){
|
||||||
|
InventoryBackup backup = openKitCreators.get(player);
|
||||||
|
if(backup == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
backup.close();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e){
|
public void onInventoryClick(InventoryClickEvent e){
|
||||||
if(!openKitCreators.containsKey(e.getWhoClicked()))
|
if(!openKitCreators.containsKey(e.getWhoClicked()))
|
||||||
|
@ -41,7 +41,7 @@ public class PistonListener implements Listener {
|
|||||||
public void handlePistonExtend(BlockPistonExtendEvent e){
|
public void handlePistonExtend(BlockPistonExtendEvent e){
|
||||||
BlockFace b = e.getDirection().getOppositeFace();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExetendRegion.inRegion(block.getRelative(b))){
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExtendRegion.inRegion(block.getRelative(b))){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class PistonListener implements Listener {
|
|||||||
public void handlePistonRetract(BlockPistonRetractEvent e){
|
public void handlePistonRetract(BlockPistonRetractEvent e){
|
||||||
BlockFace b = e.getDirection().getOppositeFace();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExetendRegion.inRegion(block.getRelative(b))) {
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExtendRegion.inRegion(block.getRelative(b))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,9 @@ public class RankedJoin implements Listener {
|
|||||||
|
|
||||||
if (fightTeam == null) {
|
if (fightTeam == null) {
|
||||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class TeamArea implements Listener {
|
|||||||
else
|
else
|
||||||
return; // Is allowed in area
|
return; // Is allowed in area
|
||||||
checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
|
checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
|
||||||
}else if(Config.RedExetendRegion.playerInRegion(to)){
|
}else if(Config.RedExtendRegion.playerInRegion(to)){
|
||||||
if(team == null)
|
if(team == null)
|
||||||
reset(event, DENY_TEAM);
|
reset(event, DENY_TEAM);
|
||||||
else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
||||||
|
@ -32,7 +32,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
|
|
||||||
public class WaterRemover implements Listener {
|
public class WaterRemover implements Listener {
|
||||||
|
|
||||||
private static final int MIN_Y = Config.AlignWater ? Config.TeamBlueCornerY + Config.WaterDepth : Config.TeamBlueCornerY;
|
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + (Config.AlignWater ? Config.WaterDepth : 0);
|
||||||
|
|
||||||
public WaterRemover() {
|
public WaterRemover() {
|
||||||
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||||
|
@ -168,8 +168,8 @@ public class RecordSystem {
|
|||||||
public static synchronized void blockChange(Block block){
|
public static synchronized void blockChange(Block block){
|
||||||
int blockState = blockToId(block);
|
int blockState = blockToId(block);
|
||||||
|
|
||||||
int shortX = block.getX() - Config.ArenaMinX;
|
int shortX = block.getX() - Config.ArenaRegion.getMinX();
|
||||||
int shortZ = block.getZ() - Config.ArenaMinZ;
|
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
|
||||||
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
|
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
|
||||||
//Short block packet
|
//Short block packet
|
||||||
Recorder.rByte(0x33);
|
Recorder.rByte(0x33);
|
||||||
|
@ -33,6 +33,7 @@ import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.VersionedCallable;
|
||||||
import de.steamwar.core.events.ChunkListener;
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
@ -40,6 +41,7 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.IStateDependent;
|
import de.steamwar.fightsystem.states.IStateDependent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -52,7 +54,10 @@ public class TechHider implements IStateDependent {
|
|||||||
|
|
||||||
private final Set<FightState> enabled;
|
private final Set<FightState> enabled;
|
||||||
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
private final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
||||||
|
private final Material obfuscateMaterial;
|
||||||
private final PacketAdapter chunkHider;
|
private final PacketAdapter chunkHider;
|
||||||
|
private final int threadMultiplier;
|
||||||
|
|
||||||
public TechHider(){
|
public TechHider(){
|
||||||
FightState.registerStateDependent(this);
|
FightState.registerStateDependent(this);
|
||||||
@ -71,13 +76,21 @@ public class TechHider implements IStateDependent {
|
|||||||
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
|
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
|
||||||
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
|
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
|
||||||
|
|
||||||
|
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||||
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
|
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
|
||||||
new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
|
new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
|
||||||
new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
|
new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
|
||||||
|
|
||||||
|
if(Config.mode == ArenaMode.EVENT)
|
||||||
|
threadMultiplier = 4;
|
||||||
|
else
|
||||||
|
threadMultiplier = 1;
|
||||||
|
|
||||||
if(DISABLED)
|
if(DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
||||||
|
|
||||||
if(Core.getVersion() > 8){
|
if(Core.getVersion() > 8){
|
||||||
protocolManager.addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
|
protocolManager.addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
|
||||||
@Override
|
@Override
|
||||||
@ -114,7 +127,7 @@ public class TechHider implements IStateDependent {
|
|||||||
protocolManager.addPacketListener(updateBlockEntity);
|
protocolManager.addPacketListener(updateBlockEntity);
|
||||||
}
|
}
|
||||||
if(chunkHider != null) {
|
if(chunkHider != null) {
|
||||||
protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(ITechHider.threadMultiplier * 4);
|
protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,14 +154,14 @@ public class TechHider implements IStateDependent {
|
|||||||
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
|
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer cached = ITechHider.packetCache.get(packet);
|
PacketContainer cached = packetCache.get(packet);
|
||||||
if(cached != null){
|
if(cached != null){
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached = packet.shallowClone();
|
cached = packet.shallowClone();
|
||||||
ITechHider.packetCache.put(packet, cached);
|
packetCache.put(packet, cached);
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
|
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
|
||||||
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
|
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
|
||||||
@ -157,7 +170,7 @@ public class TechHider implements IStateDependent {
|
|||||||
WrappedBlockData block = mbci.getData();
|
WrappedBlockData block = mbci.getData();
|
||||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||||
changed = true;
|
changed = true;
|
||||||
block.setType(ITechHider.obfuscateMaterial);
|
block.setType(obfuscateMaterial);
|
||||||
mbci.setData(block);
|
mbci.setData(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,19 +191,19 @@ public class TechHider implements IStateDependent {
|
|||||||
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer cached = ITechHider.packetCache.get(packet);
|
PacketContainer cached = packetCache.get(packet);
|
||||||
if(cached != null){
|
if(cached != null){
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached = packet.deepClone();
|
cached = packet.deepClone();
|
||||||
ITechHider.packetCache.put(packet, cached);
|
packetCache.put(packet, cached);
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
||||||
WrappedBlockData block = blockStructure.read(0);
|
WrappedBlockData block = blockStructure.read(0);
|
||||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||||
block.setType(ITechHider.obfuscateMaterial);
|
block.setType(obfuscateMaterial);
|
||||||
blockStructure.write(0, block);
|
blockStructure.write(0, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class WinconditionPercentSystem extends Wincondition implements Listener, PrintableWincondition, PercentWincondition {
|
public class WinconditionPercentSystem extends Wincondition implements Listener, PrintableWincondition, PercentWincondition {
|
||||||
|
|
||||||
private static final int SCHEMATIC_SIZE = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
|
||||||
|
|
||||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||||
|
|
||||||
public WinconditionPercentSystem() {
|
public WinconditionPercentSystem() {
|
||||||
@ -65,11 +63,13 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
|||||||
private class TeamPercent {
|
private class TeamPercent {
|
||||||
|
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
|
private final int volume;
|
||||||
private double percent;
|
private double percent;
|
||||||
private int destroyedBlocks;
|
private int destroyedBlocks;
|
||||||
|
|
||||||
private TeamPercent(FightTeam team) {
|
private TeamPercent(FightTeam team) {
|
||||||
this.team = team;
|
this.team = team;
|
||||||
|
this.volume = team.getSchemRegion().volume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(EntityExplodeEvent event) {
|
private void check(EntityExplodeEvent event) {
|
||||||
@ -78,7 +78,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroyedBlocks += event.blockList().size();
|
destroyedBlocks += event.blockList().size();
|
||||||
percent = (double)destroyedBlocks * 100 / SCHEMATIC_SIZE;
|
percent = (double)destroyedBlocks * 100 / volume;
|
||||||
if(percent >= Config.PercentWin) {
|
if(percent >= Config.PercentWin) {
|
||||||
win(Fight.getOpposite(team));
|
win(Fight.getOpposite(team));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
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;
|
||||||
@ -66,14 +65,10 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
|||||||
|
|
||||||
private void check(){
|
private void check(){
|
||||||
pumpkins = 0;
|
pumpkins = 0;
|
||||||
for(int x = team.getCornerX(); x <= team.getCornerX() + Config.SchemsizeX; x++) {
|
team.getSchemRegion().forEach((x, y, z) -> {
|
||||||
for(int y = team.getCornerY(); y <= team.getCornerY() + Config.SchemsizeY; y++) {
|
|
||||||
for (int z = team.getCornerZ(); z <= team.getCornerZ() + Config.SchemsizeZ; z++) {
|
|
||||||
if (world.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
|
if (world.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
|
||||||
pumpkins++;
|
pumpkins++;
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pumpkins == 0) {
|
if(pumpkins == 0) {
|
||||||
win(Fight.getOpposite(team));
|
win(Fight.getOpposite(team));
|
||||||
|
@ -97,7 +97,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void check(){
|
private void check(){
|
||||||
currentBlocks = currentBlocks();
|
currentBlocks();
|
||||||
|
|
||||||
if(!Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT))
|
if(!Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT))
|
||||||
return;
|
return;
|
||||||
@ -123,16 +123,12 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
|||||||
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Config.TimeoutTime - Wincondition.getTimeOverCountdown().getTimeLeft())
|
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Config.TimeoutTime - Wincondition.getTimeOverCountdown().getTimeLeft())
|
||||||
return currentBlocks;
|
return currentBlocks;
|
||||||
|
|
||||||
int blocks = 0;
|
currentBlocks = 0;
|
||||||
for(int x = team.getCornerX(); x < team.getCornerX() + Config.SchemsizeX; x++){
|
team.getSchemRegion().forEach((x, y, z) -> {
|
||||||
for(int y = team.getCornerY(); y < team.getCornerY() + Config.SchemsizeY; y++){
|
|
||||||
for(int z = team.getCornerZ(); z < team.getCornerZ() + Config.SchemsizeZ; z++){
|
|
||||||
if(!ignoredBlocks.contains(world.getBlockAt(x,y,z).getType()))
|
if(!ignoredBlocks.contains(world.getBlockAt(x,y,z).getType()))
|
||||||
blocks++;
|
currentBlocks++;
|
||||||
}
|
});
|
||||||
}
|
return currentBlocks;
|
||||||
}
|
|
||||||
return blocks;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
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.listener.WaterRemover;
|
import de.steamwar.fightsystem.listener.WaterRemover;
|
||||||
@ -65,14 +64,10 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
|||||||
|
|
||||||
private void check() {
|
private void check() {
|
||||||
water = 0;
|
water = 0;
|
||||||
for(int x = team.getCornerX(); x <= team.getCornerX() + Config.SchemsizeX; x++) {
|
team.getExtendRegion().forEach((x, y, z) -> {
|
||||||
for(int y = team.getCornerY(); y <= team.getCornerY() + Config.SchemsizeY; y++) {
|
|
||||||
for (int z = team.getCornerZ(); z <= team.getCornerZ() + Config.SchemsizeZ; z++) {
|
|
||||||
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
||||||
water++;
|
water++;
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(water == 0){
|
if(water == 0){
|
||||||
win(Fight.getOpposite(team));
|
win(Fight.getOpposite(team));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren