SteamWar/FightSystem
Archiviert
13
1

Merge branch 'setupSplitting' of SteamWar/FightSystem into master

Dieser Commit ist enthalten in:
Lixfel 2020-01-12 16:57:24 +01:00 committet von Gitea
Commit 713044064c
50 geänderte Dateien mit 1204 neuen und 810 gelöschten Zeilen

Datei anzeigen

@ -18,11 +18,14 @@ public class Config {
private Config(){}
//Fight sequence durations
//Fight sequence
public static final int NoPlayerOnlineDuration;
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;
//arena parameter
public static final int SchemsizeX;
@ -82,14 +85,12 @@ public class Config {
public static final boolean PercentSystem;
public static final boolean RelativePercent;
public static final boolean Points;
public static final boolean Entern;
public static final boolean TechKO;
public static final boolean WaterTechKO;
public static final boolean PumpkinTechKO;
//win condition parameters
public static final int TimeoutTime;
public static final int EnterPhaseBegin;
public static final double PercentWin;
public static final List<String> IgnoredBlocks;
@ -126,6 +127,7 @@ public class Config {
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration");
PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration");
SetupDuration = config.getInt("Times.SetupDuration");
PreFightDuration = config.getInt("Times.PreFightDuration");
SpectatorDuration = config.getInt("Times.SpectatorDuration");

Datei anzeigen

@ -1,8 +1,102 @@
Times:
NoPlayersOnlineDuration: 0
SetupDuration: 0
PreFightDuration: 0
SpectatorDuration: 0
NoPlayersOnlineDuration: 300
PreSchemPasteDuration: 120
SetupDuration: 300
PreFightDuration: 30
SpectatorDuration: 30
Schematic:
OnlyPublicSchematics: false
SchematicType: normal
Rotate: true
ReplaceObsidian: false
ReplaceBedrock: false
Output:
TeamRedName: Rot
TeamRedPrefix: '§c'
TeamBlueName: Blau
TeamBluePrefix: '§3'
GameName: War*
TeamChatDetection: +
WinConditions:
Timeout: true
AllDead: true
CaptainDead: false
PercentSystem: false
RelativePercent: false
Points: false
Entern: false
TechKO: false
WaterTechKO: false
HeartRatioTimeout: false
PumpkinTechKO: false
WinConditionParams:
TimeoutTime: 1200
EnterPhaseBegin: 600
PercentWin: 5.0
IgnoredBlocks:
- AIR
- WATER
- TNT
- OBSIDIAN
Kits:
MemberDefault: default
LeaderDefault: default
Techhider:
ObfuscateWith: 121
ObfuscateWithTag: ENDER_STONE
HiddenBlocks:
BEDROCK: 7
WATER: 8
STATIONARY_WATER: 9
NOTE_BLOCK: 25
DETECTOR_RAIL: 28
PISTON_BASE: 33
PISTON_EXTENSION: 34
PISTON_STICKY_BASE: 29
POWERED_RAIL: 27
TNT: 46
OBSIDIAN: 49
CHEST: 54
REDSTONE_WIRE: 55
STONE_PLATE: 70
IRON_DOOR_BLOCK: 71
WOOD_PLATE: 72
REDSTONE_TORCH_OFF: 75
REDSTONE_TORCH_ON: 76
STONE_BUTTON: 77
DIODE_BLOCK_OFF: 93
DIODE_BLOCK_ON: 94
BREWING_STAND: 117
TRIPWIRE_HOOK: 131
TRIPWIRE: 132
WOOD_BUTTON: 143
TRAPPED_CHEST: 146
GOLD_PLATE: 147
IRON_PLATE: 148
REDSTONE_COMPARATOR_OFF: 149
REDSTONE_COMPARATOR_ON: 150
REDSTONE_BLOCK: 152
HOPPER: 154
ACTIVATOR_RAIL: 157
DROPPER: 158
SLIME_BLOCK: 165
IRON_TRAPDOOR: 167
OBSERVER: 218
LEVER: 69
HiddenBlockEntites:
- minecraft:sign
- minecraft:dispenser
- minecraft:chest
- minecraft:trapped_chest
- minecraft:furnace
- minecraft:brewing_stand
- minecraft:hopper
- minecraft:dropper
- minecraft:shulker_box
- minecraft:jukebox
- minecraft:comparator
# Muss in config.yml des Weltordners gesetzt werden
Arena:
Schemsize:
x: 0
@ -21,112 +115,3 @@ Arena:
z: 0
underArenaBorder: 0
BorderFromSchematic: 0
Schematic:
OnlyPublicSchematics: boolean
Directory: /home/netuser/schematics/
SchematicType: airship
Rotate: boolean
ReplaceObsidian: boolean
ReplaceBedrock: boolean
Output:
TeamRedName: Team1
TeamRedPrefix: §c
TeamBlueName: Team2
TeamBluePrefix: §3
GameName: AirShip
TeamChatDetection: +
WinConditions:
Timeout: boolean
HeartRatioTimeout: boolean
AllDead: boolean
CaptainDead: boolean
PercentSystem: boolean
RelativePercent: boolean
Points: boolean
Entern: boolean
TechKO: boolean
WaterTechKO: boolean
PumpkinTechKO: boolean
WinConditionParams:
TimeoutTime: 0
EnterPhaseBegin: 0
PercentWin: 0.0
IgnoredBlocks:
- AIR
- WATER
- TNT
- OBSIDIAN
Kits:
MemberDefault: default
LeaderDefault: default
Techhider:
ObfuscateWith: 1
ObfuscateWithTag: STONE
HiddenBlocks:
- 7
- 8
- 9
- 25
- 27
- 28
- 29
- 33
- 34
- 46
- 49
- 54
- 55
- 63
- 68
- 69
- 70
- 71
- 72
- 75
- 76
- 77
- 93
- 94
- 117
- 131
- 132
- 143
- 146
- 147
- 148
- 149
- 150
- 152
- 154
- 157
- 158
- 165
- 167
- 218
- 219
- 220
- 221
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
HiddenBlockEntites:
- minecraft:sign
- minecraft:dispenser
- minecraft:chest
- minecraft:trapped_chest
- minecraft:furnace
- minecraft:brewing_stand
- minecraft:hopper
- minecraft:dropper
- minecraft:shulker_box
- minecraft:jukebox
- minecraft:comparator

Datei anzeigen

@ -4,10 +4,11 @@ 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.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.FightScoreboard;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WaterRemover;
@ -19,15 +20,20 @@ import org.bukkit.GameMode;
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;
public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§eArena§8» ";
private static FightSystem plugin;
private static FightState fightState = FightState.SETUP;
private static FightState fightState = FightState.PRE_LEADER_SETUP;
private static Map<StateDependent, Boolean> stateDependentFeatures = new HashMap<>();
private static int fightTime = 0;
private static Countdown mainCountdown;
@Override
public void onLoad() {
@ -39,76 +45,23 @@ public class FightSystem extends JavaPlugin {
public void onEnable() {
Fight.init();
KitManager.loadAllKits();
TechHider.init();
FightScoreboard.init();
new EntityDamageListener();
new EntityExplodeListener();
new FoodLevelChangeListener();
new PistonListener();
new PlayerChatListener();
new PlayerDeathListener();
new HotbarGUIListener();
new PlayerMoveListener();
new PlayerConnectionListener();
new PlayerRespawnListener();
new PlayerTeleportListener();
new PlayerStateListener();
new ProjectileLaunchListener();
if(!Config.test()){
new BlockListener();
TechHider.init();
}
FightScoreboard.init();
getCommand("leave").setExecutor(new LeaveCommand());
getCommand("kit").setExecutor(new KitCommand());
getCommand("remove").setExecutor(new RemoveCommand());
getCommand("accept").setExecutor(new AcceptCommand());
getCommand("decline").setExecutor(new DeclineCommand());
getCommand("invite").setExecutor(new InviteCommand());
getCommand("ready").setExecutor(new ReadyCommand());
getCommand("ak").setExecutor(new AkCommand());
getCommand("leader").setExecutor(new LeaderCommand());
getCommand("lockschem").setExecutor(new LockschemCommand());
if(Config.event()) {
new InFightDamageListener();
new FreezeWorldStateListener();
new EventJoinListener();
getCommand("invite").setExecutor(new EventDummyCommand());
getCommand("ready").setExecutor(new EventDummyCommand());
getCommand("ak").setExecutor(new EventDummyCommand());
getCommand("leader").setExecutor(new EventDummyCommand());
new EventStartCountdown();
}else if(Config.test()){
new TestListener();
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
new NoPlayersOnlineCountdown();
}else{
new NormalJoinListener();
new InventoryListener();
new NoPlayersOnlineCountdown();
}
}
public static void setPreRunningState() {
if(fightState != FightState.SETUP)
return;
setFightState(FightState.PRE_RUNNING);
Countdown.cancelAllTimers();
loadKits(Fight.getBlueTeam());
loadKits(Fight.getRedTeam());
setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
new PreRunningCountdown();
Fight.replaceSync();
new WinconditionAllDead();
new WinconditionCaptainDead();
@ -117,35 +70,117 @@ public class FightSystem extends JavaPlugin {
new WinconditionPercentSystem();
new WinconditionRelativePercent();
new WinconditionPoints();
new WinconditionTimeout();
new WinconditionHeartRatioTimeout();
new WinconditionTechKO();
if(Config.event()){
new EventTeamOffWincondition();
Objects.requireNonNull(getCommand("leave")).setExecutor(new LeaveCommand());
Objects.requireNonNull(getCommand("kit")).setExecutor(new KitCommand());
Objects.requireNonNull(getCommand("remove")).setExecutor(new RemoveCommand());
Objects.requireNonNull(getCommand("accept")).setExecutor(new AcceptCommand());
Objects.requireNonNull(getCommand("decline")).setExecutor(new DeclineCommand());
Objects.requireNonNull(getCommand("invite")).setExecutor(new InviteCommand());
Objects.requireNonNull(getCommand("ready")).setExecutor(new ReadyCommand());
Objects.requireNonNull(getCommand("ak")).setExecutor(new AkCommand());
Objects.requireNonNull(getCommand("leader")).setExecutor(new LeaderCommand());
Objects.requireNonNull(getCommand("lockschem")).setExecutor(new LockschemCommand());
mainCountdown = new NoPlayersOnlineCountdown();
if(Config.event()) {
Objects.requireNonNull(getCommand("invite")).setExecutor(new EventDummyCommand());
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
setPreSchemState();
}else if(Config.test()){
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
setPreSchemState();
setPostSchemState();
}
}
public static void setPreSchemState() {
if(fightState != FightState.PRE_LEADER_SETUP)
throw new SecurityException(fightState.name());
setFightState(FightState.PRE_SCHEM_SETUP);
mainCountdown = new PreSchemPasteCountdown();
}
public static void setPostSchemState() {
if(fightState != FightState.PRE_SCHEM_SETUP)
throw new SecurityException(fightState.name());
setFightState(FightState.POST_SCHEM_SETUP);
if(!Config.test()){
TechHider.start();
Fight.getBlueTeam().pasteSchematic();
Fight.getRedTeam().pasteSchematic();
}
if(Config.event())
mainCountdown = new EventStartCountdown();
else if(Config.test())
mainCountdown = null;
else
mainCountdown = new SetupOverCountdown();
}
public static void setPreRunningState() {
if(fightState != FightState.POST_SCHEM_SETUP)
throw new SecurityException(fightState.name());
setFightState(FightState.PRE_RUNNING);
loadKits(Fight.getBlueTeam());
loadKits(Fight.getRedTeam());
setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
mainCountdown = new PreRunningCountdown();
Fight.replaceSync();
if(Config.event())
new EventTeamOffWincondition();
}
public static void setRunningState() {
if(fightState != FightState.PRE_RUNNING)
return;
throw new SecurityException(fightState.name());
setFightState(FightState.RUNNING);
Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SURVIVAL);
new WinconditionTimeout();
new WinconditionHeartRatioTimeout();
new WinconditionEntern();
new WinconditionTechKO();
if(Config.Entern)
mainCountdown = new EnternCountdown();
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<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
final List<Pair<Integer, Integer>> 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) {
if(fightState != FightState.RUNNING && fightState != FightState.PRE_RUNNING)
return;
if(!fightState.ingame())
throw new SecurityException(fightState.name());
setFightState(FightState.SPECTATE);
Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SPECTATOR);
Fight.getBlueTeam().teleportToSpawn();
@ -177,43 +212,6 @@ public class FightSystem extends JavaPlugin {
FightSystem.fightTime = fightTime;
}
public static void setEntern(boolean entern) {
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
IFightSystem.setEntern(entern);
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
}
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksRed);
}
}
private static void loadKits(FightTeam team){
for(FightPlayer allFightPlayers : team.getPlayers()) {
if(allFightPlayers.getPlayer() == null)
continue;
allFightPlayers.getPlayer().getInventory().clear();
if(allFightPlayers.getKit() == null)
continue;
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
}
}
private static void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
}
private static void setFightState(FightState state){
fightState = state;
BasicListener.fightStateChange(state);
}
public static void setEventLeiter(Player el){
IFightSystem.setEventLeiter(el);
}
@ -242,11 +240,64 @@ public class FightSystem extends JavaPlugin {
return fightTime;
}
public static boolean isEntern() {
return IFightSystem.isEntern();
}
public static void shutdown(String reason){
IFightSystem.shutdown(reason);
}
public static void registerStateDependent(StateDependent stateDependent){
if(stateDependent.enabled().isEmpty())
return;
boolean enabled = stateDependent.enabled().contains(fightState);
stateDependentFeatures.put(stateDependent, enabled);
if(enabled)
stateDependent.enable();
}
private static void loadKits(FightTeam team){
for(FightPlayer allFightPlayers : team.getPlayers()) {
if(allFightPlayers.getPlayer() == null)
continue;
allFightPlayers.getPlayer().getInventory().clear();
if(allFightPlayers.getKit() == null)
continue;
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
}
}
private static void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
}
private static void setFightState(FightState state){
fightState = state;
if(mainCountdown != null){
mainCountdown.disable();
mainCountdown = null;
}
postStateChange();
}
private static void postStateChange(){
for(Map.Entry<StateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
//Enable feature if should be enabled and currently disabled
if(feature.getKey().enabled().contains(fightState)){
if(!feature.getValue()){
feature.getKey().enable();
feature.setValue(true);
}
feature.getKey().stateChange(fightState);
}
//Disable feature if should be disabled and currently enabled
if(!feature.getKey().enabled().contains(fightState) && feature.getValue()){
feature.getKey().disable();
feature.setValue(false);
}
}
}
}

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.Config;
@ -66,7 +66,7 @@ public class AkCommand implements CommandExecutor {
return false;
}
KitManager.saveInventory(args[1], player);
} else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getFightState() == FightState.SETUP) {
} else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getFightState() == FightState.PRE_SCHEM_SETUP) {
try {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null && fightTeam.getFightPlayer(player).isLeader()) {

Datei anzeigen

@ -3,7 +3,6 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.Kit;
import de.steamwar.fightsystem.kit.KitManager;
@ -18,7 +17,7 @@ public class Commands {
}
static boolean checkSetup(Player p){
if(FightSystem.getFightState() != FightState.SETUP){
if(FightSystem.getFightState().setup()){
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
return true;
}

Datei anzeigen

@ -9,17 +9,12 @@ import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
import java.util.logging.Level;
import org.bukkit.scheduler.BukkitTask;
public abstract class Countdown {
private static final ArrayList<Countdown> countdowns = new ArrayList<>();
private int time;
private final int taskID;
private final BukkitTask task;
private final Sound sound;
private final boolean level;
@ -30,10 +25,8 @@ public abstract class Countdown {
this.time = time;
this.sound = getSound(sound);
this.level = level;
countdowns.add(this);
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20);
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 0, 20);
}
public static Sound getSound(SWSound sound){
@ -56,16 +49,9 @@ public abstract class Countdown {
}
}
public static void cancelAllTimers() {
while (!countdowns.isEmpty()) {
countdowns.get(0).cancelTimer();
}
}
public static void cancelTimerType(Class<? extends Countdown> type) {
for(int i = countdowns.size() - 1; i >= 0; i--)
if(type.isInstance(countdowns.get(i)))
countdowns.get(i).cancelTimer();
public void disable() {
if(!task.isCancelled())
task.cancel();
}
private void broadcast(String message){
@ -95,7 +81,7 @@ public abstract class Countdown {
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 2.0F);
cancelTimer();
disable();
countdownFinished();
break;
default:
@ -108,15 +94,6 @@ public abstract class Countdown {
}
void onTime(int time){
//Unused
}
public void cancelTimer() {
try {
Bukkit.getScheduler().cancelTask(this.taskID);
} catch (AssertionError ex) {
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not cancel timer", ex);
}
countdowns.remove(this);
//Implemented in some countdowns
}
}

Datei anzeigen

@ -17,7 +17,7 @@ public class EnternCountdown extends Countdown {
@Override
public void countdownFinished() {
FightSystem.setEntern(true);
FightSystem.setEntern();
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
}
}

Datei anzeigen

@ -0,0 +1,30 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
public class PreSchemPasteCountdown extends Countdown {
public PreSchemPasteCountdown() {
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
}
@Override
String countdownCounting() {
return "bis eine Public-Schematic gewählt wird!";
}
@Override
void countdownFinished() {
checkTeam(Fight.getBlueTeam());
checkTeam(Fight.getRedTeam());
FightSystem.setPostSchemState();
}
private void checkTeam(FightTeam team){
if(!team.hasSchematic())
team.pasteDummy();
}
}

Datei anzeigen

@ -1,8 +0,0 @@
package de.steamwar.fightsystem.fight;
public enum FightState {
SETUP,
PRE_RUNNING,
RUNNING,
SPECTATE
}

Datei anzeigen

@ -6,6 +6,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.fightsystem.utils.FightScoreboard;
import de.steamwar.fightsystem.utils.ItemBuilder;
@ -27,10 +28,7 @@ import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.*;
public class FightTeam implements IFightTeam{
@ -82,28 +80,6 @@ public class FightTeam implements IFightTeam{
team.setAllowFriendlyFire(false);
}
private void setTeamColor(Team team, ChatColor color){
switch(Core.getVersion()){
case 15:
FightTeam_15.setTeamColor(team, color);
break;
case 14:
FightTeam_14.setTeamColor(team, color);
break;
case 10:
FightTeam_10.setTeamColor(team, color);
break;
case 9:
FightTeam_9.setTeamColor(team, color);
break;
case 8:
FightTeam_8.setTeamColor(team, color);
break;
default:
FightTeam_12.setTeamColor(team, color);
}
}
public final int getCornerX() {
return cornerX;
}
@ -182,24 +158,14 @@ public class FightTeam implements IFightTeam{
public void removePlayer(Player player) {
FightPlayer fightPlayer = getFightPlayer(player);
if(fightPlayer == null)
return;
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
players.remove(fightPlayer);
team.removeEntry(player.getName());
fightPlayer.getPlayer().getInventory().clear();
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
this.leader = null;
if(!players.isEmpty()) {
setLeader(players.iterator().next());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
}else if(!Config.event()){
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
}else{
if(fightPlayer.equals(leader) && FightSystem.getFightState().setup())
setLeader(null);
}
}
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
@ -221,8 +187,15 @@ public class FightTeam implements IFightTeam{
public void setLeader(FightPlayer leader) {
this.leader = leader;
if (leader == null)
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.event()){
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
}
return;
}
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
Inventory inventory = leader.getPlayer().getInventory();
@ -230,11 +203,14 @@ public class FightTeam implements IFightTeam{
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
else
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
if(!Config.event()){
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());
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
}
if(!Config.test() && FightSystem.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());
}
@ -246,28 +222,35 @@ public class FightTeam implements IFightTeam{
return ready;
}
private void pasteSchematic(){
public void pasteSchematic(){
FreezeWorld freezer = new FreezeWorld();
DyeColor c = ColorConverter.chat2dye(color);
EditSession e;
try {
switch(Core.getVersion()){
case 15:
e = FightTeam_15.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 14:
e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 10:
e = FightTeam_10.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 9:
e = FightTeam_9.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 8:
e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
default:
e = FightTeam_12.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
}
} catch (Schematic.WrongVersionException ex) {
broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden");
@ -277,42 +260,20 @@ public class FightTeam implements IFightTeam{
broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
throw new SecurityException("Error pasting arena in schematic", ex);
}
replaceTeamColor(e);
HandlerList.unregisterAll(freezer);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
}
private void replaceTeamColor(EditSession e){
DyeColor c = ColorConverter.chat2dye(color);
switch(Core.getVersion()){
case 15:
FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 14:
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 10:
FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 9:
FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 8:
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
default:
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
}
}
public void pasteDummy(){
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
if(publics.isEmpty())
return;
schematic = publics.get(0);
schematic = publics.get(new Random().nextInt(publics.size()));
pasteSchematic();
if(!Config.test() && leader != null)
leader.getPlayer().getInventory().clear(0);
}
public void setSchematic(Schematic schematic){
@ -325,9 +286,7 @@ public class FightTeam implements IFightTeam{
if(Config.test())
pasteSchematic();
else if(Fight.getOpposite(this).hasSchematic()){
TechHider.start();
pasteSchematic();
Fight.getOpposite(this).pasteSchematic();
FightSystem.setPostSchemState();
}
}
@ -347,35 +306,14 @@ public class FightTeam implements IFightTeam{
if(ready) {
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
if(Fight.getOpposite(this).isReady() || Config.test()) {
if(Fight.getOpposite(this).isReady() || Config.test())
FightSystem.setPreRunningState();
}
} else {
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
void replaceSync(boolean replace, Material target, Material replacement) {
if(!replace)
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));
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);
}
}
}
}
public Set<Player> getInvited() {
return invited;
}
@ -415,6 +353,48 @@ public class FightTeam implements IFightTeam{
return currentHearts / maximumHearts;
}
void replaceSync(boolean replace, Material target, Material replacement) {
if(!replace)
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));
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);
}
}
}
}
private void setTeamColor(Team team, ChatColor color){
switch(Core.getVersion()){
case 15:
FightTeam_15.setTeamColor(team, color);
break;
case 14:
FightTeam_14.setTeamColor(team, color);
break;
case 10:
FightTeam_10.setTeamColor(team, color);
break;
case 9:
FightTeam_9.setTeamColor(team, color);
break;
case 8:
FightTeam_8.setTeamColor(team, color);
break;
default:
FightTeam_12.setTeamColor(team, color);
}
}
private static class FreezeWorld implements Listener {
private FreezeWorld(){
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());

Datei anzeigen

@ -3,48 +3,29 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
public abstract class BasicListener implements Listener {
public abstract class BasicListener implements Listener, StateDependent {
private static final List<BasicListener> listeners = new LinkedList<>();
private final Set<FightState> enabled;
BasicListener(){
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
listeners.add(this);
}
public static void fightStateChange(FightState state){
for (int i = listeners.size() - 1; i >= 0; i--) {
listeners.get(i).stateChange(state);
}
}
boolean notRunning(){
return FightSystem.getFightState() != FightState.RUNNING;
BasicListener(Set<FightState> enabled){
this.enabled = enabled;
FightSystem.registerStateDependent(this);
}
boolean notFighting(Player p){
return Fight.getFightPlayer(p) == null;
}
void stateChange(FightState state){
//Unused
}
void disable(){
HandlerList.unregisterAll(this);
listeners.remove(this);
}
public static void toActionbar(Player player, BaseComponent... components){
switch(Core.getVersion()){
case 15:
@ -109,4 +90,19 @@ public abstract class BasicListener implements Listener {
BasicListener_12.setAttackSpeed(player);
}
}
@Override
public void enable(){
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
@Override
public void disable(){
HandlerList.unregisterAll(this);
}
@Override
public Set<FightState> enabled() {
return enabled;
}
}

Datei anzeigen

@ -1,30 +0,0 @@
package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class BlockListener extends BasicListener {
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if(notRunning() || notFighting(player)){
event.setCancelled(true);
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke abbauen!"));
}
}
@EventHandler
public void handleBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if(notRunning() || notFighting(player)) {
event.setCancelled(true);
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke setzen!"));
}
}
}

Datei anzeigen

@ -1,68 +1,25 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.EnumSet;
public class EntityDamageListener extends BasicListener {
public EntityDamageListener() {
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
}
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(notRunning()){
event.setCancelled(true);
return;
}
if(!(event.getEntity() instanceof Player))
return;
if(notFighting((Player)event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(notRunning()) {
event.setCancelled(true);
return;
}
if(!(event.getEntity() instanceof Player))
//Target is not a player
return;
Player player = ((Player) event.getEntity()).getPlayer();
Player damager;
if(event.getDamager() instanceof Player) {
damager = ((Player) event.getDamager()).getPlayer();
}else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player))
//Shooter is not a player
return;
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
damager = (Player) damagerArrow.getShooter();
}else{
//Damager is not a player
return;
}
if(notFighting(damager)){
event.setCancelled(true);
//Damager is not fighting
return;
}
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
}
}
}

