SteamWar/FightSystem
Archiviert
13
1

Not stable version

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-23 11:39:53 +01:00
Ursprung 649c1c36c7
Commit 9fa918d04e
8 geänderte Dateien mit 70 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
Times:
NoPlayersOnlineDuration: 0
SetupDuration: 0
PreFightDuration: 0
SpectatorDuration: 0

Datei anzeigen

@ -7,6 +7,7 @@ import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
@ -63,6 +64,9 @@ public class FightSystem extends JavaPlugin {
public double getDamageBlue = 0D;
public boolean entern = false;
public void onEnable() {
plugin = this;
@ -143,8 +147,8 @@ public class FightSystem extends JavaPlugin {
init();
fightState = FightState.SETUP;
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration");
Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline());
countdown.startTimer(getPlugin());
System.out.println(PREFIX + "§aPlugin gestartet!");
@ -156,7 +160,7 @@ public class FightSystem extends JavaPlugin {
}
public void init() {
private void init() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), plugin);
pm.registerEvents(new PlayerQuitListener(), plugin);
@ -176,7 +180,7 @@ public class FightSystem extends JavaPlugin {
getCommand("ak").setExecutor(new AkCommand());
}
public void loadConfig() {
private void loadConfig() {
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
saveDefaultConfig();
System.out.println(PREFIX + "config.yml erstellt und geladen!");
@ -354,4 +358,8 @@ public class FightSystem extends JavaPlugin {
public double getGetDamageBlue() {
return getDamageBlue;
}
public boolean isEntern() {
return entern;
}
}

Datei anzeigen

@ -1,11 +1,12 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.entity.Player;
public class Fight {
public static FightTeam redTeam;
public static FightTeam blueTeam;
public static FightTeam redTeam = new FightTeam(null, FightSystem.getPlugin());
public static FightTeam blueTeam = new FightTeam(null, FightSystem.getPlugin());
public static FightTeam getPlayerTeam(Player player) {

Datei anzeigen

@ -54,6 +54,8 @@ public class FightTeam {
}
public boolean isPlayerInTeam(Player player) {
if(this.leader.getPlayer() == null) return false;
if(this.leader.getPlayer().equals(player)) {
return true;
}

Datei anzeigen

@ -5,6 +5,9 @@ import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
import me.yaruma.fightsystem.utils.inventory.SetupItems;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -15,6 +18,9 @@ import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerJoinListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager();
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@ -24,16 +30,24 @@ public class PlayerJoinListener implements Listener {
player.getInventory().clear();
if (Fight.getPlayerTeam(player) == null) {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(FightSystem.getPlugin().getSpecSpawnLoc());
if(!Fight.getRedTeam().hasTeamLeader()) {
Fight.getRedTeam().setLeader(new FightPlayer(player, false));
return;
} else if(!Fight.getBlueTeam().hasTeamLeader()) {
Fight.getBlueTeam().setLeader(new FightPlayer(player, false));
return;
} else {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(instance.getSpecSpawnLoc());
return;
}
}
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if (fightTeam == Fight.blueTeam) {
if (FightSystem.getPlugin().getFightState() == FightState.SETUP) {
player.teleport(FightSystem.getPlugin().getFightManager().getBlueTeleportLocation());
if (instance.getFightState() == FightState.SETUP) {
player.teleport(instance.getFightManager().getBlueTeleportLocation());
player.setGameMode(GameMode.SURVIVAL);
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
@ -47,8 +61,8 @@ public class PlayerJoinListener implements Listener {
}
if (fightTeam == Fight.redTeam) {
if (FightSystem.getPlugin().getFightState() == FightState.SETUP) {
player.teleport(FightSystem.getPlugin().getFightManager().getRedTeleportLocation());
if (instance.getFightState() == FightState.SETUP) {
player.teleport(instance.getFightManager().getRedTeleportLocation());
player.setGameMode(GameMode.SURVIVAL);
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
@ -57,11 +71,17 @@ public class PlayerJoinListener implements Listener {
}
} else {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(FightSystem.getPlugin().getTeam1SpawnLoc());
player.teleport(instance.getTeam1SpawnLoc());
}
}
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);
if(Fight.getRedTeam().getLeader().getPlayer() != null && Fight.getBlueTeam().getLeader().getPlayer() != null) {
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
countdown.startTimer(instance);
}
instance.getScoreboard().setAutoScoreboard(20*10, player);
}

Datei anzeigen

@ -22,9 +22,7 @@ public class PlayerMoveListener implements Listener {
Location to = event.getTo();
Location from = event.getFrom();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null) {
if(Fight.getPlayerTeam(player) == null) {
if(Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic")) || Region.isInRegion(to, instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!");
@ -32,17 +30,20 @@ public class PlayerMoveListener implements Listener {
return;
}
if(!instance.isEntern()) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
if(fightTeam == Fight.blueTeam) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName") + " §c!");
return;
}
} else if(Region.isInRegion(to, instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
if(fightTeam == Fight.redTeam) {
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu Team " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName") + " §c!");
return;
}
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit;
public class FinishNoneEntern implements CountdownCallback {
@ -11,6 +12,7 @@ public class FinishNoneEntern implements CountdownCallback {
@Override
public void countdownFinished() {
FightSystem.getPlugin().entern = true;
Bukkit.broadcastMessage("§aEntern ist nun erlaubt!");
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package me.yaruma.fightsystem.utils.scoreboard;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.winconditions.Methods;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
@ -55,19 +56,12 @@ public class Scoreboard {
String gameName = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.GameName");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Fight Info");
if(gameName == "AirWargear" || gameName == "WarShip") {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
objective.getScore("§7Entern: " + (FightSystem.getPlugin().getFileManager().getBooleanFromConfig("Fight.Entern") ? "§aja" : "§cnein")).setScore(1);
objective.getScore("§7Spieltyp: §e" + gameName).setScore(2);
objective.getScore("§eSchaden ROT: " + FightSystem.getPlugin().getDamageRed()).setScore(3);
objective.getScore("§eSchaden BLAU: " + FightSystem.getPlugin().getGetDamageBlue()).setScore(4);
} else {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
objective.getScore("§7Spieltyp: §e" + gameName).setScore(2);
}
if(Methods.isEnabled("Fight.Entern")) objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(1);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden ROT: " + FightSystem.getPlugin().getDamageRed()).setScore(2);
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: " + FightSystem.getPlugin().getGetDamageBlue()).setScore(3);
}
player.setScoreboard(scoreboard);
index++;