SteamWar/FightSystem
Archiviert
13
1

FightSystem hinzugefügt

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-14 18:37:38 +01:00
Ursprung 9474d68fb9
Commit 946ddfc69a
32 geänderte Dateien mit 1599 neuen und 0 gelöschten Zeilen

42
config.yml Normale Datei
Datei anzeigen

@ -0,0 +1,42 @@
Times:
SetupDuration: 0
PreFightDuration: 0
FightDuration: 0
EnterPhaseBegin: 0
SpectatorDuration: 0
Arena:
WorldName:
Schemsize:
x: 0
y: 0
z: 0
Team1corner:
x: 0
y: 0
z: 0
Team1toTeam2distance:
x: 0
y: 0
z: 0
Schem2Border:
x: 0
z: 0
underArenaBorder: 0
BorderFromWarGear: 0
Output:
TeamRedColor: &c
TeamBlueColor: &3
TeamRedName: Team1
TeamBlueName: Team2
GameName: AirWargear
TeamChatDetection: +
ActiveWinConditions:
- Timeout
- AllDead
- CaptainDead
WinConditionParams:
TimeoutTime: 0

8
plugin.yml Normale Datei
Datei anzeigen

@ -0,0 +1,8 @@
name: FightSystem
version: 1.0
author: Yaruma3341
main: me.yaruma.fightsystem.FightSystem
depend: [WorldEdit, FastAsyncWorldEdit]
commands:
ak:

Datei anzeigen

