SteamWar/FightSystem
Archiviert
13
1

Added another water remover

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-03-06 17:09:14 +01:00
Ursprung 6d67cd7f6f
Commit 2ed9685aa4
7 geänderte Dateien mit 76 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -66,8 +66,8 @@ public class FightSystem extends JavaPlugin {
public int fightTime = 0; public int fightTime = 0;
public double damageRed = 0D; public double damageRed = 0.0D;
public double getDamageBlue = 0D; public double getDamageBlue = 0.0D;
public boolean entern = false; public boolean entern = false;
@ -198,6 +198,7 @@ public class FightSystem extends JavaPlugin {
pm.registerEvents(new PlayerRespawnListener(), plugin); pm.registerEvents(new PlayerRespawnListener(), plugin);
pm.registerEvents(new EntityDamageListener(), plugin); pm.registerEvents(new EntityDamageListener(), plugin);
pm.registerEvents(new EntityExplodeListener(), plugin); pm.registerEvents(new EntityExplodeListener(), plugin);
pm.registerEvents(new BlockFromToListener(), plugin);
//WinConditions //WinConditions
if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin); if(fileManager.getBooleanFromConfig("WinConditions.AllDead")) pm.registerEvents(new WinconditionAllDead(), plugin);
@ -293,7 +294,7 @@ public class FightSystem extends JavaPlugin {
this.fightState = FightState.RUNNING; this.fightState = FightState.RUNNING;
Countdown.cancelAllTimers(); Countdown.cancelAllTimers();
getWaterRemover().start(); //getWaterRemover().start();
setAllPlayersGM(GameMode.SURVIVAL); setAllPlayersGM(GameMode.SURVIVAL);
@ -332,16 +333,15 @@ public class FightSystem extends JavaPlugin {
} }
} else { } else {
//Keine Message! Wird in FinishTimeOver gesendet! //Keine Message! Wird in FinishTimeOver gesendet!
for(FightPlayer fightPlayer : winFightTeam.getPlayers()) { for(FightPlayer fightPlayer : Fight.getRedTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
} }
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) { for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided")); CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
} }
} }
Countdown.cancelAllTimers();
Countdown countdown = new Countdown(20*60, new FinishSpectateOver()); Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin()); countdown.startTimer(FightSystem.getPlugin());
} }

Datei anzeigen

@ -15,6 +15,8 @@ import java.util.List;
public class WaterRemover { public class WaterRemover {
/*
private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>(); private List<AbstractMap.SimpleEntry<Location, Integer>> explodedBlocks = new ArrayList<AbstractMap.SimpleEntry<Location, Integer>>();
private List<Block> waterList = new ArrayList<Block>(); private List<Block> waterList = new ArrayList<Block>();
private BukkitTask task; private BukkitTask task;
@ -103,4 +105,6 @@ public class WaterRemover {
this.collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks); this.collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
} }
*/
} }

Datei anzeigen

@ -0,0 +1,40 @@
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);
}
}
}

Datei anzeigen

@ -12,8 +12,8 @@ public class EntityExplodeListener implements Listener {
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
for(Block block : event.blockList()) { for(Block block : event.blockList()) {
if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER) //if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER)
FightSystem.getPlugin().getWaterRemover().add(block.getLocation()); //FightSystem.getPlugin().getWaterRemover().add(block.getLocation());
} }
} }

Datei anzeigen

@ -16,6 +16,8 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
@ -54,10 +56,10 @@ public class WorldEdit {
} }
} }
public static int countBlocks(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BaseBlock baseBlock) { 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(player.getWorld()); World weWorld = new BukkitWorld(world);
EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build(); EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build();
CuboidSelection cuboidSelection = new CuboidSelection(player.getWorld(), new Location(player.getWorld(), minX, minY, minZ), new Location(player.getWorld(), maxX, maxY, maxZ)); CuboidSelection cuboidSelection = new CuboidSelection(world, new Location(world, minX, minY, minZ), new Location(world, maxX, maxY, maxZ));
Set<BaseBlock> target = new HashSet<>(); Set<BaseBlock> target = new HashSet<>();
target.add(baseBlock); target.add(baseBlock);
try { try {
@ -100,5 +102,18 @@ 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;
}
} }

Datei anzeigen

@ -18,8 +18,6 @@ public class Countdown {
this.time = time; this.time = time;
this.countdownCallback = countdownCallback; this.countdownCallback = countdownCallback;
countdowns.add(this); countdowns.add(this);
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time;
} }
@ -44,6 +42,7 @@ public class Countdown {
break; break;
} }
time--; time--;
FightSystem.getPlugin().fightTime = time;
} }
}, 0, 20); }, 0, 20);
} }

Datei anzeigen

@ -18,6 +18,8 @@ public class WinconditionPercentSystem implements Listener {
FightSystem instance = FightSystem.getPlugin(); FightSystem instance = FightSystem.getPlugin();
FileManager fileManager = instance.getFileManager(); FileManager fileManager = instance.getFileManager();
public static int percentWin = FightSystem.getPlugin().getFileManager().getIntegerFromConfig("WinConditionParams.PercentWin");
private static int schematicSize = private static int schematicSize =
Math.abs( Math.abs(
FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") * FightSystem.getPlugin().getFileManager().getIntegerFromConfig("Arena.Schemsize.x") *
@ -26,18 +28,15 @@ public class WinconditionPercentSystem implements Listener {
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
Bukkit.broadcastMessage("boom");
if(!Methods.isEnabled("WinConditions.PercentSystem")) return; if(!Methods.isEnabled("WinConditions.PercentSystem")) return;
Bukkit.broadcastMessage("enabled");
Entity entity = event.getEntity(); Entity entity = event.getEntity();
//Team 1 / Rot //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"))) { 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(); team1DestroyedBlocks = team1DestroyedBlocks + event.blockList().size();
Bukkit.broadcastMessage("red");
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize; double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
Bukkit.broadcastMessage(" " + destroyPercent); instance.damageRed = destroyPercent;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) { if(destroyPercent >= percentWin) {
instance.setSpectateState(Fight.blueTeam); instance.setSpectateState(Fight.blueTeam);
} }
return; return;
@ -47,7 +46,7 @@ public class WinconditionPercentSystem implements Listener {
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"))) { 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(); team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize; double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) { if(destroyPercent >= percentWin) {
instance.setSpectateState(Fight.redTeam); instance.setSpectateState(Fight.redTeam);
} }
return; return;