SteamWar/FightSystem
Archiviert
13
1

code cleanup; performance update

Dieser Commit ist enthalten in:
BuildTools 2019-12-09 20:37:18 +01:00
Ursprung efc7af3e55
Commit 0fc5730cf5
3 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -107,8 +107,7 @@ public class FightSystem extends JavaPlugin {
new PreRunningCountdown();
Fight.getRedTeam().replaceSync();
Fight.getBlueTeam().replaceSync();
Fight.replaceSync();
new WinconditionAllDead();
new WinconditionCaptainDead();

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -66,4 +67,15 @@ public class Fight {
public static void setLevel(int level) {
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level));
}
public static void replaceSync() {
if(Config.ReplaceObsidian) {
Fight.getRedTeam().replaceSync(true, Material.OBSIDIAN, Material.TNT);
Fight.getBlueTeam().replaceSync(true, Material.OBSIDIAN, Material.TNT);
}
if(Config.ReplaceBedrock) {
Fight.getRedTeam().replaceSync(true, Material.BEDROCK, Material.SLIME_BLOCK);
Fight.getBlueTeam().replaceSync(true, Material.BEDROCK, Material.SLIME_BLOCK);
}
}
}

Datei anzeigen

@ -300,7 +300,10 @@ public class FightTeam implements IFightTeam{
}
}
public void replaceSync() {
public void replaceSync(boolean replace, Material target, Material replacement) {
if(!replace)
return;
World world = Bukkit.getWorlds().get(0);
Location minPoint = new Location(world, cornerX, cornerY, cornerZ);
Location maxPoint = new Location(world, (cornerX + Config.SchemsizeX), (cornerY + Config.SchemsizeY), (cornerZ + Config.SchemsizeZ));
@ -310,11 +313,8 @@ public class FightTeam implements IFightTeam{
for(int y = minPoint.getBlockY(); y <= maxPoint.getBlockY(); y++) {
Block block = world.getBlockAt(x, y, z);
if(Config.ReplaceObsidian && block.getType() == Material.OBSIDIAN)
block.setType(Material.TNT);
else if(Config.ReplaceBedrock && block.getType() == Material.BEDROCK)
block.setType(Material.SLIME_BLOCK);
if(block.getType() == target)
block.setType(replacement);
}
}
}