@ -0,0 +1,251 @@
package me.yaruma.fightsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.FightManager;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.Coordinates;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public class FightSystem extends JavaPlugin {
public static String PREFIX = "[FightSystem] ";
public static String NOPERM = PREFIX + "§4Du darfst das nicht!";
private static FightSystem plugin;
private FileManager fileManager;
private FightManager fightManager;
private Coordinates coordinates;
private FightState fightState;
public Location Team1SpawnLoc = null;
public Location Team2SpawnLoc = null;
public Location Team1PasteLoc = null;
public Location Team2PasteLoc = null;
public int ArenaMinX;
public int ArenaMaxX;
public int ArenaMinZ;
public int ArenaMaxZ;
public int schemsizeX;
public int schemsizeY;
public int schemsizeZ;
public int team1cornerX;
public int team1cornerY;
public int team1cornerZ;
public void onEnable() {
plugin = this;
this.fileManager = new FileManager(plugin);
this.fightManager = new FightManager();
this.coordinates = new Coordinates();
int schemsizeX = this.schemsizeX = fileManager.getIntegerFromConfig("Arena.Schemsize.x");
int schemsizeY = this.schemsizeZ = fileManager.getIntegerFromConfig("Arena.Schemsize.y");
int schemsizeZ = this.schemsizeY = fileManager.getIntegerFromConfig("Arena.Schemsize.z");
int team1cornerX = this.team1cornerX = fileManager.getIntegerFromConfig("Arena.Team1corner.x");
int team1cornerY = this.team1cornerY = fileManager.getIntegerFromConfig("Arena.Team1corner.y");
int team1cornerZ = this.team1cornerZ = fileManager.getIntegerFromConfig("Arena.Team1corner.z");
int team1toTeam2distanceX = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.x");
int team1toTeam2distanceY = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.y");
int team1toTeam2distanceZ = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.z");
int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x");
int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z");
coordinates.computePositions(schemsizeX, schemsizeY, schemsizeZ, team1cornerX, team1cornerY, team1cornerZ, team1toTeam2distanceX, team1toTeam2distanceY, team1toTeam2distanceZ, schem2BorderX, schem2BorderZ);
loadConfig();
init();
fightState = FightState.SETUP;
int setupDuration = fileManager.getIntegerFromConfig("Times.SetupDuration");
Countdown countdown = new Countdown(setupDuration, new FinishSetupOver());
countdown.startTimer(getPlugin());
System.out.println(PREFIX + "§aPlugin gestartet!");
}
public void onDisable() {
System.out.println(PREFIX + "§cPlugin deaktiviert!");
}
public void init() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(), plugin);
pm.registerEvents(new PlayerQuitListener(), plugin);
pm.registerEvents(new PlayerDeathListener(), plugin);
pm.registerEvents(new PlayerInteractListener(), plugin);
pm.registerEvents(new PlayerChatListener(), plugin);
pm.registerEvents(new BlockPlaceListener(), plugin);
pm.registerEvents(new BlockBreakListener(), plugin);
getCommand("ak").setExecutor(new AkCommand());
}
public void loadConfig() {
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
saveDefaultConfig();
System.out.println(PREFIX + "config.yml erstellt und geladen!");
Bukkit.shutdown();
}
}
public static FightSystem getPlugin() {
return plugin;
}
public FightState getCurrentFightState() {
return fightState;
}
public FileManager getFileManager() {
return this.fileManager;
}
public FightManager getFightManager() {
return this.fightManager;
}
public FightState getFightState() {
return fightState;
}
public void setSetupState() {
if(this.fightState == null) {
this.fightState = FightState.SETUP;
}
}
public void setPreRunningState() {
if(this.fightState == FightState.SETUP) {
this.fightState = FightState.PRE_RUNNING;
}
}
public void setRunningState() {
if(this.fightState == FightState.PRE_RUNNING) {
this.fightState = FightState.RUNNING;
}
}
public void setSpectateState() {
if(this.fightState == FightState.RUNNING) {
this.fightState = FightState.SPECTATE;
}
}
public static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
}
public Location getTeam1SpawnLoc() {
return Team1SpawnLoc;
}
public Location getTeam2SpawnLoc() {
return Team2SpawnLoc;
}
public Location getTeam1PasteLoc() {
return Team1PasteLoc;
}
public Location getTeam2PasteLoc() {
return Team2PasteLoc;
}
public int getArenaMinX() {
return ArenaMinX;
}
public int getArenaMaxX() {
return ArenaMaxX;
}
public int getArenaMinZ() {
return ArenaMinZ;
}
public int getArenaMaxZ() {
return ArenaMaxZ;
}
public int getSchemsizeX() {
return schemsizeX;
}
public int getSchemsizeY() {
return schemsizeY;
}
public int getSchemsizeZ() {
return schemsizeZ;
}
public int getTeam1cornerX() {
return team1cornerX;
}
public int getTeam1cornerY() {
return team1cornerY;
}
public int getTeam1cornerZ() {
return team1cornerZ;
}
public void setTeam1SpawnLoc(Location team1SpawnLoc) {
Team1SpawnLoc = team1SpawnLoc;
}
public void setTeam2SpawnLoc(Location team2SpawnLoc) {
Team2SpawnLoc = team2SpawnLoc;
}
public void setTeam1PasteLoc(Location team1PasteLoc) {
Team1PasteLoc = team1PasteLoc;
}
public void setTeam2PasteLoc(Location team2PasteLoc) {
Team2PasteLoc = team2PasteLoc;
}
public void setArenaMinX(int arenaMinX) {
ArenaMinX = arenaMinX;
}
public void setArenaMaxX(int arenaMaxX) {
ArenaMaxX = arenaMaxX;
}
public void setArenaMinZ(int arenaMinZ) {
ArenaMinZ = arenaMinZ;
}
public void setArenaMaxZ(int arenaMaxZ) {
ArenaMaxZ = arenaMaxZ;
}
}

Datei anzeigen

@ -0,0 +1,159 @@
package me.yaruma.fightsystem.commands;
import me.yaruma.fightsystem.FightSystem;
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 org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AkCommand implements CommandExecutor {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 0) {
sendHelp(player);
}
if(args.length == 1) {
if(args[0].equalsIgnoreCase("help")) {
sendHelp(player);
return false;
}
if(args[0].equalsIgnoreCase("ready")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
if(!fightTeam.isReady()) {
fightTeam.setReady(true);
fightTeam.broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
} else {
fightTeam.setReady(false);
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
}
return false;
}
if(args[0].equalsIgnoreCase("accept")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
if(Fight.getRedTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().addMember(player);
player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!");
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten");
}
if(Fight.getBlueTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().addMember(player);
player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!");
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten");
}
}
return false;
}
if(args[0].equalsIgnoreCase("decline")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
if(Fight.getRedTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().getInvited().remove(player);
player.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von §6" + leader.getPlayer().getName() + " §aabgelehnt!");
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat deine Einladung abgelehnt!");
}
if(Fight.getBlueTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getBlueTeam().getLeader();
Fight.getBlueTeam().getInvited().remove(player);
player.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von §6" + leader.getPlayer().getName() + " §aabgelehnt!");
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat deine Einladung abgelehnt!");
}
}
return false;
}
if(args[0].equalsIgnoreCase("leader")) {
if(!Fight.getBlueTeam().hasTeamLeader()) {
FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName"));
return false;
} else if(!Fight.getRedTeam().hasTeamLeader()) {
FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName"));
return false;
} else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
return false;
}
}
if(args.length == 2) {
if(args[0].equalsIgnoreCase("invite")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLeader()) {
Player target = Bukkit.getPlayer(args[1]);
if(target != null) {
if(!(Fight.getOpposite(fightTeam).getInvited().contains(player) && fightTeam.getInvited().contains(target))) {
fightTeam.getInvited().add(target);
player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler ist nicht online!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!");
}
}
return false;
}
if(args[0].equalsIgnoreCase("remove")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
Player target = Bukkit.getPlayer(args[1]);
if(target != null) {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLeader()) {
if(fightTeam.isPlayerInTeam(target)) {
fightTeam.removePlayer(target);
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!");
}
}
}
}
}
return false;
}
}
}
return false;
}
private void sendHelp(Player player) {
player.sendMessage("-----[ Hilfe ]-----");
}
}

Datei anzeigen

@ -0,0 +1,43 @@
package me.yaruma.fightsystem.fight;
import org.bukkit.entity.Player;
public class Fight {
public static FightTeam redTeam;
public static FightTeam blueTeam;
public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player)) {
return redTeam;
}
if(blueTeam.isPlayerInTeam(player)) {
return blueTeam;
}
return null;
}
public static FightTeam getOpposite(FightTeam fightTeam) {
if(fightTeam == redTeam) {
return blueTeam;
}
if(fightTeam == blueTeam) {
return redTeam;
}
return null;
}
public void broadcast(String message) {
blueTeam.broadcast(message);
redTeam.broadcast(message);
}
public static FightTeam getRedTeam() {
return redTeam;
}
public static FightTeam getBlueTeam() {
return blueTeam;
}
}

Datei anzeigen

@ -0,0 +1,12 @@
package me.yaruma.fightsystem.fight;
import org.bukkit.entity.Player;
public class FightCreator {
public static void invitePlayerToTeam(Player player) {
}
}

Datei anzeigen

@ -0,0 +1,40 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class FightManager {
public FileManager fileManager = FightSystem.getPlugin().getFileManager();
public void teleportAllToFightSpawn() {
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
fightPlayer.getPlayer().teleport(getBlueTeleportLocation());
}
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
fightPlayer.getPlayer().teleport(getRedTeleportLocation());
}
}
public Location getBlueTeleportLocation() {
return FightSystem.getPlugin().getTeam1SpawnLoc();
}
public Location getRedTeleportLocation() {
return FightSystem.getPlugin().getTeam2SpawnLoc();
}
public Location getBlueTeamPasteLocation() {
return null;
}
public Location getRedTeamPasteLocation() {
return null;
}
}

Datei anzeigen

@ -0,0 +1,49 @@
package me.yaruma.fightsystem.fight;
import org.bukkit.entity.Player;
public class FightPlayer {
private final Player player;
private boolean isOut;
public boolean equals(Object obj) {
if (!(obj instanceof Player)) {
return false;
}
Player comp = (Player)obj;
return this.player.getUniqueId().equals(comp.getUniqueId());
}
public void sendMessage(String message) {
if (this.player.isOnline()) {
this.player.sendMessage(message);
}
}
public FightPlayer(Player player, boolean isOut) {
this.player = player;
this.isOut = isOut;
}
public void setOut(boolean isOut) {
this.isOut = isOut;
}
public Player getPlayer() {
return this.player;
}
public boolean isOut() {
return this.isOut;
}
public boolean isLeader() {
if(Fight.getPlayerTeam(player).getLeader().getPlayer() == player) {
return true;
} else
return false;
}
}

Datei anzeigen

@ -0,0 +1,9 @@
package me.yaruma.fightsystem.fight;
public enum FightState {
SETUP,
PRE_RUNNING,
RUNNING,
SPECTATE;
}

Datei anzeigen

@ -0,0 +1,140 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.entity.Player;
import java.util.ArrayList;
public class FightTeam {
private FightPlayer leader;
private ArrayList<FightPlayer> players;
private FightSystem plugin;
private boolean ready;
private ArrayList<Player> invited;
public FightTeam(Player leader, FightSystem plugin) {
this.plugin = plugin;
this.leader = new FightPlayer(leader, false);
this.players = new ArrayList<>();
this.invited = new ArrayList<>();
}
public FightPlayer getFightPlayer(Player player) {
if(this.leader.getPlayer().equals(player)) {
return this.leader;
}
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return fightPlayer;
}
return null;
}
public void setPlayerOut(Player player) {
this.getFightPlayer(player).setOut(true);
}
public boolean allPlayersOut() {
boolean allout = true;
if(!this.leader.isOut()) {
allout = false;
}
for(FightPlayer fightPlayer : this.players) {
if(fightPlayer.isOut()) continue;
allout = false;
}
return allout;
}
public boolean isPlayerInTeam(Player player) {
if(this.leader.getPlayer().equals(player)) {
return true;
}
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return true;
}
return false;
}
public boolean isPlayerLeader(Player player) {
if(this.leader.getPlayer().equals(player)) {
return true;
}
return false;
}
public boolean isPlayerMember(Player player) {
for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.getPlayer().equals(player)) continue;
return true;
}
return false;
}
public void broadcast(String message) {
this.leader.sendMessage(message);
for(FightPlayer fightPlayer : this.players) {
fightPlayer.sendMessage(message);
}
}
public void addMember(Player player) {
FightPlayer fightPlayer = new FightPlayer(player, false);
this.players.add(fightPlayer);
this.invited.remove(player);
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
this.players.remove(fightPlayer);
}
public boolean hasTeamLeader() {
if(this.leader != null) {
return true;
} else
return false;
}
public FightPlayer getLeader() {
return leader;
}
public void setLeader(FightPlayer leader) {
this.leader = leader;
}
public ArrayList<FightPlayer> getPlayers() {
return players;
}
public void setPlayers(ArrayList<FightPlayer> players) {
this.players = players;
}
public FightSystem getPlugin() {
return plugin;
}
public void setPlugin(FightSystem plugin) {
this.plugin = plugin;
}
public boolean isReady() {
return ready;
}
public void setReady(boolean ready) {
this.ready = ready;
}
public ArrayList<Player> getInvited() {
return invited;
}
public void setInvited(ArrayList<Player> invited) {
this.invited = invited;
}
}

Datei anzeigen

@ -0,0 +1,32 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener {
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) {
event.setCancelled(true);
return;
}
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getPlugin().getFightState() == FightState.RUNNING || FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
return;
}
}
}

Datei anzeigen

@ -0,0 +1,32 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class BlockPlaceListener implements Listener {
@EventHandler
public void handleBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) {
event.setCancelled(true);
return;
}
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getPlugin().getFightState() == FightState.RUNNING || FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
return;
}
}
}

Datei anzeigen

@ -0,0 +1,46 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
public class PlayerChatListener implements Listener {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@EventHandler
public void handlePlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String teamChatDetection = fileManager.getStringFromConfig("Output.TeamChatDetection");
if(message.startsWith(teamChatDetection)) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
event.setCancelled(true);
fightTeam.broadcast("§5" + player.getName() + "§e--> §2" + message);
}
} else {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == Fight.redTeam) {
String prefixColorCode = fileManager.getStringFromConfig("Output.TeamRedColor");
String teamName = fileManager.getStringFromConfig("Output.TeamRedName");
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8>> " + message);
}
if(fightTeam == Fight.blueTeam) {
String prefixColorCode = fileManager.getStringFromConfig("Output.TeamBlueColor");
String teamName = fileManager.getStringFromConfig("Output.TeamBlueName");
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8>> " + message);
}
}
}
}

Datei anzeigen

@ -0,0 +1,32 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class PlayerDeathListener implements Listener {
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
if(fightTeam.allPlayersOut()) {
FightSystem.getPlugin().setSpectateState();
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
Bukkit.broadcastMessage(" ");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDas Team von §6" + oppositeFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
FightSystem.getPlugin().getFightManager().teleportAllToFightSpawn();
}
}
}

Datei anzeigen

@ -0,0 +1,86 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
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.ItemBuilder;
import me.yaruma.fightsystem.utils.WorldEdit;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishPreRunning;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.meta.ItemMeta;
public class PlayerInteractListener implements Listener {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Material material = event.getItem().getType();
ItemMeta itemMeta = event.getItem().getItemMeta();
String displayName = itemMeta.getDisplayName();
if(instance.getFightState() == FightState.SETUP) {
if(Fight.getPlayerTeam(player) == null) return;
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
if(fightPlayer.isLeader()) {
if(material == null) return;
if(material == Material.INK_SACK) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
switch (displayName) {
case "§cNicht bereit":
fightTeam.setReady(true);
fightPlayer.getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
fightTeam.broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
if(Fight.getOpposite(fightTeam).isReady()) {
FightSystem.getPlugin().setPreRunningState();
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
Countdown countdown = new Countdown(time, new FinishPreRunning());
countdown.startTimer(FightSystem.getPlugin());
for(FightPlayer allFightPlayers : fightTeam.getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
for(FightPlayer allFightPlayers : Fight.getOpposite(fightTeam).getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
}
FightSystem.getPlugin().getFightManager().teleportAllToFightSpawn();
WorldEdit.replace(player, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeY(), instance.getSchemsizeZ());
}
break;
case "§aBereit":
fightTeam.setReady(false);
fightPlayer.getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
break;
case "§4Abbrechen":
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team von §a" + fightTeam.getLeader().getPlayer().getName() + " §6hat den Kampf abgebrochen! \n Server stoppt in 30 Sekunden...");
Countdown countdown = new Countdown(20*30, new FinishNoPlayersOnline());
countdown.startTimer(instance);
break;
default:
event.setCancelled(true);
break;
}
}
}
}
}
}

Datei anzeigen

@ -0,0 +1,62 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
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.utils.inventory.SetupItems;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerJoinListener implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Fight.getPlayerTeam(player) == null) {
player.setGameMode(GameMode.SPECTATOR);
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());
player.setGameMode(GameMode.SURVIVAL);
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
fightPlayer.setOut(false);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf wieder beigetreten!");
}
} else
player.setGameMode(GameMode.SPECTATOR);
}
if (fightTeam == Fight.redTeam) {
if (FightSystem.getPlugin().getFightState() == FightState.SETUP) {
player.teleport(FightSystem.getPlugin().getFightManager().getRedTeleportLocation());
player.setGameMode(GameMode.SURVIVAL);
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
if(fightPlayer.isLeader()) SetupItems.giveSetupItems(player);
if(fightPlayer.isOut()) {
fightPlayer.setOut(false);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf wieder beigetreten!");
}
} else
player.setGameMode(GameMode.SPECTATOR);
}
}
}

Datei anzeigen

@ -0,0 +1,32 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Region;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
if(!Region.isInRegion(to, instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getSchemsizeX(), instance.getSchemsizeY(), instance.getSchemsizeZ())) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == Fight.redTeam) {
player.teleport(from);
}
}
}
}

Datei anzeigen

@ -0,0 +1,43 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitListener implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Fight verlassen!");
if(fightTeam.allPlayersOut()) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden...");
Countdown countdown = new Countdown(30*20, new FinishNoPlayersOnline());
countdown.startTimer(FightSystem.getPlugin());
return;
} else {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §60 Sekunden Zeit zum Begutachten!");
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
}
}
}
}

Datei anzeigen

@ -0,0 +1,77 @@
package me.yaruma.fightsystem.manager;
import me.yaruma.fightsystem.FightSystem;
import java.io.File;
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.FileConfigurationOptions;
public class FileManager
{
public File file;
public FileConfiguration config;
public FileManager(FightSystem instance) {
this.config = instance.getConfig();
this.config.options().copyDefaults(true);
this.file = new File(instance.getDataFolder(), "config.yml");
instance.saveConfig();
}
public void reloadFiles(FightSystem instance) {
instance.reloadConfig();
}
public void addNewPath(String path, String data) {
if ((this.config.contains(path)) || (this.config.contains(data))) {
return;
}
this.config.set(path, data);
save();
}
public String getStringFromConfig(String path) {
return this.config.getString(path).replaceAll("&", "§");
}
public int getIntegerFromConfig(String path) {
return this.config.getInt(path);
}
public boolean getBooleanFromConfig(String path) {
return this.config.getBoolean(path);
}
public File getFile() {
return this.file;
}
public FileConfiguration getConfig() {
return this.config;
}
public void save() {
try {
this.config.save(this.file);
}
catch (IOException e) {
e.printStackTrace();
}
}
public Location getLocationFormConfig(String path) {
World world = Bukkit.getWorld(getStringFromConfig(path + ".world"));
int x = getIntegerFromConfig(path + ".x");
int y = getIntegerFromConfig(path + ".y");
int z = getIntegerFromConfig(path + ".z");
Location location = new Location(world, x, y, z);
return location;
}
}

Datei anzeigen

@ -0,0 +1,85 @@
package me.yaruma.fightsystem.utils;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
public class Coordinates {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
public void computePositions(
int SchemsizeX, int SchemsizeY, int SchemsizeZ,
int Team1cornerX, int Team1cornerY, int Team1cornerZ,
int Team1toTeam2distanceX, int Team1toTeam2distanceY, int Team1toTeam2distanceZ,
int Schem2BorderX, int Schem2BorderZ){
if(SchemsizeX < 0){
SchemsizeX = -SchemsizeX;
Team1cornerX = -Team1cornerX;
}
if(SchemsizeY < 0){
SchemsizeY = -SchemsizeY;
Team1cornerY = -Team1cornerY;
}
if(SchemsizeZ < 0){
SchemsizeZ = -SchemsizeZ;
Team1cornerZ = -Team1cornerZ;
}
if(Team1toTeam2distanceX < 0){
Team1cornerX += Team1toTeam2distanceX;
Team1toTeam2distanceX = -Team1toTeam2distanceX;
}
if(Team1toTeam2distanceY < 0){
Team1cornerY += Team1toTeam2distanceY;
Team1toTeam2distanceY = -Team1toTeam2distanceY;
}
if(Team1toTeam2distanceZ < 0){
Team1cornerZ += Team1toTeam2distanceZ;
Team1toTeam2distanceZ = -Team1toTeam2distanceZ;
}
//Team1corner hat nun kleinste X- Y- und Z-Koordinate
//Schemsize und Team1toTeam2distance sind nun ausschließlich positiv
int Team1centerX = Team1cornerX + SchemsizeX/2;
int Team1centerY = Team1cornerY;
int Team1centerZ = Team1cornerZ + SchemsizeZ/2;
int Team2centerX = Team1centerX + Team1toTeam2distanceX;
int Team2centerY = Team1centerY + Team1toTeam2distanceY;
int Team2centerZ = Team1centerZ + Team1toTeam2distanceZ;
World world = Bukkit.getWorld(fileManager.getStringFromConfig("Arena.WorldName"));
Location Team1SpawnLoc = new Location(world, Team1centerX, Team1centerY + SchemsizeY, Team1centerZ);
Location Team2SpawnLoc = new Location(world, Team1centerX, Team1centerY + SchemsizeY, Team1centerZ);
Location Team1PasteLoc = new Location(world, Team1centerX, Team1centerY, Team1centerZ);
Location Team2PasteLoc = new Location(world, Team2centerX, Team2centerY, Team2centerZ);
int ArenaMinX = Team1cornerX - Schem2BorderX;
int ArenaMaxX = Team1cornerX + Team1toTeam2distanceX + Schem2BorderX;
int ArenaMinZ = Team1cornerZ - Schem2BorderZ;
int ArenaMaxZ = Team1cornerZ + Team1toTeam2distanceZ + Schem2BorderZ;
FightSystem.getPlugin().setTeam1SpawnLoc(Team1SpawnLoc);
FightSystem.getPlugin().setTeam2SpawnLoc(Team2SpawnLoc);
FightSystem.getPlugin().setTeam1PasteLoc(Team1PasteLoc);
FightSystem.getPlugin().setTeam2PasteLoc(Team2PasteLoc);
FightSystem.getPlugin().setArenaMinX(ArenaMinX);
FightSystem.getPlugin().setArenaMaxX(ArenaMaxX);
FightSystem.getPlugin().setArenaMinZ(ArenaMinZ);
FightSystem.getPlugin().setArenaMaxZ(ArenaMaxZ);
}
}

Datei anzeigen

@ -0,0 +1,61 @@
package me.yaruma.fightsystem.utils;
import java.util.ArrayList;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ItemBuilder {
private ItemStack item;
private ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
meta = item.getItemMeta();
}
public ItemBuilder removeAllAtributs() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(ArrayList<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
return this;
}
public ItemStack build() {
item.setItemMeta(meta);
return item;
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package me.yaruma.fightsystem.utils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class Region {
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
if(location.getBlockX() >= minX && location.getBlockX() <= maxX && location.getBlockY() >= minY && location.getBlockY() <= maxY && location.getBlockZ() >= minZ && location.getBlockZ() <= maxX) {
return true;
} else
return false;
}
}

Datei anzeigen

@ -0,0 +1,50 @@
package me.yaruma.fightsystem.utils;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.util.EditSessionBuilder;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
public class WorldEdit {
public static void replace(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
World weWorld = new BukkitWorld(player.getWorld());
EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build();
CuboidSelection cuboidSelection = new CuboidSelection(player.getWorld(), new Location(player.getWorld(), minX, minY, minZ), new Location(player.getWorld(), maxX, maxY, maxZ));
Set<BaseBlock> targetObsidian = new HashSet<>();
targetObsidian.add(new BaseBlock(49));
Set<BaseBlock> targetBedrock = new HashSet<>();
targetBedrock.add(new BaseBlock(7));
try {
int tnt = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
int slime = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(7));
editSession.flushQueue();
} catch (Exception ex){
ex.printStackTrace();
}
}
public static void pasteSchematic(File file, World world, Vector vector, boolean allowUndo, boolean pasteAir, AffineTransform affineTransform) {
try {
FaweAPI.load(file).paste(world, vector, allowUndo, pasteAir, affineTransform).flushQueue();
} catch (IOException e) { }
}
}

Datei anzeigen

@ -0,0 +1,57 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
public class Countdown {
private int time;
private CountdownCallback countdownCallback;
private int taskID;
public Countdown() {
}
public Countdown(int time, CountdownCallback countdownCallback) {
this.time = time;
this.countdownCallback = countdownCallback;
}
public void startTimer(FightSystem plugin) {
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
switch (time) {
case 600: case 300:
Bukkit.broadcastMessage("§6Noch §a" + time / 60 + " §6Minuten" + countdownCallback.countdownCounting());
break;
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());
break;
case 1:
Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting());
break;
case 0:
countdownCallback.countdownFinished();
break;
}
time--;
}
}, 0, 20);
}
public void cancelTimer(int taskID) {
Bukkit.getScheduler().cancelTask(taskID);
}
public void cancelAllTimers(FightSystem plugin) {
Bukkit.getScheduler().cancelTasks(plugin);
}
}

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,17 @@
package me.yaruma.fightsystem.utils.countdown;
import org.bukkit.Bukkit;
public class FinishNoPlayersOnline implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis der Server gestoppt wird!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown();
}
}

Datei anzeigen

@ -0,0 +1,16 @@
package me.yaruma.fightsystem.utils.countdown;
import org.bukkit.Bukkit;
public class FinishNoneEntern implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis Entern erlaubt ist!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aEntern ist nun erlaubt!");
}
}

Datei anzeigen

@ -0,0 +1,24 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.manager.FileManager;
import org.bukkit.Bukkit;
public class FinishPreRunning implements CountdownCallback {
FileManager fileManager = FightSystem.getPlugin().getFileManager();
@Override
public String countdownCounting() {
return "bis die Arena freigegeben ist!";
}
@Override
public void countdownFinished() {
FightSystem.getPlugin().setRunningState();
int time = fileManager.getIntegerFromConfig("Times.FightDuration");
Countdown countdown = new Countdown(time, new FinishTimeOver());
countdown.startTimer(FightSystem.getPlugin());
Bukkit.broadcastMessage("§aArena freigegeben!");
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package me.yaruma.fightsystem.utils.countdown;
import org.bukkit.Bukkit;
public class FinishSetupOver implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis die Teams bereit sein müssen!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server...");
Bukkit.getServer().shutdown();
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package me.yaruma.fightsystem.utils.countdown;
import org.bukkit.Bukkit;
public class FinishSpectateOver implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis der Server gestoppt wird!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown();
}
}

Datei anzeigen

@ -0,0 +1,16 @@
package me.yaruma.fightsystem.utils.countdown;
import org.bukkit.Bukkit;
public class FinishTimeOver implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis die Zeit abgelaufen ist!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aZeit abgelaufen!");
}
}

Datei anzeigen

@ -0,0 +1,18 @@
package me.yaruma.fightsystem.utils.inventory;
import me.yaruma.fightsystem.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class SetupItems {
public static void giveSetupItems(Player player) {
Inventory inventory = player.getInventory();
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
}
}