WIP Splitting Setup and refactoring
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
37955438ba
Commit
72096710b3
@ -4,10 +4,11 @@ import de.steamwar.fightsystem.commands.*;
|
|||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
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.FightScoreboard;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
@ -19,14 +20,15 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
public class FightSystem extends JavaPlugin {
|
public class FightSystem extends JavaPlugin {
|
||||||
|
|
||||||
public static final String PREFIX = "§eArena§8» ";
|
public static final String PREFIX = "§eArena§8» ";
|
||||||
private static FightSystem plugin;
|
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 int fightTime = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,16 +47,14 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new FoodLevelChangeListener();
|
new FoodLevelChangeListener();
|
||||||
new PistonListener();
|
new PistonListener();
|
||||||
new PlayerChatListener();
|
new PlayerChatListener();
|
||||||
new PlayerDeathListener();
|
|
||||||
new HotbarGUIListener();
|
new HotbarGUIListener();
|
||||||
new PlayerMoveListener();
|
new PlayerMoveListener();
|
||||||
new PlayerConnectionListener();
|
new PlayerStateListener();
|
||||||
new PlayerRespawnListener();
|
|
||||||
new PlayerTeleportListener();
|
|
||||||
new ProjectileLaunchListener();
|
new ProjectileLaunchListener();
|
||||||
|
new InFightDamageListener();
|
||||||
|
|
||||||
if(!Config.test()){
|
if(!Config.test()){
|
||||||
new BlockListener();
|
new FreezeWorldStateListener();
|
||||||
TechHider.init();
|
TechHider.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,14 +89,13 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
}else{
|
}else{
|
||||||
new NormalJoinListener();
|
new NormalJoinListener();
|
||||||
new InventoryListener();
|
|
||||||
|
|
||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreRunningState() {
|
public static void setPreRunningState() {
|
||||||
if(fightState != FightState.SETUP)
|
if(fightState != FightState.PRE_LEADER_SETUP) //TODO
|
||||||
return;
|
return;
|
||||||
setFightState(FightState.PRE_RUNNING);
|
setFightState(FightState.PRE_RUNNING);
|
||||||
Countdown.cancelAllTimers();
|
Countdown.cancelAllTimers();
|
||||||
@ -189,31 +188,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
public static void setEventLeiter(Player el){
|
||||||
IFightSystem.setEventLeiter(el);
|
IFightSystem.setEventLeiter(el);
|
||||||
}
|
}
|
||||||
@ -249,4 +223,52 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static void shutdown(String reason){
|
public static void shutdown(String reason){
|
||||||
IFightSystem.shutdown(reason);
|
IFightSystem.shutdown(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerStateDependent(StateDependent stateDependent){
|
||||||
|
stateDependentFeatures.put(stateDependent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ package de.steamwar.fightsystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.commands;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.Kit;
|
import de.steamwar.fightsystem.kit.Kit;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package de.steamwar.fightsystem.fight;
|
|
||||||
|
|
||||||
public enum FightState {
|
|
||||||
SETUP,
|
|
||||||
PRE_RUNNING,
|
|
||||||
RUNNING,
|
|
||||||
SPECTATE
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ package de.steamwar.fightsystem.fight;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
|
@ -3,48 +3,29 @@ package de.steamwar.fightsystem.listener;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.Set;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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(){
|
BasicListener(Set<FightState> enabled){
|
||||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
this.enabled = enabled;
|
||||||
listeners.add(this);
|
FightSystem.registerStateDependent(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean notFighting(Player p){
|
boolean notFighting(Player p){
|
||||||
return Fight.getFightPlayer(p) == null;
|
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){
|
public static void toActionbar(Player player, BaseComponent... components){
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 15:
|
case 15:
|
||||||
@ -109,4 +90,19 @@ public abstract class BasicListener implements Listener {
|
|||||||
BasicListener_12.setAttackSpeed(player);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +1,25 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
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.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class EntityDamageListener extends BasicListener {
|
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
|
@EventHandler
|
||||||
public void handleEntityDamage(EntityDamageEvent event) {
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
if(notRunning()) {
|
|
||||||
event.setCancelled(true);
|
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!"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class EntityExplodeListener extends BasicListener {
|
public class EntityExplodeListener extends BasicListener {
|
||||||
|
|
||||||
|
public EntityExplodeListener() {
|
||||||
|
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||||
if(notRunning()){
|
event.setYield(0); //No drops (additionally to world config)
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setYield(0); //No drops (additionally to world config
|
|
||||||
WaterRemover.add(event.blockList());
|
WaterRemover.add(event.blockList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class EventJoinListener extends BasicListener {
|
public class EventJoinListener extends BasicListener {
|
||||||
|
|
||||||
|
public EventJoinListener() {
|
||||||
|
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -54,9 +60,4 @@ public class EventJoinListener extends BasicListener {
|
|||||||
if(player == FightSystem.getEventLeiter())
|
if(player == FightSystem.getEventLeiter())
|
||||||
FightSystem.setEventLeiter(null);
|
FightSystem.setEventLeiter(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void stateChange(FightState state){
|
|
||||||
disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class FoodLevelChangeListener extends BasicListener {
|
public class FoodLevelChangeListener extends BasicListener {
|
||||||
|
|
||||||
|
public FoodLevelChangeListener() {
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
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(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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,23 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
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.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class HotbarGUIListener extends BasicListener {
|
public class HotbarGUIListener extends BasicListener {
|
||||||
|
|
||||||
|
public HotbarGUIListener() {
|
||||||
|
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -55,9 +61,4 @@ public class HotbarGUIListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void stateChange(FightState state){
|
|
||||||
disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
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.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if(FightSystem.getFightState() == FightState.SETUP){
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Inventory clicked = event.getClickedInventory();
|
Inventory clicked = event.getClickedInventory();
|
||||||
if(event.getClick().isShiftClick()){
|
if(event.getClick().isShiftClick()){
|
||||||
ItemStack clickedOn = event.getCurrentItem();
|
ItemStack clickedOn = event.getCurrentItem();
|
||||||
@ -41,11 +41,6 @@ public class InventoryListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryDrag(InventoryDragEvent event) {
|
public void onInventoryDrag(InventoryDragEvent event) {
|
||||||
if(FightSystem.getFightState() == FightState.SETUP){
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getInventory().getType() != InventoryType.PLAYER) {
|
if (event.getInventory().getType() != InventoryType.PLAYER) {
|
||||||
int inventorySize = event.getInventory().getSize();
|
int inventorySize = event.getInventory().getSize();
|
||||||
|
|
@ -4,14 +4,20 @@ import de.steamwar.fightsystem.countdown.Countdown;
|
|||||||
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
||||||
import de.steamwar.fightsystem.countdown.SetupOverCountdown;
|
import de.steamwar.fightsystem.countdown.SetupOverCountdown;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class NormalJoinListener extends BasicListener {
|
public class NormalJoinListener extends BasicListener {
|
||||||
|
|
||||||
|
public NormalJoinListener() {
|
||||||
|
super(EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -31,9 +37,4 @@ public class NormalJoinListener extends BasicListener {
|
|||||||
new SetupOverCountdown();
|
new SetupOverCountdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void stateChange(FightState state){
|
|
||||||
disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
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.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
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.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class PistonListener extends BasicListener {
|
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
|
@EventHandler
|
||||||
public void handlePistonExtend(BlockPistonExtendEvent e){
|
public void handlePistonExtend(BlockPistonExtendEvent e){
|
||||||
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(
|
||||||
@ -32,9 +37,6 @@ public class PistonListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonRetract(BlockPistonRetractEvent e){
|
public void handlePistonRetract(BlockPistonRetractEvent e){
|
||||||
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(
|
||||||
|
@ -4,6 +4,7 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
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.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -11,15 +12,20 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class PlayerChatListener extends BasicListener {
|
public class PlayerChatListener extends BasicListener {
|
||||||
|
|
||||||
|
public PlayerChatListener(){
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerChat(AsyncPlayerChatEvent event) {
|
public void handlePlayerChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
if(fightTeam != null) {
|
if(fightTeam != null) {
|
||||||
String teamName = fightTeam.getColoredName();
|
String teamName = fightTeam.getColoredName();
|
||||||
if(message.startsWith(Config.TeamChatDetection)) {
|
if(message.startsWith(Config.TeamChatDetection)) {
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,21 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class ProjectileLaunchListener extends BasicListener {
|
public class ProjectileLaunchListener extends BasicListener {
|
||||||
|
|
||||||
|
public ProjectileLaunchListener() {
|
||||||
|
super(EnumSet.of(FightState.RUNNING, FightState.ENTERN));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
if(FightSystem.getFightState() != FightState.RUNNING) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(event.getEntity().getShooter() instanceof Player){
|
if(event.getEntity().getShooter() instanceof Player){
|
||||||
Player player = (Player) event.getEntity().getShooter();
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
@ -19,4 +23,3 @@ public class ProjectileLaunchListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -4,17 +4,21 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.permissions.PermissionAttachment;
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class TestListener extends BasicListener {
|
public class TestListener extends BasicListener {
|
||||||
|
|
||||||
|
public TestListener() {
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -26,23 +30,138 @@ public class TestListener extends BasicListener {
|
|||||||
|
|
||||||
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
|
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
|
||||||
|
|
||||||
|
|
||||||
PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
|
PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
|
||||||
attachment.setPermission("fawe.permpack.basic", true);
|
attachment.setPermission("fawe.permpack.basic", true);
|
||||||
attachment.setPermission("minecraft.command.gamemode", true);
|
attachment.setPermission("minecraft.command.gamemode", true);
|
||||||
attachment.setPermission("minecraft.command.tp", true);
|
attachment.setPermission("minecraft.command.tp", true);
|
||||||
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
||||||
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
||||||
}
|
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
||||||
|
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
||||||
@EventHandler
|
attachment.setPermission("worldedit.biome.info", true);
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event){
|
attachment.setPermission("worldedit.biome.set", true);
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty())
|
attachment.setPermission("worldedit.biome.list", true);
|
||||||
FightSystem.shutdown(null);
|
attachment.setPermission("worldedit.chunkinfo", true);
|
||||||
}
|
attachment.setPermission("worldedit.listchunks", true);
|
||||||
|
attachment.setPermission("worldedit.clipboard.cut", true);
|
||||||
@Override
|
attachment.setPermission("worldedit.clipboard.paste", true);
|
||||||
void stateChange(FightState state){
|
attachment.setPermission("worldedit.schematic.formats", true);
|
||||||
disable();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java
Normale Datei
39
FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
package de.steamwar.fightsystem.states;
|
||||||
|
|
||||||
|
public enum FightState {
|
||||||
|
PRE_LEADER_SETUP(true, true, false, false), //Can be skipped
|
||||||
|
PRE_SCHEM_SETUP(true, true, false, false), //Can be skipped
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -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){}
|
||||||
|
}
|
@ -3,20 +3,23 @@ package de.steamwar.fightsystem.utils;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class FightScoreboard {
|
public class FightScoreboard {
|
||||||
|
|
||||||
private 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 Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||||
private static final Objective objective;
|
private static final Objective objective;
|
||||||
private static int index = 0;
|
private static int index = 0;
|
||||||
@ -70,7 +73,7 @@ public class FightScoreboard {
|
|||||||
if (Config.Entern)
|
if (Config.Entern)
|
||||||
objective.getScore("§7Entern: " + (FightSystem.isEntern() ? "§aja" : "§cnein")).setScore(2);
|
objective.getScore("§7Entern: " + (FightSystem.isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||||
|
|
||||||
if(FightSystem.getFightState() == FightState.RUNNING){
|
if(fullScoreboard.contains(FightSystem.getFightState())){
|
||||||
if (Config.PercentSystem){
|
if (Config.PercentSystem){
|
||||||
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1);
|
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);
|
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0);
|
||||||
|
@ -213,6 +213,6 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean disabled(){
|
private static boolean disabled(){
|
||||||
return Config.OnlyPublicSchematics;
|
return Config.OnlyPublicSchematics || Config.test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.winconditions;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
abstract class PlayerWincondition extends ListenerWincondition {
|
abstract class PlayerWincondition extends ListenerWincondition {
|
||||||
|
@ -2,7 +2,7 @@ package de.steamwar.fightsystem.winconditions;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.winconditions;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren