The big refactoring #238
@ -289,13 +289,14 @@ public class Config {
|
|||||||
RedRotate = teamRedRotate;
|
RedRotate = teamRedRotate;
|
||||||
BlueRotate = teamBlueRotate;
|
BlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
|
int arenaYSize = schemsizeY + PreperationArea;
|
||||||
|
|
||||||
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
|
|
||||||
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
|
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||||
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
|
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||||
int upperArenaBorder = blueCornerY + schemsizeY + PreperationArea;
|
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ);
|
||||||
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underBorder, arenaMaxZ - arenaMinZ);
|
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(EventKampfID >= 1){
|
if(EventKampfID >= 1){
|
||||||
@ -380,7 +381,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean test(){
|
public static boolean test(){
|
||||||
return ArenaMode.Test.contains(ArenaMode.TEST);
|
return ArenaMode.Test.contains(mode);
|
||||||
}
|
}
|
||||||
public static boolean recording(){
|
public static boolean recording(){
|
||||||
return mode == ArenaMode.EVENT;
|
return mode == ArenaMode.EVENT;
|
||||||
|
@ -40,9 +40,9 @@ public class ITechHider {
|
|||||||
if(ft == null){
|
if(ft == null){
|
||||||
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
||||||
}else if(ft.isBlue()){
|
}else if(ft.isBlue()){
|
||||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
|
||||||
}else{
|
|
||||||
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
|
}else{
|
||||||
|
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ public class Region {
|
|||||||
private final int maxY;
|
private final int maxY;
|
||||||
private final int maxZ;
|
private final int maxZ;
|
||||||
|
|
||||||
public Region(int minX, int minY, int minZ, int sizeX, int maxY, int sizeZ, int extendX, int extendZ) {
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendZ) {
|
||||||
this(minX - extendX, minY, minZ - extendZ,
|
this(minX - extendX, minY, minZ - extendZ,
|
||||||
minX + sizeX + extendX, maxY, minZ + sizeZ + extendZ);
|
sizeX + extendX * 2, sizeY, sizeZ + extendZ * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||||
@ -52,20 +52,24 @@ public class Region {
|
|||||||
return maxZ;
|
return maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinChunkX(){
|
public double posToChunk(int pos){
|
||||||
return ITechHider.posToChunk(minX);
|
return pos / 16.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxChunkX(){
|
private int getMinChunkX(){
|
||||||
return ITechHider.posToChunk(maxX);
|
return (int) Math.floor(posToChunk(minX));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinChunkZ(){
|
private int getMaxChunkX(){
|
||||||
return ITechHider.posToChunk(minZ);
|
return (int) Math.ceil(posToChunk(maxX));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxChunkZ(){
|
private int getMinChunkZ(){
|
||||||
return ITechHider.posToChunk(maxZ);
|
return (int) Math.floor(posToChunk(minZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMaxChunkZ(){
|
||||||
|
return (int) Math.ceil(posToChunk(maxZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean chunkOutside(int cX, int cZ) {
|
public boolean chunkOutside(int cX, int cZ) {
|
||||||
@ -110,7 +114,7 @@ public class Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerInRegion(Location location){
|
public boolean playerInRegion(Location location){
|
||||||
return in2dRegion(location) && minY < location.getY() && location.getY() + 1.8 < maxY;
|
return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean in2dRegion(Block block){
|
public boolean in2dRegion(Block block){
|
||||||
|
@ -96,9 +96,6 @@ public class Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void toggleSkip(Player p){
|
static void toggleSkip(Player p){
|
||||||
if(checkSetup(p))
|
|
||||||
return;
|
|
||||||
|
|
||||||
FightTeam fightTeam = checkGetTeam(p);
|
FightTeam fightTeam = checkGetTeam(p);
|
||||||
if(fightTeam == null || checkGetLeader(p) == null)
|
if(fightTeam == null || checkGetLeader(p) == null)
|
||||||
return;
|
return;
|
||||||
@ -213,8 +210,10 @@ public class Commands {
|
|||||||
Kit k = null;
|
Kit k = null;
|
||||||
if(Config.PersonalKits){
|
if(Config.PersonalKits){
|
||||||
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
||||||
if(kit != null)
|
if(kit != null){
|
||||||
kit.setInUse();
|
kit.setInUse();
|
||||||
|
k = new Kit(kit);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
k = Kit.getKitByName(kitName);
|
k = Kit.getKitByName(kitName);
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,11 @@ public class FightSchematic extends StateDependent {
|
|||||||
this.team = team;
|
this.team = team;
|
||||||
this.region = team.getSchemRegion();
|
this.region = team.getSchemRegion();
|
||||||
this.rotate = rotate;
|
this.rotate = rotate;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
public boolean hasSchematic(){
|
||||||
return clipboard == null;
|
return clipboard != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(){
|
public int getId(){
|
||||||
@ -109,6 +110,10 @@ public class FightSchematic extends StateDependent {
|
|||||||
else
|
else
|
||||||
RecordSystem.redSchem(schematic);
|
RecordSystem.redSchem(schematic);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paste(){
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
||||||
|
|
||||||
|
@ -140,15 +140,18 @@ public class FightTeam implements IFightTeam{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
skip = false;
|
||||||
|
ready = false;
|
||||||
schematic.reset();
|
schematic.reset();
|
||||||
invited.clear();
|
invited.clear();
|
||||||
|
|
||||||
Set<Player> playerSet = new HashSet<>(players.keySet());
|
Set<Player> playerSet = new HashSet<>(players.keySet());
|
||||||
for(Player player : playerSet){
|
for(Player player : playerSet){
|
||||||
if(!player.isOnline())
|
if(!Bukkit.getOnlinePlayers().contains(player))
|
||||||
removePlayer(player);
|
removePlayer(player);
|
||||||
}
|
}
|
||||||
FightPlayer leaderBackup = leader;
|
FightPlayer leaderBackup = leader;
|
||||||
playerSet.removeIf(player -> !player.isOnline());
|
playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player));
|
||||||
players.clear();
|
players.clear();
|
||||||
leader = null;
|
leader = null;
|
||||||
|
|
||||||
@ -183,6 +186,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
|
player.getInventory().clear();
|
||||||
BasicListener.setAttackSpeed(player);
|
BasicListener.setAttackSpeed(player);
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
||||||
@ -234,13 +238,12 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
private void setLeader(FightPlayer leader) {
|
private void setLeader(FightPlayer leader) {
|
||||||
if (leader == null) {
|
if (leader == null) {
|
||||||
if (FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
this.leader = null;
|
||||||
this.leader = null;
|
if(!players.isEmpty()) {
|
||||||
}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(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
FightSystem.setPreLeaderState();
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -271,6 +274,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||||
|
|
||||||
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||||
|
FightSystem.setPreSchemState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<FightPlayer> getPlayers() {
|
public Collection<FightPlayer> getPlayers() {
|
||||||
@ -284,7 +291,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
public void pasteSchem(Schematic schematic){
|
public void pasteSchem(Schematic schematic){
|
||||||
setSchem(schematic);
|
setSchem(schematic);
|
||||||
|
|
||||||
if(ArenaMode.Test.contains(Config.mode))
|
if(Config.test())
|
||||||
this.schematic.enable();
|
this.schematic.enable();
|
||||||
else if(Fight.getOpposite(this).hasSchematic()){
|
else if(Fight.getOpposite(this).hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
@ -385,6 +392,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
private class KitLoader extends StateDependent {
|
private class KitLoader extends StateDependent {
|
||||||
private KitLoader() {
|
private KitLoader() {
|
||||||
super(ArenaMode.All, FightState.Ingame);
|
super(ArenaMode.All, FightState.Ingame);
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -408,6 +416,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
private class SpectateHandler extends StateDependent {
|
private class SpectateHandler extends StateDependent {
|
||||||
private SpectateHandler() {
|
private SpectateHandler() {
|
||||||
super(ArenaMode.All, FightState.Spectate);
|
super(ArenaMode.All, FightState.Spectate);
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,6 +18,7 @@ public class FightWorld extends StateDependent {
|
|||||||
|
|
||||||
public FightWorld() {
|
public FightWorld() {
|
||||||
super(ArenaMode.Restartable, FightState.Schem);
|
super(ArenaMode.Restartable, FightState.Schem);
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +59,7 @@ public class ArenaBorder implements Listener {
|
|||||||
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.ArenaRegion.getMaxY()){
|
}else if(to.getY() + 1.8 > Config.ArenaRegion.getMaxY()){
|
||||||
reset(event);
|
reset(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,7 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.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;
|
||||||
@ -50,11 +48,5 @@ public class NormalJoin implements Listener {
|
|||||||
Fight.getRedTeam().addMember(player);
|
Fight.getRedTeam().addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FightPlayer redLeader = Fight.getRedTeam().getLeader();
|
|
||||||
FightPlayer blueLeader = Fight.getBlueTeam().getLeader();
|
|
||||||
if(redLeader != null && blueLeader != null && (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
|
||||||
FightSystem.setPreSchemState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class Recording implements Listener {
|
|||||||
despawnTeam(Fight.getBlueTeam());
|
despawnTeam(Fight.getBlueTeam());
|
||||||
despawnTNT();
|
despawnTNT();
|
||||||
}
|
}
|
||||||
};
|
}.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ public class SetupQuit implements Listener {
|
|||||||
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ public class OneShotStateDependent extends StateDependent{
|
|||||||
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
|
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
|
||||||
super(mode, states);
|
super(mode, states);
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||||||
public abstract class StateDependent implements IStateDependent {
|
public abstract class StateDependent implements IStateDependent {
|
||||||
|
|
||||||
private final Set<FightState> enabled;
|
private final Set<FightState> enabled;
|
||||||
|
private final boolean register;
|
||||||
|
|
||||||
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
||||||
this(Config.ActiveWinconditions.contains(wincondition), states);
|
this(Config.ActiveWinconditions.contains(wincondition), states);
|
||||||
@ -20,8 +21,11 @@ public abstract class StateDependent implements IStateDependent {
|
|||||||
|
|
||||||
protected StateDependent(boolean enabled, Set<FightState> states){
|
protected StateDependent(boolean enabled, Set<FightState> states){
|
||||||
this.enabled = states;
|
this.enabled = states;
|
||||||
|
this.register = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
if(enabled)
|
public void register(){
|
||||||
|
if(register)
|
||||||
FightState.registerStateDependent(this);
|
FightState.registerStateDependent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public class StateDependentCommand extends StateDependent {
|
|||||||
this.command = FightSystem.getPlugin().getCommand(name);
|
this.command = FightSystem.getPlugin().getCommand(name);
|
||||||
assert command != null;
|
assert command != null;
|
||||||
disable();
|
disable();
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,11 +33,13 @@ public class StateDependentCountdown extends StateDependent {
|
|||||||
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
|
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
|
||||||
super(mode, states);
|
super(mode, states);
|
||||||
this.countdown = countdown;
|
this.countdown = countdown;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
||||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||||
this.countdown = countdown;
|
this.countdown = countdown;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Countdown getCountdown(){
|
public Countdown getCountdown(){
|
||||||
|
@ -36,16 +36,19 @@ public class StateDependentListener extends StateDependent{
|
|||||||
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
||||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener){
|
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener){
|
||||||
super(enabled, states);
|
super(enabled, states);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
|
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
|
||||||
super(mode, states);
|
super(mode, states);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,6 +45,7 @@ public class StateDependentTask extends StateDependent {
|
|||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.period = period;
|
this.period = period;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
|
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||||
@ -52,6 +53,7 @@ public class StateDependentTask extends StateDependent {
|
|||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.period = period;
|
this.period = period;
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +38,7 @@ 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;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.IStateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -48,11 +48,10 @@ import java.util.*;
|
|||||||
|
|
||||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
|
|
||||||
public class TechHider implements IStateDependent {
|
public class TechHider extends StateDependent {
|
||||||
|
|
||||||
private static final boolean DISABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
private static final boolean enabled = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
||||||
|
|
||||||
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 Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
||||||
private final Material obfuscateMaterial;
|
private final Material obfuscateMaterial;
|
||||||
@ -60,10 +59,7 @@ public class TechHider implements IStateDependent {
|
|||||||
private final int threadMultiplier;
|
private final int threadMultiplier;
|
||||||
|
|
||||||
public TechHider(){
|
public TechHider(){
|
||||||
FightState.registerStateDependent(this);
|
super(enabled, FightState.Schem);
|
||||||
enabled = DISABLED
|
|
||||||
? EnumSet.noneOf(FightState.class)
|
|
||||||
: EnumSet.complementOf(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP));
|
|
||||||
|
|
||||||
Set<Integer> hiddenBlockIds = VersionedCallable.call(
|
Set<Integer> hiddenBlockIds = VersionedCallable.call(
|
||||||
new VersionedCallable<>(Collections::emptySet, 8),
|
new VersionedCallable<>(Collections::emptySet, 8),
|
||||||
@ -76,7 +72,7 @@ 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);
|
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase());
|
||||||
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));
|
||||||
@ -86,9 +82,6 @@ public class TechHider implements IStateDependent {
|
|||||||
else
|
else
|
||||||
threadMultiplier = 1;
|
threadMultiplier = 1;
|
||||||
|
|
||||||
if(DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
||||||
|
|
||||||
if(Core.getVersion() > 8){
|
if(Core.getVersion() > 8){
|
||||||
@ -111,11 +104,7 @@ public class TechHider implements IStateDependent {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
register();
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<FightState> enabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -174,7 +163,7 @@ public class TechHider implements IStateDependent {
|
|||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for(MultiBlockChangeInfo mbci : changes){
|
for(MultiBlockChangeInfo mbci : changes){
|
||||||
WrappedBlockData block = mbci.getData();
|
WrappedBlockData block = mbci.getData();
|
||||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){
|
||||||
changed = true;
|
changed = true;
|
||||||
block.setType(obfuscateMaterial);
|
block.setType(obfuscateMaterial);
|
||||||
mbci.setData(block);
|
mbci.setData(block);
|
||||||
@ -208,7 +197,7 @@ public class TechHider implements IStateDependent {
|
|||||||
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().toLowerCase())){
|
||||||
block.setType(obfuscateMaterial);
|
block.setType(obfuscateMaterial);
|
||||||
blockStructure.write(0, block);
|
blockStructure.write(0, block);
|
||||||
}
|
}
|
||||||
@ -251,7 +240,7 @@ public class TechHider implements IStateDependent {
|
|||||||
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().toLowerCase())){
|
||||||
block.setType(obfuscateMaterial);
|
block.setType(obfuscateMaterial);
|
||||||
blockStructure.write(0, block);
|
blockStructure.write(0, block);
|
||||||
}
|
}
|
||||||
@ -277,7 +266,7 @@ public class TechHider implements IStateDependent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static List<ChunkPos> prepareChunkReload(Player p){
|
public static List<ChunkPos> prepareChunkReload(Player p){
|
||||||
if(DISABLED)
|
if(enabled)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
List<ChunkPos> chunksToReload = new ArrayList<>();
|
List<ChunkPos> chunksToReload = new ArrayList<>();
|
||||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||||
@ -288,7 +277,7 @@ public class TechHider implements IStateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadChunks(Player p, List<ChunkPos> chunksToReload){
|
public static void reloadChunks(Player p, List<ChunkPos> chunksToReload){
|
||||||
if(DISABLED)
|
if(enabled)
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
for(ChunkPos chunk : chunksToReload){
|
for(ChunkPos chunk : chunksToReload){
|
||||||
|
@ -44,7 +44,7 @@ public class EventTeamOffWincondition extends Wincondition{
|
|||||||
public void disable() {
|
public void disable() {
|
||||||
//Team off is a one time trigger
|
//Team off is a one time trigger
|
||||||
}
|
}
|
||||||
};
|
}.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teamOff(FightTeam team){
|
private void teamOff(FightTeam team){
|
||||||
|
@ -57,6 +57,8 @@ public abstract class Wincondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Countdown getTimeOverCountdown(){
|
public static Countdown getTimeOverCountdown(){
|
||||||
|
if(timeOverCountdown == null)
|
||||||
|
return null;
|
||||||
return timeOverCountdown.getCountdown();
|
return timeOverCountdown.getCountdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,12 +37,14 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
|||||||
|
|
||||||
public WinconditionPercentSystem() {
|
public WinconditionPercentSystem() {
|
||||||
super("Percent", "§cTeam ", " §chat den Gegnern");
|
super("Percent", "§cTeam ", " §chat den Gegnern");
|
||||||
printableWinconditions.add(this);
|
|
||||||
percentWincondition = this;
|
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||||
|
|
||||||
new StateDependentListener(Winconditions.PERCENT_SYSTEM, FightState.Running, this);
|
new StateDependentListener(Winconditions.PERCENT_SYSTEM, FightState.Running, this);
|
||||||
|
if(Config.ActiveWinconditions.contains(Winconditions.PERCENT_SYSTEM)){
|
||||||
|
printableWinconditions.add(this);
|
||||||
|
percentWincondition = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
@ -46,7 +47,6 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
|
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
||||||
printableWinconditions.add(this);
|
|
||||||
|
|
||||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||||
@ -60,7 +60,10 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
public void disable() {
|
public void disable() {
|
||||||
teamMap.values().forEach(TeamPoints::disable);
|
teamMap.values().forEach(TeamPoints::disable);
|
||||||
}
|
}
|
||||||
};
|
}.register();
|
||||||
|
if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){
|
||||||
|
printableWinconditions.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void timeOver() {
|
protected void timeOver() {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
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;
|
||||||
@ -40,9 +41,13 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
|||||||
|
|
||||||
public WinconditionPumpkinTechKO(){
|
public WinconditionPumpkinTechKO(){
|
||||||
super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!");
|
super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!");
|
||||||
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
||||||
|
|
||||||
|
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
||||||
|
if(Config.ActiveWinconditions.contains(Winconditions.PUMPKIN_TECH_KO)){
|
||||||
|
printableWinconditions.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(){
|
private void check(){
|
||||||
|
@ -50,8 +50,6 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
|||||||
super("RelativePercent", null);
|
super("RelativePercent", null);
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||||
printableWinconditions.add(this);
|
|
||||||
percentWincondition = this;
|
|
||||||
new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){
|
new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
@ -62,7 +60,11 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
|||||||
public void disable() {
|
public void disable() {
|
||||||
teamMap.values().forEach(TeamPercent::disable);
|
teamMap.values().forEach(TeamPercent::disable);
|
||||||
}
|
}
|
||||||
};
|
}.register();
|
||||||
|
if(Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT)){
|
||||||
|
printableWinconditions.add(this);
|
||||||
|
percentWincondition = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
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;
|
||||||
@ -40,9 +41,11 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
|||||||
super("WaterTechKO", "§cDas Team ", " §cwurde Tech K.O. gesetzt!");
|
super("WaterTechKO", "§cDas Team ", " §cwurde Tech K.O. gesetzt!");
|
||||||
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
||||||
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
||||||
printableWinconditions.add(this);
|
|
||||||
|
|
||||||
new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200);
|
new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200);
|
||||||
|
if(Config.ActiveWinconditions.contains(Winconditions.WATER_TECH_KO)){
|
||||||
|
printableWinconditions.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check() {
|
private void check() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren