Added another water remover
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
6d67cd7f6f
Commit
2ed9685aa4
@ -66,8 +66,8 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
|
||||
public int fightTime = 0;
|
||||
public double damageRed = 0D;
|
||||
public double getDamageBlue = 0D;
|
||||
public double damageRed = 0.0D;
|
||||
public double getDamageBlue = 0.0D;
|
||||
|
||||
|
||||
public boolean entern = false;
|
||||
@ -198,6 +198,7 @@ public class FightSystem extends JavaPlugin {
|
||||
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);
|
||||
@ -293,7 +294,7 @@ public class FightSystem extends JavaPlugin {
|
||||
this.fightState = FightState.RUNNING;
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
getWaterRemover().start();
|
||||
//getWaterRemover().start();
|
||||
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
|
||||
@ -332,16 +333,15 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
} else {
|
||||
//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"));
|
||||
}
|
||||
|
||||
for(FightPlayer fightPlayer : Fight.getOpposite(winFightTeam).getPlayers()) {
|
||||
for(FightPlayer fightPlayer : Fight.getBlueTeam().getPlayers()) {
|
||||
CoinSystem.getCoinsManager(fightPlayer.getPlayer()).addCoins(getMoneyToPay("Money.Undecided"));
|
||||
}
|
||||
}
|
||||
|
||||
Countdown.cancelAllTimers();
|
||||
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
|
||||
countdown.startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ 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;
|
||||
@ -103,4 +105,6 @@ public class WaterRemover {
|
||||
this.collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
40
src/me/yaruma/fightsystem/listener/BlockFromToListener.java
Normale Datei
40
src/me/yaruma/fightsystem/listener/BlockFromToListener.java
Normale Datei
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -12,8 +12,8 @@ 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());
|
||||
//if(block.getType() != Material.WATER || block.getType() != Material.STATIONARY_WATER)
|
||||
//FightSystem.getPlugin().getWaterRemover().add(block.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.TextComponent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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) {
|
||||
World weWorld = new BukkitWorld(player.getWorld());
|
||||
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);
|
||||
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<>();
|
||||
target.add(baseBlock);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ public class Countdown {
|
||||
this.time = time;
|
||||
this.countdownCallback = countdownCallback;
|
||||
countdowns.add(this);
|
||||
|
||||
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +42,7 @@ public class Countdown {
|
||||
break;
|
||||
}
|
||||
time--;
|
||||
FightSystem.getPlugin().fightTime = time;
|
||||
}
|
||||
}, 0, 20);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public class WinconditionPercentSystem implements Listener {
|
||||
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") *
|
||||
@ -26,18 +28,15 @@ public class WinconditionPercentSystem implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||
Bukkit.broadcastMessage("boom");
|
||||
if(!Methods.isEnabled("WinConditions.PercentSystem")) return;
|
||||
Bukkit.broadcastMessage("enabled");
|
||||
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();
|
||||
Bukkit.broadcastMessage("red");
|
||||
double destroyPercent = team1DestroyedBlocks * 100 / schematicSize;
|
||||
Bukkit.broadcastMessage(" " + destroyPercent);
|
||||
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
|
||||
instance.damageRed = destroyPercent;
|
||||
if(destroyPercent >= percentWin) {
|
||||
instance.setSpectateState(Fight.blueTeam);
|
||||
}
|
||||
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"))) {
|
||||
team2DestroyedBlocks = team2DestroyedBlocks + event.blockList().size();
|
||||
double destroyPercent = team2DestroyedBlocks * 100 / schematicSize;
|
||||
if(destroyPercent >= fileManager.getIntegerFromConfig("WinConditionParams.PercentWin")) {
|
||||
if(destroyPercent >= percentWin) {
|
||||
instance.setSpectateState(Fight.redTeam);
|
||||
}
|
||||
return;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren