SteamWar/FightSystem
Archiviert
13
1

PercentSystem rework; Issues: #18 #19 #20

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-18 20:05:21 +01:00
Ursprung d956ee7353
Commit 5c56e47732
10 geänderte Dateien mit 90 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,6 @@
Times:
SetupDuration: 0
PreFightDuration: 0
FightDuration: 0
SpectatorDuration: 0
Arena:

Datei anzeigen

@ -8,6 +8,7 @@ import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
import me.yaruma.fightsystem.winconditions.WinconditionAllDead;
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
@ -55,12 +56,6 @@ public class FightSystem extends JavaPlugin {
public int team2cornerZ;
public int team1SchematicBlocks;
public int team2SchematicBlocks;
public int team1DestroyedBlocks;
public int team2DestroyedBlocks;
public void onEnable() {
plugin = this;
@ -248,6 +243,11 @@ public class FightSystem extends JavaPlugin {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
}
}
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
}
}
@ -332,19 +332,4 @@ public class FightSystem extends JavaPlugin {
return team2cornerZ;
}
public int getTeam1SchematicBlocks() {
return team1SchematicBlocks;
}
public int getTeam2SchematicBlocks() {
return team2SchematicBlocks;
}
public int getTeam1DestroyedBlocks() {
return team1DestroyedBlocks;
}
public int getTeam2DestroyedBlocks() {
return team2DestroyedBlocks;
}
}

Datei anzeigen

@ -154,6 +154,7 @@ public class FightTeam {
}
FightSystem.getPlugin().getFightManager().teleportAllToFightSpawn();
WorldEdit.replace(fightTeam.getLeader().getPlayer(), FightSystem.getPlugin().getTeam1cornerX(), FightSystem.getPlugin().getTeam1cornerY(), FightSystem.getPlugin().getTeam1cornerZ(), FightSystem.getPlugin().getSchemsizeX(), FightSystem.getPlugin().getSchemsizeY(), FightSystem.getPlugin().getSchemsizeZ());
WorldEdit.replace(Fight.getOpposite(fightTeam).getLeader().getPlayer(), FightSystem.getPlugin().getTeam2cornerX(), FightSystem.getPlugin().getTeam2cornerY(), FightSystem.getPlugin().getTeam2cornerZ(), FightSystem.getPlugin().getSchemsizeX(), FightSystem.getPlugin().getSchemsizeY(), FightSystem.getPlugin().getSchemsizeZ());
}
} else {
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());

Datei anzeigen

@ -25,16 +25,13 @@ public class PlayerQuitListener implements Listener {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Fight verlassen!");
if(fightTeam.allPlayersOut()) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden...");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §chaben den Kampf verlassen! \n §4Stoppe Server in 30 Sekunden...");
Countdown countdown = new Countdown(30*20, new FinishNoPlayersOnline());
countdown.startTimer(FightSystem.getPlugin());
return;
} else {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von §6" + fightTeam.getLeader().getPlayer() + " §csind tot oder haben den Kampf verlassen! \n §60 Sekunden Zeit zum Begutachten!");
Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin());
FightSystem.getPlugin().setSpectateState(Fight.getOpposite(fightTeam));
}
}
}

Datei anzeigen

@ -10,6 +10,11 @@ import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World;
import 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.Location;
import org.bukkit.entity.Player;
@ -44,7 +49,9 @@ public class WorldEdit {
public static void pasteSchematic(File file, World world, Vector vector, boolean allowUndo, boolean pasteAir, AffineTransform affineTransform) {
try {
FaweAPI.load(file).paste(world, vector, allowUndo, pasteAir, affineTransform).flushQueue();
} catch (IOException e) { }
} catch (IOException e) {
e.printStackTrace();
}
}
public static int countBlocks(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BaseBlock baseBlock) {
@ -55,9 +62,28 @@ public class WorldEdit {
target.add(baseBlock);
try {
return editSession.countBlocks(cuboidSelection.getRegionSelector().getRegion(), target);
} catch (IncompleteRegionException e) { }
} catch (IncompleteRegionException e) {
e.printStackTrace();
}
return 0;
}
public static void sendPlayerScheamticList(File folder, int currentPage, int filesPerPage, Player player) {
File[] listOfFiles = folder.listFiles();
int pages = listOfFiles.length / filesPerPage;
for(int i = listOfFiles.length; i <= (currentPage * 10) + 10; i++) {
player.sendMessage(listOfFiles[i].toString());
TextComponent message = new TextComponent(listOfFiles[i].toString());
message.setColor(ChatColor.AQUA);
message.setBold(true);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "")); //COMMAND MISSING
}
}
}

Datei anzeigen

@ -16,9 +16,12 @@ public class FinishPreRunning implements CountdownCallback {
@Override
public void countdownFinished() {
FightSystem.getPlugin().setRunningState();
int time = fileManager.getIntegerFromConfig("Times.FightDuration");
Countdown countdown = new Countdown(time, new FinishTimeOver());
countdown.startTimer(FightSystem.getPlugin());
if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) {
int time = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
Countdown countdown = new Countdown(time, new FinishTimeOver());
countdown.startTimer(FightSystem.getPlugin());
}
Bukkit.broadcastMessage("§aArena freigegeben!");
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package me.yaruma.fightsystem.utils.countdown;
import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit;
public class FinishTimeOver implements CountdownCallback {
@ -12,5 +13,6 @@ public class FinishTimeOver implements CountdownCallback {
@Override
public void countdownFinished() {
Bukkit.broadcastMessage("§aZeit abgelaufen!");
FightSystem.getPlugin().setSpectateState(null);
}
}

Datei anzeigen

@ -9,6 +9,7 @@ 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 {
@ -29,5 +30,19 @@ public class WinconditionAllDead implements Listener {
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Methods.isEnabled("WinConditions.AllDead")) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
if(fightTeam.allPlayersOut()) {
instance.setSpectateState(oppositeFightTeam);
return;
}
}
}

Datei anzeigen

@ -9,6 +9,7 @@ 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 {
@ -32,5 +33,21 @@ public class WinconditionCaptainDead implements Listener {
}
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Methods.isEnabled("WinConditions.CaptainDead")) return;
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
String team = Fight.getRedTeam().isPlayerLeader(player) ? "Red" : "Blue";
if(fightTeam.isPlayerLeader(player)) {
instance.setSpectateState(oppositeFightTeam);
return;
}
}
}

Datei anzeigen

@ -13,9 +13,18 @@ import org.bukkit.event.entity.EntityExplodeEvent;
public class WinconditionPercentSystem implements Listener {
public static int team1DestroyedBlocks;
public static int team2DestroyedBlocks;
FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager();
private static int schematicSize =
Math.abs(
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.y") *
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.z"));
@EventHandler
public void handleEntityExplode(EntityExplodeEvent event) {
if(!Methods.isEnabled("WinConditions.PercentWin")) return;
@ -23,8 +32,8 @@ public class WinconditionPercentSystem implements Listener {
//Team 1 / Rot
if(Region.isInRegion(entity.getLocation(), instance.getTeam1cornerX(), instance.getTeam1cornerY(), instance.getTeam1cornerZ(), instance.getTeam1cornerX() + instance.getSchemsizeX(), instance.getTeam1cornerY() + instance.getSchemsizeY(), instance.getTeam1cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
instance.team1DestroyedBlocks = instance.getTeam1DestroyedBlocks() + event.blockList().size();
double destroyPercent = instance.getTeam1DestroyedBlocks() * 100 / instance.getTeam1SchematicBlocks();
team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.blueTeam);
Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());
@ -35,8 +44,8 @@ public class WinconditionPercentSystem implements Listener {
//Team 2 / Blau
if(Region.isInRegion(entity.getLocation(), instance.getTeam2cornerX(), instance.getTeam1cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
instance.team2DestroyedBlocks = instance.getTeam2DestroyedBlocks() + event.blockList().size();
double destroyPercent = instance.getTeam2DestroyedBlocks() * 100 / instance.getTeam2SchematicBlocks();
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
instance.setSpectateState(Fight.redTeam);
Countdown countdown = new Countdown(fileManager.getIntegerFromConfig("Times.SpectatorDuration"), new FinishSpectateOver());