SteamWar/FightSystem
Archiviert
13
1

Complete Rework, new Features.

Dieser Commit ist enthalten in:
Lixfel 2019-09-05 18:26:13 +02:00
Ursprung ee83bf6177
Commit 9796266c29
95 geänderte Dateien mit 2560 neuen und 1877 gelöschten Zeilen

Datei anzeigen

@ -18,9 +18,5 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.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: 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: 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" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:ProtocolLib:1.0" level="project" />
</component> </component>
</module> </module>

Datei anzeigen

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>me.yaruma</groupId> <groupId>de.steamwar</groupId>
<artifactId>FightSystem</artifactId> <artifactId>FightSystem</artifactId>
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -36,10 +36,9 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration> <configuration>
<source>1.8</source> <source>8</source>
<target>1.8</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

Datei anzeigen

@ -0,0 +1,235 @@
package de.steamwar.fightsystem;
import de.steamwar.fightsystem.commands.*;
import de.steamwar.fightsystem.countdown.*;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.utils.FightScoreboard;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WaterRemover;
import de.steamwar.fightsystem.utils.sql.EventFight;
import de.steamwar.fightsystem.winconditions.*;
import javafx.util.Pair;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§eArena§8» ";
private static FightSystem plugin;
private static FightState fightState = FightState.SETUP;
private static int fightTime = 0;
private static boolean entern = false;
private static EventFight eventFight;
private static Player eventLeiter;
@Override
public void onEnable() {
setPlugin(this);
Config.load();
KitManager.loadAllKits();
new EntityDamageListener();
new EntityExplodeListener();
new FoodLevelChangeListener();
new InventoryListener();
new PistonListener();
new PlayerChatListener();
new PlayerDeathListener();
new HotbarGUIListener();
new PlayerMoveListener();
new PlayerConnectionListener();
new PlayerRespawnListener();
new PlayerTeleportListener();
new ProjectileLaunchListener();
if(!Config.test()){
new BlockListener();
TechHider.init();
}
FightScoreboard.init();
getCommand("leave").setExecutor(new LeaveCommand());
getCommand("kit").setExecutor(new KitCommand());
getCommand("remove").setExecutor(new RemoveCommand());
getCommand("accept").setExecutor(new AcceptCommand());
getCommand("decline").setExecutor(new DeclineCommand());
getCommand("invite").setExecutor(new InviteCommand());
getCommand("ready").setExecutor(new ReadyCommand());
getCommand("ak").setExecutor(new AkCommand());
getCommand("leader").setExecutor(new LeaderCommand());
if(Config.event()) {
new EventJoinListener();
getCommand("invite").setExecutor(new EventDummyCommand());
getCommand("ready").setExecutor(new EventDummyCommand());
getCommand("ak").setExecutor(new EventDummyCommand());
getCommand("leader").setExecutor(new EventDummyCommand());
new EventStartCountdown();
}else if(Config.test()){
new TestListener();
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
new NoPlayersOnlineCountdown();
}else{
new NormalJoinListener();
new NoPlayersOnlineCountdown();
}
}
public static void setPreRunningState() {
if(fightState != FightState.SETUP)
return;
setFightState(FightState.PRE_RUNNING);
Countdown.cancelAllTimers();
loadKits(Fight.getBlueTeam());
loadKits(Fight.getRedTeam());
setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
new WinconditionAllDead();
new WinconditionCaptainDead();
new WinconditionWaterTechKO();
new WinconditionPercentSystem();
if(Config.event()){
new EventTeamOffWincondition();
}
new PreRunningCountdown();
}
public static void setRunningState() {
if(fightState != FightState.PRE_RUNNING)
return;
setFightState(FightState.RUNNING);
Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SURVIVAL);
new WinconditionTechKO();
new WinconditionTimeout();
new WinconditionEntern();
WaterRemover.init();
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
}
public static void setSpectateState(FightTeam winFightTeam) {
if(fightState != FightState.RUNNING && fightState != FightState.PRE_RUNNING)
return;
setFightState(FightState.SPECTATE);
Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SPECTATOR);
Fight.getBlueTeam().teleportToSpawn();
Fight.getRedTeam().teleportToSpawn();
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
Bukkit.broadcastMessage(" ");
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getName() + " §ahat gewonnen!");
} else {
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
}
if(Config.event())
eventFight.setErgebnis(winFightTeam);
if(!Config.test())
new SpectateOverCountdown();
}
public static void setFightTime(int fightTime) {
FightSystem.fightTime = fightTime;
}
public static void setEntern(boolean entern) {
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
FightSystem.entern = entern;
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
}
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksRed);
}
}
private static void loadKits(FightTeam team){
for(FightPlayer allFightPlayers : team.getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
}
}
private static void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
}
private static void setFightState(FightState state){
fightState = state;
BasicListener.fightStateChange(state);
}
public static void setEventFight(EventFight ef){
eventFight = ef;
}
public static void setEventLeiter(Player el){
eventLeiter = el;
}
public static Player getEventLeiter(){
return eventLeiter;
}
public static EventFight getEventFight(){
return eventFight;
}
private static void setPlugin(FightSystem pl){
plugin = pl;
}
public static FightSystem getPlugin() {
return plugin;
}
public static FightState getFightState() {
return fightState;
}
public static int getFightTime() {
return fightTime;
}
public static boolean isEntern() {
return entern;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -1,14 +1,15 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.utils.Config;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.UserGroup; import de.warking.hunjy.MySQL.UserGroup;
import de.warking.hunjy.MySQL.WarkingUser; import de.warking.hunjy.MySQL.WarkingUser;
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.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
@ -19,8 +20,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AkCommand implements CommandExecutor { public class AkCommand implements CommandExecutor {
private static final String SCHEMLIST_COMMAND = "/ak schemlist ";
private static final int FILES_PER_PAGE = 15;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -31,25 +38,7 @@ public class AkCommand implements CommandExecutor {
switch(args.length){ switch(args.length){
case 1: case 1:
if(args[0].equalsIgnoreCase("ready")) if(args[0].equalsIgnoreCase("schem") || args[0].equalsIgnoreCase("schemlist")){
Commands.toggleReady(player);
else if(args[0].equalsIgnoreCase("accept"))
Commands.acceptInvitation(player);
else if(args[0].equalsIgnoreCase("decline"))
Commands.declineInvitation(player);
else if(args[0].equalsIgnoreCase("leave"))
Commands.leaveTeam(player);
else if(args[0].equalsIgnoreCase("leader")) {
if (!Fight.getBlueTeam().hasTeamLeader()) {
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getName());
} else if (!Fight.getRedTeam().hasTeamLeader()) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getName());
} else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
}else if(args[0].equalsIgnoreCase("schem") || args[0].equalsIgnoreCase("schemlist")){
//TEXT COMPONENTS //TEXT COMPONENTS
TextComponent publicList = new TextComponent("PUBLIC"); TextComponent publicList = new TextComponent("PUBLIC");
@ -71,13 +60,7 @@ public class AkCommand implements CommandExecutor {
Commands.sendHelp(player); Commands.sendHelp(player);
break; break;
case 2: case 2:
if(args[0].equalsIgnoreCase("invite")){ if(args[0].equalsIgnoreCase("addkit")){
Commands.invite(player, args[1]);
}else if(args[0].equalsIgnoreCase("remove")){
Commands.kick(player, args[1]);
}else if(args[0].equalsIgnoreCase("kit")) {
Commands.kit(player, args[1]);
} else if(args[0].equalsIgnoreCase("addkit")){
if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){
Commands.sendHelp(player); Commands.sendHelp(player);
return false; return false;
@ -88,16 +71,12 @@ public class AkCommand implements CommandExecutor {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null && fightTeam.getFightPlayer(player).isLeader()) { if(fightTeam != null && fightTeam.getFightPlayer(player).isLeader()) {
if(args[1].equalsIgnoreCase("public")) { if(args[1].equalsIgnoreCase("public")) {
Fight.getPlayerTeam(player).sendPlayerSchematicList(true, 0, 15, player, Config.SchematicType); sendPlayerSchematicList(true, 0, player, Config.SchematicType);
return false; return false;
} else { } else {
int page; int page;
try { page = Integer.parseInt(args[1]);
page = Integer.parseInt(args[1]); sendPlayerSchematicList(false, page, player, Config.SchematicType);
} catch (NumberFormatException ex) {
return false;
}
Fight.getPlayerTeam(player).sendPlayerSchematicList(false, page, 15, player, Config.SchematicType);
} }
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -150,4 +129,82 @@ public class AkCommand implements CommandExecutor {
return false; return false;
} }
private void sendPlayerSchematicList(boolean publicSchematics, int currentPage, Player player, SchematicType schematicType) {
List<Schematic> preSchematicList;
List<Schematic> schematicList = new ArrayList<>();
if(publicSchematics) {
preSchematicList = Schematic.getSchemsAccessibleByUser(0);
} else {
preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
}
for(Schematic s : preSchematicList) {
if(s.getSchemType() == schematicType)
schematicList.add(s);
}
if(schematicList.isEmpty()) {
player.sendMessage(FightSystem.PREFIX + "§cDu hast noch keine Schematic(s)!");
return;
}
int pages;
double doublePages = (double) schematicList.size() / (double) FILES_PER_PAGE;
int intPages = schematicList.size() / FILES_PER_PAGE;
if(schematicList.size() <= FILES_PER_PAGE) {
pages = 1;
} else if(doublePages > intPages) {
pages = (intPages + 1);
} else
pages = intPages;
if(currentPage >= pages) return;
player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " Schematic(s)§8]§5======");
for(int i = currentPage * FILES_PER_PAGE; i < (currentPage * FILES_PER_PAGE) + FILES_PER_PAGE; i++) {
if(schematicList.size() <= i) break;
Schematic schem = schematicList.get(i);
TextComponent schematics = new TextComponent("§b" + schem.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schem " + schem.getSchemName() + (publicSchematics ? " public" : " private")));
player.spigot().sendMessage(schematics);
}
if(pages <= 1) return;
if(currentPage == 0) {
TextComponent nextPage = new TextComponent("Nächste Seite >>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + "1"));
player.spigot().sendMessage(nextPage);
} else if((currentPage + 1) == pages) {
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage - 1)));
player.spigot().sendMessage(beforePage);
} else {
TextComponent beforePage = new TextComponent("<< Seite ");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage - 1)));
TextComponent nextPage = new TextComponent(">>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage + 1)));
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
}
} }

Datei anzeigen

@ -1,12 +1,12 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.kit.Kit; import de.steamwar.fightsystem.kit.Kit;
import me.yaruma.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,12 +18,12 @@ class Commands {
p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
} }
private static boolean checkSetupOver(Player p){ static boolean checkSetup(Player p){
if(FightSystem.getFightState() != FightState.SETUP){ if(FightSystem.getFightState() != FightState.SETUP){
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!"); p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
return false; return true;
} }
return true; return false;
} }
private static FightTeam checkGetInvitedTeam(Player p){ private static FightTeam checkGetInvitedTeam(Player p){
@ -68,7 +68,7 @@ class Commands {
} }
static void toggleReady(Player p){ static void toggleReady(Player p){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam fightTeam = checkGetTeam(p); FightTeam fightTeam = checkGetTeam(p);
@ -79,7 +79,7 @@ class Commands {
} }
static void acceptInvitation(Player p){ static void acceptInvitation(Player p){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam team = checkGetInvitedTeam(p); FightTeam team = checkGetInvitedTeam(p);
@ -93,7 +93,7 @@ class Commands {
} }
static void declineInvitation(Player p){ static void declineInvitation(Player p){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam team = checkGetInvitedTeam(p); FightTeam team = checkGetInvitedTeam(p);
@ -107,7 +107,7 @@ class Commands {
} }
static void leaveTeam(Player p){ static void leaveTeam(Player p){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam fightTeam = checkGetTeam(p); FightTeam fightTeam = checkGetTeam(p);
@ -119,7 +119,7 @@ class Commands {
} }
static void invite(Player p, String invited){ static void invite(Player p, String invited){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam fightTeam = checkGetTeam(p); FightTeam fightTeam = checkGetTeam(p);
@ -151,7 +151,7 @@ class Commands {
} }
static void kick(Player p, String kicked){ static void kick(Player p, String kicked){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightTeam fightTeam = checkGetTeam(p); FightTeam fightTeam = checkGetTeam(p);
@ -177,7 +177,7 @@ class Commands {
} }
static void kit(Player p, String kitName){ static void kit(Player p, String kitName){
if(!checkSetupOver(p)) if(checkSetup(p))
return; return;
FightPlayer fightPlayer = checkGetPlayer(p); FightPlayer fightPlayer = checkGetPlayer(p);
@ -202,17 +202,18 @@ class Commands {
static void sendHelp(Player p) { static void sendHelp(Player p) {
p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem"); p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem");
p.sendMessage("§8/§eak help §8- §7Zeigt diese Hilfeseite");
FightPlayer fightPlayer = Fight.getFightPlayer(p); FightPlayer fightPlayer = Fight.getFightPlayer(p);
if(fightPlayer == null){ if(fightPlayer == null){
p.sendMessage("§8/§eaccept §8- §7Einladung annehmen"); p.sendMessage("§8/§eaccept §8- §7Einladung annehmen");
p.sendMessage("§8/§edecline §8- §7Einladung ablehnen"); p.sendMessage("§8/§edecline §8- §7Einladung ablehnen");
p.sendMessage("§8/§eleader §8- §7Werde der Leader eines Teams");
}else{ }else{
if(fightPlayer.isLeader()){ if(fightPlayer.isLeader()){
p.sendMessage("§8/§eak schem §8<§eSchematic§8> - §7Setze deine Schematic"); p.sendMessage("§8/§eak schem §8<§eSchematic§8> - §7Setze deine Schematic");
p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit"); p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit");
p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein"); p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein");
p.sendMessage("§8/§eremove §8<§eSpieler§8> - §7Wirft einen Spieler aus dem Team");
} }
p.sendMessage("§8/§ekit §8<§eKit§8> - §7Wähle ein Kit"); p.sendMessage("§8/§ekit §8<§eKit§8> - §7Wähle ein Kit");
p.sendMessage("§8/§eleave §8- §7Team verlassen"); p.sendMessage("§8/§eleave §8- §7Team verlassen");

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class EventDummyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage(FightSystem.PREFIX + "§cWährend des Events ist der Befehl nicht verfügbar.");
return false;
}
}

Datei anzeigen

@ -1,18 +1,18 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.Kit;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.WarkingUser; import de.warking.hunjy.MySQL.WarkingUser;
import javafx.util.Pair; import javafx.util.Pair;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.kit.Kit;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,11 +29,11 @@ public class GUI {
static void invitation(Player p, Player target){ static void invitation(Player p, Player target){
SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName()); SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName());
inv.setItem(0, Material.INK_SACK, (byte)10, "§aAnnehmen", (ClickType click) ->{ inv.setItem(0, Material.INK_SACK, (byte)10, "§aAnnehmen", (ClickType click) ->{
target.performCommand("accept"); Commands.acceptInvitation(target);
target.closeInventory(); target.closeInventory();
}); });
inv.setItem(8, Material.INK_SACK, (byte)1, "§cAblehnen", (ClickType click) ->{ inv.setItem(8, Material.INK_SACK, (byte)1, "§cAblehnen", (ClickType click) ->{
target.performCommand("decline"); Commands.declineInvitation(target);
target.closeInventory(); target.closeInventory();
}); });
inv.addCloseCallback((ClickType click) ->{ inv.addCloseCallback((ClickType click) ->{
@ -50,7 +50,7 @@ public class GUI {
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p); List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p);
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getValue())) != null); players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getValue())) != null);
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler einladen", (ClickType click, UUID player) -> { SWListInv<UUID> inv = new SWListInv<>(p, "Spieler einladen", (ClickType click, UUID player) -> {
p.performCommand("invite " + WarkingUser.get(player).getUserName()); Commands.invite(p, WarkingUser.get(player).getUserName());
p.closeInventory(); p.closeInventory();
}, players); }, players);
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
@ -60,9 +60,11 @@ public class GUI {
public static void chooseRemove(Player p){ public static void chooseRemove(Player p){
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p); List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p);
FightTeam team = Fight.getPlayerTeam(p); FightTeam team = Fight.getPlayerTeam(p);
if(team == null)
return;
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getValue())))); players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getValue()))));
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler rauswerfen", (ClickType click, UUID player) -> { SWListInv<UUID> inv = new SWListInv<>(p, "Spieler rauswerfen", (ClickType click, UUID player) -> {
p.performCommand("ak remove " + WarkingUser.get(player).getUserName()); Commands.kick(p, WarkingUser.get(player).getUserName());
p.closeInventory(); p.closeInventory();
}, players); }, players);
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
@ -71,6 +73,8 @@ public class GUI {
public static void kitSelection(Player p){ public static void kitSelection(Player p){
FightPlayer fightPlayer = Fight.getFightPlayer(p); FightPlayer fightPlayer = Fight.getFightPlayer(p);
if(fightPlayer == null)
return;
List<Pair<SWItem, Kit>> iconList = new ArrayList<>(); List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader()); List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
@ -79,7 +83,7 @@ public class GUI {
} }
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> { SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> {
p.performCommand("kit " + k.getName()); Commands.kit(p, k.getName());
p.closeInventory(); p.closeInventory();
}, iconList); }, iconList);
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
@ -89,7 +93,9 @@ public class GUI {
public static void preSchemDialog(Player p){ public static void preSchemDialog(Player p){
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl"); SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true)); inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty()){ if(Config.OnlyPublicSchematics){
inv.setItem(0, Material.INK_SACK, (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{});
}else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty()){
inv.setItem(0, Material.INK_SACK, (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{}); inv.setItem(0, Material.INK_SACK, (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{});
}else{ }else{
inv.setItem(0, Material.CAULDRON_ITEM, "§ePrivates " + Config.GameName, (ClickType click) -> schemDialog(p, false)); inv.setItem(0, Material.CAULDRON_ITEM, "§ePrivates " + Config.GameName, (ClickType click) -> schemDialog(p, false));
@ -102,10 +108,14 @@ public class GUI {
List<Pair<SWItem, Schematic>> schems; List<Pair<SWItem, Schematic>> schems;
if(publicSchems) if(publicSchems)
schems = SWListInv.getSchemList(0, Config.SchematicType); schems = SWListInv.getSchemList(0, Config.SchematicType);
else if(Config.test())
schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), null);
else else
schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), Config.SchematicType); schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), Config.SchematicType);
SWListInv<Schematic> inv = new SWListInv<>(p, Config.GameName + "-Auswahl", (ClickType click, Schematic s) -> { SWListInv<Schematic> inv = new SWListInv<>(p, Config.GameName + "-Auswahl", (ClickType click, Schematic s) -> {
FightTeam fightTeam = Fight.getPlayerTeam(p); FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null)
return;
fightTeam.setSchematic(s); fightTeam.setSchematic(s);
p.closeInventory(); p.closeInventory();
}, schems); }, schems);

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -0,0 +1,35 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class LeaderCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Commands.checkSetup(player))
return false;
if(args.length == 0){
if(Fight.getFightPlayer(player) == null){
if(!Fight.getBlueTeam().hasTeamLeader())
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
else if(!Fight.getRedTeam().hasTeamLeader())
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
}else
player.sendMessage(FightSystem.PREFIX + "§cDu bist bereits in einem Team");
}else
Commands.sendHelp(player);
return false;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.commands; package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

Datei anzeigen

@ -0,0 +1,24 @@
package de.steamwar.fightsystem.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class RemoveCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
if(args.length != 1){
Commands.sendHelp(player);
return false;
}
Commands.kick(player, args[0]);
return false;
}
}

Datei anzeigen

@ -0,0 +1,91 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
import java.util.logging.Level;
public abstract class Countdown {
private static final ArrayList<Countdown> countdowns = new ArrayList<>();
private int time;
private final int taskID;
private final Sound sound;
private final boolean level;
abstract String countdownCounting();
abstract void countdownFinished();
Countdown(int time, Sound sound, boolean level) {
this.time = time;
this.sound = sound;
this.level = level;
countdowns.add(this);
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20);
}
public static void cancelAllTimers() {
while (!countdowns.isEmpty()) {
countdowns.get(0).cancelTimer();
}
}
public static void cancelTimerType(Class<? extends Countdown> type) {
for(int i = countdowns.size() - 1; i >= 0; i--)
if(type.isInstance(countdowns.get(i)))
countdowns.get(i).cancelTimer();
}
private void count(){
switch (time) {
case 900: case 600: case 300: case 180: case 120:
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time / 60 + " §7Minuten " + countdownCounting());
break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 1.0F);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time + " §7Sekunden " + countdownCounting());
break;
case 1:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 1.0F);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §aeine §7Sekunde " + countdownCounting());
break;
case 0:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 2.0F);
cancelTimer();
countdownFinished();
break;
default:
}
if(this.level)
Fight.setLevel(time);
time--;
onTime(time);
}
void onTime(int time){
//Unused
}
public void cancelTimer() {
try {
Bukkit.getScheduler().cancelTask(this.taskID);
} catch (AssertionError ex) {
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not cancel timer", ex);
}
countdowns.remove(this);
}
}

Datei anzeigen

@ -1,9 +1,15 @@
package me.yaruma.fightsystem.utils.countdown; package de.steamwar.fightsystem.countdown;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class FinishNoneEntern implements CountdownCallback { public class EnternCountdown extends Countdown {
public EnternCountdown() {
super(Config.EnterPhaseBegin, Sound.BLOCK_NOTE_PLING, false);
}
@Override @Override
public String countdownCounting() { public String countdownCounting() {
@ -15,9 +21,4 @@ public class FinishNoneEntern implements CountdownCallback {
FightSystem.setEntern(true); FightSystem.setEntern(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
} }
@Override
public CountdownType getType() {
return CountdownType.NO_ENTERN;
}
} }

Datei anzeigen

@ -0,0 +1,22 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Sound;
public class EventStartCountdown extends Countdown {
public EventStartCountdown() {
super(Config.SetupDuration, Sound.BLOCK_NOTE_PLING, false);
}
@Override
String countdownCounting() {
return "bis der Kampf beginnt!";
}
@Override
void countdownFinished() {
FightSystem.setPreRunningState();
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
public class NoPlayersOnlineCountdown extends Countdown {
public NoPlayersOnlineCountdown() {
super(Config.NoPlayerOnlineDuration, null, false);
}
@Override
public String countdownCounting() {
return "bis der Server gestoppt wird!";
}
@Override
public void countdownFinished() {
Bukkit.getServer().shutdown();
}
}

Datei anzeigen

@ -0,0 +1,22 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Sound;
public class PreRunningCountdown extends Countdown {
public PreRunningCountdown() {
super(Config.PreFightDuration, Sound.BLOCK_NOTE_PLING, true);
}
@Override
public String countdownCounting() {
return "bis die Arena freigegeben ist!";
}
@Override
public void countdownFinished() {
FightSystem.getPlugin().setRunningState();
}
}

Datei anzeigen

@ -1,9 +1,14 @@
package me.yaruma.fightsystem.utils.countdown; package de.steamwar.fightsystem.countdown;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
public class FinishSetupOver implements CountdownCallback { public class SetupOverCountdown extends Countdown {
public SetupOverCountdown() {
super(Config.SetupDuration, null, false);
}
@Override @Override
public String countdownCounting() { public String countdownCounting() {
@ -15,9 +20,4 @@ public class FinishSetupOver implements CountdownCallback {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cKampf wird abgebrochen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cKampf wird abgebrochen!");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }
@Override
public CountdownType getType() {
return CountdownType.SETUP_OVER;
}
} }

Datei anzeigen

@ -0,0 +1,22 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class SpectateOverCountdown extends Countdown {
public SpectateOverCountdown() {
super(Config.SpectatorDuration, Sound.BLOCK_NOTE_PLING, false);
}
@Override
public String countdownCounting() {
return "bis der Server gestoppt wird!";
}
@Override
public void countdownFinished() {
Bukkit.shutdown();
}
}

Datei anzeigen

@ -0,0 +1,29 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.winconditions.WinconditionTechKO;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class TechKOCountdown extends Countdown {
private final FightTeam team;
public TechKOCountdown(FightTeam team) {
super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, Sound.BLOCK_NOTE_PLING, false);
this.team = team;
}
@Override
final String countdownCounting() {
return "bis " + team.getName() + " §7einen Schuss abgegeben haben muss!";
}
@Override
void countdownFinished() {
Bukkit.broadcastMessage(FightSystem.PREFIX + team.getName() + "§7 ist §eTech K§8.§eO§8.!");
FightSystem.setSpectateState(Fight.getOpposite(team));
}
}

Datei anzeigen

@ -0,0 +1,29 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class TimeOverCountdown extends Countdown {
public TimeOverCountdown() {
super(Config.TimeoutTime, Sound.BLOCK_NOTE_BASS, false);
}
@Override
public String countdownCounting() {
return "bis der Kampf vorbei ist!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
FightSystem.setSpectateState(null);
}
@Override
void onTime(int time) {
FightSystem.setFightTime(time);
}
}

Datei anzeigen

@ -1,15 +1,16 @@
package me.yaruma.fightsystem.fight; package de.steamwar.fightsystem.fight;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Fight { public class Fight {
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedRotate, false); private Fight(){}
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueRotate, true);
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true);
public static FightTeam getPlayerTeam(Player player) { public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player)) if(redTeam.isPlayerInTeam(player))
@ -20,11 +21,14 @@ public class Fight {
} }
public static FightTeam getOpposite(FightTeam fightTeam) { public static FightTeam getOpposite(FightTeam fightTeam) {
if(fightTeam == null){
throw new IllegalArgumentException();
}
if(fightTeam == redTeam) if(fightTeam == redTeam)
return blueTeam; return blueTeam;
if(fightTeam == blueTeam) else
return redTeam; return redTeam;
return null;
} }
public static FightTeam getInvitedTeam(Player player){ public static FightTeam getInvitedTeam(Player player){
@ -52,14 +56,11 @@ public class Fight {
} }
public static void playSound(Sound sound, float volume, float pitch) { public static void playSound(Sound sound, float volume, float pitch) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) { //volume: max. 100, pitch: max. 2
player.playSound(player.getLocation(), sound, volume, pitch); //volume: max. 100, pitch: max. 2 Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
}
} }
public static void setLevel(int level) { public static void setLevel(int level) {
for(Player player : Bukkit.getServer().getOnlinePlayers()) { Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level));
player.setLevel(level);
}
} }
} }

Datei anzeigen

@ -1,13 +1,14 @@
package me.yaruma.fightsystem.fight; package de.steamwar.fightsystem.fight;
import me.yaruma.fightsystem.kit.Kit; import de.steamwar.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.kit.KitManager; import de.steamwar.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.kit.Kit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class FightPlayer { public class FightPlayer {
private final Player player; private final Player player;
private final FightTeam team;
private boolean isOut; private boolean isOut;
private Kit kit; private Kit kit;
@ -16,26 +17,27 @@ public class FightPlayer {
this.player.sendMessage(message); this.player.sendMessage(message);
} }
FightPlayer(Player player, boolean isOut) { FightPlayer(Player player, FightTeam team) {
this.player = player; this.player = player;
this.isOut = isOut; this.team = team;
this.isOut = false;
kit = KitManager.getKitByName(Config.MemberDefault); kit = KitManager.getKitByName(Config.MemberDefault);
} }
public void setOut(boolean isOut) { public void setOut() {
this.isOut = isOut; isOut = true;
} }
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
public boolean isOut() { public boolean isLiving() {
return this.isOut; return !this.isOut;
} }
public boolean isLeader() { public boolean isLeader() {
FightPlayer leader = Fight.getPlayerTeam(player).getLeader(); FightPlayer leader = team.getLeader();
return leader != null && leader.getPlayer() == player; return leader != null && leader.getPlayer() == player;
} }
@ -46,4 +48,8 @@ public class FightPlayer {
public void setKit(Kit kit) { public void setKit(Kit kit) {
this.kit = kit; this.kit = kit;
} }
public FightTeam getTeam(){
return team;
}
} }

Datei anzeigen

@ -1,7 +1,6 @@
package me.yaruma.fightsystem.fight; package de.steamwar.fightsystem.fight;
public enum FightState { public enum FightState {
SETUP, SETUP,
PRE_RUNNING, PRE_RUNNING,
RUNNING, RUNNING,

Datei anzeigen

@ -0,0 +1,338 @@
package de.steamwar.fightsystem.fight;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.utils.*;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.WarkingUser;
import javafx.util.Pair;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
public class FightTeam {
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@SuppressWarnings("deprecation")
private static final BaseBlock WOOL = new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS = new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CLAY = new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS_PANE = new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE = new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE);
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(WOOL);
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(CONCRETE);
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(CLAY);
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(GLASS);
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(GLASS_PANE);
private FightPlayer leader;
private final Set<FightPlayer> players = new HashSet<>();
private boolean ready;
private final Set<Player> invited = new HashSet<>();
private final String name;
private final String prefix;
private final ChatColor color;
private Schematic schematic;
private final Team team;
private final boolean blue;
private final Location spawn;
private final Vector paste;
private final Vector corner;
private final boolean rotate;
public FightTeam(String name, String prefix, Location spawn, Vector paste, Vector corner, boolean rotate, boolean blue) {
this.spawn = spawn;
this.paste = paste;
this.name = name;
this.prefix = prefix;
this.ready = false;
this.rotate = rotate;
this.corner = corner;
this.blue = blue;
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
if(FightScoreboard.getScoreboard().getTeam(name) == null)
team = FightScoreboard.getScoreboard().registerNewTeam(name);
else
team = FightScoreboard.getScoreboard().getTeam(name);
team.setColor(color);
team.setAllowFriendlyFire(false);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
public void teleportToSpawn(){
for(FightPlayer player : players){
player.getPlayer().teleport(spawn);
}
}
public FightPlayer getFightPlayer(Player player) {
for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player))
return fightPlayer;
}
return null;
}
public boolean allPlayersOut() {
for(FightPlayer fightPlayer : players) {
if(fightPlayer.isLiving())
return false;
}
return true;
}
public boolean isPlayerInTeam(Player player) {
for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player))
return true;
}
return false;
}
public boolean isPlayerLeader(Player player) {
if(leader != null)
return leader.getPlayer().equals(player);
else
return false;
}
public void broadcast(String message) {
for(FightPlayer fightPlayer : players) {
fightPlayer.sendMessage(message);
}
}
public FightPlayer addMember(Player player) {
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
FightPlayer fightPlayer = new FightPlayer(player, this);
players.add(fightPlayer);
invited.remove(player);
team.addEntry(player.getName());
player.setGameMode(GameMode.ADVENTURE);
player.teleport(spawn);
if(KitManager.getKits(false).size() > 1)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
player.getInventory().setItem(4, new ItemBuilder(Material.BEACON).removeAllAtributs().setDisplayName("§eRespawn").build());
TechHider.reloadChunks(player, chunksToReload);
return fightPlayer;
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = getFightPlayer(player);
if(fightPlayer == null)
return;
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
players.remove(fightPlayer);
team.removeEntry(player.getName());
fightPlayer.getPlayer().getInventory().clear();
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
this.leader = null;
if(!players.isEmpty()) {
setLeader(players.iterator().next());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getName() + "§a!");
}else if(!Config.event()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cTeam " + getName() + " §chat keine Spieler mehr.\n Arena schließt...");
Bukkit.shutdown();
}else{
setLeader(null);
}
}
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
TechHider.reloadChunks(player, chunksToReload);
}
public boolean hasTeamLeader() {
return leader != null;
}
public boolean isBlue(){
return blue;
}
public FightPlayer getLeader() {
return leader;
}
public void setLeader(FightPlayer leader) {
this.leader = leader;
if (leader == null)
return;
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
Inventory inventory = leader.getPlayer().getInventory();
if (KitManager.getKits(true).size() > 1)
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
else
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
if(!Config.event()){
inventory.setItem(0, new ItemBuilder(Material.PAPER).removeAllAtributs().setDisplayName("§eSpieler einladen").build());
inventory.setItem(2, new ItemBuilder(Material.FIREWORK_CHARGE).removeAllAtributs().setDisplayName("§cSpieler rauswerfen").build());
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
}
inventory.setItem(7, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
}
public Set<FightPlayer> getPlayers() {
return players;
}
public boolean isReady() {
return ready;
}
private void pasteSchematic(){
File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()).getUUID().toString(), schematic.getSchemName() + ".schematic");
com.boydti.fawe.object.schematic.Schematic schem;
try {
schem = FaweAPI.load(file);
if(schem.getClipboard() == null)
throw new IOException();
}catch(IOException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e);
return;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v;
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
v = paste.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(Config.AlignWater){
Vector it = schem.getClipboard().getMinimumPoint();
int depth = 0;
while(!schem.getClipboard().getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, Config.WaterDepth - depth, 0);
}
EditSession e = schem.paste(w, v, false, true, aT);
replaceTeamColor(e);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
}
@SuppressWarnings("deprecation")
private void replaceTeamColor(EditSession e){
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize));
DyeColor c = ColorConverter.chat2dye(color);
try {
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
e.replaceBlocks(region, GLASS_SET, new BaseBlock(GLASS.getId(), c.getWoolData()));
e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(GLASS_PANE.getId(), c.getWoolData()));
} catch (MaxChangedBlocksException ex) {
// ignore, will never occur
}
e.flushQueue();
}
public void pasteDummy(){
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
if(publics.isEmpty())
return;
schematic = publics.get(0);
pasteSchematic();
}
public void setSchematic(Schematic schematic){
this.schematic = schematic;
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
if(!Config.test())
leader.getPlayer().getInventory().clear(7);
if(Config.test())
pasteSchematic();
else if(Fight.getOpposite(this).hasSchematic()){
pasteSchematic();
Fight.getOpposite(this).pasteSchematic();
}
}
public boolean hasSchematic(){
return schematic != null;
}
public void setReady(boolean ready) {
Player l = leader.getPlayer();
if(schematic == null){
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
return;
}
this.ready = ready;
if(ready) {
l.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!");
if(Fight.getOpposite(this).isReady() || Config.test()) {
FightSystem.setPreRunningState();
}
} else {
l.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
public Set<Player> getInvited() {
return invited;
}
public String getName() {
return prefix + name;
}
public String getPrefix() {
return prefix;
}
public Location getSpawn() {
return spawn;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.kit; package de.steamwar.fightsystem.kit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -6,14 +6,12 @@ import org.bukkit.inventory.ItemStack;
public class Kit { public class Kit {
private String name; private String name;
private int price;
private boolean leaderAllowed; private boolean leaderAllowed;
private boolean memberAllowed; private boolean memberAllowed;
private ItemStack[] inventory; private ItemStack[] inventory;
public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] inventory) { Kit(String name, boolean leaderAllowed, boolean memberAllowed, ItemStack[] inventory) {
this.name = name; this.name = name;
this.price = price;
this.leaderAllowed = leaderAllowed; this.leaderAllowed = leaderAllowed;
this.memberAllowed = memberAllowed; this.memberAllowed = memberAllowed;
this.inventory = inventory; this.inventory = inventory;
@ -23,10 +21,6 @@ public class Kit {
return name; return name;
} }
public int getPrice() {
return price;
}
public boolean isLeaderAllowed() { public boolean isLeaderAllowed() {
return leaderAllowed; return leaderAllowed;
} }
@ -35,7 +29,7 @@ public class Kit {
return memberAllowed; return memberAllowed;
} }
public ItemStack[] getInventory() { ItemStack[] getInventory() {
return inventory; return inventory;
} }

Datei anzeigen

@ -1,7 +1,7 @@
package me.yaruma.fightsystem.kit; package de.steamwar.fightsystem.kit;
import de.warking.hunjy.CoinSystem.CoinSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.FightSystem; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,53 +11,46 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
public class KitManager { public class KitManager {
public static final FightSystem instance = FightSystem.getPlugin(); private KitManager(){}
private static final String kitsPath = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data";
private static final String KITS_PATH = "plugins/" + FightSystem.getPlugin().getName() + "/kits.data";
private static final File kits = new File(KITS_PATH);
private static final FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits);
private static final ArrayList<Kit> loadedKits = new ArrayList<>(); private static final ArrayList<Kit> loadedKits = new ArrayList<>();
public static void saveInventory(String kitName, Player player){ public static void saveInventory(String kitName, Player player){
loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getContents())); loadedKits.add(new Kit(kitName, true, true, player.getInventory().getContents()));
saveAllKits(); saveAllKits();
} }
public static boolean canBuy(Player player, String kitName) { private static Kit loadKitFromConfig(String name) {
if(getKitByName(kitName).getPrice() <= CoinSystem.getCoinsManager(player).getCoins()) {
return true;
} else
return false;
}
public void buyKit() {
//wird spaeter gemacht
}
public static boolean ownsKit(Player player) {
return true; //wird spaeter gemacht
}
public static Kit loadKitFromConfig(String name) {
FileConfiguration data = instance.getKitData();
String path = "Kits." + name; String path = "Kits." + name;
if(data.contains(path)) { if(kitData.contains(path)) {
List<ItemStack> items = (List<ItemStack>) data.getList(path + ".Items"); List<ItemStack> items = (List<ItemStack>) kitData.getList(path + ".Items");
int price = data.getInt(path + ".Price"); boolean leaderAllowed = kitData.getBoolean(path + ".LeaderAllowed");
boolean leaderAllowed = data.getBoolean(path + ".LeaderAllowed"); boolean memberAllowed = kitData.getBoolean(path + ".MemberAllowed");
boolean memberAllowed = data.getBoolean(path + ".MemberAllowed");
Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, items.toArray(new ItemStack[1])); return new Kit(name, leaderAllowed, memberAllowed, items.toArray(new ItemStack[1]));
return kit;
} }
return null; return null;
} }
public static void loadAllKits() { public static void loadAllKits() {
if(instance.getKitData().getConfigurationSection("Kits") != null) { if(!new File(KITS_PATH).exists()) {
for(String key : instance.getKitData().getConfigurationSection("Kits").getKeys(false)) { saveAllKits();
Bukkit.getLogger().log(Level.INFO, "kits.data erstellt!");
Bukkit.shutdown();
return;
}
if(kitData.getConfigurationSection("Kits") != null) {
for(String key : kitData.getConfigurationSection("Kits").getKeys(false)) {
loadedKits.add(loadKitFromConfig(key)); loadedKits.add(loadKitFromConfig(key));
} }
} }
@ -68,13 +61,15 @@ public class KitManager {
for(Kit k : loadedKits){ for(Kit k : loadedKits){
String path = "Kits." + k.getName(); String path = "Kits." + k.getName();
yamlConfiguration.set(path + ".Items", k.getInventory()); yamlConfiguration.set(path + ".Items", k.getInventory());
yamlConfiguration.set(path + ".Price", k.getPrice());
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed()); yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());
yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed()); yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed());
} }
try { try {
yamlConfiguration.save(new File(kitsPath)); yamlConfiguration.save(kits);
}catch(IOException ignored){} }catch(IOException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save kits.data", e);
}
} }
public static Kit getKitByName(String kitName) { public static Kit getKitByName(String kitName) {

Datei anzeigen

@ -0,0 +1,45 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import java.util.LinkedList;
import java.util.List;
public abstract class BasicListener implements Listener {
private static final List<BasicListener> listeners = new LinkedList<>();
BasicListener(){
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
listeners.add(this);
}
public static void fightStateChange(FightState state){
for (int i = listeners.size() - 1; i >= 0; i--) {
listeners.get(i).stateChange(state);
}
}
boolean notRunning(){
return FightSystem.getFightState() != FightState.RUNNING;
}
boolean notFighting(Player p){
return Fight.getFightPlayer(p) == null;
}
void stateChange(FightState state){
//Unused
}
void disable(){
HandlerList.unregisterAll(this);
listeners.remove(this);
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,50 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class EventJoinListener extends BasicListener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
WarkingUser user = WarkingUser.get(player.getUniqueId());
FightTeam team = null;
if(user.getTeam() == Config.EventTeamBlueID)
team = Fight.getBlueTeam();
else if(user.getTeam() == Config.EventTeamRedID)
team = Fight.getRedTeam();
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
FightPlayer fp = team.addMember(player);
if(!team.hasTeamLeader())
team.setLeader(fp);
}
if(user.getId() == FightSystem.getEventFight().getKampfleiter())
FightSystem.setEventLeiter(player);
}
@EventHandler
public void handlePlayerLeave(PlayerQuitEvent event){
Player player = event.getPlayer();
if(player == FightSystem.getEventLeiter())
FightSystem.setEventLeiter(null);
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -1,10 +1,9 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
public class FoodLevelChangeListener implements Listener { public class FoodLevelChangeListener extends BasicListener {
@EventHandler @EventHandler
public void handleFoodLevelChange(FoodLevelChangeEvent event) { public void handleFoodLevelChange(FoodLevelChangeEvent event) {

Datei anzeigen

@ -1,34 +1,35 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight;
import me.yaruma.fightsystem.commands.GUI; import de.steamwar.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.fight.Fight; import de.steamwar.fightsystem.utils.Config;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.commands.GUI;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.fight.FightState;
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;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
public class PlayerInteractListener implements Listener { public class HotbarGUIListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(FightSystem.getFightState() == FightState.SETUP && if(event.getItem() != null) {
event.getItem() != null && FightTeam fightTeam = Fight.getPlayerTeam(player);
Fight.getPlayerTeam(player) != null) { if(fightTeam == null)
return;
ItemMeta itemMeta = event.getItem().getItemMeta(); ItemMeta itemMeta = event.getItem().getItemMeta();
String displayName = itemMeta.getDisplayName(); String displayName = itemMeta.getDisplayName();
event.setCancelled(true);
if(displayName == null) if(displayName == null)
return; return;
FightTeam fightTeam = Fight.getPlayerTeam(player); event.setCancelled(true);
if(displayName.equals("§e" + Config.GameName + " wählen")){ if(displayName.equals("§e" + Config.GameName + " wählen")){
GUI.preSchemDialog(player); GUI.preSchemDialog(player);
return; return;
@ -54,9 +55,15 @@ public class PlayerInteractListener implements Listener {
case "§eKit wählen": case "§eKit wählen":
GUI.kitSelection(player); GUI.kitSelection(player);
break; break;
case "§eRespawn":
player.teleport(fightTeam.getSpawn());
break;
} }
} }
} }
@Override
} void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -1,17 +1,17 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class InventoryListener implements Listener { public class InventoryListener extends BasicListener {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
@ -21,20 +21,21 @@ public class InventoryListener implements Listener {
} }
Inventory clicked = event.getClickedInventory(); Inventory clicked = event.getClickedInventory();
if (event.getClick().isShiftClick()) { if(event.getClick().isShiftClick()){
ItemStack clickedOn = event.getCurrentItem(); ItemStack clickedOn = event.getCurrentItem();
if (clickedOn != null && event.getView().getTopInventory().getType() != InventoryType.CRAFTING && clicked == event.getWhoClicked().getInventory()) { if(
clickedOn != null &&
event.getView().getTopInventory().getType() != InventoryType.CRAFTING &&
clicked == event.getWhoClicked().getInventory())
event.setCancelled(true); event.setCancelled(true);
}
}else if ( }else if (
clicked != event.getWhoClicked().getInventory() && clicked != event.getWhoClicked().getInventory() &&
clicked != null && clicked != null &&
clicked.getType() != InventoryType.PLAYER && clicked.getType() != InventoryType.PLAYER &&
event.getCursor() != null && event.getCursor() != null &&
event.getCursor().getType() != Material.AIR){ event.getCursor().getType() != Material.AIR)
event.setCancelled(true); event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@ -55,4 +56,9 @@ public class InventoryListener implements Listener {
} }
} }
} }
@EventHandler
public void onDropPickup(InventoryPickupItemEvent e){
e.setCancelled(true);
}
} }

Datei anzeigen

@ -0,0 +1,39 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
import de.steamwar.fightsystem.countdown.SetupOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
public class NormalJoinListener extends BasicListener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
if(!Fight.getRedTeam().hasTeamLeader()) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
} else if(!Fight.getBlueTeam().hasTeamLeader()) {
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
}
}
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
new SetupOverCountdown();
}
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -1,17 +1,16 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.Region;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
public class PistonListener implements Listener { public class PistonListener extends BasicListener {
@EventHandler @EventHandler
public void handlePistonExtend(BlockPistonExtendEvent e){ public void handlePistonExtend(BlockPistonExtendEvent e){

Datei anzeigen

@ -1,15 +1,15 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.fight.Fight; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.Fight;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
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;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
public class PlayerChatListener implements Listener { public class PlayerChatListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerChat(PlayerChatEvent event) { public void handlePlayerChat(PlayerChatEvent event) {
@ -25,6 +25,8 @@ public class PlayerChatListener implements Listener {
} else { } else {
Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message); Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message);
} }
}else if(player == FightSystem.getEventLeiter()){
Bukkit.broadcastMessage("§e" + player.getName() + "§8» §e" + message);
}else{ }else{
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message); Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,79 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
public class PlayerMoveListener extends BasicListener {
private static final String DENY_ARENA = "§cDu darfst die Arena nicht verlassen";
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
@EventHandler
public void teamAreas(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(player == FightSystem.getEventLeiter() || Config.test())
return;
Location to = event.getTo();
FightTeam fightTeam = Fight.getPlayerTeam(player);
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
if(inBlueArea || inRedArea) {
if(fightTeam == null)
reset(event, DENY_TEAM);
}else if(fightTeam != null && (
!FightSystem.isEntern() || player.getGameMode() == GameMode.SPECTATOR)){
reset(event, DENY_ENTERN);
}
}
@EventHandler
public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer();
Location to = event.getTo();
//Check in Arena
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
reset(event, DENY_ARENA);
return;
}
FightTeam team = Fight.getPlayerTeam(player);
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
if(to.getY() <= Config.underArenaBorder) {
if(player.getGameMode() == GameMode.SPECTATOR){
reset(event, DENY_ARENA);
}else if(FightSystem.getFightState() == FightState.RUNNING)
player.damage(2);
else if(team != null){
player.teleport(team.getSpawn());
}else
reset(event, DENY_ARENA);
}else if(team != null && !inArenaY){
reset(event, DENY_ARENA);
}
}
private void reset(PlayerMoveEvent event, String message){
Player player = event.getPlayer();
player.teleport(event.getFrom());
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}

Datei anzeigen

@ -1,14 +1,13 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
public class PlayerRespawnListener implements Listener { public class PlayerRespawnListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) { public void handlePlayerRespawn(PlayerRespawnEvent event) {

Datei anzeigen

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

Datei anzeigen

@ -1,13 +1,14 @@
package me.yaruma.fightsystem.listener; package de.steamwar.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
public class ProjectileLaunchListener implements Listener { public class ProjectileLaunchListener extends BasicListener {
@EventHandler @EventHandler
public void handleProjectileLaunch(ProjectileLaunchEvent event) { public void handleProjectileLaunch(ProjectileLaunchEvent event) {
@ -15,7 +16,7 @@ public class ProjectileLaunchListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
if(event.getEntity().getShooter() instanceof Player){ if(event.getEntity().getShooter() instanceof Player){
Player player = (Player) event.getEntity().getShooter(); Player player = (Player) event.getEntity().getShooter();
player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!"); player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Fightbeginn nutzen!"));
} }
} }
} }

Datei anzeigen

@ -0,0 +1,48 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.permissions.PermissionAttachment;
public class TestListener extends BasicListener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null && (!Fight.getRedTeam().hasTeamLeader() || !Fight.getBlueTeam().hasTeamLeader())) {
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
}
Countdown.cancelTimerType(NoPlayersOnlineCountdown.class);
PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
attachment.setPermission("fawe.permpack.basic", true);
attachment.setPermission("bukkit.command.gamemode", true);
attachment.setPermission("bukkit.command.teleport", true);
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
attachment.setPermission("worldedit.navigation.thru.tool", true);
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event){
if(Bukkit.getOnlinePlayers().isEmpty())
Bukkit.shutdown();
}
@Override
void stateChange(FightState state){
disable();
}
}

Datei anzeigen

@ -0,0 +1,38 @@
package de.steamwar.fightsystem.utils;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import java.util.EnumMap;
import java.util.Map;
public class ColorConverter {
private ColorConverter(){}
private static final Map<ChatColor, DyeColor> chat2dye = new EnumMap<>(ChatColor.class);
static{
chat2dye.put(ChatColor.WHITE, DyeColor.WHITE);
chat2dye.put(ChatColor.GOLD, DyeColor.ORANGE);
chat2dye.put(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA);
chat2dye.put(ChatColor.BLUE, DyeColor.LIGHT_BLUE);
chat2dye.put(ChatColor.YELLOW, DyeColor.YELLOW);
chat2dye.put(ChatColor.GREEN, DyeColor.LIME);
chat2dye.put(ChatColor.RED, DyeColor.RED);
chat2dye.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
chat2dye.put(ChatColor.GRAY, DyeColor.SILVER);
chat2dye.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
chat2dye.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
chat2dye.put(ChatColor.DARK_BLUE, DyeColor.BLUE);
chat2dye.put(ChatColor.AQUA, DyeColor.CYAN);
chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
chat2dye.put(ChatColor.DARK_RED, DyeColor.RED);
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
//Rosa 9pink, Braun 3brown
}
public static DyeColor chat2dye(ChatColor color){
return chat2dye.get(color);
}
}

Datei anzeigen

@ -1,8 +1,11 @@
package me.yaruma.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.sql.Event;
import de.steamwar.fightsystem.utils.sql.EventFight;
import de.steamwar.fightsystem.utils.sql.Team;
import de.warking.hunjy.MySQL.SchematicType; import de.warking.hunjy.MySQL.SchematicType;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -11,9 +14,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.logging.Level;
public class Config { public class Config {
private Config(){}
public static int NoPlayerOnlineDuration; public static int NoPlayerOnlineDuration;
public static int SetupDuration; public static int SetupDuration;
public static int PreFightDuration; public static int PreFightDuration;
@ -55,6 +61,7 @@ public class Config {
public static boolean PercentSystem; public static boolean PercentSystem;
public static boolean Entern; public static boolean Entern;
public static boolean TechKO; public static boolean TechKO;
public static boolean WaterTechKO = false;
public static int TimeoutTime; public static int TimeoutTime;
public static int EnterPhaseBegin; public static int EnterPhaseBegin;
@ -77,6 +84,9 @@ public class Config {
public static Vector TeamBluePaste; public static Vector TeamBluePaste;
public static Vector TeamRedPaste; public static Vector TeamRedPaste;
public static Vector TeamBlueCorner;
public static Vector TeamRedCorner;
public static Vector Schemsize;
public static int ArenaMinX; public static int ArenaMinX;
public static int ArenaMinZ; public static int ArenaMinZ;
@ -87,6 +97,11 @@ public class Config {
public static List<String> HiddenBlockEntities; public static List<String> HiddenBlockEntities;
public static int ObfuscateWith; public static int ObfuscateWith;
public static int EventKampfID;
public static int EventTeamBlueID;
public static int EventTeamRedID;
public static int MaximumTeamMembers = Integer.MAX_VALUE;
public static void load(){ public static void load(){
if(!new File(Bukkit.getWorldContainer().getPath() + '/' + Bukkit.getWorlds().get(0).getName() + "/config.yml").exists()) { if(!new File(Bukkit.getWorldContainer().getPath() + '/' + Bukkit.getWorlds().get(0).getName() + "/config.yml").exists()) {
FightSystem.getPlugin().saveDefaultConfig(); FightSystem.getPlugin().saveDefaultConfig();
@ -181,14 +196,17 @@ public class Config {
TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ); TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ);
TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ); TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ);
Schemsize = new Vector(SchemsizeX, SchemsizeY, SchemsizeZ);
TeamBlueCorner = new Vector(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ);
TeamRedCorner = new Vector(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ);
World world = Bukkit.getWorlds().get(0); World world = Bukkit.getWorlds().get(0);
TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + SchemsizeY, teamBluePasteZ + 0.5); TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + SchemsizeY, teamBluePasteZ + 0.5);
TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + SchemsizeY, teamRedPasteZ + 0.5); TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + SchemsizeY, teamRedPasteZ + 0.5);
SpecSpawn = new Location(world, SpecSpawn = new Location(world,
teamBluePasteX + TeamBluetoReddistanceX/2, teamBluePasteX + TeamBluetoReddistanceX/2.0,
TeamBlueCornerY + TeamBluetoReddistanceY/2 + SchemsizeY/2, TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
teamBluePasteZ + TeamBluetoReddistanceZ/2); teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
if(TeamBluetoReddistanceX > 0){ if(TeamBluetoReddistanceX > 0){
ArenaMinX = TeamBlueCornerX - Schem2BorderX; ArenaMinX = TeamBlueCornerX - Schem2BorderX;
@ -219,5 +237,42 @@ public class Config {
TeamRedRotate = false; TeamRedRotate = false;
TeamBlueRotate = false; TeamBlueRotate = false;
} }
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(event()){
EventFight eventFight = EventFight.get(EventKampfID);
if(eventFight == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
Bukkit.shutdown();
return;
}
Team team1 = Team.get(eventFight.getTeamBlue());
Team team2 = Team.get(eventFight.getTeamRed());
if(team1 == null || team2 == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
Bukkit.shutdown();
return;
}
TeamBlueName = team1.getTeamKuerzel();
TeamRedName = team2.getTeamKuerzel();
EventTeamBlueID = team1.getTeamId();
EventTeamRedID = team2.getTeamId();
FightSystem.setEventFight(eventFight);
Event event = Event.get(eventFight.getEventID());
MaximumTeamMembers = event.getMaximumTeamMembers();
OnlyPublicSchematics = event.publicSchemsOnly();
}
}
public static boolean event(){
return EventKampfID >= 1;
}
public static boolean test(){
return EventKampfID == -1;
} }
} }

Datei anzeigen

@ -0,0 +1,86 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.winconditions.WinconditionPercentSystem;
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
import org.bukkit.Bukkit;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class FightScoreboard {
private FightScoreboard(){}
private static final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
private static final Objective objective;
private static int index = 0;
static{
if(scoreboard.getObjective("AAA") == null)
objective = scoreboard.registerNewObjective("AAA", "BBB");
else
objective = scoreboard.getObjective("AAA");
}
public static void init(){
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), () -> {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
FightTeam fightTeam = getIndexDisplay();
if(fightTeam != null)
teamScoreboard(fightTeam);
else
generalScoreboard();
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
}, 0, 200);
}
public static Scoreboard getScoreboard() {
return scoreboard;
}
private static void teamScoreboard(FightTeam fightTeam){
objective.setDisplayName(fightTeam.getName());
fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving())
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
});
}
private static void generalScoreboard(){
objective.setDisplayName("§6Kampf");
if (Config.Timeout) {
int fightTime = FightSystem.getFightTime();
if (fightTime >= 60)
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
else
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
}
if (Config.Entern)
objective.getScore("§7Entern: " + (FightSystem.isEntern() ? "§aja" : "§cnein")).setScore(2);
if (Config.PercentSystem){
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0);
}else if(Config.WaterTechKO){
objective.getScore(Fight.getRedTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamRedWater()).setScore(1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamBlueWater()).setScore(0);
}
}
private static FightTeam getIndexDisplay() {
index++;
if(index == 1)
return Fight.redTeam;
if(index == 2)
return Fight.blueTeam;
index = 0;
return null;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.utils; package de.steamwar.fightsystem.utils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.utils; package de.steamwar.fightsystem.utils;
import org.bukkit.Location; import org.bukkit.Location;

Datei anzeigen

@ -1,4 +1,4 @@
package me.yaruma.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
@ -13,10 +13,10 @@ import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.nbt.NbtCompound; import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory; import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import javafx.util.Pair; import javafx.util.Pair;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -66,6 +66,10 @@ public class TechHider {
obfuscateShift4 = (short)(Config.ObfuscateWith << 4); obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
int threadMultiplier = 1;
if(Config.event())
threadMultiplier = 4;
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
@ -134,7 +138,6 @@ public class TechHider {
i += readVarIntLength(Bytes.toArray(newData), i); i += readVarIntLength(Bytes.toArray(newData), i);
i += dataArrayLength * 8; i += dataArrayLength * 8;
}else{ }else{
//System.out.println("Full chunk " + chunkX + " " + chunkZ + " " + chunkX*16 + " " + chunkZ*16);
int dataArrayLength = readVarInt(Bytes.toArray(newData), i); int dataArrayLength = readVarInt(Bytes.toArray(newData), i);
i += readVarIntLength(Bytes.toArray(newData), i); i += readVarIntLength(Bytes.toArray(newData), i);
/*int arrayEnd = dataArrayLength * 8 + i; /*int arrayEnd = dataArrayLength * 8 + i;
@ -165,8 +168,7 @@ public class TechHider {
byteArray.write(0, Bytes.toArray(newData)); byteArray.write(0, Bytes.toArray(newData));
} }
} }
}).start(4); }).start(4 * threadMultiplier);
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
@ -186,7 +188,7 @@ public class TechHider {
blockStructure.write(0, block); blockStructure.write(0, block);
} }
} }
}).start(); }).start(threadMultiplier);
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
@ -215,7 +217,7 @@ public class TechHider {
blockStructure.write(0, changes); blockStructure.write(0, changes);
} }
} }
}).start(); }).start(threadMultiplier);
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
@ -238,7 +240,7 @@ public class TechHider {
e.setCancelled(true); e.setCancelled(true);
} }
} }
}).start(); }).start(threadMultiplier);
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
@ -248,10 +250,13 @@ public class TechHider {
e.setCancelled(true); e.setCancelled(true);
} }
} }
}).start(); }).start(threadMultiplier);
} }
private static boolean bypass(Player p, int chunkX, int chunkZ){ private static boolean bypass(Player p, int chunkX, int chunkZ){
if(p == FightSystem.getEventLeiter())
return true;
FightTeam ft = Fight.getPlayerTeam(p); FightTeam ft = Fight.getPlayerTeam(p);
if(ft == null){ if(ft == null){
//Außerhalb der Arena //Außerhalb der Arena

Datei anzeigen

@ -0,0 +1,97 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import java.util.*;
public class WaterRemover {
private WaterRemover(){}
private static Map<Location, Integer> explodedBlocks = new HashMap<>();
private static Set<Block> waterList = new HashSet<>();
public static void init() {
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
wateredCheck();
removeWater();
}, 0, 20);
}
public static void add(List<Block> l) {
l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0));
}
private static void wateredCheck() {
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Location, Integer> e = it.next();
Block b = e.getKey().getBlock();
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) {
waterList.add(b);
}
if(b.getType() != Material.AIR){
it.remove();
continue;
}
explodedBlocks.replace(e.getKey(), e.getValue() + 1);
if(explodedBlocks.get(e.getKey()) > 15){
it.remove();
}
}
}
private static void removeWater() {
List<Block> blocksToRemove = new LinkedList<>();
Iterator<Block> it = waterList.iterator();
while(it.hasNext()){
Block b = it.next();
blocksToRemove.addAll(getSourceBlocksOfWater(b));
if (b.getType() != Material.WATER && b.getType() != Material.STATIONARY_WATER) {
it.remove();
}
}
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> {
blocksToRemove.forEach((Block b) -> b.setType(Material.AIR));
WinconditionWaterTechKO.removeWater();
});
}
private static Set<Block> getSourceBlocksOfWater(Block startBlock) {
Set<Block> water = new HashSet<>();
collectBlocks(startBlock, water, new HashSet<>());
return water;
}
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
if(
(anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) ||
visitedBlocks.contains(anchor)
)
return;
visitedBlocks.add(anchor);
if (anchor.getType() == Material.STATIONARY_WATER)
collected.add(anchor);
if(visitedBlocks.size() > 50) {
collected.clear();
return;
}
collectBlocks(anchor.getRelative(BlockFace.UP), collected, visitedBlocks);
collectBlocks(anchor.getRelative(BlockFace.NORTH), collected, visitedBlocks);
collectBlocks(anchor.getRelative(BlockFace.EAST), collected, visitedBlocks);
collectBlocks(anchor.getRelative(BlockFace.SOUTH), collected, visitedBlocks);
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
}
}

Datei anzeigen

@ -0,0 +1,61 @@
package de.steamwar.fightsystem.utils.sql;
import org.bukkit.Bukkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.logging.Level;
import static de.warking.hunjy.Core.sql;
public class Event {
private final int eventID;
private final String eventName;
private final Timestamp start;
private final Timestamp end;
private final int maximumTeamMembers;
private final boolean publicSchemsOnly;
private Event(int eventID, String eventName, Timestamp start, Timestamp end, int maximumTeamMembers, boolean publicSchemsOnly){
this.eventID = eventID;
this.eventName = eventName;
this.start = start;
this.end = end;
this.maximumTeamMembers = maximumTeamMembers;
this.publicSchemsOnly = publicSchemsOnly;
}
public static Event get(int eventID){
ResultSet rs = sql.select("SELECT * FROM Event WHERE EventID = " + eventID);
try{
if(!rs.next())
throw new IllegalArgumentException();
return new Event(eventID, rs.getString("EventName"), rs.getTimestamp("Start"), rs.getTimestamp("End"), rs.getInt("MaximumTeamMembers"), rs.getBoolean("PublicSchemsOnly"));
}catch (SQLException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Event", e);
throw new SecurityException();
}
}
public int getEventID() {
return eventID;
}
public String getEventName() {
return eventName;
}
public Timestamp getStart() {
return start;
}
public Timestamp getEnd() {
return end;
}
public int getMaximumTeamMembers() {
return maximumTeamMembers;
}
public boolean publicSchemsOnly() {
return publicSchemsOnly;
}
}

Datei anzeigen

@ -0,0 +1,77 @@
package de.steamwar.fightsystem.utils.sql;
import de.steamwar.fightsystem.fight.FightTeam;
import de.warking.hunjy.Core;
import org.bukkit.Bukkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
public class EventFight {
private int eventID;
private int fightID;
private int teamBlue;
private int teamRed;
private int kampfleiter;
private int ergebnis;
private EventFight(int eventID, int fightID, int teamBlue, int teamRed, int kampfleiter, int ergebnis){
this.eventID = eventID;
this.fightID = fightID;
this.teamBlue = teamBlue;
this.teamRed = teamRed;
this.kampfleiter = kampfleiter;
this.ergebnis = ergebnis;
}
public static EventFight get(int fightID){
ResultSet rs = Core.sql.select("SELECT * FROM EventFight WHERE FightID = " + fightID);
try{
return new EventFight(
rs.getInt("EventID"),
fightID,
rs.getInt("TeamBlue"),
rs.getInt("TeamRed"),
rs.getInt("Kampfleiter"),
rs.getInt("Ergebnis"));
}catch (SQLException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight", e);
}
return null;
}
public void setErgebnis(FightTeam winner){
if (winner == null)
ergebnis = 0;
else if (winner.isBlue())
ergebnis = 1;
else
ergebnis = 2;
Core.sql.update("UPDATE EventFight SET Ergebnis = " + ergebnis + " WHERE FightID = " + fightID);
}
public int getTeamBlue() {
return teamBlue;
}
public int getTeamRed() {
return teamRed;
}
public int getEventID() {
return eventID;
}
public int getFightID() {
return fightID;
}
public int getKampfleiter() {
return kampfleiter;
}
public int getErgebnis() {
return ergebnis;
}
}

Datei anzeigen

@ -0,0 +1,75 @@
package de.steamwar.fightsystem.utils.sql;
import org.bukkit.Bukkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import static de.warking.hunjy.Core.sql;
public class Team {
private final int teamId;
private String teamKuerzel;
private String teamName;
private int teamLeader;
private Team(int id, String kuerzel, String name, int leader){
teamId = id;
teamKuerzel = kuerzel;
teamName = name;
teamLeader = leader;
}
public static Team get(int id){
return load(sql.select("SELECT * FROM Team WHERE TeamID = " + id));
}
private static Team load(ResultSet dbteam){
try {
if(!dbteam.next()){
return null;
}
int id = dbteam.getInt("TeamID");
String kuerzel = dbteam.getString("TeamKuerzel");
String name = dbteam.getString("TeamName");
int leader = dbteam.getInt("TeamLeader");
return new Team(id, kuerzel, name, leader);
} catch (SQLException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not load teammembers", e);
return null;
}
}
public int getTeamId() {
return teamId;
}
public String getTeamKuerzel() {
return teamKuerzel;
}
public String getTeamName() {
return teamName;
}
public int getTeamLeader() {
return teamLeader;
}
public List<Integer> getMembers(){
try{
ResultSet memberlist = sql.select("SELECT id FROM UserData WHERE Team = '" + teamId + "'");
List<Integer> members = new ArrayList<>();
while(memberlist.next()){
members.add(memberlist.getInt("id"));
}
return members;
}catch(SQLException e){
Bukkit.getLogger().log(Level.SEVERE, "Could not load Teammembers", e);
}
return new ArrayList<>();
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.Bukkit;
public class EventTeamOffWincondition {
public EventTeamOffWincondition(){
teamOff(Fight.getBlueTeam());
teamOff(Fight.getRedTeam());
}
private void teamOff(FightTeam team){
if(team.allPlayersOut()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getName() + " §6ist Offline!");
FightSystem.setSpectateState(team);
}
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
abstract class ListenerWincondition implements Listener {
void init(boolean condition){
if(!condition)
return;
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
}

Datei anzeigen

@ -0,0 +1,22 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightState;
import org.bukkit.entity.Player;
abstract class PlayerWincondition extends ListenerWincondition {
boolean isTarget(Player player){
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
return false;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return false;
fightTeam.getFightPlayer(player).setOut();
return true;
}
}

Datei anzeigen

@ -0,0 +1,46 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead extends PlayerWincondition {
public WinconditionAllDead(){
init(Config.AllDead);
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer();
if(!isTarget(player))
return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(!isTarget(player))
return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
}
}
}

Datei anzeigen

@ -0,0 +1,46 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends PlayerWincondition {
public WinconditionCaptainDead(){
init(Config.CaptainDead);
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer();
if(!isTarget(player))
return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(!isTarget(player))
return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
}
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,16 +1,15 @@
package me.yaruma.fightsystem.winconditions; package de.steamwar.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.Region;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener { public class WinconditionPercentSystem extends ListenerWincondition {
private static double bluePercent = 0D; private static double bluePercent = 0D;
private static double redPercent = 0D; private static double redPercent = 0D;
@ -21,12 +20,13 @@ public class WinconditionPercentSystem implements Listener {
private static int schematicSize; private static int schematicSize;
public WinconditionPercentSystem() { public WinconditionPercentSystem() {
init(Config.PercentSystem);
schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ); schematicSize = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
} }
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
if(!Config.PercentSystem) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return; if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -37,7 +37,7 @@ public class WinconditionPercentSystem implements Listener {
double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize; double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize;
bluePercent = destroyPercent; bluePercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.blueTeam); FightSystem.setSpectateState(Fight.redTeam);
} }
//Team Red //Team Red
}else if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) { }else if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
@ -46,7 +46,7 @@ public class WinconditionPercentSystem implements Listener {
double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize; double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize;
redPercent = destroyPercent; redPercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.getPlugin().setSpectateState(Fight.redTeam); FightSystem.setSpectateState(Fight.blueTeam);
} }
} }
} }

Datei anzeigen

@ -0,0 +1,95 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TechKOCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.HashMap;
import java.util.Map;
public class WinconditionTechKO implements Listener {
private static final int TECH_KO_TIME_IN_S = 90;
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
public static final int TECH_KO_COUNTDOWN_TIME = TECH_KO_HALF_TIME/20;
private World world;
private Map<Integer, Boolean> map = new HashMap<>(400);
private double toggle;
private int smallerZtime;
private int biggerZtime;
private TechKOCountdown smallerZcountdown = null;
private TechKOCountdown biggerZcountdown = null;
//Works only for z-Axis fight direction for performance reasons
public WinconditionTechKO(){
if(!Config.TechKO)
return;
world = Bukkit.getWorlds().get(0);
toggle = Config.SpecSpawn.getZ();
smallerZtime=TECH_KO_HALF_TIME;
biggerZtime=TECH_KO_HALF_TIME;
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
private void run(){
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
int id = tnt.getEntityId();
boolean smallerZ = tnt.getLocation().getZ() < toggle;
Boolean old = map.put(id, smallerZ);
if(old != null && old != smallerZ){
if(old)
smallerZtime = TECH_KO_HALF_TIME;
else
biggerZtime = TECH_KO_HALF_TIME;
}
}
if(smallerZtime == TECH_KO_HALF_TIME && smallerZcountdown != null){
smallerZcountdown.cancelTimer();
smallerZcountdown = null;
}else if(smallerZtime == 0){
smallerZcountdown = new TechKOCountdown(smallerTeam());
}
if(biggerZtime == TECH_KO_HALF_TIME && biggerZcountdown != null){
biggerZcountdown.cancelTimer();
biggerZcountdown = null;
}else if(biggerZtime == 0){
biggerZcountdown = new TechKOCountdown(biggerTeam());
}
smallerZtime--;
biggerZtime--;
}
private FightTeam smallerTeam(){
if(Config.TeamBluetoReddistanceZ > 0)
return Fight.getBlueTeam();
else
return Fight.getRedTeam();
}
private FightTeam biggerTeam(){
if(Config.TeamBluetoReddistanceZ < 0)
return Fight.getBlueTeam();
else
return Fight.getRedTeam();
}
@EventHandler
public void onEntityDead(EntityExplodeEvent event){
map.remove(event.getEntity().getEntityId());
}
}

Datei anzeigen

@ -0,0 +1,13 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.utils.Config;
public class WinconditionTimeout {
public WinconditionTimeout() {
if(!Config.Timeout)
return;
new TimeOverCountdown();
}
}

Datei anzeigen

@ -0,0 +1,95 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.HashSet;
import java.util.Set;
public class WinconditionWaterTechKO {
private static final Set<Location> teamRedWater = new HashSet<>();
private static final Set<Location> teamBlueWater = new HashSet<>();
public WinconditionWaterTechKO() {
if(!Config.WaterTechKO)
return;
Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 0, 200);
}
private void addWater() {
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
return;
checkForWater(teamRedWater,
Config.TeamRedCornerX,
Config.TeamRedCornerY,
Config.TeamRedCornerZ,
Config.TeamRedCornerX + Config.SchemsizeX,
Config.TeamRedCornerY + Config.SchemsizeY,
Config.TeamRedCornerZ + Config.SchemsizeZ);
checkForWater(teamBlueWater,
Config.TeamBlueCornerX,
Config.TeamBlueCornerY,
Config.TeamBlueCornerZ,
Config.TeamBlueCornerX + Config.SchemsizeX,
Config.TeamBlueCornerY + Config.SchemsizeY,
Config.TeamBlueCornerZ + Config.SchemsizeZ);
checkEmpty(Fight.getRedTeam(), teamRedWater);
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
}
public static void removeWater() {
if(!Config.WaterTechKO)
return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
return;
checkWaterspots(teamRedWater);
checkWaterspots(teamBlueWater);
checkEmpty(Fight.getRedTeam(), teamRedWater);
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
}
public static int getTeamBlueWater() {
return teamBlueWater.size();
}
public static int getTeamRedWater() {
return teamRedWater.size();
}
private void checkForWater(Set<Location> teamWater, int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
teamWater.clear();
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z);
if (location.getBlock().getType() == Material.STATIONARY_WATER)
teamRedWater.add(location);
}
}
}
}
private static void checkWaterspots(Set<Location> teamWater){
teamWater.removeIf(location -> location.getBlock().getType() != Material.STATIONARY_WATER);
}
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getName() + " §6ist Tech K.O.!");
FightSystem.setSpectateState(team);
}
}
}

Datei anzeigen

@ -1,251 +0,0 @@
package me.yaruma.fightsystem;
import de.warking.hunjy.CoinSystem.CoinSystem;
import javafx.util.Pair;
import me.yaruma.fightsystem.commands.*;
import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.TechHider;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import me.yaruma.fightsystem.utils.countdown.FinishPreRunning;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
import me.yaruma.fightsystem.winconditions.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§eArena§8» ";
private static FightSystem plugin;
private static Scoreboard scoreboard;
private static WaterRemover waterRemover;
private static FightState fightState = FightState.SETUP;
private static int fightTime = 0;
private static boolean entern = false;
private final File kits = new File("plugins/" + this.getName(), "kits.data");
private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
private void saveKitData() {
try { getKitData.save(kits); } catch (Exception ignored) { }
}
public FileConfiguration getKitData() {
return getKitData;
}
@Override
public void onEnable() {
plugin = this;
Config.load();
scoreboard = new Scoreboard();
waterRemover = new WaterRemover();
entern = false;
loadConfig();
KitManager.loadAllKits();
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);
pm.registerEvents(new PlayerMoveListener(), plugin);
pm.registerEvents(new EntityDamageByEntityListener(), plugin);
pm.registerEvents(new FoodLevelChangeListener(), plugin);
pm.registerEvents(new PlayerRespawnListener(), plugin);
pm.registerEvents(new EntityDamageListener(), plugin);
pm.registerEvents(new EntityExplodeListener(), plugin);
pm.registerEvents(new PlayerTeleportListener(), plugin);
pm.registerEvents(new ProjectileLaunchListener(), plugin);
pm.registerEvents(new PistonListener(), plugin);
pm.registerEvents(new InventoryListener(), plugin);
//WinConditions
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
if(Config.CaptainDead) pm.registerEvents(new WinconditionCaptainDead(), plugin);
if(Config.PercentSystem) pm.registerEvents(new WinconditionPercentSystem(), plugin);
getCommand("ak").setExecutor(new AkCommand());
getCommand("invite").setExecutor(new InviteCommand());
getCommand("leave").setExecutor(new LeaveCommand());
getCommand("accept").setExecutor(new AcceptCommand());
getCommand("decline").setExecutor(new DeclineCommand());
getCommand("ready").setExecutor(new ReadyCommand());
getCommand("kit").setExecutor(new KitCommand());
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline(), null, false);
countdown.startTimer(getPlugin());
TechHider.init();
}
private void loadConfig() {
if(!new File("plugins/" + this.getName() + "/kits.data").exists()) {
saveKitData();
System.out.println(PREFIX + "kits.data erstellt und geladen!");
Bukkit.shutdown();
}
}
public static FightSystem getPlugin() {
return plugin;
}
public static FightState getFightState() {
return fightState;
}
public Scoreboard getScoreboard() {
return scoreboard;
}
public WaterRemover getWaterRemover() {
return waterRemover;
}
public void setPreRunningState() {
if(fightState != FightState.SETUP)
return;
fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers();
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning(), Sound.BLOCK_NOTE_PLING, true);
countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
}
for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear();
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
}
teleportAllToFightSpawn();
setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
WinconditionTechKO.startAutoChecker();
}
private void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm);
}
}
public void setRunningState() {
if(fightState != FightState.PRE_RUNNING)
return;
fightState = FightState.RUNNING;
Countdown.cancelAllTimers();
getWaterRemover().start();
setAllPlayersGM(GameMode.SURVIVAL);
WinconditionTimeout.timeout();
WinconditionEntern.entern();
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
}
public void setSpectateState(FightTeam winFightTeam) {
if(fightState != FightState.RUNNING)
return;
fightState = FightState.SPECTATE;
Countdown.cancelAllTimers();
Bukkit.getScheduler().cancelTask(WinconditionTechKO.getTaskID());
setAllPlayersGM(GameMode.SPECTATOR);
for(Player p : Bukkit.getOnlinePlayers()){
p.getInventory().clear();
}
Bukkit.broadcastMessage(" ");
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getName() + " §ahat gewonnen!");
teleportAllToFightSpawn();
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyWin);
}
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyLose);
}
} else {
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyDraw);
}
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(Config.MoneyDraw);
}
}
Countdown countdown = new Countdown(Config.SpectatorDuration, new FinishSpectateOver(), Sound.BLOCK_NOTE_PLING, false);
countdown.startTimer(FightSystem.getPlugin());
}
public int getFightTime() {
return fightTime;
}
public static boolean isEntern() {
return entern;
}
private void teleportAllToFightSpawn() {
Fight.getBlueTeam().teleportToSpawn();
Fight.getRedTeam().teleportToSpawn();
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null) player.teleport(Config.SpecSpawn);
}
}
public static void setFightTime(int fightTime) {
FightSystem.fightTime = fightTime;
}
public static void setEntern(boolean entern) {
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().get(0).getPlayer());
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().get(0).getPlayer());
FightSystem.entern = entern;
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
}
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksRed);
}
}
}

Datei anzeigen

@ -1,343 +0,0 @@
package me.yaruma.fightsystem.fight;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
import javafx.util.Pair;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder;
import me.yaruma.fightsystem.utils.TechHider;
import me.yaruma.fightsystem.winconditions.WinconditionTechKO;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FightTeam {
private FightPlayer leader;
private final List<FightPlayer> players = new ArrayList<>();
private boolean ready;
private final List<Player> invited = new ArrayList<>();
private final String name;
private final String prefix;
private Schematic schematic;
private final boolean blue;
private final Location spawn;
private final Vector paste;
private final boolean rotate;
public FightTeam(String Name, String Prefix, Location Spawn, Vector Paste, boolean Rotate, boolean Blue) {
spawn = Spawn;
paste = Paste;
name = Name;
prefix = Prefix;
ready = false;
rotate = Rotate;
blue = Blue;
}
public void teleportToSpawn(){
for(FightPlayer player : players){
player.getPlayer().teleport(spawn);
}
}
public FightPlayer getFightPlayer(Player player) {
for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player))
return fightPlayer;
}
return null;
}
public boolean allPlayersOut() {
for(FightPlayer fightPlayer : players) {
if(!fightPlayer.isOut())
return false;
}
return true;
}
public boolean isPlayerInTeam(Player player) {
for(FightPlayer fightPlayer : players) {
if(fightPlayer.getPlayer().equals(player))
return true;
}
return false;
}
public boolean isPlayerLeader(Player player) {
if(leader != null)
return leader.getPlayer().equals(player);
else
return false;
}
public void broadcast(String message) {
for(FightPlayer fightPlayer : players) {
fightPlayer.sendMessage(message);
}
}
public FightPlayer addMember(Player player) {
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
FightPlayer fightPlayer = new FightPlayer(player, false);
players.add(fightPlayer);
invited.remove(player);
player.setGameMode(GameMode.ADVENTURE);
player.teleport(spawn);
if(KitManager.getKits(false).size() > 1)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
TechHider.reloadChunks(player, chunksToReload);
return fightPlayer;
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = getFightPlayer(player);
if(fightPlayer == null)
return;
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
players.remove(fightPlayer);
fightPlayer.getPlayer().getInventory().clear();
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
this.leader = null;
if(!players.isEmpty()) {
setLeader(players.get(0));
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getName() + "§a!");
}else{
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cTeam " + getName() + " §chat keine Spieler mehr.\n Arena schließt...");
Bukkit.shutdown();
}
}
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
TechHider.reloadChunks(player, chunksToReload);
}
public boolean hasTeamLeader() {
return leader != null;
}
public boolean isBlue(){
return blue;
}
public boolean isRed(){
return !blue;
}
public FightPlayer getLeader() {
return leader;
}
public void setLeader(FightPlayer leader) {
this.leader = leader;
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
Inventory inventory = leader.getPlayer().getInventory();
inventory.setItem(0, new ItemBuilder(Material.PAPER).removeAllAtributs().setDisplayName("§eSpieler einladen").build());
if(KitManager.getKits(true).size() > 1)
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
else
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
inventory.setItem(2, new ItemBuilder(Material.FIREWORK_CHARGE).removeAllAtributs().setDisplayName("§cSpieler rauswerfen").build());
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
inventory.setItem(7, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
}
public List<FightPlayer> getPlayers() {
return players;
}
public boolean isReady() {
return ready;
}
private void pasteSchematic(){
File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()).getUUID().toString() + "/" + schematic.getSchemName() + ".schematic");
com.boydti.fawe.object.schematic.Schematic schem;
try {
schem = FaweAPI.load(file);
}catch(IOException e){
e.printStackTrace();
return;
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v;
Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
v = paste.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(Config.AlignWater){
Vector it = schem.getClipboard().getMinimumPoint();
int depth = 0;
while(!schem.getClipboard().getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
System.out.println(name + " " + Config.WaterDepth + " " + depth + " " + schem.getClipboard().getBlock(new Vector(0, 0, 0)));
v = v.add(0, Config.WaterDepth - depth, 0);
}
schem.paste(w, v, false, true, aT).flushQueue();
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () ->{
teleportToSpawn();
},20);
}
public void setSchematic(Schematic schematic){
this.schematic = schematic;
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
leader.getPlayer().getInventory().clear(7);
if(Fight.getOpposite(this).hasSchematic()){
pasteSchematic();
Fight.getOpposite(this).pasteSchematic();
Bukkit.getScheduler().scheduleSyncDelayedTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 20*10L);
}
}
public boolean hasSchematic(){
return schematic != null;
}
public void setReady(boolean ready) {
Player leader = getLeader().getPlayer();
if(schematic == null){
leader.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
return;
}
this.ready = ready;
if(ready) {
leader.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!");
if(Fight.getOpposite(this).isReady()) {
FightSystem.getPlugin().setPreRunningState();
}
} else {
leader.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
public List<Player> getInvited() {
return invited;
}
public String getName() {
return prefix + name;
}
public String getPrefix() {
return prefix;
}
public Location getSpawn() {
return spawn;
}
public void sendPlayerSchematicList(boolean publicSchematics, int currentPage, int filesPerPage, Player player, SchematicType schematicType) {
List<Schematic> preSchematicList;
List<Schematic> schematicList = new ArrayList<>();
if(publicSchematics) {
preSchematicList = Schematic.getSchemsAccessibleByUser(0);
} else {
preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
}
for(Schematic s : preSchematicList) {
if(s.getSchemType() == schematicType)
schematicList.add(s);
}
if(schematicList.isEmpty()) {
player.sendMessage(FightSystem.PREFIX + "§cDu hast noch keine Schematic(s)!");
return;
}
int pages;
double doublePages = (double) schematicList.size() / (double) filesPerPage;
int intPages = schematicList.size() / filesPerPage;
if(schematicList.size() <= filesPerPage) {
pages = 1;
} else if(doublePages > intPages) {
pages = (intPages + 1);
} else
pages = intPages;
if(currentPage >= pages) return;
player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " Schematic(s)§8]§5======");
for(int i = currentPage * filesPerPage; i < (currentPage * filesPerPage) + filesPerPage; i++) {
if(schematicList.size() <= i) break;
Schematic schematic = schematicList.get(i);
TextComponent schematics = new TextComponent("§b" + schematic.getSchemName());
schematics.setBold(true);
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schem " + schematic.getSchemName() + (publicSchematics ? " public" : " private")));
player.spigot().sendMessage(schematics);
}
if(pages <= 1) return;
if(currentPage == 0) {
TextComponent nextPage = new TextComponent("Nächste Seite >>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist 1"));
player.spigot().sendMessage(nextPage);
} else if((currentPage + 1) == pages) {
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist " + (currentPage - 1)));
player.spigot().sendMessage(beforePage);
} else {
TextComponent beforePage = new TextComponent("<< Seite ");
beforePage.setColor(ChatColor.RED);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist " + (currentPage - 1)));
TextComponent nextPage = new TextComponent(">>");
nextPage.setColor(ChatColor.RED);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist " + (currentPage + 1)));
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
}
}

Datei anzeigen

@ -1,106 +0,0 @@
package me.yaruma.fightsystem.fight;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.winconditions.WinconditionTechKO;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
public class WaterRemover {
private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<>();
private List<Block> waterList = new ArrayList<>();
private BukkitTask task;
public void start() {
this.stop();
this.explodedBlocks = new ArrayList<>();
this.waterList = new ArrayList<>();
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), () -> {
try {
WaterRemover.this.wateredCheck();
WaterRemover.this.removeWater();
}
catch (Exception e) {
e.printStackTrace();
}
}, 0L, 20L);
}
public void stop() {
if (this.task != null) {
this.task.cancel();
}
}
public void add(Location loc) {
this.explodedBlocks.add(new AbstractMap.SimpleEntry<>(loc, 0));
}
private void wateredCheck() {
for (int i = this.explodedBlocks.size() - 1; i >= 0; i--) {
if (this.explodedBlocks.get(i).getValue() >= 15) {
Block b = this.explodedBlocks.get(i).getKey().getBlock();
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) {
this.waterList.add(b);
}
this.explodedBlocks.remove(i);
continue;
}
this.explodedBlocks.get(i).setValue(this.explodedBlocks.get(i).getValue() + 1);
}
}
private void removeWater() {
ArrayList<Block> blocksToRemove = new ArrayList<>();
for (int i = this.waterList.size() - 1; i > -1; --i) {
Block current = this.waterList.get(i);
blocksToRemove.addAll(this.getSourceBlocksOfWater(current));
if (current.getType() != Material.AIR) continue;
this.waterList.remove(i);
}
Bukkit.getScheduler().runTask((Plugin)FightSystem.getPlugin(), () -> {
for (Block block : blocksToRemove) {
block.setType(Material.AIR);
}
WinconditionTechKO.removeWater();
});
}
private List<Block> getSourceBlocksOfWater(Block startBlock) {
ArrayList<Block> water = new ArrayList<>();
this.collectBlocks(startBlock, water, new ArrayList<>());
return water;
}
private void collectBlocks(Block anchor, List<Block> collected, List<Block> visitedBlocks) {
if (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) {
return;
}
if (visitedBlocks.contains((Object)anchor)) {
return;
}
visitedBlocks.add(anchor);
if (anchor.getType() == Material.STATIONARY_WATER) {
collected.add(anchor);
}
if(visitedBlocks.size() > 50) {
collected.clear();
return;
}
this.collectBlocks(anchor.getRelative(BlockFace.UP), collected, visitedBlocks);
this.collectBlocks(anchor.getRelative(BlockFace.NORTH), collected, visitedBlocks);
this.collectBlocks(anchor.getRelative(BlockFace.EAST), collected, visitedBlocks);
this.collectBlocks(anchor.getRelative(BlockFace.SOUTH), collected, visitedBlocks);
this.collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
}
}

Datei anzeigen

@ -1,28 +0,0 @@
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);
else if(FightSystem.getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getFightState() == FightState.SETUP || FightSystem.getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");
}
}
}

Datei anzeigen

@ -1,27 +0,0 @@
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);
else if(FightSystem.getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(FightSystem.getFightState() == FightState.PRE_RUNNING || FightSystem.getFightState() == FightState.SETUP) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
}
}
}

Datei anzeigen

@ -1,50 +0,0 @@
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.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class EntityDamageByEntityListener implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(instance.getFightState() != FightState.RUNNING) {
event.setCancelled(true);
} else if(event.getEntity() instanceof Player) {
Player player = ((Player) event.getEntity()).getPlayer();
if(event.getDamager() instanceof Player) {
Player damager = ((Player) event.getDamager()).getPlayer();
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 zufügen!");
}
} else
event.setCancelled(true);
}else 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)) {
event.setCancelled(true);
damager.sendMessage(FightSystem.PREFIX + "§cDu darfst deinen Teamkollegen keinen Schaden zufügen!");
damagerArrow.setFireTicks(0);
player.setFireTicks(0);
}
}
}
}
}

Datei anzeigen

@ -1,24 +0,0 @@
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.entity.EntityDamageEvent;
public class EntityDamageListener implements Listener {
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if(Fight.getPlayerTeam(player) != null) {
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) event.setCancelled(true);
} else
event.setCancelled(true);
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,36 +0,0 @@
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.Config;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class PlayerDeathListener implements Listener {
FightSystem instance = FightSystem.getPlugin();
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
event.setDeathMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §cist gestorben!");
fightTeam.getFightPlayer(player).setOut(true);
player.setGameMode(GameMode.SPECTATOR);
if(fightTeam == Fight.redTeam)
player.teleport(Config.TeamRedSpawn);
else
player.teleport(Config.TeamBlueSpawn);
Fight.playSound(Sound.ENTITY_WITHER_DEATH, 100.0F, 1.0F);
}
}

Datei anzeigen

@ -1,54 +0,0 @@
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.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.CountdownType;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
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) {
event.setJoinMessage(null);
Player player = event.getPlayer();
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
if(!Fight.getRedTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
} else if(!Fight.getBlueTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP) {
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
} else {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
}
} else {
player.teleport(fightTeam.getSpawn());
player.setGameMode(GameMode.SPECTATOR);
}
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
new Countdown(Config.SetupDuration, new FinishSetupOver(), null, false).startTimer(FightSystem.getPlugin());
}
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);
}
}

Datei anzeigen

@ -1,69 +0,0 @@
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.Config;
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 {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
FightTeam fightTeam = Fight.getPlayerTeam(player);
//Check in Arena
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
return;
}
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
//Check under Arena
if(to.getY() <= Config.underArenaBorder) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
}else if(FightSystem.getFightState() == FightState.RUNNING)
player.damage(2);
else if(fightTeam == Fight.redTeam)
player.teleport(Config.TeamRedSpawn);
else
player.teleport(Config.TeamBlueSpawn);
return;
}else if(fightTeam != null && !inArenaY){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
return;
}
//Check TeamAreas
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
if(inBlueArea || inRedArea) {
if(fightTeam == null){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!");
}
}else if(fightTeam != null && (
(!FightSystem.isEntern() && !fightTeam.getFightPlayer(player).isOut()) ||
FightSystem.getFightState() == FightState.SPECTATE)){
player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getName() + "§c!");
}
}
}

Datei anzeigen

@ -1,37 +0,0 @@
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 org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return;
FightState fightState = FightSystem.getFightState();
if(fightState == FightState.SETUP){
fightTeam.removePlayer(player);
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(!fightPlayer.isOut()) {
fightTeam.getFightPlayer(player).setOut(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
}
}
}
}

Datei anzeigen

@ -1,19 +0,0 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class PlayerTeleportListener implements Listener {
@EventHandler
public void onTpGM3(PlayerTeleportEvent e) {
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
e.setCancelled(true);
e.getPlayer().sendMessage(FightSystem.PREFIX + "§cDu darfst die GM3 Teleportfunktion nicht benutzen!");
}
}
}

Datei anzeigen

@ -1,92 +0,0 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
public class Countdown {
private static final ArrayList<Countdown> countdowns = new ArrayList<>();
private int time;
private final CountdownCallback countdownCallback;
private int taskID;
private Sound sound;
private boolean level;
public Countdown(int time, CountdownCallback countdownCallback, Sound sound, boolean level) {
this.time = time;
this.countdownCallback = countdownCallback;
this.sound = sound;
this.level = level;
countdowns.add(this);
}
public void startTimer(FightSystem plugin) {
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, () -> {
switch (time) {
case 900: case 600: case 300: case 180: case 120:
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time / 60 + " §7Minuten " + countdownCallback.countdownCounting());
break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 1.0F);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §a" + time + " §7Sekunden " + countdownCallback.countdownCounting());
break;
case 1:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 1.0F);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7Noch §aeine §7Sekunde " + countdownCallback.countdownCounting());
break;
case 0:
if(this.sound != null)
Fight.playSound(this.sound, 100.0F, 2.0F);
cancelTimer();
countdownCallback.countdownFinished();
break;
}
if(this.level)
Fight.setLevel(time);
time--;
if(countdownCallback instanceof FinishTimeOver) FightSystem.setFightTime(time);
}, 0, 20);
}
private void cancelTimer() {
try {
Bukkit.getScheduler().cancelTask(this.taskID);
} catch (AssertionError ex) {
ex.printStackTrace();
}
countdowns.remove(this);
}
public static void cancelAllTimers() {
while (!countdowns.isEmpty()) {
countdowns.get(0).cancelTimer();
}
}
public static void cancelTimerType(CountdownType countdownType) {
for(int i = countdowns.size() - 1; i >= 0; i--) {
if(countdowns.get(i).getType() == countdownType) countdowns.get(i).cancelTimer();
}
}
private CountdownType getType() {
return countdownCallback.getType();
}
}

Datei anzeigen

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

Datei anzeigen

@ -1,13 +0,0 @@
package me.yaruma.fightsystem.utils.countdown;
public enum CountdownType {
NO_ENTERN,
NO_PLAYERS_ONLINE,
PRE_RUNNING,
SETUP_OVER,
SPECTATE_OVER,
TIME_OVER
}

Datei anzeigen

@ -1,21 +0,0 @@
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.getServer().shutdown();
}
@Override
public CountdownType getType() {
return CountdownType.NO_PLAYERS_ONLINE;
}
}

Datei anzeigen

@ -1,21 +0,0 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
public class FinishPreRunning implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis die Arena freigegeben ist!";
}
@Override
public void countdownFinished() {
FightSystem.getPlugin().setRunningState();
}
@Override
public CountdownType getType() {
return CountdownType.PRE_RUNNING;
}
}

Datei anzeigen

@ -1,21 +0,0 @@
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.getServer().shutdown();
}
@Override
public CountdownType getType() {
return CountdownType.SPECTATE_OVER;
}
}

Datei anzeigen

@ -1,23 +0,0 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit;
public class FinishTimeOver implements CountdownCallback {
@Override
public String countdownCounting() {
return "bis der Kampf vorbei ist!";
}
@Override
public void countdownFinished() {
Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
FightSystem.getPlugin().setSpectateState(null);
}
@Override
public CountdownType getType() {
return CountdownType.TIME_OVER;
}
}

Datei anzeigen

@ -1,88 +0,0 @@
package me.yaruma.fightsystem.utils.scoreboard;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.ScoreboardManager;
public class Scoreboard {
private final org.bukkit.scoreboard.Scoreboard scoreboard;
private final Objective objective;
public Scoreboard() {
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
this.scoreboard = scoreboardManager.getNewScoreboard();
this.objective = scoreboard.registerNewObjective("AAA", "BBB");
}
public void setAutoScoreboard(int delay, Player player) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
private int index = 0;
@Override
public void run() {
FightTeam fightTeam = getIndexDisplay(index);
if (fightTeam != null) {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(fightTeam.getName());
for (FightPlayer fp : fightTeam.getPlayers()) {
if(!fp.isOut())
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
}
index++;
} else {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Kampf");
if (Config.Timeout) {
int fightTime = FightSystem.getPlugin().getFightTime();
if (fightTime >= 60)
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
else
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
}
if (Config.Entern)
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
if (Config.PercentSystem){
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: §c" + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: §c" + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0);
}
index = 0;
}
player.setScoreboard(scoreboard);
}
}, 0, delay);
}
private FightTeam getIndexDisplay(int index) {
if(index == 0) {
return Fight.redTeam;
}
if(index == 1) {
return Fight.blueTeam;
}
if(index == 2) {
return null;
}
return null;
}
}

Datei anzeigen

@ -1,50 +0,0 @@
package me.yaruma.fightsystem.winconditions;
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.Config;
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;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Config.AllDead) return;
if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
instance.setSpectateState(Fight.getOpposite(fightTeam));
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Config.AllDead) return;
if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
instance.setSpectateState(Fight.getOpposite(fightTeam));
}
}
}

Datei anzeigen

@ -1,51 +0,0 @@
package me.yaruma.fightsystem.winconditions;
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.Config;
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;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Config.CaptainDead) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!");
instance.setSpectateState(Fight.getOpposite(fightTeam));
return;
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Config.CaptainDead) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
fightTeam.getFightPlayer(player).setOut(true);
if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
instance.setSpectateState(Fight.getOpposite(fightTeam));
}
}
}

Datei anzeigen

@ -1,21 +0,0 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoneEntern;
import org.bukkit.Sound;
public class WinconditionEntern {
private static final FightSystem instance = FightSystem.getPlugin();
public static void entern() {
if(!Config.Entern) return;
Countdown countdownTimeOver = new Countdown(Config.EnterPhaseBegin, new FinishNoneEntern(), Sound.BLOCK_NOTE_PLING, false);
countdownTimeOver.startTimer(instance);
}
}

Datei anzeigen

@ -1,121 +0,0 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.HashSet;
import java.util.Iterator;
public class WinconditionTechKO {
private static HashSet<Location> teamRedWater = new HashSet<>();
private static HashSet<Location> teamBlueWater = new HashSet<>();
private static int taskID;
public static void addWater() {
if(!Config.TechKO) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
teamRedWater.clear();
teamBlueWater.clear();
int redMinX = Config.TeamRedCornerX;
int redMinY = Config.TeamRedCornerY;
int redMinZ = Config.TeamRedCornerZ;
int redMaxX = (redMinX + Config.SchemsizeX);
int redMaxY = (redMinY+ Config.SchemsizeY);
int redMaxZ = (redMinZ + Config.SchemsizeZ);
int blueMinX = Config.TeamBlueCornerX;
int blueMinY = Config.TeamBlueCornerY;
int blueMinZ = Config.TeamBlueCornerZ;
int blueMaxX = (blueMinX + Config.SchemsizeX);
int blueMaxY = (blueMinY + Config.SchemsizeY);
int blueMaxZ = (blueMinZ + Config.SchemsizeZ);
//Team Red
for(int x = redMinX; x <= redMaxX; x++) {
for(int y = redMinY; y <= redMaxY; y++) {
for(int z = redMinZ; z <= redMaxZ; z++) {
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z);
if(location.getBlock().getType() == Material.WATER
|| location.getBlock().getType() == Material.STATIONARY_WATER)
teamRedWater.add(location);
}
}
}
//Team Blue
for(int x = blueMinX; x <= blueMaxX; x++) {
for(int y = blueMinY; y <= blueMaxY; y++) {
for(int z = blueMinZ; z <= blueMaxZ; z++) {
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z);
if(location.getBlock().getType() == Material.WATER
|| location.getBlock().getType() == Material.STATIONARY_WATER)
teamBlueWater.add(location);
}
}
}
if(teamRedWater.isEmpty()) {
Bukkit.getScheduler().cancelTask(getTaskID());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
FightSystem.getPlugin().getWaterRemover().stop();
} else if(teamBlueWater.isEmpty()) {
Bukkit.getScheduler().cancelTask(getTaskID());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
FightSystem.getPlugin().getWaterRemover().stop();
}
}
public static void removeWater() {
if(!Config.TechKO) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
//Team Red
Iterator itrRed = teamRedWater.iterator();
while (itrRed.hasNext()) {
Location location = (Location) itrRed.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) {
itrRed.remove();
}
}
if(teamRedWater.isEmpty()) {
Bukkit.getScheduler().cancelTask(getTaskID());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
FightSystem.getPlugin().getWaterRemover().stop();
}
//Team Blue
Iterator itrBlue = teamBlueWater.iterator();
while (itrBlue.hasNext()) {
Location location = (Location) itrBlue.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) {
itrBlue.remove();
}
}
if(teamBlueWater.isEmpty()) {
Bukkit.getScheduler().cancelTask(getTaskID());
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
FightSystem.getPlugin().getWaterRemover().stop();
}
}
public static void startAutoChecker() {
if(!Config.TechKO) return;
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 400, 400);
}
public static int getTaskID() {
return taskID;
}
}

Datei anzeigen

@ -1,21 +0,0 @@
package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishTimeOver;
import org.bukkit.Sound;
public class WinconditionTimeout {
private static final FightSystem instance = FightSystem.getPlugin();
public static void timeout() {
if(!Config.Timeout) return;
Countdown countdownTimeOver = new Countdown(Config.TimeoutTime, new FinishTimeOver(), Sound.BLOCK_NOTE_BASS, false);
countdownTimeOver.startTimer(instance);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
name: FightSystem name: FightSystem
version: 1.0 version: 1.0
author: [Yaruma3341, Lixfel] author: [Yaruma3341, Lixfel]
main: me.yaruma.fightsystem.FightSystem main: de.steamwar.fightsystem.FightSystem
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit, ProtocolLib] depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit, ProtocolLib]
commands: commands:
@ -11,4 +11,6 @@ commands:
leave: leave:
invite: invite:
ready: ready:
kit: kit:
remove:
leader: