Added another water remover
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
2ed9685aa4
Commit
3d8b05df34
@ -1,449 +0,0 @@
|
||||
package me.yaruma.fightsystem;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import de.diamant.hunjy.CoinSystem.CoinSystem;
|
||||
import me.yaruma.fightsystem.commands.AkCommand;
|
||||
import me.yaruma.fightsystem.fight.*;
|
||||
import me.yaruma.fightsystem.kit.KitManager;
|
||||
import me.yaruma.fightsystem.listener.*;
|
||||
import me.yaruma.fightsystem.manager.FileManager;
|
||||
import me.yaruma.fightsystem.utils.WorldEdit;
|
||||
import me.yaruma.fightsystem.utils.countdown.*;
|
||||
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
|
||||
import me.yaruma.fightsystem.winconditions.WinconditionAllDead;
|
||||
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
|
||||
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
|
||||
public static String PREFIX = "[FightSystem] ";
|
||||
public static String NOPERM = PREFIX + "§4Du darfst das nicht!";
|
||||
|
||||
private static FightSystem plugin;
|
||||
private FileManager fileManager;
|
||||
private FightManager fightManager;
|
||||
private Scoreboard scoreboard;
|
||||
private KitManager kitManager;
|
||||
private WaterRemover waterRemover;
|
||||
|
||||
private FightState fightState;
|
||||
|
||||
|
||||
public Location Team1SpawnLoc = null;
|
||||
public Location Team2SpawnLoc = null;
|
||||
public Location SpecSpawnLoc = null;
|
||||
public Location Team1PasteLoc = null;
|
||||
public Location Team2PasteLoc = null;
|
||||
|
||||
public int ArenaMinX;
|
||||
public int ArenaMaxX;
|
||||
public int ArenaMinZ;
|
||||
public int ArenaMaxZ;
|
||||
|
||||
public int schemsizeX;
|
||||
public int schemsizeY;
|
||||
public int schemsizeZ;
|
||||
|
||||
public int team1cornerX;
|
||||
public int team1cornerY;
|
||||
public int team1cornerZ;
|
||||
|
||||
public int team2cornerX;
|
||||
public int team2cornerY;
|
||||
public int team2cornerZ;
|
||||
|
||||
public int underArenaBorder;
|
||||
|
||||
|
||||
public int fightTime = 0;
|
||||
public double damageRed = 0.0D;
|
||||
public double getDamageBlue = 0.0D;
|
||||
|
||||
|
||||
public boolean entern = false;
|
||||
|
||||
public File kits = new File("plugins/" + this.getName(), "kits.data");
|
||||
public FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
|
||||
|
||||
public void saveKitData() {
|
||||
try { getKitData.save(kits); } catch (Exception ex) { }
|
||||
}
|
||||
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
this.fileManager = new FileManager(plugin);
|
||||
this.fightManager = new FightManager();
|
||||
this.scoreboard = new Scoreboard(plugin);
|
||||
this.kitManager = new KitManager();
|
||||
this.waterRemover = new WaterRemover();
|
||||
|
||||
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
|
||||
Fight.getRedTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamRedColor"));
|
||||
Fight.getBlueTeam().setName(fileManager.getStringFromConfig("Output.TeamBlueName"));
|
||||
Fight.getBlueTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamBlueColor"));
|
||||
|
||||
//Load config
|
||||
schemsizeX = fileManager.getIntegerFromConfig("Arena.Schemsize.x");
|
||||
schemsizeY = fileManager.getIntegerFromConfig("Arena.Schemsize.y");
|
||||
schemsizeZ = fileManager.getIntegerFromConfig("Arena.Schemsize.z");
|
||||
|
||||
team1cornerX = fileManager.getIntegerFromConfig("Arena.Team1corner.x");
|
||||
team1cornerY = fileManager.getIntegerFromConfig("Arena.Team1corner.y");
|
||||
team1cornerZ = fileManager.getIntegerFromConfig("Arena.Team1corner.z");
|
||||
|
||||
int team1toTeam2distanceX = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.x");
|
||||
int team1toTeam2distanceY = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.y");
|
||||
int team1toTeam2distanceZ = fileManager.getIntegerFromConfig("Arena.Team1toTeam2distance.z");
|
||||
|
||||
int schem2BorderX = fileManager.getIntegerFromConfig("Arena.Schem2Border.x");
|
||||
int schem2BorderZ = fileManager.getIntegerFromConfig("Arena.Schem2Border.z");
|
||||
|
||||
World world = Bukkit.getWorld(fileManager.getStringFromConfig("Arena.WorldName"));
|
||||
|
||||
underArenaBorder = fileManager.getIntegerFromConfig("Arena.underArenaBorder");
|
||||
|
||||
//Rotate team1corner to edge (min. x, min. y, min. z)
|
||||
if(schemsizeX < 0){
|
||||
schemsizeX = -schemsizeX;
|
||||
team1cornerX -= schemsizeX;
|
||||
}
|
||||
if(schemsizeY < 0){
|
||||
schemsizeY = -schemsizeY;
|
||||
team1cornerY -= schemsizeY;
|
||||
}
|
||||
if(schemsizeZ < 0){
|
||||
schemsizeZ = -schemsizeZ;
|
||||
team1cornerZ -= schemsizeZ;
|
||||
}
|
||||
|
||||
//Compute various positions
|
||||
team2cornerX = team1toTeam2distanceX + team1cornerX;
|
||||
team2cornerY = team1toTeam2distanceY + team1cornerY;
|
||||
team2cornerZ = team1toTeam2distanceZ + team1cornerZ;
|
||||
|
||||
int Team1centerX = team1cornerX + schemsizeX/2;
|
||||
int Team1centerY = team1cornerY;
|
||||
int Team1centerZ = team1cornerZ + schemsizeZ/2;
|
||||
|
||||
int Team2centerX = Team1centerX + team1toTeam2distanceX;
|
||||
int Team2centerY = Team1centerY + team1toTeam2distanceY;
|
||||
int Team2centerZ = Team1centerZ + team1toTeam2distanceZ;
|
||||
|
||||
|
||||
Team1SpawnLoc = new Location(world, Team1centerX, Team1centerY + schemsizeY, Team1centerZ);
|
||||
Team2SpawnLoc = new Location(world, Team2centerX, Team2centerY + schemsizeY, Team2centerZ);
|
||||
SpecSpawnLoc = new Location(world, Team1centerX + team1toTeam2distanceX/2,
|
||||
Team1centerY + team1toTeam2distanceY/2 + schemsizeY/2,
|
||||
Team1centerZ + team1toTeam2distanceZ/2);
|
||||
Team1PasteLoc = new Location(world, Team1centerX, Team1centerY, Team1centerZ);
|
||||
Team2PasteLoc = new Location(world, Team2centerX, Team2centerY, Team2centerZ);
|
||||
|
||||
if(team1toTeam2distanceX > 0){
|
||||
ArenaMinX = team1cornerX - schem2BorderX;
|
||||
ArenaMaxX = team1cornerX + team1toTeam2distanceX + schemsizeX + schem2BorderX;
|
||||
}else{
|
||||
ArenaMinX = team1cornerX + team1toTeam2distanceX - schem2BorderX;
|
||||
ArenaMaxX = team1cornerX + schemsizeX + schem2BorderX;
|
||||
}
|
||||
if(team1toTeam2distanceZ > 0){
|
||||
ArenaMinZ = team1cornerZ - schem2BorderZ;
|
||||
ArenaMaxZ = team1cornerZ + team1toTeam2distanceZ + schemsizeZ + schem2BorderZ;
|
||||
}else{
|
||||
ArenaMinZ = team1cornerZ + team1toTeam2distanceZ - schem2BorderZ;
|
||||
ArenaMaxZ = team1cornerZ + schemsizeZ + schem2BorderZ;
|
||||
}
|
||||
|
||||
loadConfig();
|
||||
|
||||
init();
|
||||
|
||||
fightState = FightState.SETUP;
|
||||
int setupDuration = fileManager.getIntegerFromConfig("Times.NoPlayersOnlineDuration");
|
||||
Countdown countdown = new Countdown(setupDuration, new FinishNoPlayersOnline());
|
||||
countdown.startTimer(getPlugin());
|
||||
|
||||
System.out.println(PREFIX + "§aPlugin gestartet!");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
System.out.println(PREFIX + "§cPlugin deaktiviert!");
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new PlayerJoinListener(), plugin);
|
||||
pm.registerEvents(new PlayerQuitListener(), plugin);
|
||||
pm.registerEvents(new PlayerDeathListener(), plugin);
|
||||
pm.registerEvents(new PlayerInteractListener(), plugin);
|
||||
pm.registerEvents(new PlayerChatListener(), plugin);
|
||||
pm.registerEvents(new BlockPlaceListener(), plugin);
|
||||
pm.registerEvents(new BlockBreakListener(), plugin);
|
||||
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 BlockFromToListener(), plugin);
|
||||
|
||||
//WinConditions
|
||||
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
|
||||
if(fileManager.getBooleanFromConfig("WinConditions.CaptainDead")) pm.registerEvents(new WinconditionCaptainDead(), plugin);
|
||||
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
|
||||
if(fileManager.getBooleanFromConfig("WinConditions.PercentSystem")) pm.registerEvents(new WinconditionPercentSystem(), plugin);
|
||||
|
||||
getCommand("ak").setExecutor(new AkCommand());
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
|
||||
saveDefaultConfig();
|
||||
System.out.println(PREFIX + "config.yml erstellt und geladen!");
|
||||
}
|
||||
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 FightState getCurrentFightState() {
|
||||
return fightState;
|
||||
}
|
||||
|
||||
public FileManager getFileManager() {
|
||||
return this.fileManager;
|
||||
}
|
||||
|
||||
public FightManager getFightManager() {
|
||||
return this.fightManager;
|
||||
}
|
||||
|
||||
public FightState getFightState() {
|
||||
return fightState;
|
||||
}
|
||||
|
||||
public Scoreboard getScoreboard() {
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
public KitManager getKitManager() {
|
||||
return kitManager;
|
||||
}
|
||||
|
||||
public WaterRemover getWaterRemover() {
|
||||
return waterRemover;
|
||||
}
|
||||
|
||||
public void setSetupState() {
|
||||
if(this.fightState == null) {
|
||||
this.fightState = FightState.SETUP;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPreRunningState() {
|
||||
if(this.fightState != FightState.SETUP)
|
||||
return;
|
||||
this.fightState = FightState.PRE_RUNNING;
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
|
||||
Countdown countdown = new Countdown(time, new FinishPreRunning());
|
||||
countdown.startTimer(this);
|
||||
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
|
||||
allFightPlayers.getPlayer().getInventory().clear();
|
||||
}
|
||||
for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) {
|
||||
allFightPlayers.getPlayer().getInventory().clear();
|
||||
}
|
||||
getFightManager().teleportAllToFightSpawn();
|
||||
WorldEdit.replace(Fight.getBlueTeam().getLeader().getPlayer(), team1cornerX, team1cornerY, team1cornerZ, team1cornerX + schemsizeX, team1cornerY + schemsizeY, team1cornerZ + schemsizeZ);
|
||||
WorldEdit.replace(Fight.getRedTeam().getLeader().getPlayer(), team2cornerX, team2cornerY, team2cornerZ, team2cornerX + schemsizeX, team2cornerY + schemsizeY, team2cornerZ + schemsizeZ);
|
||||
}
|
||||
|
||||
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(this.fightState != FightState.PRE_RUNNING)
|
||||
return;
|
||||
this.fightState = FightState.RUNNING;
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
//getWaterRemover().start();
|
||||
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
|
||||
if(fileManager.getBooleanFromConfig("WinConditions.Timeout")) {
|
||||
int timeTimeOver = fileManager.getIntegerFromConfig("WinConditionParams.TimeoutTime");
|
||||
Countdown countdownTimeOver = new Countdown(timeTimeOver, new FinishTimeOver());
|
||||
countdownTimeOver.startTimer(plugin);
|
||||
|
||||
int timeNoEntern = fileManager.getIntegerFromConfig("WinConditionParams.EnterPhaseBegin");
|
||||
Countdown countdownTimeNoEntern = new Countdown(timeNoEntern, new FinishNoneEntern());
|
||||
countdownTimeNoEntern.startTimer(plugin);
|
||||
}
|
||||
Bukkit.broadcastMessage("§aArena freigegeben!");
|
||||
}
|
||||
|
||||
public void setSpectateState(FightTeam winFightTeam) {
|
||||
if(this.fightState != FightState.RUNNING)
|
||||
return;
|
||||
this.fightState = FightState.SPECTATE;
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
setAllPlayersGM(GameMode.SPECTATOR);
|
||||
Bukkit.broadcastMessage(" ");
|
||||
|
||||
if(winFightTeam != null) {
|
||||
|
||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team von §6" + winFightTeam.getLeader().getPlayer().getName() + " §ahat gewonnen!");
|
||||
plugin.getFightManager().teleportAllToFightSpawn();
|
||||
|
||||
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) {
|
||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Win"));
|
||||
}
|
||||
|
||||
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
|
||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Lose"));
|
||||
}
|
||||
} else {
|
||||
//Keine Message! Wird in FinishTimeOver gesendet!
|
||||
for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
|
||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
|
||||
}
|
||||
|
||||
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
|
||||
}
|
||||
}
|
||||
|
||||
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
|
||||
countdown.startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
public int getMoneyToPay(String moneyPath) {
|
||||
return fileManager.getIntegerFromConfig(moneyPath);
|
||||
}
|
||||
|
||||
public static WorldEditPlugin getWorldEditPlugin() {
|
||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
}
|
||||
|
||||
|
||||
public Location getTeam1SpawnLoc() {
|
||||
return Team1SpawnLoc;
|
||||
}
|
||||
|
||||
public Location getTeam2SpawnLoc() {
|
||||
return Team2SpawnLoc;
|
||||
}
|
||||
|
||||
public Location getSpecSpawnLoc() {
|
||||
return SpecSpawnLoc;
|
||||
}
|
||||
|
||||
public Location getTeam1PasteLoc() {
|
||||
return Team1PasteLoc;
|
||||
}
|
||||
|
||||
public Location getTeam2PasteLoc() {
|
||||
return Team2PasteLoc;
|
||||
}
|
||||
|
||||
public int getArenaMinX() {
|
||||
return ArenaMinX;
|
||||
}
|
||||
|
||||
public int getArenaMaxX() {
|
||||
return ArenaMaxX;
|
||||
}
|
||||
|
||||
public int getArenaMinZ() {
|
||||
return ArenaMinZ;
|
||||
}
|
||||
|
||||
public int getArenaMaxZ() {
|
||||
return ArenaMaxZ;
|
||||
}
|
||||
|
||||
public int getSchemsizeX() {
|
||||
return schemsizeX;
|
||||
}
|
||||
|
||||
public int getSchemsizeY() {
|
||||
return schemsizeY;
|
||||
}
|
||||
|
||||
public int getSchemsizeZ() {
|
||||
return schemsizeZ;
|
||||
}
|
||||
|
||||
public int getTeam1cornerX() {
|
||||
return team1cornerX;
|
||||
}
|
||||
|
||||
public int getTeam1cornerY() {
|
||||
return team1cornerY;
|
||||
}
|
||||
|
||||
public int getTeam1cornerZ() {
|
||||
return team1cornerZ;
|
||||
}
|
||||
|
||||
public int getTeam2cornerX() {
|
||||
return team2cornerX;
|
||||
}
|
||||
|
||||
public int getTeam2cornerY() {
|
||||
return team2cornerY;
|
||||
}
|
||||
|
||||
public int getTeam2cornerZ() {
|
||||
return team2cornerZ;
|
||||
}
|
||||
|
||||
public int getUnderArenaBorder() {
|
||||
return underArenaBorder;
|
||||
}
|
||||
|
||||
public int getFightTime() {
|
||||
return fightTime;
|
||||
}
|
||||
|
||||
public double getDamageRed() {
|
||||
return damageRed;
|
||||
}
|
||||
|
||||
public double getGetDamageBlue() {
|
||||
return getDamageBlue;
|
||||
}
|
||||
|
||||
public boolean isEntern() {
|
||||
return entern;
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package me.yaruma.fightsystem.fight;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
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<AbstractMap.SimpleEntry<Location, Integer>>();
|
||||
private List<Block> waterList = new ArrayList<Block>();
|
||||
private BukkitTask task;
|
||||
|
||||
public void start() {
|
||||
this.stop();
|
||||
this.explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>();
|
||||
this.waterList = new ArrayList<Block>();
|
||||
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously((Plugin)FightSystem.getPlugin(), new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
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<Location, Integer>(loc, 0));
|
||||
}
|
||||
|
||||
private void wateredCheck() {
|
||||
for (int i = 0; i < this.explodedBlocks.size(); ++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<Block>();
|
||||
for (int i = this.waterList.size() - 1; i > -1; --i) {
|
||||
Block current = this.waterList.get(i);
|
||||
for (Block removeBlock : this.getSourceBlocksOfWater(current)) {
|
||||
blocksToRemove.add(removeBlock);
|
||||
}
|
||||
if (current.getType() != Material.AIR) continue;
|
||||
this.waterList.remove(i);
|
||||
}
|
||||
Bukkit.getScheduler().runTask((Plugin)FightSystem.getPlugin(), () -> {
|
||||
for (Block block : blocksToRemove) {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Block> getSourceBlocksOfWater(Block startBlock) {
|
||||
ArrayList<Block> water = new ArrayList<Block>();
|
||||
this.collectBlocks(startBlock, water, new ArrayList<Block>());
|
||||
return water;
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.utils.WorldEdit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
public class BlockFromToListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockFromTo(BlockFromToEvent event) {
|
||||
if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) return;
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if(block.getType() != Material.WATER && block.getType() != Material.STATIONARY_WATER) return;
|
||||
|
||||
Location location = event.getToBlock().getLocation();
|
||||
if(WorldEdit.countBlocksInRadius(location,
|
||||
location.getBlockX() - 2,
|
||||
location.getBlockY() - 2,
|
||||
location.getBlockZ() - 2,
|
||||
location.getBlockX() + 2,
|
||||
location.getBlockY() + 2,
|
||||
location.getBlockZ() + 2,
|
||||
Material.WATER)
|
||||
< 8) {
|
||||
event.setCancelled(true);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
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) {
|
||||
for(Block block : event.blockList()) {
|
||||
//if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER)
|
||||
//FightSystem.getPlugin().getWaterRemover().add(block.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -16,8 +16,6 @@ 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.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
@ -56,10 +54,10 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
public static int countBlocks(org.bukkit.World world, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BaseBlock baseBlock) {
|
||||
World weWorld = new BukkitWorld(world);
|
||||
public static int countBlocks(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BaseBlock baseBlock) {
|
||||
World weWorld = new BukkitWorld(player.getWorld());
|
||||
EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build();
|
||||
CuboidSelection cuboidSelection = new CuboidSelection(world, new Location(world, minX, minY, minZ), new Location(world, maxX, maxY, maxZ));
|
||||
CuboidSelection cuboidSelection = new CuboidSelection(player.getWorld(), new Location(player.getWorld(), minX, minY, minZ), new Location(player.getWorld(), maxX, maxY, maxZ));
|
||||
Set<BaseBlock> target = new HashSet<>();
|
||||
target.add(baseBlock);
|
||||
try {
|
||||
@ -102,18 +100,5 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
public static int countBlocksInRadius(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Material except) {
|
||||
int containing = 0;
|
||||
for(int x = minX; x <= maxX; x++) {
|
||||
for(int y = minY; y <= maxY; y++) {
|
||||
for(int z = minZ; z <= maxZ; z++) {
|
||||
Block block = location.getWorld().getBlockAt(x, y, z);
|
||||
if(block.getType() != Material.AIR && block.getType() != except) containing++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return containing;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
package me.yaruma.fightsystem.utils.countdown;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Countdown {
|
||||
|
||||
private static ArrayList<Countdown> countdowns = new ArrayList<>();
|
||||
|
||||
private int time;
|
||||
private CountdownCallback countdownCallback;
|
||||
private int taskID;
|
||||
|
||||
public Countdown(int time, CountdownCallback countdownCallback) {
|
||||
this.time = time;
|
||||
this.countdownCallback = countdownCallback;
|
||||
countdowns.add(this);
|
||||
}
|
||||
|
||||
|
||||
public void startTimer(FightSystem plugin) {
|
||||
BukkitScheduler bukkitScheduler = Bukkit.getServer().getScheduler();
|
||||
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
switch (time) {
|
||||
case 600: case 300:
|
||||
Bukkit.broadcastMessage("§6Noch §a" + time / 60 + " §6Minuten " + countdownCallback.countdownCounting());
|
||||
break;
|
||||
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
|
||||
Bukkit.broadcastMessage("§6Noch §a" + time + " §6Sekunden " + countdownCallback.countdownCounting());
|
||||
break;
|
||||
case 1:
|
||||
Bukkit.broadcastMessage("§6Noch §aeine §6Sekunde " + countdownCallback.countdownCounting());
|
||||
break;
|
||||
case 0:
|
||||
countdownCallback.countdownFinished();
|
||||
break;
|
||||
}
|
||||
time--;
|
||||
FightSystem.getPlugin().fightTime = time;
|
||||
}
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
public void cancelTimer() {
|
||||
Bukkit.getScheduler().cancelTask(this.taskID);
|
||||
countdowns.remove(this);
|
||||
}
|
||||
|
||||
public static void cancelAllTimers() {
|
||||
for(int i = countdowns.size() - 1; i >= 0; i--) {
|
||||
countdowns.get(i).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();
|
||||
}
|
||||
}
|
||||
|
||||
public CountdownType getType() {
|
||||
return countdownCallback.getType();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package me.yaruma.fightsystem.winconditions;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.manager.FileManager;
|
||||
import me.yaruma.fightsystem.utils.Region;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
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();
|
||||
|
||||
public static int percentWin = FightSystem.getPlugin().getFileManager().getIntegerFromConfig("WinConditionParams.PercentWin");
|
||||
|
||||
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.PercentSystem")) return;
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
//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"))) {
|
||||
team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
|
||||
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
|
||||
instance.damageRed = destroyPercent;
|
||||
if(destroyPercent >= percentWin) {
|
||||
instance.setSpectateState(Fight.blueTeam);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Team 2 / Blau
|
||||
if(Region.isInRegion(entity.getLocation(), instance.getTeam2cornerX(), instance.getTeam2cornerY(), instance.getTeam2cornerZ(), instance.getTeam2cornerX() + instance.getSchemsizeX(), instance.getTeam2cornerY() + instance.getSchemsizeY(), instance.getTeam2cornerZ() + instance.getSchemsizeZ(), fileManager.getIntegerFromConfig("Arena.BorderFromSchematic"))) {
|
||||
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
|
||||
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
|
||||
if(destroyPercent >= percentWin) {
|
||||
instance.setSpectateState(Fight.redTeam);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren