SteamWar/FightSystem
Archiviert
13
1

The big refactoring #238

Manuell gemergt
Lixfel hat 16 Commits von refactoring nach master 2021-03-31 20:08:07 +02:00 zusammengeführt
26 geänderte Dateien mit 287 neuen und 299 gelöschten Zeilen
Nur Änderungen aus Commit 9b65277c66 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -24,7 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.regions.CuboidRegion;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.Region;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
@ -54,10 +54,9 @@ class FightTeam_12 {
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
Vector corner = new Vector(cornerX, cornerY, cornerZ);
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
FightTeam_8.replaceTeamColor(e, c, r);
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
try {
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));

Datei anzeigen

@ -33,6 +33,7 @@ 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.utils.Region;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@ -61,10 +62,8 @@ class FightTeam_14 {
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){
BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ);
BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ);
CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3));
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
CuboidRegion region = new CuboidRegion(BlockVector3.at(r.getMinX(), r.getMinY(), r.getMinZ()), BlockVector3.at(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
try {
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());

Datei anzeigen

@ -32,6 +32,7 @@ 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.utils.Region;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@ -72,9 +73,8 @@ class FightTeam_8 {
}
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
Vector corner = new Vector(cornerX, cornerY, cornerZ);
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
try {
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));

Datei anzeigen

@ -54,39 +54,20 @@ public class Config {
public static final Region BluePasteRegion;
public static final Region RedPasteRegion;
public static final Region BlueExtendRegion;
public static final Region RedExetendRegion;
public static final Region RedExtendRegion;
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 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 SpecSpawn;
private static final int TeamBluetoReddistanceX;
private static final int TeamBluetoReddistanceY;
public static final int TeamBluetoReddistanceZ;
public static final Location SpecSpawn;
public static final int underArenaBorder;
public static final int BorderFromSchematic;
public static final int upperArenaBorder;
public static final boolean AlignWater;
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;
//schematic parameter
@ -94,10 +75,9 @@ public class Config {
public static final boolean OnlyPublicSchematics;
public static final boolean IgnorePublicOnly;
public static final de.steamwar.sql.SchematicType SchematicType;
public static final boolean TeamRedRotate;
public static final boolean TeamBlueRotate;
public static final boolean ReplaceObsidian;
public static final boolean ReplaceBedrock;
public static final boolean RedRotate;
public static final boolean BlueRotate;
public static final boolean ReplaceObsidianBedrock;
public static final boolean ReplaceWithBlockupdates;
//team parameter
@ -180,9 +160,9 @@ public class Config {
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
Schem2BorderX = config.getInt("Arena.Schem2Border.x");
Schem2BorderZ = config.getInt("Arena.Schem2Border.z");
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
int schem2BorderX = config.getInt("Arena.Schem2Border.x");
int schem2BorderZ = config.getInt("Arena.Schem2Border.z");
int underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
BorderFromSchematic = config.getInt("Arena.BorderFromSchematic");
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
@ -195,14 +175,13 @@ public class Config {
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
boolean rotate = config.getBoolean("Schematic.Rotate");
ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian");
ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock");
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock");
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
GameName = config.getString("Output.GameName");
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");
PercentWin = config.getDouble("WinConditionParams.PercentWin");
@ -214,7 +193,7 @@ public class Config {
MemberDefault = config.getString("Kits.MemberDefault");
LeaderDefault = config.getString("Kits.LeaderDefault");
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")));
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
@ -222,88 +201,81 @@ public class Config {
TechhiderActive = config.getBoolean("Techhider.Active");
if(schemsizeX < 0){
SchemsizeX = -schemsizeX;
TeamBlueCornerX = teamBlueCornerX - SchemsizeX;
}else{
SchemsizeX = schemsizeX;
TeamBlueCornerX = teamBlueCornerX;
schemsizeX = -schemsizeX;
teamBlueCornerX = teamBlueCornerX - schemsizeX;
}
if(schemsizeY < 0){
SchemsizeY = -schemsizeY;
TeamBlueCornerY = teamBlueCornerY - SchemsizeY;
}else{
SchemsizeY = schemsizeY;
TeamBlueCornerY = teamBlueCornerY;
schemsizeY = -schemsizeY;
teamBlueCornerY = teamBlueCornerY - schemsizeY;
}
if(schemsizeZ < 0){
SchemsizeZ = -schemsizeZ;
TeamBlueCornerZ = teamBlueCornerZ - SchemsizeZ;
}else{
SchemsizeZ = schemsizeZ;
TeamBlueCornerZ = teamBlueCornerZ;
schemsizeZ = -schemsizeZ;
teamBlueCornerZ = teamBlueCornerZ - schemsizeZ;
}
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
int teamRedCornerX = TeamBluetoReddistanceX + teamBlueCornerX;
int teamRedCornerY = TeamBluetoReddistanceY + teamBlueCornerY;
int teamRedCornerZ = TeamBluetoReddistanceZ + teamBlueCornerZ;
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
int teamBluePasteX = teamBlueCornerX + schemsizeX / 2;
int teamBluePasteZ = teamBlueCornerZ + schemsizeZ / 2;
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
World world = Bukkit.getWorlds().get(0);
TeamBlueSpawn = new Location(world,
TeamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
TeamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
TeamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
teamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
TeamRedSpawn = new Location(world,
TeamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
TeamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
TeamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
teamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
teamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
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());
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 pitchInverted = pitch * -1;
double yawInverted = yaw + 180;
TeamBlueSpawn.setYaw((float) yawInverted);
TeamBlueSpawn.setYaw((float) yaw + 180);
TeamBlueSpawn.setPitch((float) pitch);
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 teamBlueRotate;
int arenaMinX;
int arenaMaxX;
int arenaMinZ;
int arenaMaxZ;
if(TeamBluetoReddistanceX > 0){
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
arenaMinX = teamBlueCornerX - schem2BorderX;
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
teamRedRotate = true;
teamBlueRotate = false;
}else{
ArenaMinX = TeamRedCornerX - Schem2BorderX;
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
arenaMinX = teamRedCornerX - schem2BorderX;
arenaMaxX = teamBlueCornerX + schemsizeX + schem2BorderX;
teamRedRotate = false;
teamBlueRotate = true;
}
if(TeamBluetoReddistanceZ > 0){
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
arenaMinZ = teamBlueCornerZ - schem2BorderZ;
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
teamRedRotate = true;
teamBlueRotate = false;
}else{
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
arenaMinZ = teamRedCornerZ - schem2BorderZ;
arenaMaxZ = teamBlueCornerZ + schemsizeZ + schem2BorderZ;
if(TeamBluetoReddistanceZ != 0){
teamRedRotate = false;
teamBlueRotate = true;
@ -313,14 +285,16 @@ public class Config {
teamRedRotate = false;
teamBlueRotate = false;
}
TeamRedRotate = teamRedRotate;
TeamBlueRotate = teamBlueRotate;
RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate;
RedPasteRegion = new Region(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ, 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);
ArenaRegion = new Region(ArenaMinX, underArenaBorder, ArenaMinZ, ArenaMaxX - ArenaMinX, upperArenaBorder - underArenaBorder, ArenaMaxZ - ArenaMinZ);
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(teamBlueCornerX, teamBlueCornerY, teamBlueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, underArenaBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, BorderFromSchematic, BorderFromSchematic);
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"));
if(EventKampfID >= 1){

Datei anzeigen

@ -19,39 +19,19 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.protocol.events.PacketContainer;
import com.google.common.primitives.Bytes;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.fight.IFight;
import de.steamwar.fightsystem.fight.IFightTeam;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class 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){
if(p == IFightSystem.getEventLeiter())
return true;
@ -62,7 +42,7 @@ public class ITechHider {
}else if(ft.isBlue()){
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
}else{
return ft.canPlayerEntern(p) || Config.RedExetendRegion.chunkOutside(chunkX, chunkZ);
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.fightsystem.utils;
import org.apache.logging.log4j.util.TriConsumer;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -79,6 +80,28 @@ public class Region {
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){
return minX <= location.getX() && location.getX() < maxX && minZ <= location.getZ() && location.getZ() <= maxZ;
}

Datei anzeigen

@ -24,9 +24,9 @@ import de.steamwar.core.Core;
import de.steamwar.fightsystem.commands.*;
import de.steamwar.fightsystem.countdown.*;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.record.Recorder;
@ -38,7 +38,6 @@ import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -144,10 +143,11 @@ public class FightSystem extends JavaPlugin {
Recorder.closeAll();
}
public static void setPreLeaderState() {
FightState.setFightState(FightState.PRE_LEADER_SETUP);
Fight.getBlueTeam().reset();
Fight.getRedTeam().reset();
}
public static void setPreSchemState() {
@ -161,12 +161,7 @@ public class FightSystem extends JavaPlugin {
public static void setPreRunningState() {
FightState.setFightState(FightState.PRE_RUNNING);
Fight.getBlueTeam().loadKits();
Fight.getRedTeam().loadKits();
setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
Fight.replaceSync();
}
public static void setRunningState() {
@ -179,11 +174,6 @@ public class FightSystem extends JavaPlugin {
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
FightState.setFightState(FightState.SPECTATE);
setAllPlayersGM(GameMode.SPECTATOR);
Fight.getBlueTeam().teleportToSpawn();
Fight.getRedTeam().teleportToSpawn();
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
} else {
@ -223,14 +213,4 @@ public class FightSystem extends JavaPlugin {
public static void shutdown(String 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);
}
}
}

Datei anzeigen

@ -44,9 +44,9 @@ public class LeaderCommand implements CommandExecutor {
if(args.length == 0){
if(Fight.getFightPlayer(player) == null){
if(Fight.getBlueTeam().isLeaderless())
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
Fight.getBlueTeam().addMember(player);
else if(Fight.getRedTeam().isLeaderless())
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
Fight.getRedTeam().addMember(player);
else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
}else

Datei anzeigen

@ -42,8 +42,8 @@ import java.util.logging.Level;
public class 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 blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.TeamBlueRotate, true, Config.BlueLeader);
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);
public static void init(){
IFight.init(redTeam, blueTeam);
@ -106,11 +106,6 @@ public class Fight {
return null;
}
public static void replaceSync() {
redTeam.replaceSync();
blueTeam.replaceSync();
}
public static void setPlayerGamemode(Player player, GameMode gameMode) {
player.setGameMode(gameMode);

Datei anzeigen

@ -54,9 +54,7 @@ public class FightPlayer {
public void setOut() {
isOut = true;
if(enternCountdown != null){
enternCountdown.disable();
}
stopEnternCountdown();
}
public void setEnternCountdown(EnternCountdown countdown){

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.*;
@ -48,26 +49,16 @@ import java.util.logging.Level;
public class FightSchematic extends StateDependent {
private final FightTeam team;
private final int pasteX;
private final int pasteY;
private final int pasteZ;
private final int cornerX;
private final int cornerY;
private final int cornerZ;
private final Region region;
private final boolean rotate;
private Clipboard clipboard = null;
private int schematic = 0;
public FightSchematic(FightTeam team, int pasteX, int pasteY, int pasteZ, int cornerX, int cornerY, int cornerZ, boolean rotate) {
super(ArenaMode.All, FightState.Schem);
public FightSchematic(FightTeam team, boolean rotate) {
super(ArenaMode.All, FightState.PostSchemSetup);
this.team = team;
this.pasteX = pasteX;
this.pasteY = pasteY;
this.pasteZ = pasteZ;
this.cornerX = cornerX;
this.cornerY = cornerY;
this.cornerZ = cornerZ;
this.region = team.getSchemRegion();
this.rotate = rotate;
}
@ -89,6 +80,11 @@ public class FightSchematic extends StateDependent {
}
}
public void reset(){
schematic = 0;
clipboard = null;
}
@Override
public void enable() {
if(FightState.getFightState() == FightState.SPECTATE)
@ -119,22 +115,22 @@ public class FightSchematic extends StateDependent {
try {
VersionedRunnable.call(new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_8.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
FightTeam_8.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
throw new SecurityException("Error pasting arena in schematic", ex);
}
}, 8), new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_8.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
FightTeam_12.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
throw new SecurityException("Error pasting arena in schematic", ex);
}
}, 12), new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_14.pasteSchematic(clipboard, pasteX, pasteY, pasteZ, rotate);
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
EditSession e = FightTeam_14.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
FightTeam_14.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException 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);
}
public void replaceSync(boolean replace, Material target, Material replacement){
if(!replace)
@Override
public void disable() {
if(!Config.ReplaceObsidianBedrock)
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;
if(!Config.ReplaceWithBlockupdates)
freezer = new FreezeWorld();
for(int x = minPoint.getBlockX(); x < maxPoint.getBlockX(); x++) {
for(int z = minPoint.getBlockZ(); z < maxPoint.getBlockZ(); z++) {
for(int y = minPoint.getBlockY(); y < maxPoint.getBlockY(); y++) {
Block block = world.getBlockAt(x, y, z);
if(block.getType() == target)
block.setType(replacement);
}
}
}
replaceSync(Material.OBSIDIAN, Material.TNT);
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
if(!Config.ReplaceWithBlockupdates)
HandlerList.unregisterAll(freezer);
}
@Override
public void disable() {
team.teleportToSpawn();
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);
if(block.getType() == target)
block.setType(replacement);
});
}
private static class FreezeWorld implements Listener {

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.ItemBuilder;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.TechHider;
@ -48,14 +49,14 @@ import java.util.*;
public class FightTeam implements IFightTeam{
private FightPlayer leader;
private final UUID designatedLeader;
private UUID designatedLeader;
private final Map<Player, FightPlayer> players = new HashMap<>();
private boolean ready;
private final Set<Player> invited = new HashSet<>();
private final String name;
private final String prefix;
private final ChatColor color;
private FightSchematic schematic;
private final FightSchematic schematic;
private final Team team;
private final boolean blue;
@ -67,16 +68,16 @@ public class FightTeam implements IFightTeam{
this.spawn = spawn;
this.schemRegion = schemRegion;
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.prefix = prefix;
this.ready = false;
this.schematic = new FightSchematic(this, pasteX, pasteY, pasteZ, schemRegion.getMinX(), schemRegion.getMinY(), schemRegion.getMinZ(), rotate);
this.blue = blue;
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)
team = FightScoreboard.getScoreboard().registerNewTeam(name);
else
@ -96,18 +97,6 @@ public class FightTeam implements IFightTeam{
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){
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
}
@ -145,11 +134,41 @@ public class FightTeam implements IFightTeam{
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) {
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);
FightPlayer fightPlayer = new FightPlayer(player, this);
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);
RecordSystem.playerJoins(player);
TechHider.reloadChunks(player, chunksToReload);
return fightPlayer;
if(isLeaderless())
setLeader(fightPlayer);
}
public void removePlayer(Player player) {
@ -181,14 +202,17 @@ public class FightTeam implements IFightTeam{
if(fightPlayer.equals(leader))
setLeader(null);
RecordSystem.entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
player.getInventory().clear();
if(player.isOnline()){
if(!ArenaMode.Test.contains(Config.mode))
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
RecordSystem.entityDespawns(player);
TechHider.reloadChunks(player, chunksToReload);
}
}
public boolean isLeaderless() {
return leader == null;
@ -203,9 +227,11 @@ public class FightTeam implements IFightTeam{
return leader;
}
public void setLeader(FightPlayer leader) {
if (leader == null){
if(!players.isEmpty()) {
private void setLeader(FightPlayer leader) {
if (leader == null) {
if (FightState.getFightState() == FightState.PRE_LEADER_SETUP){
this.leader = null;
}else if(!players.isEmpty()) {
setLeader(players.values().iterator().next());
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)){
@ -213,10 +239,10 @@ public class FightTeam implements IFightTeam{
}
return;
}
if (!PersonalKitCreator.notInKitCreator(leader.getPlayer()))
leader.getPlayer().closeInventory();
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
this.leader = leader;
designatedLeader = null;
if(ready)
setReady(false);
@ -328,18 +354,6 @@ public class FightTeam implements IFightTeam{
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){
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
@ -350,4 +364,43 @@ public class FightTeam implements IFightTeam{
public ChatColor getColor() {
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));
}
}
}

Datei anzeigen

@ -54,12 +54,12 @@ public class ArenaBorder implements Listener {
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
return;
if(to.getY() <= Config.underArenaBorder) {
if(to.getY() <= Config.ArenaRegion.getMinY()) {
if(FightState.infight())
player.damage(2);
else if(!Config.GroundWalkable)
player.teleport(team.getSpawn());
}else if(to.getY() + 1.8 <= Config.upperArenaBorder){
}else if(to.getY() + 1.8 <= Config.ArenaRegion.getMaxY()){
reset(event);
}
}

Datei anzeigen

@ -23,7 +23,6 @@ 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.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@ -80,9 +79,7 @@ public class EventJoin implements Listener {
}
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
FightPlayer fp = team.addMember(player);
if(team.isLeaderless())
team.setLeader(fp);
team.addMember(player);
return;
}

Datei anzeigen

@ -45,9 +45,9 @@ public class NormalJoin implements Listener {
if (fightTeam == null) {
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)) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
Fight.getRedTeam().addMember(player);
}
}

Datei anzeigen

@ -50,15 +50,7 @@ public class PersonalKitCreator implements Listener {
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
public PersonalKitCreator(){
new StateDependentListener(Config.PersonalKits, FightState.Setup, this){
@Override
public void disable(){
while(!openKitCreators.isEmpty()){
openKitCreators.values().iterator().next().close();
}
super.disable();
}
};
new StateDependentListener(Config.PersonalKits, FightState.Setup, this);
}
public static void openKitCreator(Player player, PersonalKit kit){
@ -73,6 +65,14 @@ public class PersonalKitCreator implements Listener {
return !openKitCreators.containsKey(player);
}
public static void closeIfInKitCreator(HumanEntity player){
InventoryBackup backup = openKitCreators.get(player);
if(backup == null)
return;
backup.close();
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
if(!openKitCreators.containsKey(e.getWhoClicked()))

Datei anzeigen

@ -41,7 +41,7 @@ public class PistonListener implements Listener {
public void handlePistonExtend(BlockPistonExtendEvent e){
BlockFace b = e.getDirection().getOppositeFace();
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);
return;
}
@ -52,7 +52,7 @@ public class PistonListener implements Listener {
public void handlePistonRetract(BlockPistonRetractEvent e){
BlockFace b = e.getDirection().getOppositeFace();
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);
return;
}

Datei anzeigen

@ -43,9 +43,9 @@ public class RankedJoin implements Listener {
if (fightTeam == null) {
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)) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
Fight.getRedTeam().addMember(player);
}
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class TeamArea implements Listener {
else
return; // Is allowed in area
checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
}else if(Config.RedExetendRegion.playerInRegion(to)){
}else if(Config.RedExtendRegion.playerInRegion(to)){
if(team == null)
reset(event, DENY_TEAM);
else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
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() {
new StateDependentListener(ArenaMode.All, FightState.Running, this);

Datei anzeigen

@ -168,8 +168,8 @@ public class RecordSystem {
public static synchronized void blockChange(Block block){
int blockState = blockToId(block);
int shortX = block.getX() - Config.ArenaMinX;
int shortZ = block.getZ() - Config.ArenaMinZ;
int shortX = block.getX() - Config.ArenaRegion.getMinX();
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
//Short block packet
Recorder.rByte(0x33);

Datei anzeigen

@ -33,6 +33,7 @@ import com.comphenix.protocol.wrappers.WrappedBlockData;
import de.steamwar.core.Core;
import de.steamwar.core.VersionedCallable;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.IFightSystem;
@ -40,6 +41,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.IStateDependent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.*;
@ -52,7 +54,10 @@ public class TechHider implements IStateDependent {
private final Set<FightState> enabled;
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
private final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
private final Material obfuscateMaterial;
private final PacketAdapter chunkHider;
private final int threadMultiplier;
public TechHider(){
FightState.registerStateDependent(this);
@ -71,13 +76,21 @@ public class TechHider implements IStateDependent {
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
if(Config.mode == ArenaMode.EVENT)
threadMultiplier = 4;
else
threadMultiplier = 1;
if(DISABLED)
return;
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
if(Core.getVersion() > 8){
protocolManager.addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
@Override
@ -114,7 +127,7 @@ public class TechHider implements IStateDependent {
protocolManager.addPacketListener(updateBlockEntity);
}
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()))
return;
PacketContainer cached = ITechHider.packetCache.get(packet);
PacketContainer cached = packetCache.get(packet);
if(cached != null){
e.setPacket(cached);
return;
}
cached = packet.shallowClone();
ITechHider.packetCache.put(packet, cached);
packetCache.put(packet, cached);
e.setPacket(cached);
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
@ -157,7 +170,7 @@ public class TechHider implements IStateDependent {
WrappedBlockData block = mbci.getData();
if(Config.HiddenBlocks.contains(block.getType().name())){
changed = true;
block.setType(ITechHider.obfuscateMaterial);
block.setType(obfuscateMaterial);
mbci.setData(block);
}
}
@ -178,19 +191,19 @@ public class TechHider implements IStateDependent {
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
return;
PacketContainer cached = ITechHider.packetCache.get(packet);
PacketContainer cached = packetCache.get(packet);
if(cached != null){
e.setPacket(cached);
return;
}
cached = packet.deepClone();
ITechHider.packetCache.put(packet, cached);
packetCache.put(packet, cached);
e.setPacket(cached);
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
WrappedBlockData block = blockStructure.read(0);
if(Config.HiddenBlocks.contains(block.getType().name())){
block.setType(ITechHider.obfuscateMaterial);
block.setType(obfuscateMaterial);
blockStructure.write(0, block);
}
}

Datei anzeigen

@ -33,8 +33,6 @@ import java.util.Map;
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<>();
public WinconditionPercentSystem() {
@ -65,11 +63,13 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
private class TeamPercent {
private final FightTeam team;
private final int volume;
private double percent;
private int destroyedBlocks;
private TeamPercent(FightTeam team) {
this.team = team;
this.volume = team.getSchemRegion().volume();
}
private void check(EntityExplodeEvent event) {
@ -78,7 +78,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
}
destroyedBlocks += event.blockList().size();
percent = (double)destroyedBlocks * 100 / SCHEMATIC_SIZE;
percent = (double)destroyedBlocks * 100 / volume;
if(percent >= Config.PercentWin) {
win(Fight.getOpposite(team));
}

Datei anzeigen

@ -19,7 +19,6 @@
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;
@ -66,14 +65,10 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
private void check(){
pumpkins = 0;
for(int x = team.getCornerX(); x <= team.getCornerX() + Config.SchemsizeX; x++) {
for(int y = team.getCornerY(); y <= team.getCornerY() + Config.SchemsizeY; y++) {
for (int z = team.getCornerZ(); z <= team.getCornerZ() + Config.SchemsizeZ; z++) {
team.getSchemRegion().forEach((x, y, z) -> {
if (world.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
pumpkins++;
}
}
}
});
if(pumpkins == 0) {
win(Fight.getOpposite(team));

Datei anzeigen

@ -97,7 +97,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
}
private void check(){
currentBlocks = currentBlocks();
currentBlocks();
if(!Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT))
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())
return currentBlocks;
int blocks = 0;
for(int x = team.getCornerX(); x < team.getCornerX() + Config.SchemsizeX; x++){
for(int y = team.getCornerY(); y < team.getCornerY() + Config.SchemsizeY; y++){
for(int z = team.getCornerZ(); z < team.getCornerZ() + Config.SchemsizeZ; z++){
currentBlocks = 0;
team.getSchemRegion().forEach((x, y, z) -> {
if(!ignoredBlocks.contains(world.getBlockAt(x,y,z).getType()))
blocks++;
}
}
}
return blocks;
currentBlocks++;
});
return currentBlocks;
}
}
}

Datei anzeigen

@ -19,7 +19,6 @@
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.listener.WaterRemover;
@ -65,14 +64,10 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
private void check() {
water = 0;
for(int x = team.getCornerX(); x <= team.getCornerX() + Config.SchemsizeX; x++) {
for(int y = team.getCornerY(); y <= team.getCornerY() + Config.SchemsizeY; y++) {
for (int z = team.getCornerZ(); z <= team.getCornerZ() + Config.SchemsizeZ; z++) {
team.getExtendRegion().forEach((x, y, z) -> {
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
water++;
}
}
}
});
if(water == 0){
win(Fight.getOpposite(team));