SteamWar/FightSystem
Archiviert
13
1

Merge branch 'lixfel' into 'master'

Fixes, Fixes, Fixes

See merge request Yaruma3341/fightsystem!9
Dieser Commit ist enthalten in:
Yaruma3341 2019-03-26 16:40:19 +01:00
Commit c76cac319e
40 geänderte Dateien mit 281 neuen und 219 gelöschten Zeilen

4
.gitignore vendored
Datei anzeigen

@ -1,3 +1 @@
.idea .idea
pom.xml
*.iml

25
fightsystem.iml Normale Datei
Datei anzeigen

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:SpigotCore:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:WorldEdit:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:FAWE:1.0" level="project" />
</component>
</module>

78
pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.yaruma</groupId>
<artifactId>FightSystem</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<url>https://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven</id>
<url>https://warking.de:81/maven/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>warking</groupId>
<artifactId>SpigotCore</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>warking</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>warking</groupId>
<artifactId>FAWE</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -3,7 +3,6 @@ Times:
SetupDuration: 0 SetupDuration: 0
PreFightDuration: 0 PreFightDuration: 0
SpectatorDuration: 0 SpectatorDuration: 0
Arena: Arena:
Schemsize: Schemsize:
x: 0 x: 0
@ -22,30 +21,25 @@ Arena:
z: 0 z: 0
underArenaBorder: 0 underArenaBorder: 0
BorderFromSchematic: 0 BorderFromSchematic: 0
Output: Output:
TeamRedColor: &c TeamRedColor: &c
TeamBlueColor: &3 TeamBlueColor: &3
TeamRedName: Team1 TeamRedName: Team1
TeamBlueName: Team2 TeamBlueName: Team2
GameName: AirWargear GameName: AirShip
TeamChatDetection: + TeamChatDetection: +
WinConditions: WinConditions:
Timeout: boolean Timeout: boolean
AllDead: boolean AllDead: boolean
CaptainDead: boolean CaptainDead: boolean
PercentSystem: boolean PercentSystem: boolean
Entern: boolean Entern: boolean
WinConditionParams: WinConditionParams:
TimeoutTime: 0 TimeoutTime: 0
EnterPhaseBegin: 0 EnterPhaseBegin: 0
PercentWin: 0 PercentWin: 0
Fight: Fight:
OnlyPublicSchematics: boolean OnlyPublicSchematics: boolean
Money: Money:
Win: 0 Win: 0
Lose: 0 Lose: 0

Datei anzeigen

@ -24,8 +24,8 @@ import java.io.File;
public class FightSystem extends JavaPlugin { public class FightSystem extends JavaPlugin {
public static String PREFIX = "[FightSystem] "; public static final String PREFIX = "§6Arena§8» ";
public static String NOPERM = PREFIX + "§4Du darfst das nicht!"; public static final String NOPERM = PREFIX + "§cDu darfst das nicht!";
private static FightSystem plugin; private static FightSystem plugin;
private FileManager fileManager; private FileManager fileManager;
@ -37,44 +37,42 @@ public class FightSystem extends JavaPlugin {
private FightState fightState; private FightState fightState;
public Location Team1SpawnLoc = null; private Location Team1SpawnLoc = null;
public Location Team2SpawnLoc = null; private Location Team2SpawnLoc = null;
public Location SpecSpawnLoc = null; private Location SpecSpawnLoc = null;
public Location Team1PasteLoc = null; private Location Team1PasteLoc = null;
public Location Team2PasteLoc = null; private Location Team2PasteLoc = null;
public int ArenaMinX; public int ArenaMinX;
public int ArenaMaxX; public int ArenaMaxX;
public int ArenaMinZ; public int ArenaMinZ;
public int ArenaMaxZ; public int ArenaMaxZ;
public int schemsizeX; private int schemsizeX;
public int schemsizeY; private int schemsizeY;
public int schemsizeZ; private int schemsizeZ;
public int team1cornerX; private int team1cornerX;
public int team1cornerY; private int team1cornerY;
public int team1cornerZ; private int team1cornerZ;
public int team2cornerX; private int team2cornerX;
public int team2cornerY; private int team2cornerY;
public int team2cornerZ; private int team2cornerZ;
public int underArenaBorder; public int underArenaBorder;
public int fightTime = 0; public int fightTime = 0;
public double damageRed = 0D;
public double getDamageBlue = 0D;
public boolean entern = false; public boolean entern = false;
public File kits = new File("plugins/" + this.getName(), "kits.data"); private final File kits = new File("plugins/" + this.getName(), "kits.data");
public FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits); private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
public void saveKitData() { private void saveKitData() {
try { getKitData.save(kits); } catch (Exception ex) { } try { getKitData.save(kits); } catch (Exception ignored) { }
} }
@ -171,14 +169,10 @@ public class FightSystem extends JavaPlugin {
int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration"); int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration");
Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline()); Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline());
countdown.startTimer(getPlugin()); countdown.startTimer(getPlugin());
System.out.println(PREFIX + "§aPlugin gestartet!");
} }
public void onDisable() { public void onDisable() {
System.out.println(PREFIX + "§cPlugin deaktiviert!");
} }
private void init() { private void init() {
@ -276,9 +270,7 @@ public class FightSystem extends JavaPlugin {
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ); WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ);
WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ); WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ);
Bukkit.broadcastMessage(" "); Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
Bukkit.broadcastMessage("§aDer Fight beginnt!");
Bukkit.broadcastMessage(" ");
} }
private void setAllPlayersGM(GameMode gm) { private void setAllPlayersGM(GameMode gm) {
@ -303,7 +295,7 @@ public class FightSystem extends JavaPlugin {
WinconditionTimeout.timeout(); WinconditionTimeout.timeout();
WinconditionEntern.entern(); WinconditionEntern.entern();
Bukkit.broadcastMessage("§aArena freigegeben!"); Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
} }
public void setSpectateState(FightTeam winFightTeam) { public void setSpectateState(FightTeam winFightTeam) {
@ -316,8 +308,7 @@ public class FightSystem extends JavaPlugin {
Bukkit.broadcastMessage(" "); Bukkit.broadcastMessage(" ");
if(winFightTeam != null) { if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getPrefix() + winFightTeam.getName() + " §ahat gewonnen!");
Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
plugin.getFightManager().teleportAllToFightSpawn(); plugin.getFightManager().teleportAllToFightSpawn();
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) { for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
@ -328,21 +319,21 @@ public class FightSystem extends JavaPlugin {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose")); CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
} }
} else { } else {
//Keine Message! Wird in FinishTimeOver gesendet! Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) { for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
} }
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) { for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
} }
} }
Countdown countdown = new Countdown(20*60, new FinishSpectateOver()); Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin()); countdown.startTimer(FightSystem.getPlugin());
} }
public int getMoneyToPay(String moneyPath) { private int getMoneyToPay(String moneyPath) {
return fileManager.getIntegerFromConfig(moneyPath); return fileManager.getIntegerFromConfig(moneyPath);
} }
@ -432,10 +423,12 @@ public class FightSystem extends JavaPlugin {
} }
public double getDamageRed() { public double getDamageRed() {
double damageRed = 0D;
return damageRed; return damageRed;
} }
public double getGetDamageBlue() { public double getGetDamageBlue() {
double getDamageBlue = 0D;
return getDamageBlue; return getDamageBlue;
} }

Datei anzeigen

@ -64,12 +64,12 @@ public class AkCommand implements CommandExecutor {
if(!Fight.getBlueTeam().hasTeamLeader()){ if(!Fight.getBlueTeam().hasTeamLeader()){
FightPlayer fightPlayer = new FightPlayer(player, false); FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer); Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName")); player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getName());
} else if(!Fight.getRedTeam().hasTeamLeader()){ } else if(!Fight.getRedTeam().hasTeamLeader()){
FightPlayer fightPlayer = new FightPlayer(player, false); FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer); Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName")); player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getName());
} else } else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!"); player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
@ -107,7 +107,7 @@ public class AkCommand implements CommandExecutor {
if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){ if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){
fightTeam.removePlayer(target); fightTeam.removePlayer(target);
player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!"); player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!");
target.sendMessage(FightSystem.PREFIX + "§4Du wurdest auf deinem Team entfernt!"); target.sendMessage(FightSystem.PREFIX + "§cDu wurdest auf deinem Team entfernt!");
} }
} }
} }

Datei anzeigen

@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
public class Fight { public class Fight {
public static FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin()); public static final FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
public static FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin()); public static final FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
public static FightTeam getPlayerTeam(Player player) { public static FightTeam getPlayerTeam(Player player) {

Datei anzeigen

@ -2,8 +2,9 @@ package me.yaruma.fightsystem.fight;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class FightCreator { class FightCreator {
@SuppressWarnings("EmptyMethod")
public static void invitePlayerToTeam(Player player) { public static void invitePlayerToTeam(Player player) {
} }

Datei anzeigen

@ -5,5 +5,5 @@ public enum FightState {
SETUP, SETUP,
PRE_RUNNING, PRE_RUNNING,
RUNNING, RUNNING,
SPECTATE; SPECTATE
} }

Datei anzeigen

@ -11,10 +11,10 @@ import java.util.ArrayList;
public class FightTeam { public class FightTeam {
private FightPlayer leader; private FightPlayer leader;
private ArrayList<FightPlayer> players; private final ArrayList<FightPlayer> players;
private FightSystem plugin; private FightSystem plugin;
private boolean ready; private boolean ready;
private ArrayList<Player> invited; private final ArrayList<Player> invited;
private String name; private String name;
private String prefix; private String prefix;
@ -115,7 +115,7 @@ public class FightTeam {
FightSystem instance = FightSystem.getPlugin(); FightSystem instance = FightSystem.getPlugin();
if(this.ready == true) { if(this.ready) {
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build()); fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!"); broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");

Datei anzeigen

@ -15,41 +15,37 @@ import java.util.List;
public class WaterRemover { public class WaterRemover {
private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>(); private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<>();
private List<Block> waterList = new ArrayList<Block>(); private List<Block> waterList = new ArrayList<>();
private BukkitTask task; private BukkitTask task;
public void start() { public void start() {
this.stop(); this.stop();
this.explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>(); this.explodedBlocks = new ArrayList<>();
this.waterList = new ArrayList<Block>(); this.waterList = new ArrayList<>();
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), new Runnable(){ this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), () -> {
try {
@Override WaterRemover.this.wateredCheck();
public void run() { WaterRemover.this.removeWater();
try { }
WaterRemover.this.wateredCheck(); catch (Exception e) {
WaterRemover.this.removeWater(); e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
} }
}, 0L, 20L); }, 0L, 20L);
} }
public void stop() { private void stop() {
if (this.task != null) { if (this.task != null) {
this.task.cancel(); this.task.cancel();
} }
} }
public void add(Location loc) { public void add(Location loc) {
this.explodedBlocks.add(new AbstractMap.SimpleEntry<Location, Integer>(loc, 0)); this.explodedBlocks.add(new AbstractMap.SimpleEntry<>(loc, 0));
} }
private void wateredCheck() { private void wateredCheck() {
for (int i = 0; i < this.explodedBlocks.size(); ++i) { for (int i = this.explodedBlocks.size() - 1; i >= 0; i--) {
if (this.explodedBlocks.get(i).getValue() >= 15) { if (this.explodedBlocks.get(i).getValue() >= 15) {
Block b = this.explodedBlocks.get(i).getKey().getBlock(); Block b = this.explodedBlocks.get(i).getKey().getBlock();
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) {
@ -63,12 +59,10 @@ public class WaterRemover {
} }
private void removeWater() { private void removeWater() {
ArrayList<Block> blocksToRemove = new ArrayList<Block>(); ArrayList<Block> blocksToRemove = new ArrayList<>();
for (int i = this.waterList.size() - 1; i > -1; --i) { for (int i = this.waterList.size() - 1; i > -1; --i) {
Block current = this.waterList.get(i); Block current = this.waterList.get(i);
for (Block removeBlock : this.getSourceBlocksOfWater(current)) { blocksToRemove.addAll(this.getSourceBlocksOfWater(current));
blocksToRemove.add(removeBlock);
}
if (current.getType() != Material.AIR) continue; if (current.getType() != Material.AIR) continue;
this.waterList.remove(i); this.waterList.remove(i);
} }
@ -80,12 +74,12 @@ public class WaterRemover {
} }
private List<Block> getSourceBlocksOfWater(Block startBlock) { private List<Block> getSourceBlocksOfWater(Block startBlock) {
ArrayList<Block> water = new ArrayList<Block>(); ArrayList<Block> water = new ArrayList<>();
this.collectBlocks(startBlock, water, new ArrayList<Block>()); this.collectBlocks(startBlock, water, new ArrayList<>());
return water; return water;
} }
public void collectBlocks(Block anchor, List<Block> collected, List<Block> visitedBlocks) { private void collectBlocks(Block anchor, List<Block> collected, List<Block> visitedBlocks) {
if (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) { if (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) {
return; return;
} }

Datei anzeigen

@ -10,7 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener { public class BlockBreakListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler
public void handleBlockBreak(BlockBreakEvent event) { public void handleBlockBreak(BlockBreakEvent event) {

Datei anzeigen

@ -11,43 +11,37 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class EntityDamageByEntityListener implements Listener { public class EntityDamageByEntityListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) { public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(instance.getFightState() != FightState.RUNNING) { if(instance.getFightState() != FightState.RUNNING) {
event.setCancelled(true); event.setCancelled(true);
} else { } else if(event.getEntity() instanceof Player) {
if(event.getEntity() instanceof Player) { Player player = ((Player) event.getEntity()).getPlayer();
Player player = ((Player) event.getEntity()).getPlayer();
if(event.getDamager() instanceof Player) { if(event.getDamager() instanceof Player) {
Player damager = ((Player) event.getDamager()).getPlayer(); Player damager = ((Player) event.getDamager()).getPlayer();
if(Fight.getPlayerTeam(player) != null) { if(Fight.getPlayerTeam(player) != null) {
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!");
}
} else
event.setCancelled(true);
return;
}
if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player)) {
return;
}
Player damager = (Player) damagerArrow.getShooter();
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) { if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true); event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden machen!"); damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!");
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
} }
} else
event.setCancelled(true);
}else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player)) {
return; return;
} }
Player damager = (Player) damagerArrow.getShooter();
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!");
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
}
} }
} }
} }

Datei anzeigen

@ -1,6 +1,7 @@
package me.yaruma.fightsystem.listener; package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightState;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -11,6 +12,7 @@ public class EntityExplodeListener implements Listener {
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) return;
for(Block block : event.blockList()) { for(Block block : event.blockList()) {
if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER) if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER)
FightSystem.getPlugin().getWaterRemover().add(block.getLocation()); FightSystem.getPlugin().getWaterRemover().add(block.getLocation());

Datei anzeigen

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerChatEvent;
public class PlayerChatListener implements Listener { public class PlayerChatListener implements Listener {
FileManager fileManager = FightSystem.getPlugin().getFileManager(); private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler @EventHandler
public void handlePlayerChat(PlayerChatEvent event) { public void handlePlayerChat(PlayerChatEvent event) {
@ -29,10 +29,10 @@ public class PlayerChatListener implements Listener {
if(message.startsWith(teamChatDetection)) { if(message.startsWith(teamChatDetection)) {
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1)); fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1));
} else { } else {
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message); Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + "§8» §7" + message);
} }
}else{ }else{
Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message); Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
} }
event.setCancelled(true); event.setCancelled(true);

Datei anzeigen

@ -3,9 +3,9 @@ package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -13,13 +13,13 @@ public class PlayerDeathListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler(priority = EventPriority.HIGH)
public void handlePlayerDeath(PlayerDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer(); Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
event.setDeathMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!"); event.setDeathMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
fightTeam.getFightPlayer(player).setOut(true);
} }

Datei anzeigen

@ -17,7 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
public class PlayerInteractListener implements Listener { public class PlayerInteractListener implements Listener {
FileManager fileManager = FightSystem.getPlugin().getFileManager(); FileManager fileManager = FightSystem.getPlugin().getFileManager();
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {

Datei anzeigen

@ -19,8 +19,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerJoinListener implements Listener { public class PlayerJoinListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager(); private final FileManager fileManager = instance.getFileManager();
@EventHandler @EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) { public void handlePlayerJoin(PlayerJoinEvent event) {

Datei anzeigen

@ -14,8 +14,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener implements Listener { public class PlayerMoveListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = FightSystem.getPlugin().getFileManager(); private final FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler @EventHandler
public void handlePlayerMove(PlayerMoveEvent event) { public void handlePlayerMove(PlayerMoveEvent event) {
@ -56,10 +56,7 @@ public class PlayerMoveListener implements Listener {
} }
}else if(fightTeam != null && !instance.isEntern()){ }else if(fightTeam != null && !instance.isEntern()){
player.teleport(from); player.teleport(from);
if (fightTeam == Fight.blueTeam) player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getPrefix() + Fight.getOpposite(fightTeam).getName() + "§c!");
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!");
else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!");
} }
} }
} }

Datei anzeigen

@ -6,7 +6,6 @@ import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam; import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline; import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -26,8 +25,8 @@ public class PlayerQuitListener implements Listener {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) { if(fightTeam.allPlayersOut() && FightSystem.getPlugin().getFightState() == FightState.SETUP) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §chaben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden..."); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getPrefix() + fightTeam.getName() + " §chaben den Kampf verlassen!");
Countdown countdown = new Countdown(30*20, new FinishNoPlayersOnline()); Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
countdown.startTimer(FightSystem.getPlugin()); countdown.startTimer(FightSystem.getPlugin());
} }
} }

Datei anzeigen

@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
public class PlayerRespawnListener implements Listener { public class PlayerRespawnListener implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) { public void handlePlayerRespawn(PlayerRespawnEvent event) {

Datei anzeigen

@ -4,16 +4,12 @@ import me.yaruma.fightsystem.FightSystem;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.FileConfigurationOptions;
public class FileManager public class FileManager
{ {
public File file; private final File file;
public FileConfiguration config; private final FileConfiguration config;
public FileManager(FightSystem instance) { public FileManager(FightSystem instance) {
this.config = instance.getConfig(); this.config = instance.getConfig();
@ -55,7 +51,7 @@ public class FileManager
return this.config; return this.config;
} }
public void save() { private void save() {
try { try {
this.config.save(this.file); this.config.save(this.file);
} }

Datei anzeigen

@ -10,8 +10,8 @@ import org.bukkit.inventory.meta.ItemMeta;
public class ItemBuilder { public class ItemBuilder {
private ItemStack item; private final ItemStack item;
private ItemMeta meta; private final ItemMeta meta;
public ItemBuilder(Material matrial) { public ItemBuilder(Material matrial) {
item = new ItemStack(matrial); item = new ItemStack(matrial);

Datei anzeigen

@ -1,7 +1,6 @@
package me.yaruma.fightsystem.utils; package me.yaruma.fightsystem.utils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player;
public class Region { public class Region {
@ -17,7 +16,7 @@ public class Region {
return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin); return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin);
} }
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){ private static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin); return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
} }
@ -25,11 +24,11 @@ public class Region {
return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ); return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ);
} }
public static boolean inRange(double value, int min, int max, int margin){ private static boolean inRange(double value, int min, int max, int margin){
return inRange(value, min-margin, max+margin); return inRange(value, min-margin, max+margin);
} }
public static boolean inRange(double value, int min, int max){ private static boolean inRange(double value, int min, int max){
return min <= value && value <= max; return min <= value && value <= max;
} }
} }

Datei anzeigen

@ -8,55 +8,51 @@ import java.util.ArrayList;
public class Countdown { public class Countdown {
private static ArrayList<Countdown> countdowns = new ArrayList<>(); private static final ArrayList<Countdown> countdowns = new ArrayList<>();
private int time; private int time;
private CountdownCallback countdownCallback; private final CountdownCallback countdownCallback;
private int taskID; private int taskID;
public Countdown(int time, CountdownCallback countdownCallback) { public Countdown(int time, CountdownCallback countdownCallback) {
this.time = time; this.time = time;
this.countdownCallback = countdownCallback; this.countdownCallback = countdownCallback;
countdowns.add(this); countdowns.add(this);
if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time;
} }
public void startTimer(FightSystem plugin) { public void startTimer(FightSystem plugin) {
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler(); BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, new Runnable() { this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, () -> {
@Override
public void run() {
switch (time) { switch (time) {
case 600: case 300: case 900: case 600: case 300: case 180: case 120:
Bukkit.broadcastMessage("§6Noch §a" + time / 60 + " §6Minuten " + countdownCallback.countdownCounting()); Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time / 60 + " §7Minuten " + countdownCallback.countdownCounting());
break; break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
Bukkit.broadcastMessage("§6Noch §a" + time + " §6Sekunden " + countdownCallback.countdownCounting()); Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time + " §7Sekunden " + countdownCallback.countdownCounting());
break; break;
case 1: case 1:
Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting()); Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §aeine §7Sekunde " + countdownCallback.countdownCounting());
break; break;
case 0: case 0:
cancelTimer(); cancelTimer();
countdownCallback.countdownFinished(); countdownCallback.countdownFinished();
break; break;
}
time--;
} }
time--;
if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time;
}, 0, 20); }, 0, 20);
} }
public void cancelTimer() { private void cancelTimer() {
try { try {
Bukkit.getScheduler().cancelTask(this.taskID); Bukkit.getScheduler().cancelTask(this.taskID);
countdowns.remove(this);
} catch (AssertionError ex) { } catch (AssertionError ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
countdowns.remove(this);
} }
public static void cancelAllTimers() { public static void cancelAllTimers() {
@ -72,7 +68,7 @@ public class Countdown {
} }
} }
public CountdownType getType() { private CountdownType getType() {
return countdownCallback.getType(); return countdownCallback.getType();
} }
} }

Datei anzeigen

@ -1,6 +1,6 @@
package me.yaruma.fightsystem.utils.countdown; package me.yaruma.fightsystem.utils.countdown;
public interface CountdownCallback { interface CountdownCallback {
String countdownCounting(); String countdownCounting();
void countdownFinished(); void countdownFinished();

Datei anzeigen

@ -7,7 +7,7 @@ public enum CountdownType {
PRE_RUNNING, PRE_RUNNING,
SETUP_OVER, SETUP_OVER,
SPECTATE_OVER, SPECTATE_OVER,
TIME_OVER; TIME_OVER
} }

Datei anzeigen

@ -11,7 +11,6 @@ public class FinishNoPlayersOnline implements CountdownCallback {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }

Datei anzeigen

@ -13,7 +13,7 @@ public class FinishNoneEntern implements CountdownCallback {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
FightSystem.getPlugin().entern = true; FightSystem.getPlugin().entern = true;
Bukkit.broadcastMessage("§aEntern ist nun erlaubt!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
} }
@Override @Override

Datei anzeigen

@ -2,7 +2,6 @@ package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager; import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
public class FinishPreRunning implements CountdownCallback { public class FinishPreRunning implements CountdownCallback {

Datei anzeigen

@ -1,5 +1,6 @@
package me.yaruma.fightsystem.utils.countdown; package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
public class FinishSetupOver implements CountdownCallback { public class FinishSetupOver implements CountdownCallback {
@ -11,7 +12,7 @@ public class FinishSetupOver implements CountdownCallback {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server..."); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cKampf wird abgebrochen!");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }

Datei anzeigen

@ -11,7 +11,6 @@ public class FinishSpectateOver implements CountdownCallback {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }

Datei anzeigen

@ -12,7 +12,7 @@ public class FinishTimeOver implements CountdownCallback {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
Bukkit.broadcastMessage("§aZeit abgelaufen! Der Kampf ist vorbei..."); Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
FightSystem.getPlugin().setSpectateState(null); FightSystem.getPlugin().setSpectateState(null);
} }

Datei anzeigen

@ -13,33 +13,31 @@ import org.bukkit.scoreboard.ScoreboardManager;
public class Scoreboard { public class Scoreboard {
private ScoreboardManager scoreboardManager; private final org.bukkit.scoreboard.Scoreboard scoreboard;
private org.bukkit.scoreboard.Scoreboard scoreboard; private final Objective objective;
private Objective objective;
private int taskID;
public Scoreboard(FightSystem instance) { public Scoreboard(FightSystem instance) {
this.scoreboardManager = Bukkit.getScoreboardManager(); ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
this.scoreboard = this.scoreboardManager.getNewScoreboard(); this.scoreboard = scoreboardManager.getNewScoreboard();
this.objective = scoreboard.registerNewObjective("AAA", "BBB"); this.objective = scoreboard.registerNewObjective("AAA", "BBB");
} }
public void setAutoScoreboard(int delay, Player player) { public void setAutoScoreboard(int delay, Player player) {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() { int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
private int index = 0; private int index = 0;
@Override @Override
public void run() { public void run() {
FightTeam fightTeam = getIndexDisplay(index); FightTeam fightTeam = getIndexDisplay(index);
if(fightTeam != null) { if (fightTeam != null) {
objective.unregister(); objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB"); scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Info " + fightTeam.getPrefix() + fightTeam.getName()); objective.setDisplayName(fightTeam.getPrefix() + fightTeam.getName());
for(FightPlayer fp : fightTeam.getPlayers()) { for (FightPlayer fp : fightTeam.getPlayers()) {
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
} }
@ -51,11 +49,20 @@ public class Scoreboard {
scoreboard.registerNewObjective("AAA", "BBB"); scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Fight Info"); objective.setDisplayName("§6Kampf");
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(3); if (Methods.isEnabled("WinConditions.Timeout")) {
if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2); int fightTime = FightSystem.getPlugin().getFightTime();
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1); if (fightTime >= 60)
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0); objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
else
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
}
if (Methods.isEnabled("WinConditions.Entern"))
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
if (Methods.isEnabled("WinConditions.PercentSystem"))
objective.getScore("§eSchaden ROT: §c" + FightSystem.getPlugin().getDamageRed() + "%").setScore(1);
if (Methods.isEnabled("WinConditions.PercentSystem"))
objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(0);
index = 0; index = 0;
} }
player.setScoreboard(scoreboard); player.setScoreboard(scoreboard);

Datei anzeigen

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead implements Listener { public class WinconditionAllDead implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
@EventHandler @EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
@ -20,12 +20,10 @@ public class WinconditionAllDead implements Listener {
Player player = event.getEntity().getPlayer(); Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) { if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
instance.setSpectateState(oppositeFightTeam); instance.setSpectateState(Fight.getOpposite(fightTeam));
return;
} }
} }
@ -35,12 +33,10 @@ public class WinconditionAllDead implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) { if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben oder haben den Kampf verlassen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
instance.setSpectateState(oppositeFightTeam); instance.setSpectateState(Fight.getOpposite(fightTeam));
return;
} }
} }

Datei anzeigen

@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead implements Listener { public class WinconditionCaptainDead implements Listener {
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager(); FileManager fileManager = instance.getFileManager();
@EventHandler @EventHandler
@ -22,13 +22,10 @@ public class WinconditionCaptainDead implements Listener {
Player player = event.getEntity().getPlayer(); Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue";
if(fightTeam.isPlayerLeader(player)) { if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von Team " + fileManager.getStringFromConfig("Output.Team" + team + "Color") + fileManager.getStringFromConfig("Output.Team" + team + "Name") + " §cist gestorben!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
instance.setSpectateState(oppositeFightTeam); instance.setSpectateState(Fight.getOpposite(fightTeam));
return; return;
} }
} }
@ -39,12 +36,10 @@ public class WinconditionCaptainDead implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue";
if(fightTeam.isPlayerLeader(player)) { if(fightTeam.isPlayerLeader(player)) {
instance.setSpectateState(oppositeFightTeam); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
instance.setSpectateState(Fight.getOpposite(fightTeam));
return; return;
} }
} }

Datei anzeigen

@ -3,18 +3,18 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager; import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver; import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
public class WinconditionEntern { public class WinconditionEntern {
private static FightSystem instance = FightSystem.getPlugin(); private static final FightSystem instance = FightSystem.getPlugin();
private static FileManager fileManager = instance.getFileManager(); private static final FileManager fileManager = instance.getFileManager();
public static void entern() { public static void entern() {
if(!Methods.isEnabled("WinConditions.Entern")) return; if(!Methods.isEnabled("WinConditions.Entern")) return;
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin"); int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver()); Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishNoneEntern());
countdownTimeOver.startTimer(instance); countdownTimeOver.startTimer(instance);
} }

Datei anzeigen

@ -12,13 +12,13 @@ import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener { public class WinconditionPercentSystem implements Listener {
public static int team1DestroyedBlocks; private static int team1DestroyedBlocks;
public static int team2DestroyedBlocks; private static int team2DestroyedBlocks;
FightSystem instance = FightSystem.getPlugin(); private final FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager(); private final FileManager fileManager = instance.getFileManager();
private static int schematicSize = private static final int schematicSize =
Math.abs( Math.abs(
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") * FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") * FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *

Datei anzeigen

@ -7,8 +7,8 @@ import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
public class WinconditionTimeout { public class WinconditionTimeout {
private static FightSystem instance = FightSystem.getPlugin(); private static final FightSystem instance = FightSystem.getPlugin();
private static FileManager fileManager = instance.getFileManager(); private static final FileManager fileManager = instance.getFileManager();
public static void timeout() { public static void timeout() {
if(!Methods.isEnabled("WinConditions.Timeout")) return; if(!Methods.isEnabled("WinConditions.Timeout")) return;