Datei anzeigen

@ -1,19 +1,21 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.WaterRemover;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.EnumSet;
public class EntityExplodeListener extends BasicListener {
public EntityExplodeListener() {
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
if(notRunning()){
event.setCancelled(true);
return;
}
event.setYield(0); //No drops (additionally to world config
event.setYield(0); //No drops (additionally to world config)
WaterRemover.add(event.blockList());
}
}

Datei anzeigen

@ -1,19 +1,25 @@
package de.steamwar.fightsystem.listener;
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.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.EnumSet;
public class EventJoinListener extends BasicListener {
public EventJoinListener() {
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@ -54,9 +60,4 @@ public class EventJoinListener extends BasicListener {
if(player == FightSystem.getEventLeiter())
FightSystem.setEventLeiter(null);
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -1,11 +1,18 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import java.util.EnumSet;
public class FoodLevelChangeListener extends BasicListener {
public FoodLevelChangeListener() {
super(EnumSet.allOf(FightState.class));
}
@EventHandler
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true);

Datei anzeigen

@ -0,0 +1,62 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import java.util.EnumSet;
public class FreezeWorldStateListener extends BasicListener {
public FreezeWorldStateListener() {
super(Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
}
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
event.setCancelled(true);
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke abbauen!"));
}
@EventHandler
public void handleBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
event.setCancelled(true);
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke setzen!"));
}
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onDropPickup(InventoryPickupItemEvent e){
e.setCancelled(true);
}
@EventHandler
public void onDropping(PlayerDropItemEvent e){
e.setCancelled(true);
}
}

Datei anzeigen

@ -1,17 +1,23 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.EnumSet;
public class HotbarGUIListener extends BasicListener {
public HotbarGUIListener() {
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
}
@EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
@ -55,9 +61,4 @@ public class HotbarGUIListener extends BasicListener {
}
}
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -0,0 +1,65 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.EnumSet;
public class InFightDamageListener extends BasicListener {
public InFightDamageListener() {
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(!(event.getEntity() instanceof Player))
return;
if(notFighting((Player)event.getEntity()))
event.setCancelled(true);
}
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof Player))
//Target is not a player
return;
Player player = ((Player) event.getEntity());
Player damager;
if(event.getDamager() instanceof Player) {
damager = ((Player) event.getDamager()).getPlayer();
}else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player))
//Shooter is not a player
return;
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
damager = (Player) damagerArrow.getShooter();
}else{
//Damager is not a player
return;
}
if(notFighting(damager)){
event.setCancelled(true);
//Damager is not fighting
return;
}
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
}
}
}

Datei anzeigen

@ -1,7 +1,6 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -12,15 +11,16 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class InventoryListener extends BasicListener {
import java.util.EnumSet;
public class InFightInventoryListener extends BasicListener {
public InFightInventoryListener() {
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if(FightSystem.getFightState() == FightState.SETUP){
event.setCancelled(true);
return;
}
Inventory clicked = event.getClickedInventory();
if(event.getClick().isShiftClick()){
ItemStack clickedOn = event.getCurrentItem();
@ -41,11 +41,6 @@ public class InventoryListener extends BasicListener {
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
if(FightSystem.getFightState() == FightState.SETUP){
event.setCancelled(true);
return;
}
if (event.getInventory().getType() != InventoryType.PLAYER) {
int inventorySize = event.getInventory().getSize();

Datei anzeigen

@ -1,18 +1,22 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
import de.steamwar.fightsystem.countdown.SetupOverCountdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
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 NormalJoinListener extends BasicListener {
public NormalJoinListener() {
super(Config.event() || Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@ -28,13 +32,7 @@ public class NormalJoinListener extends BasicListener {
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
new SetupOverCountdown();
FightSystem.setPreSchemState();
}
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -1,8 +1,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.Region;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -10,13 +9,19 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import java.util.EnumSet;
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));
}
@EventHandler
public void handlePistonExtend(BlockPistonExtendEvent e){
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
return;
BlockFace b = e.getDirection();
for(Block block : e.getBlocks()){
if(
@ -32,9 +37,6 @@ public class PistonListener extends BasicListener {
@EventHandler
public void handlePistonRetract(BlockPistonRetractEvent e){
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
return;
BlockFace b = e.getDirection();
for(Block block : e.getBlocks()){
if(

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -11,15 +12,20 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.EnumSet;
public class PlayerChatListener extends BasicListener {
public PlayerChatListener(){
super(EnumSet.allOf(FightState.class));
}
@EventHandler
public void handlePlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
String teamName = fightTeam.getColoredName();
if(message.startsWith(Config.TeamChatDetection)) {

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerConnectionListener extends BasicListener{
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerJoin(PlayerJoinEvent event) {
event.setJoinMessage(null);
Player player = event.getPlayer();
player.setHealth(20);
player.setFoodLevel(20);
setAttackSpeed(player);
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
} else {
player.teleport(fightTeam.getSpawn());
if(FightSystem.getFightState() == FightState.SETUP)
player.setGameMode(GameMode.ADVENTURE);
else
player.setGameMode(GameMode.SPECTATOR);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return;
FightState fightState = FightSystem.getFightState();
if(fightState == FightState.SETUP){
fightTeam.removePlayer(player);
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLiving()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
fightTeam.getFightPlayer(player).setOut();
}
}
}
}

Datei anzeigen

@ -1,32 +0,0 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.SWSound;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
public class PlayerDeathListener extends BasicListener {
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return;
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!");
event.setDeathMessage(null);
fightTeam.getFightPlayer(player).setOut();
player.setGameMode(GameMode.SPECTATOR);
player.teleport(fightTeam.getSpawn());
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
}
}

Datei anzeigen

@ -1,10 +1,10 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.GameMode;
@ -13,12 +13,18 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.EnumSet;
public class PlayerMoveListener extends BasicListener {
private static final String DENY_ARENA = "§cDu darfst die Arena nicht verlassen";
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
public PlayerMoveListener() {
super(EnumSet.allOf(FightState.class));
}
@EventHandler
public void teamAreas(PlayerMoveEvent event) {
Player player = event.getPlayer();
@ -28,6 +34,7 @@ public class PlayerMoveListener extends BasicListener {
Location to = event.getTo();
FightTeam fightTeam = Fight.getPlayerTeam(player);
assert to != null;
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
@ -37,7 +44,7 @@ public class PlayerMoveListener extends BasicListener {
if(fightTeam == null)
reset(event, DENY_TEAM);
}else if(fightTeam != null && (
!FightSystem.isEntern() || player.getGameMode() == GameMode.SPECTATOR)){
FightSystem.getFightState() != FightState.ENTERN || player.getGameMode() == GameMode.SPECTATOR)){
reset(event, DENY_ENTERN);
}
}
@ -48,6 +55,7 @@ public class PlayerMoveListener extends BasicListener {
Location to = event.getTo();
//Check in Arena
assert to != null;
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
reset(event, DENY_ARENA);
return;

Datei anzeigen

@ -1,21 +0,0 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerRespawnEvent;
public class PlayerRespawnListener extends BasicListener {
@EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
FightTeam team = Fight.getPlayerTeam(player);
if(team == null)
event.setRespawnLocation(Config.SpecSpawn);
else
event.setRespawnLocation(team.getSpawn());
}
}

Datei anzeigen

@ -0,0 +1,113 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.SWSound;
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 net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.EnumSet;
public class PlayerStateListener extends BasicListener{
public PlayerStateListener() {
super(EnumSet.allOf(FightState.class));
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerJoin(PlayerJoinEvent event) {
event.setJoinMessage(null);
Player player = event.getPlayer();
player.setHealth(20);
player.setFoodLevel(20);
setAttackSpeed(player);
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
} else {
player.teleport(fightTeam.getSpawn());
if(FightSystem.getFightState().setup())
player.setGameMode(GameMode.ADVENTURE);
else
player.setGameMode(GameMode.SPECTATOR);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return;
assert player != null;
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!");
event.setDeathMessage(null);
fightTeam.getFightPlayer(player).setOut();
player.setGameMode(GameMode.SPECTATOR);
player.teleport(fightTeam.getSpawn());
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
}
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return;
FightState fightState = FightSystem.getFightState();
if(fightState.setup()){
fightTeam.removePlayer(player);
}else if(fightState.ingame()){
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLiving()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
fightTeam.getFightPlayer(player).setOut();
}
}
//Shutdown server if nobody online and its not an event server
if(!Config.event() && (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(player))))
FightSystem.shutdown(null);
}
@EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
FightTeam team = Fight.getPlayerTeam(player);
if(team == null)
event.setRespawnLocation(Config.SpecSpawn);
else
event.setRespawnLocation(team.getSpawn());
}
@EventHandler
public void onTpGM3(PlayerTeleportEvent e) {
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
e.setCancelled(true);
toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
}
}
}

Datei anzeigen

@ -1,16 +0,0 @@
package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerTeleportEvent;
public class PlayerTeleportListener extends BasicListener {
@EventHandler
public void onTpGM3(PlayerTeleportEvent e) {
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
e.setCancelled(true);
toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
}
}
}

Datei anzeigen

@ -1,22 +1,25 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import java.util.EnumSet;
public class ProjectileLaunchListener extends BasicListener {
public ProjectileLaunchListener() {
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
}
@EventHandler
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
if(FightSystem.getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(event.getEntity().getShooter() instanceof Player){
Player player = (Player) event.getEntity().getShooter();
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Fightbeginn nutzen!"));
}
}
}
}

Datei anzeigen

@ -1,20 +1,28 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.permissions.PermissionAttachment;
import java.util.EnumSet;
public class TestListener extends BasicListener {
private NoPlayersOnlineCountdown countdown;
public TestListener() {
super(Config.test() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
if(Config.test())
countdown = new NoPlayersOnlineCountdown();
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@ -24,8 +32,10 @@ public class TestListener extends BasicListener {
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
}
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
if(countdown != null){
countdown.disable();
countdown = null;
}
PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
attachment.setPermission("fawe.permpack.basic", true);
@ -33,16 +43,132 @@ public class TestListener extends BasicListener {
attachment.setPermission("minecraft.command.tp", true);
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
attachment.setPermission("worldedit.navigation.thru.tool", true);
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event){
if(Bukkit.getOnlinePlayers().isEmpty())
FightSystem.shutdown(null);
}
@Override
void stateChange(FightState state){
disable();
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
attachment.setPermission("worldedit.navigation.thru.tool", true);
attachment.setPermission("worldedit.biome.info", true);
attachment.setPermission("worldedit.biome.set", true);
attachment.setPermission("worldedit.biome.list", true);
attachment.setPermission("worldedit.chunkinfo", true);
attachment.setPermission("worldedit.listchunks", true);
attachment.setPermission("worldedit.clipboard.cut", true);
attachment.setPermission("worldedit.clipboard.paste", true);
attachment.setPermission("worldedit.schematic.formats", true);
attachment.setPermission("worldedit.schematic.load", true);
attachment.setPermission("worldedit.schematic.list", true);
attachment.setPermission("worldedit.schematic.save", true);
attachment.setPermission("worldedit.clipboard.clear", true);
attachment.setPermission("worldedit.clipboard.copy", true);
attachment.setPermission("worldedit.clipboard.lazycopy", true);
attachment.setPermission("worldedit.clipboard.place", true);
attachment.setPermission("worldedit.clipboard.download", true);
attachment.setPermission("worldedit.clipboard.flip", true);
attachment.setPermission("worldedit.clipboard.rotate", true);
attachment.setPermission("worldedit.help", true);
attachment.setPermission("worldedit.global-mask", true);
attachment.setPermission("worldedit.global-transform", true);
attachment.setPermission("worldedit.generation.cylinder", true);
attachment.setPermission("worldedit.generation.sphere", true);
attachment.setPermission("worldedit.generation.forest", true);
attachment.setPermission("worldedit.generation.pumpkins", true);
attachment.setPermission("worldedit.generation.pyramid", true);
attachment.setPermission("worldedit.generation.shape", true);
attachment.setPermission("worldedit.biome.set", true);
attachment.setPermission("worldedit.history.undo", true);
attachment.setPermission("worldedit.history.redo", true);
attachment.setPermission("worldedit.history.rollback", true);
attachment.setPermission("worldedit.navigation.unstuck", true);
attachment.setPermission("worldedit.navigation.ascend", true);
attachment.setPermission("worldedit.navigation.descend", true);
attachment.setPermission("worldedit.navigation.ceiling", true);
attachment.setPermission("worldedit.navigation.thru.command", true);
attachment.setPermission("worldedit.navigation.jumpto.command", true);
attachment.setPermission("worldedit.navigation.up", true);
attachment.setPermission("worldedit.region.hollow", true);
attachment.setPermission("worldedit.region.line", true);
attachment.setPermission("worldedit.region.curve", true);
attachment.setPermission("worldedit.region.overlay", true);
attachment.setPermission("worldedit.region.center", true);
attachment.setPermission("worldedit.region.naturalize", true);
attachment.setPermission("worldedit.region.walls", true);
attachment.setPermission("worldedit.region.faces", true);
attachment.setPermission("worldedit.region.smooth", true);
attachment.setPermission("worldedit.region.move", true);
attachment.setPermission("worldedit.region.forest", true);
attachment.setPermission("worldedit.region.replace", true);
attachment.setPermission("worldedit.region.stack", true);
attachment.setPermission("worldedit.region.set", true);
attachment.setPermission("worldedit.selection.pos", true);
attachment.setPermission("worldedit.selection.chunk", true);
attachment.setPermission("worldedit.selection.hpos", true);
attachment.setPermission("worldedit.wand", true);
attachment.setPermission("worldedit.wand.toggle", true);
attachment.setPermission("worldedit.selection.contract", true);
attachment.setPermission("worldedit.selection.outset", true);
attachment.setPermission("worldedit.selection.inset", true);
attachment.setPermission("worldedit.analysis.distr", true);
attachment.setPermission("worldedit.analysis.count", true);
attachment.setPermission("worldedit.selection.size", true);
attachment.setPermission("worldedit.selection.expand", true);
attachment.setPermission("worldedit.selection.shift", true);
attachment.setPermission("worldedit.snapshots.list", true);
attachment.setPermission("worldedit.superpickaxe", true);
attachment.setPermission("worldedit.superpickaxe.area", true);
attachment.setPermission("worldedit.superpickaxe.recursive", true);
attachment.setPermission("worldedit.brush.blendball", true);
attachment.setPermission("worldedit.brush.erode", true);
attachment.setPermission("worldedit.brush.pull", true);
attachment.setPermission("worldedit.brush.circle", true);
attachment.setPermission("worldedit.brush.recursive", true);
attachment.setPermission("worldedit.brush.line", true);
attachment.setPermission("worldedit.brush.spline", true);
attachment.setPermission("worldedit.brush.surfacespline", true);
attachment.setPermission("worldedit.brush.shatter", true);
attachment.setPermission("worldedit.brush.stencil", true);
attachment.setPermission("worldedit.brush.height", true);
attachment.setPermission("worldedit.brush.layer", true);
attachment.setPermission("worldedit.brush.populateschematic", true);
attachment.setPermission("worldedit.brush.scatter", true);
attachment.setPermission("worldedit.brush.splatter", true);
attachment.setPermission("worldedit.brush.scattercommand", true);
attachment.setPermission("worldedit.brush.copy", true);
attachment.setPermission("worldedit.brush.command", true);
attachment.setPermission("worldedit.brush.apply", true);
attachment.setPermission("worldedit.brush.sphere", true);
attachment.setPermission("worldedit.brush.cylinder", true);
attachment.setPermission("worldedit.brush.clipboard", true);
attachment.setPermission("worldedit.brush.smooth", true);
attachment.setPermission("worldedit.brush.ex", true);
attachment.setPermission("worldedit.brush.gravity", true);
attachment.setPermission("worldedit.brush.options.range", true);
attachment.setPermission("worldedit.brush.options.material", true);
attachment.setPermission("worldedit.brush.options.size", true);
attachment.setPermission("worldedit.brush.options.mask", true);
attachment.setPermission("worldedit.brush.options.smask", true);
attachment.setPermission("worldedit.brush.options.transform", true);
attachment.setPermission("worldedit.brush.options.scroll", true);
attachment.setPermission("worldedit.brush.options.visualize", true);
attachment.setPermission("worldedit.tool.deltree", true);
attachment.setPermission("worldedit.tool.farwand", true);
attachment.setPermission("worldedit.tool.lrbuild", true);
attachment.setPermission("worldedit.tool.info", true);
attachment.setPermission("worldedit.tool.tree", true);
attachment.setPermission("worldedit.tool.replacer", true);
attachment.setPermission("worldedit.tool.data-cycler", true);
attachment.setPermission("worldedit.tool.flood-fill", true);
attachment.setPermission("worldedit.tool.inspect", true);
attachment.setPermission("worldedit.fill.recursive", true);
attachment.setPermission("worldedit.drain", true);
attachment.setPermission("worldedit.fixlava", true);
attachment.setPermission("worldedit.fixwater", true);
attachment.setPermission("worldedit.removeabove", true);
attachment.setPermission("worldedit.removebelow", true);
attachment.setPermission("worldedit.removenear", true);
attachment.setPermission("worldedit.replacenear", true);
attachment.setPermission("worldedit.snow", true);
attachment.setPermission("worldedit.thaw", true);
attachment.setPermission("worldedit.green", true);
attachment.setPermission("worldedit.extinguish", true);
attachment.setPermission("worldedit.calc", true);
attachment.setPermission("worldedit.fill", true);
}
}

Datei anzeigen

@ -0,0 +1,39 @@
package de.steamwar.fightsystem.states;
public enum FightState {
PRE_LEADER_SETUP(true, true, false, false),
PRE_SCHEM_SETUP(true, true, false, false),
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
FightState(boolean setup, boolean outgame, boolean ingame, boolean infight){
this.setup = setup;
this.outgame = outgame;
this.ingame = ingame;
this.infight = infight;
}
public boolean setup(){
return setup;
}
public boolean outgame(){
return outgame;
}
public boolean ingame(){
return ingame;
}
public boolean infight(){
return infight;
}
}

Datei anzeigen

@ -0,0 +1,26 @@
package de.steamwar.fightsystem.states;
import java.util.Set;
public interface StateDependent {
/**
* @return returns a set containing
*/
Set<FightState> enabled();
/**
* Enables the state dependent object
*/
void enable();
/**
* Disables the state dependent object
*/
void disable();
/**
* On state change when enabled
*/
default void stateChange(FightState state){}
}

Datei anzeigen

@ -3,20 +3,23 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.winconditions.*;
import org.bukkit.Bukkit;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;
public class FightScoreboard {
private FightScoreboard(){}
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.ENTERN, FightState.SPECTATE);
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
private static final Objective objective;
private static int index = 0;
@ -68,9 +71,9 @@ public class FightScoreboard {
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
}
if (Config.Entern)
objective.getScore("§7Entern: " + (FightSystem.isEntern() ? "§aja" : "§cnein")).setScore(2);
objective.getScore("§7Entern: " + (FightSystem.getFightState() == FightState.ENTERN ? "§aja" : "§cnein")).setScore(2);
if(FightSystem.getFightState() == FightState.RUNNING){
if(fullScoreboard.contains(FightSystem.getFightState())){
if (Config.PercentSystem){
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0);

Datei anzeigen

@ -213,6 +213,6 @@ public class TechHider {
}
private static boolean disabled(){
return Config.OnlyPublicSchematics;
return Config.OnlyPublicSchematics || Config.test();
}
}

Datei anzeigen

@ -1,17 +1,31 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Bukkit;
public class EventTeamOffWincondition {
import java.util.EnumSet;
public class EventTeamOffWincondition extends Wincondition {
public EventTeamOffWincondition(){
super(Config.event(), EnumSet.of(FightState.PRE_RUNNING));
}
@Override
public void enable() {
teamOff(Fight.getBlueTeam());
teamOff(Fight.getRedTeam());
}
@Override
public void disable() {
//Team off is a on time trigger
}
private void teamOff(FightTeam team){
if(team.allPlayersOut()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getColoredName() + " §6ist Offline!");

Datei anzeigen

@ -1,15 +1,33 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
abstract class ListenerWincondition implements Listener {
import java.util.Set;
void init(boolean condition){
if(!condition)
return;
abstract class ListenerWincondition extends Wincondition implements Listener {
ListenerWincondition(boolean condition, Set<FightState> enabled){
//If the condition is not met, never enable
super(condition, enabled);
}
/**
* Enables the state dependent object
*/
@Override
public void enable(){
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
/**
* Disables the state dependent object
*/
@Override
public void disable(){
HandlerList.unregisterAll(this);
}
}

Datei anzeigen

@ -1,17 +1,19 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.entity.Player;
import java.util.EnumSet;
abstract class PlayerWincondition extends ListenerWincondition {
boolean isTarget(Player player){
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
return false;
PlayerWincondition(boolean condition) {
super(condition, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
}
boolean isTarget(Player player){
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return false;

Datei anzeigen

@ -0,0 +1,23 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import java.util.Set;
abstract class Wincondition implements StateDependent {
private final Set<FightState> enabled;
Wincondition(boolean condition, Set<FightState> enabled){
this.enabled = enabled;
if(condition)
FightSystem.registerStateDependent(this);
}
@Override
public Set<FightState> enabled(){
return enabled;
}
}

Datei anzeigen

@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead extends PlayerWincondition {
public WinconditionAllDead(){
init(Config.AllDead);
super(Config.AllDead);
}
@EventHandler

Datei anzeigen

@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends PlayerWincondition {
public WinconditionCaptainDead(){
init(Config.CaptainDead);
super(Config.CaptainDead);
}
@EventHandler

Datei anzeigen

@ -1,13 +0,0 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.Config;
public class WinconditionEntern {
public WinconditionEntern() {
if(!Config.Entern)
return;
new EnternCountdown();
}
}

Datei anzeigen

@ -4,14 +4,21 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
public class WinconditionHeartRatioTimeout {
import java.util.EnumSet;
public class WinconditionHeartRatioTimeout extends Wincondition {
private TimeOverCountdown countdown;
public WinconditionHeartRatioTimeout() {
if(!Config.HeartRatioTimeout)
return;
super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
new TimeOverCountdown(() -> {
@Override
public void enable() {
countdown = new TimeOverCountdown(() -> {
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
@ -23,4 +30,9 @@ public class WinconditionHeartRatioTimeout {
FightSystem.setSpectateState(null);
});
}
@Override
public void disable(){
countdown.disable();
}
}

Datei anzeigen

@ -1,14 +1,16 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.Region;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.EnumSet;
public class WinconditionPercentSystem extends ListenerWincondition {
private static double bluePercent = 0D;
@ -17,12 +19,10 @@ public class WinconditionPercentSystem extends ListenerWincondition {
private static int blueDestroyedBlocks;
private static int redDestroyedBlocks;
private static int schematicSize;
private static final int schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
public WinconditionPercentSystem() {
init(Config.PercentSystem);
schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
super(Config.PercentSystem, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
@EventHandler

Datei anzeigen

@ -5,6 +5,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,15 +16,38 @@ public class WinconditionPoints extends PlayerWincondition {
private static TeamPoints blue;
private static TeamPoints red;
private TimeOverCountdown countdown;
public WinconditionPoints(){
if(!Config.Points)
return;
super(Config.Points);
}
init(true);
public static TeamPoints getRed(){
return red;
}
public static TeamPoints getBlue(){
return blue;
}
@Override
public void enable() {
super.enable();
blue = new TeamPoints(Fight.getRedTeam(), WinconditionRelativePercent.getBlue(), WinconditionRelativePercent.getRed());
red = new TeamPoints(Fight.getBlueTeam(), WinconditionRelativePercent.getRed(), WinconditionRelativePercent.getBlue());
new TimeOverCountdown(this::fightEnds);
}
@Override
public void disable() {
super.disable();
countdown.disable();
}
@Override
public void stateChange(FightState state){
if(state == FightState.RUNNING){
countdown = new TimeOverCountdown(this::fightEnds);
}
}
@EventHandler
@ -54,14 +78,6 @@ public class WinconditionPoints extends PlayerWincondition {
}
public static TeamPoints getRed(){
return red;
}
public static TeamPoints getBlue(){
return blue;
}
private void fightEnds(){
if(red.getPoints() > blue.getPoints())
FightSystem.setSpectateState(blue.enemy);
@ -78,7 +94,7 @@ public class WinconditionPoints extends PlayerWincondition {
return red;
}
public static class TeamPoints extends PlayerWincondition {
public static class TeamPoints {
private final FightTeam enemy;
private final WinconditionRelativePercent.TeamPercent enemyPercent;
private final double factor;
@ -89,13 +105,12 @@ public class WinconditionPoints extends PlayerWincondition {
TeamPoints(FightTeam enemy, WinconditionRelativePercent.TeamPercent ownPercent, WinconditionRelativePercent.TeamPercent enemyPercent){
this.enemy = enemy;
this.enemyPercent = enemyPercent;
init(true);
points = 0;
if(enemyPercent.getBlockCount() < ownPercent.getBlockCount())
this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte
else{
double f = 10000 * ownPercent.getBlockCount() / enemyPercent.getBlockCount();
double f = 10000.0 * ownPercent.getBlockCount() / enemyPercent.getBlockCount();
if(f > 10000)
f = 10000;

Datei anzeigen

@ -4,23 +4,25 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitTask;
public class WinconditionPumpkinTechKO {
import java.util.EnumSet;
public class WinconditionPumpkinTechKO extends Wincondition {
private static int teamRedPumpkins = -1;
private static int teamBluePumpkins = -1;
private static final World WORLD = Bukkit.getWorlds().get(0);
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
private BukkitTask task;
public WinconditionPumpkinTechKO(){
if(!Config.PumpkinTechKO)
return;
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), WinconditionPumpkinTechKO::recursiveCheck, 0, 200);
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.ENTERN));
}
public static int getTeamBluePumpkins() {
@ -30,6 +32,16 @@ public class WinconditionPumpkinTechKO {
return teamRedPumpkins;
}
@Override
public void enable() {
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), WinconditionPumpkinTechKO::recursiveCheck, 0, 200);
}
@Override
public void disable() {
task.cancel();
}
private static void recursiveCheck(){
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
Config.TeamRedCornerY,

Datei anzeigen

@ -4,15 +4,18 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitTask;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class WinconditionRelativePercent{
public class WinconditionRelativePercent extends Wincondition{
private static final Set<Material> ignoredBlocks;
private static TeamPercent blue;
@ -26,11 +29,7 @@ public class WinconditionRelativePercent{
}
public WinconditionRelativePercent(){
if(!Config.RelativePercent && !Config.Points)
return;
blue = new TeamPercent(Fight.getBlueTeam());
red = new TeamPercent(Fight.getRedTeam());
super(Config.RelativePercent || Config.Points, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
}
public static TeamPercent getBlue(){
@ -41,19 +40,32 @@ public class WinconditionRelativePercent{
return red;
}
@Override
public void enable() {
blue = new TeamPercent(Fight.getBlueTeam());
red = new TeamPercent(Fight.getRedTeam());
}
@Override
public void disable() {
blue.task.cancel();
red.task.cancel();
}
public static class TeamPercent {
private static final World world = Bukkit.getWorlds().get(0);
private final FightTeam team;
private final int blockCount;
private final BukkitTask task;
private int currentBlocks;
TeamPercent(FightTeam team){
private TeamPercent(FightTeam team){
this.team = team;
this.blockCount = currentBlocks();
this.currentBlocks = blockCount;
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
currentBlocks = currentBlocks();
checkPercentDefeat();
}, 400, 400);
@ -73,7 +85,7 @@ public class WinconditionRelativePercent{
}
private int currentBlocks(){
if(FightSystem.isEntern())
if(FightSystem.getFightState() == FightState.ENTERN || FightSystem.getFightState() == FightState.SPECTATE)
return currentBlocks;
int blocks = 0;

Datei anzeigen

@ -1,46 +1,61 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TechKOCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
public class WinconditionTechKO implements Listener {
public class WinconditionTechKO extends ListenerWincondition {
private static final int TECH_KO_TIME_IN_S = 90;
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
public static final int TECH_KO_COUNTDOWN_TIME = TECH_KO_HALF_TIME/20;
private World world;
private World world = Bukkit.getWorlds().get(0);
private Map<Integer, Boolean> map = new HashMap<>(400);
private double toggle;
private int smallerZtime;
private int biggerZtime;
private double toggle = Config.SpecSpawn.getZ();
private int smallerZtime = TECH_KO_HALF_TIME;
private int biggerZtime = TECH_KO_HALF_TIME;
private TechKOCountdown smallerZcountdown = null;
private TechKOCountdown biggerZcountdown = null;
private BukkitTask task;
//Works only for z-Axis fight direction for performance reasons
/**
* Works only for z-Axis fight direction for performance reasons
*/
public WinconditionTechKO(){
if(!Config.TechKO)
return;
super(Config.TechKO, EnumSet.of(FightState.RUNNING, FightState.SPECTATE));
}
world = Bukkit.getWorlds().get(0);
toggle = Config.SpecSpawn.getZ();
smallerZtime=TECH_KO_HALF_TIME;
biggerZtime=TECH_KO_HALF_TIME;
@Override
public void enable() {
super.enable();
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
}
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
@Override
public void disable() {
super.disable();
smallerZcountdown.disable();
biggerZcountdown.disable();
task.cancel();
}
@EventHandler
public void onEntityDead(EntityExplodeEvent event){
map.remove(event.getEntity().getEntityId());
}
private void run(){
@ -57,14 +72,14 @@ public class WinconditionTechKO implements Listener {
}
if(smallerZtime == TECH_KO_HALF_TIME && smallerZcountdown != null){
smallerZcountdown.cancelTimer();
smallerZcountdown.disable();
smallerZcountdown = null;
}else if(smallerZtime == 0){
smallerZcountdown = new TechKOCountdown(smallerTeam());
}
if(biggerZtime == TECH_KO_HALF_TIME && biggerZcountdown != null){
biggerZcountdown.cancelTimer();
biggerZcountdown.disable();
biggerZcountdown = null;
}else if(biggerZtime == 0){
biggerZcountdown = new TechKOCountdown(biggerTeam());
@ -87,9 +102,4 @@ public class WinconditionTechKO implements Listener {
else
return Fight.getRedTeam();
}
@EventHandler
public void onEntityDead(EntityExplodeEvent event){
map.remove(event.getEntity().getEntityId());
}
}

Datei anzeigen

@ -1,14 +1,27 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import java.util.EnumSet;
public class WinconditionTimeout extends Wincondition {
private TimeOverCountdown countdown;
public class WinconditionTimeout {
public WinconditionTimeout() {
if(!Config.Timeout)
return;
super(Config.Timeout, EnumSet.of(FightState.RUNNING, FightState.ENTERN));
}
new TimeOverCountdown(() -> FightSystem.setSpectateState(null));
@Override
public void enable() {
countdown = new TimeOverCountdown(() -> FightSystem.setSpectateState(null));
}
@Override
public void disable() {
countdown.disable();
}
}

Datei anzeigen

@ -3,28 +3,41 @@ package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.WaterRemover;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitTask;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class WinconditionWaterTechKO {
public class WinconditionWaterTechKO extends Wincondition {
private static final Set<Location> teamRedWater = new HashSet<>();
private static final Set<Location> teamBlueWater = new HashSet<>();
private static final World WORLD = Bukkit.getWorlds().get(0);
public WinconditionWaterTechKO() {
if(!Config.WaterTechKO)
return;
private BukkitTask task;
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200);
public WinconditionWaterTechKO() {
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.SPECTATE));
}
public static int getTeamBlueWater() {
return teamBlueWater.size();
}
public static int getTeamRedWater() {
return teamRedWater.size();
}
@Override
public void enable() {
checkForWater(teamRedWater,
Config.TeamRedCornerX,
Config.TeamRedCornerY,
@ -39,6 +52,19 @@ public class WinconditionWaterTechKO {
Config.TeamBlueCornerX + Config.SchemsizeX,
Config.TeamBlueCornerY + Config.SchemsizeY,
Config.TeamBlueCornerZ + Config.SchemsizeZ);
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200);
}
@Override
public void disable() {
task.cancel();
}
private void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
}
}
private void addWater() {
@ -77,19 +103,4 @@ public class WinconditionWaterTechKO {
}
}
}
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
}
}
public static int getTeamBlueWater() {
return teamBlueWater.size();
}
public static int getTeamRedWater() {
return teamRedWater.size();
}
}