RecordSystem (Beta) #199
@ -24,9 +24,10 @@ public class Config {
|
||||
public static final int PreSchemPasteDuration;
|
||||
public static final int SetupDuration;
|
||||
public static final int PreFightDuration;
|
||||
public static final int EnterPhaseBegin;
|
||||
public static final int SpectatorDuration;
|
||||
public static final boolean Entern;
|
||||
|
||||
// entern parameter
|
||||
public static final List<Integer> EnterStages;
|
||||
|
||||
//arena parameter
|
||||
public static final int SchemsizeX;
|
||||
@ -81,6 +82,7 @@ public class Config {
|
||||
public static final String TeamChatDetection;
|
||||
public static final UUID BlueLeader;
|
||||
public static final UUID RedLeader;
|
||||
public static final boolean Ranked;
|
||||
|
||||
//Active win conditions
|
||||
public static final boolean Timeout;
|
||||
@ -183,16 +185,16 @@ public class Config {
|
||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||
RelativePercent = config.getBoolean("WinConditions.RelativePercent");
|
||||
Points = config.getBoolean("WinConditions.Points");
|
||||
Entern = config.getBoolean("WinConditions.Entern");
|
||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
||||
PumpkinTechKO = config.getBoolean("WinConditions.PumpkinTechKO");
|
||||
|
||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||
IgnoredBlocks = Collections.unmodifiableList(config.getStringList("WinConditionParams.IgnoredBlocks"));
|
||||
|
||||
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
||||
|
||||
MemberDefault = config.getString("Kits.MemberDefault");
|
||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
||||
@ -372,6 +374,7 @@ public class Config {
|
||||
RedLeader = null;
|
||||
|
||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
||||
}
|
||||
|
||||
public static boolean event(){
|
||||
|
@ -11,7 +11,6 @@ public class IFightSystem {
|
||||
private static Plugin plugin;
|
||||
private static String prefix;
|
||||
private static EventFight eventFight;
|
||||
private static boolean entern = false;
|
||||
private static Player eventLeiter;
|
||||
|
||||
public static void init(Plugin plugin, String prefix){
|
||||
@ -21,9 +20,6 @@ public class IFightSystem {
|
||||
static void setEventFight(EventFight ef){
|
||||
eventFight = ef;
|
||||
}
|
||||
static void setEntern(boolean entern){
|
||||
IFightSystem.entern = entern;
|
||||
}
|
||||
static void setEventLeiter(Player el){
|
||||
eventLeiter = el;
|
||||
}
|
||||
@ -37,9 +33,6 @@ public class IFightSystem {
|
||||
public static EventFight getEventFight(){
|
||||
return eventFight;
|
||||
}
|
||||
public static boolean isEntern(){
|
||||
return entern;
|
||||
}
|
||||
public static Player getEventLeiter(){
|
||||
return eventLeiter;
|
||||
}
|
||||
|
@ -6,4 +6,5 @@ public interface IFightTeam {
|
||||
|
||||
boolean isBlue();
|
||||
boolean isPlayerInTeam(Player player);
|
||||
boolean canPlayerEntern(Player player);
|
||||
}
|
||||
|
@ -70,13 +70,13 @@ public class ITechHider {
|
||||
arenaMinZ > chunkZ ||
|
||||
chunkZ > arenaMaxZ;
|
||||
}else if(ft.isBlue()){
|
||||
return IFightSystem.isEntern() ||
|
||||
return ft.canPlayerEntern(p) ||
|
||||
redMinX > chunkX ||
|
||||
chunkX > redMaxX ||
|
||||
redMinZ > chunkZ ||
|
||||
chunkZ > redMaxZ;
|
||||
}else{
|
||||
return IFightSystem.isEntern() ||
|
||||
return ft.canPlayerEntern(p) ||
|
||||
blueMinX > chunkX ||
|
||||
chunkX > blueMaxX ||
|
||||
blueMinZ > chunkZ ||
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
@ -76,9 +75,12 @@ public class FightSystem extends JavaPlugin {
|
||||
new CheckListener();
|
||||
new TestListener();
|
||||
new NormalJoinListener();
|
||||
new RankedJoinListener();
|
||||
if(Core.getVersion() > 8)
|
||||
new ExtendedInventoryListener();
|
||||
|
||||
new EnterHandler();
|
||||
|
||||
new WinconditionAllDead();
|
||||
new WinconditionCaptainDead();
|
||||
new WinconditionPumpkinTechKO();
|
||||
@ -103,7 +105,7 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
mainCountdown = new NoPlayersOnlineCountdown();
|
||||
|
||||
if(Config.event()) {
|
||||
if(Config.event() || Config.Ranked) {
|
||||
Objects.requireNonNull(getCommand("invite")).setExecutor(new EventDummyCommand());
|
||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
|
||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
|
||||
@ -175,33 +177,13 @@ public class FightSystem extends JavaPlugin {
|
||||
setFightState(FightState.RUNNING);
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
|
||||
if(Config.Entern)
|
||||
mainCountdown = new EnternCountdown();
|
||||
|
||||
FightStatistics.start();
|
||||
WaterRemover.init();
|
||||
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
|
||||
}
|
||||
|
||||
public static void setEntern() {
|
||||
if(fightState != FightState.RUNNING)
|
||||
throw new SecurityException(fightState.name());
|
||||
setFightState(FightState.ENTERN);
|
||||
|
||||
final List<ITechHider.ChunkPos> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
|
||||
final List<ITechHider.ChunkPos> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
|
||||
IFightSystem.setEntern(true);
|
||||
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
|
||||
}
|
||||
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksRed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
||||
if(!fightState.ingame())
|
||||
throw new SecurityException(fightState.name());
|
||||
if(fightState == FightState.SPECTATE)
|
||||
return;
|
||||
setFightState(FightState.SPECTATE);
|
||||
|
||||
setAllPlayersGM(GameMode.SPECTATOR);
|
||||
|
@ -59,7 +59,7 @@ public abstract class Countdown {
|
||||
BasicListener.toActionbar(p, msg);
|
||||
}
|
||||
|
||||
private void count(){
|
||||
void count(){
|
||||
switch (time) {
|
||||
case 900: case 600: case 300: case 180: case 120:
|
||||
broadcast("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting());
|
||||
|
@ -1,13 +1,24 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.listener.BasicListener;
|
||||
import de.steamwar.fightsystem.utils.ITechHider;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnternCountdown extends Countdown {
|
||||
|
||||
public EnternCountdown() {
|
||||
super(Config.EnterPhaseBegin, SWSound.BLOCK_NOTE_PLING, false);
|
||||
private final FightPlayer fightPlayer;
|
||||
private List<ITechHider.ChunkPos> chunkPos;
|
||||
|
||||
public EnternCountdown(FightPlayer fp) {
|
||||
super(fp.getKit().getEnterStage(), SWSound.BLOCK_NOTE_PLING, false);
|
||||
fightPlayer = fp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -17,7 +28,42 @@ public class EnternCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightSystem.setEntern();
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
||||
fightPlayer.getPlayer().sendMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
||||
TechHider.reloadChunks(fightPlayer.getPlayer(), chunkPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
void count(){
|
||||
if(!fightPlayer.isLiving()){
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = fightPlayer.getPlayer();
|
||||
int time = FightSystem.getFightTime() - Config.EnterStages.get(fightPlayer.getKit().getEnterStage());
|
||||
switch (time) {
|
||||
case 900: case 600: case 300: case 180: case 120:
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
|
||||
break;
|
||||
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
|
||||
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
|
||||
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting()));
|
||||
break;
|
||||
case 1:
|
||||
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
|
||||
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting()));
|
||||
|
||||
chunkPos = TechHider.prepareChunkReload(player);
|
||||
break;
|
||||
case 0:
|
||||
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 2.0F);
|
||||
|
||||
disable();
|
||||
countdownFinished();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class Fight {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.IgnorePublicOnly || Config.event()){
|
||||
if(Config.IgnorePublicOnly || Config.event() || Config.Ranked){
|
||||
schemRank = 1000;
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.kit.Kit;
|
||||
@ -62,4 +63,10 @@ public class FightPlayer {
|
||||
public void addKill(){
|
||||
kills++;
|
||||
}
|
||||
|
||||
public boolean canEntern(){
|
||||
if(Config.EnterStages.size() <= kit.getEnterStage() || kit.getEnterStage() < 0)
|
||||
return false;
|
||||
return Config.EnterStages.get(kit.getEnterStage()) >= FightSystem.getFightTime();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.winconditions.RankedPlayerLeftWincondition;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
@ -127,6 +128,11 @@ public class FightTeam implements IFightTeam{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerEntern(Player player) {
|
||||
return getFightPlayer(player).canEntern();
|
||||
}
|
||||
|
||||
public boolean isPlayerLeader(Player player) {
|
||||
if(leader != null)
|
||||
return leader.getPlayer().equals(player);
|
||||
@ -186,19 +192,20 @@ public class FightTeam implements IFightTeam{
|
||||
}
|
||||
|
||||
public void setLeader(FightPlayer leader) {
|
||||
this.leader = leader;
|
||||
if(ready && leader != null)
|
||||
setReady(false);
|
||||
|
||||
if (leader == null){
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.iterator().next());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||
}else if(Config.Ranked){
|
||||
RankedPlayerLeftWincondition.leaderQuit(this);
|
||||
}else if(!Config.event()){
|
||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.leader = leader;
|
||||
if(ready)
|
||||
setReady(false);
|
||||
|
||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||
Inventory inventory = leader.getPlayer().getInventory();
|
||||
@ -209,7 +216,7 @@ public class FightTeam implements IFightTeam{
|
||||
else
|
||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||
|
||||
if(!Config.event()){
|
||||
if(!Config.event() && !Config.Ranked){
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
||||
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ public class Kit {
|
||||
private final ItemStack[] inventory;
|
||||
private final ItemStack[] armor;
|
||||
private final Collection<PotionEffect> effects;
|
||||
private final int enterStage;
|
||||
private final boolean tnt;
|
||||
|
||||
Kit(String name, Player player) {
|
||||
this.name = name;
|
||||
@ -29,13 +31,15 @@ public class Kit {
|
||||
this.inventory = player.getInventory().getContents();
|
||||
this.armor = player.getInventory().getArmorContents();
|
||||
this.effects = player.getActivePotionEffects();
|
||||
this.enterStage = 0;
|
||||
this.tnt = true;
|
||||
}
|
||||
|
||||
Kit(ConfigurationSection kit){
|
||||
name = kit.getName();
|
||||
inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[1]);
|
||||
inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[0]);
|
||||
if(kit.isList("Armor"))
|
||||
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[1]);
|
||||
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]);
|
||||
else
|
||||
armor = null;
|
||||
leaderAllowed = kit.getBoolean("LeaderAllowed");
|
||||
@ -44,6 +48,8 @@ public class Kit {
|
||||
effects = (Collection<PotionEffect>) kit.getList("Effects");
|
||||
else
|
||||
effects = null;
|
||||
enterStage = kit.getInt("EnterStage", 0);
|
||||
tnt = kit.getBoolean("TNT", true);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -58,6 +64,16 @@ public class Kit {
|
||||
return memberAllowed;
|
||||
}
|
||||
|
||||
/* Is this kit allowed to set/handle tnt? */
|
||||
public boolean isTnt(){
|
||||
return tnt;
|
||||
}
|
||||
|
||||
/* In which stage is entern allowed? */
|
||||
public int getEnterStage() {
|
||||
return enterStage;
|
||||
}
|
||||
|
||||
public boolean isStackInKit(ItemStack stack){
|
||||
for(ItemStack is : inventory){
|
||||
if(stack.equals(is))
|
||||
@ -88,6 +104,8 @@ public class Kit {
|
||||
section.set("LeaderAllowed", leaderAllowed);
|
||||
section.set("MemberAllowed", memberAllowed);
|
||||
section.set("Effects", effects);
|
||||
section.set("EnterStage", enterStage);
|
||||
section.set("TNT", tnt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,8 +145,7 @@ public class Kit {
|
||||
}
|
||||
}
|
||||
|
||||
inv.setCallback(-999, (click) -> GUI.kitSelection(player));
|
||||
inv.addCloseCallback((click) -> GUI.kitSelection(player));
|
||||
inv.setCallback(-999, (click) -> player.closeInventory());
|
||||
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> {
|
||||
Commands.kit(player, name);
|
||||
player.closeInventory();
|
||||
|
@ -15,8 +15,7 @@ import java.util.logging.Level;
|
||||
public class KitManager {
|
||||
private KitManager(){}
|
||||
|
||||
private static final String KITS_PATH = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data";
|
||||
private static final File kits = new File(KITS_PATH);
|
||||
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), "kits.data");
|
||||
private static final FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits);
|
||||
|
||||
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
||||
@ -49,7 +48,7 @@ public class KitManager {
|
||||
}
|
||||
|
||||
public static void loadAllKits() {
|
||||
if(!new File(KITS_PATH).exists()) {
|
||||
if(!kits.exists()) {
|
||||
saveAllKits();
|
||||
Bukkit.getLogger().log(Level.INFO, "kits.data erstellt!");
|
||||
FightSystem.shutdown(null);
|
||||
|
@ -10,7 +10,7 @@ import java.util.EnumSet;
|
||||
public class EntityExplodeListener extends BasicListener {
|
||||
|
||||
public EntityExplodeListener() {
|
||||
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -15,7 +15,7 @@ import java.util.Objects;
|
||||
public class InFightDamageListener extends BasicListener {
|
||||
|
||||
public InFightDamageListener() {
|
||||
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -44,8 +44,6 @@ public class InFightDamageListener extends BasicListener {
|
||||
//Shooter is not a player
|
||||
return;
|
||||
|
||||
damagerArrow.setFireTicks(0);
|
||||
player.setFireTicks(0);
|
||||
damager = (Player) damagerArrow.getShooter();
|
||||
}else{
|
||||
//Damager is not a player
|
||||
@ -60,6 +58,10 @@ public class InFightDamageListener extends BasicListener {
|
||||
|
||||
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
|
||||
event.setCancelled(true);
|
||||
if(event.getDamager() instanceof Arrow){
|
||||
event.getDamager().setFireTicks(0);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
@ -17,7 +21,7 @@ import java.util.EnumSet;
|
||||
public class InFightInventoryListener extends BasicListener {
|
||||
|
||||
public InFightInventoryListener() {
|
||||
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -93,4 +97,12 @@ public class InFightInventoryListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
FightPlayer fp = Fight.getFightPlayer(e.getPlayer());
|
||||
if(fp != null && !fp.getKit().isTnt() && e.getBlockPlaced().getType() == Material.TNT){
|
||||
BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst kein TNT setzen!"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.EnumSet;
|
||||
public class NormalJoinListener extends BasicListener {
|
||||
|
||||
public NormalJoinListener() {
|
||||
super(Config.event() || Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||
super(Config.event() || Config.test() || Config.Ranked ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -15,9 +15,9 @@ public class PistonListener extends BasicListener {
|
||||
|
||||
public PistonListener() {
|
||||
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
||||
super(Config.Entern
|
||||
? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP)
|
||||
: EnumSet.allOf(FightState.class));
|
||||
super(Config.EnterStages.isEmpty()
|
||||
? EnumSet.allOf(FightState.class)
|
||||
: EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -50,7 +50,7 @@ public class PlayerMoveListener extends BasicListener {
|
||||
reset(event, DENY_TEAM);
|
||||
else if(fightTeam == Fight.getBlueTeam() && player.getGameMode() == GameMode.SPECTATOR)
|
||||
reset(event, DENY_ENTERN);
|
||||
}else if(fightTeam != null && FightSystem.getFightState() != FightState.ENTERN && player.getGameMode() != GameMode.SPECTATOR)
|
||||
}else if(fightTeam != null && player.getGameMode() != GameMode.SPECTATOR && !fightTeam.canPlayerEntern(player))
|
||||
reset(event, DENY_ENTERN);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class RankedJoinListener extends BasicListener {
|
||||
|
||||
public RankedJoinListener() {
|
||||
super(!Config.event() && Config.Ranked ? EnumSet.of(FightState.PRE_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
if (fightTeam == null) {
|
||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,13 +6,12 @@ public enum FightState {
|
||||
POST_SCHEM_SETUP(true, true, false, false),
|
||||
PRE_RUNNING(false, false, true, false),
|
||||
RUNNING(false, false, true, true),
|
||||
ENTERN(false, false, true, true), //Can be skipped
|
||||
SPECTATE(false, true, false, false);
|
||||
|
||||
private final boolean setup; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP
|
||||
private final boolean outgame; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP, SPECTATE
|
||||
private final boolean ingame; //PRE_RUNNING, RUNNING, ENTERN
|
||||
private final boolean infight; //RUNNING, ENTERN
|
||||
private final boolean ingame; //PRE_RUNNING, RUNNING
|
||||
private final boolean infight; //RUNNING
|
||||
|
||||
FightState(boolean setup, boolean outgame, boolean ingame, boolean infight){
|
||||
this.setup = setup;
|
||||
|
49
FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java
Normale Datei
49
FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||
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.StateDependent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EnterHandler implements StateDependent {
|
||||
private static final Set<FightState> enabled = EnumSet.of(FightState.RUNNING);
|
||||
private static final Set<EnternCountdown> countdowns = new HashSet<>();
|
||||
|
||||
public EnterHandler(){
|
||||
FightSystem.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private void registerTeam(FightTeam team){
|
||||
for(FightPlayer fp : team.getPlayers()){
|
||||
if(Config.EnterStages.size() > fp.getKit().getEnterStage() && fp.getKit().getEnterStage() >= 0)
|
||||
countdowns.add(new EnternCountdown(fp));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
registerTeam(Fight.getBlueTeam());
|
||||
registerTeam(Fight.getRedTeam());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
for(EnternCountdown countdown : countdowns){
|
||||
countdown.disable();
|
||||
}
|
||||
countdowns.clear();
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class FightScoreboard {
|
||||
|
||||
private FightScoreboard(){}
|
||||
|
||||
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.ENTERN, FightState.SPECTATE);
|
||||
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
|
||||
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||
private static final Objective objective;
|
||||
private static int index = 0;
|
||||
@ -70,8 +70,6 @@ public class FightScoreboard {
|
||||
else
|
||||
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
|
||||
}
|
||||
if (Config.Entern)
|
||||
objective.getScore("§7Entern: " + (FightSystem.getFightState() == FightState.ENTERN ? "§aja" : "§cnein")).setScore(2);
|
||||
|
||||
if(fullScoreboard.contains(FightSystem.getFightState())){
|
||||
if (Config.PercentSystem){
|
||||
|
@ -5,6 +5,7 @@ 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.sql.Elo;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -17,20 +18,29 @@ public class FightStatistics {
|
||||
private FightStatistics(){}
|
||||
|
||||
private static Timestamp starttime = Timestamp.from(Instant.now());
|
||||
private static int K = 20;
|
||||
|
||||
public static void start(){
|
||||
starttime = Timestamp.from(Instant.now());
|
||||
}
|
||||
|
||||
public static void saveStats(FightTeam winner, String windescription){
|
||||
String gameMode = Config.SchematicType.toDB();
|
||||
SteamwarUser blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId());
|
||||
SteamwarUser redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId());
|
||||
int win = 0;
|
||||
if(winner == Fight.getBlueTeam())
|
||||
double blueResult;
|
||||
if(winner == Fight.getBlueTeam()) {
|
||||
win = 1;
|
||||
else if(winner == Fight.getRedTeam())
|
||||
blueResult = 1;
|
||||
}else if(winner == Fight.getRedTeam()) {
|
||||
win = 2;
|
||||
int fightId = create(Config.SchematicType.toDB(), Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
|
||||
blueResult = 0;
|
||||
}else{
|
||||
blueResult = 0.5;
|
||||
}
|
||||
if(Fight.getBlueTeam().getSchematic() != null && Fight.getRedTeam().getSchematic() != null){
|
||||
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
|
||||
blueLeader.getId(), redLeader.getId(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
|
||||
|
||||
for(FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||
@ -39,8 +49,22 @@ public class FightStatistics {
|
||||
savePlayerStats(fp, fightId);
|
||||
}
|
||||
|
||||
if(Config.Ranked && !Config.event()){
|
||||
int blueElo = Elo.getElo(blueLeader.getId(), gameMode);
|
||||
int redElo = Elo.getElo(redLeader.getId(), gameMode);
|
||||
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
||||
double blueWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
|
||||
int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
|
||||
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
||||
Elo.setElo(blueLeader.getId(), gameMode, newBlueElo);
|
||||
Elo.setElo(redLeader.getId(), gameMode, newRedElo);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + blueLeader.getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + redLeader.getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerStats(FightPlayer fp, int fightId){
|
||||
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
|
||||
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
||||
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
||||
}
|
||||
}
|
||||
|
@ -1,106 +1,57 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class WaterRemover {
|
||||
|
||||
private WaterRemover(){}
|
||||
|
||||
private static final Map<Location, Integer> explodedBlocks = Collections.synchronizedMap(new HashMap<>());
|
||||
private static Set<Block> waterList = new HashSet<>();
|
||||
private static boolean isRunning = false;
|
||||
private static int steps = 1;
|
||||
|
||||
public static void init() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||
if(isRunning){
|
||||
steps++;
|
||||
return;
|
||||
}
|
||||
isRunning = true;
|
||||
wateredCheck();
|
||||
removeWater();
|
||||
isRunning = false;
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
public static void add(List<Block> l) {
|
||||
l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0));
|
||||
}
|
||||
for(Block b : l){
|
||||
//b cannot be water or air due to current explosion
|
||||
|
||||
private static void wateredCheck() {
|
||||
int startX = b.getX();
|
||||
int startY = b.getY();
|
||||
int startZ = b.getZ();
|
||||
try{
|
||||
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Location, Integer> e = it.next();
|
||||
Block b = e.getKey().getBlock();
|
||||
if (isWater(b))
|
||||
waterList.add(b);
|
||||
|
||||
if(b.getType() != Material.AIR){
|
||||
it.remove();
|
||||
continue;
|
||||
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.NORTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.UP), startX, startY, startZ);
|
||||
}catch(IsAnOcean e){
|
||||
//ignore
|
||||
}
|
||||
e.setValue(e.getValue() + steps);
|
||||
|
||||
if(e.getValue() > 15)
|
||||
it.remove();
|
||||
}
|
||||
steps = 1;
|
||||
}catch(ConcurrentModificationException e){
|
||||
steps++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeWater() {
|
||||
List<Block> blocksToRemove = new LinkedList<>();
|
||||
Iterator<Block> it = waterList.iterator();
|
||||
while(it.hasNext()){
|
||||
Block b = it.next();
|
||||
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
||||
private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean {
|
||||
if(!isWater(b))
|
||||
it.remove();
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> blocksToRemove.forEach((Block b) -> b.setType(Material.AIR)));
|
||||
}
|
||||
|
||||
private static Set<Block> getSourceBlocksOfWater(Block startBlock) {
|
||||
Set<Block> water = new HashSet<>();
|
||||
collectBlocks(startBlock, water, new HashSet<>());
|
||||
return water;
|
||||
}
|
||||
|
||||
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
||||
if(
|
||||
!isWater(anchor) ||
|
||||
visitedBlocks.contains(anchor)
|
||||
)
|
||||
return;
|
||||
|
||||
visitedBlocks.add(anchor);
|
||||
if (isWater(anchor))
|
||||
collected.add(anchor);
|
||||
// If distance to original block is greater than 20
|
||||
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20)
|
||||
throw new IsAnOcean();
|
||||
|
||||
if(visitedBlocks.size() > 100) {
|
||||
collected.clear();
|
||||
return;
|
||||
b.setType(Material.AIR);
|
||||
try{
|
||||
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.NORTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.UP), startX, startY, startZ);
|
||||
}catch(IsAnOcean e){
|
||||
b.setType(Material.WATER);
|
||||
throw e;
|
||||
}
|
||||
collectBlocks(anchor.getRelative(BlockFace.UP), collected, visitedBlocks);
|
||||
collectBlocks(anchor.getRelative(BlockFace.NORTH), collected, visitedBlocks);
|
||||
collectBlocks(anchor.getRelative(BlockFace.EAST), collected, visitedBlocks);
|
||||
collectBlocks(anchor.getRelative(BlockFace.SOUTH), collected, visitedBlocks);
|
||||
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
||||
}
|
||||
|
||||
private static class IsAnOcean extends Throwable{}
|
||||
|
||||
public static boolean isWater(Block block){
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
|
@ -10,7 +10,7 @@ import java.util.EnumSet;
|
||||
abstract class PlayerWincondition extends ListenerWincondition {
|
||||
|
||||
PlayerWincondition(boolean condition) {
|
||||
super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
|
||||
super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||
}
|
||||
|
||||
boolean isTarget(Player player){
|
||||
|
@ -0,0 +1,13 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
||||
public class RankedPlayerLeftWincondition {
|
||||
private RankedPlayerLeftWincondition(){}
|
||||
|
||||
public static void leaderQuit(FightTeam leaderlessTeam){
|
||||
FightSystem.setSpectateState(Fight.getOpposite(leaderlessTeam), "LeaderQuit");
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class WinconditionHeartRatioTimeout extends Wincondition {
|
||||
private TimeOverCountdown countdown;
|
||||
|
||||
public WinconditionHeartRatioTimeout() {
|
||||
super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,7 @@ public class WinconditionPercentSystem extends ListenerWincondition {
|
||||
private static final int schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
||||
|
||||
public WinconditionPercentSystem() {
|
||||
super(Config.PercentSystem, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(Config.PercentSystem, EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -22,7 +22,7 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
||||
private BukkitTask task;
|
||||
|
||||
public WinconditionPumpkinTechKO(){
|
||||
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
|
||||
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||
}
|
||||
|
||||
public static int getTeamBluePumpkins() {
|
||||
|
@ -89,7 +89,8 @@ public class WinconditionRelativePercent extends Wincondition{
|
||||
}
|
||||
|
||||
private int currentBlocks(){
|
||||
if(FightSystem.getFightState() == FightState.ENTERN || FightSystem.getFightState() == FightState.SPECTATE)
|
||||
// Entern active
|
||||
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) <= FightSystem.getFightTime())
|
||||
return currentBlocks;
|
||||
|
||||
int blocks = 0;
|
||||
|
@ -12,7 +12,7 @@ public class WinconditionTimeout extends Wincondition {
|
||||
private TimeOverCountdown countdown;
|
||||
|
||||
public WinconditionTimeout() {
|
||||
super(Config.Timeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||
super(Config.Timeout, EnumSet.of(FightState.RUNNING));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren