From 882336d910aef019811eb400844a77c942c83090 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 6 Dec 2019 22:51:26 +0100 Subject: [PATCH 1/4] added block-replacer as option --- .../src/de/steamwar/fightsystem/Config.java | 4 ++++ FightSystem_Main/src/config.yml | 2 ++ .../de/steamwar/fightsystem/FightSystem.java | 2 ++ .../steamwar/fightsystem/fight/FightTeam.java | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index ee08967..48b4196 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -63,6 +63,8 @@ public class Config { public static final de.steamwar.sql.SchematicType SchematicType; public static final boolean TeamRedRotate; public static final boolean TeamBlueRotate; + public static final boolean ReplaceObsidian; + public static final boolean ReplaceBedrock; //team parameter public static final String TeamRedName; @@ -143,6 +145,8 @@ public class Config { SchematicDirectory = config.getString("Schematic.Directory"); SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType")); boolean rotate = config.getBoolean("Schematic.Rotate"); + ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian"); + ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock"); TeamRedPrefix = config.getString("Output.TeamRedPrefix"); TeamBluePrefix = config.getString("Output.TeamBluePrefix"); diff --git a/FightSystem_Main/src/config.yml b/FightSystem_Main/src/config.yml index ae53ebe..a71e4a3 100644 --- a/FightSystem_Main/src/config.yml +++ b/FightSystem_Main/src/config.yml @@ -26,6 +26,8 @@ Schematic: Directory: /home/netuser/schematics/ SchematicType: airship Rotate: boolean + ReplaceObsidian: boolean + ReplaceBedrock: boolean Output: TeamRedName: Team1 TeamRedPrefix: §c diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 01378c7..3fe5251 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -107,6 +107,8 @@ public class FightSystem extends JavaPlugin { new PreRunningCountdown(); + Fight.getRedTeam().replaceSync(); + new WinconditionAllDead(); new WinconditionCaptainDead(); new WinconditionWaterTechKO(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index be15e27..9d14e6b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -14,6 +14,7 @@ import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; import javafx.util.Pair; import org.bukkit.*; +import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -299,6 +300,26 @@ public class FightTeam implements IFightTeam{ } } + public void replaceSync() { + 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)); + + for(int x = minPoint.getBlockX(); x <= maxPoint.getBlockX(); x++) { + for(int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ(); z++) { + 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); + } + } + } + } + public Set getInvited() { return invited; } -- 2.39.5 From efc7af3e55b36527169eb143398962c7536b08f0 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 6 Dec 2019 22:52:03 +0100 Subject: [PATCH 2/4] hotfix --- FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java | 1 + 1 file changed, 1 insertion(+) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 3fe5251..fcd90d7 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -108,6 +108,7 @@ public class FightSystem extends JavaPlugin { new PreRunningCountdown(); Fight.getRedTeam().replaceSync(); + Fight.getBlueTeam().replaceSync(); new WinconditionAllDead(); new WinconditionCaptainDead(); -- 2.39.5 From 0fc5730cf5aee8aafb77e8fe66afe3970405d0bb Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 9 Dec 2019 20:37:18 +0100 Subject: [PATCH 3/4] code cleanup; performance update --- .../src/de/steamwar/fightsystem/FightSystem.java | 3 +-- .../src/de/steamwar/fightsystem/fight/Fight.java | 12 ++++++++++++ .../src/de/steamwar/fightsystem/fight/FightTeam.java | 12 ++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index fcd90d7..1ffa994 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -107,8 +107,7 @@ public class FightSystem extends JavaPlugin { new PreRunningCountdown(); - Fight.getRedTeam().replaceSync(); - Fight.getBlueTeam().replaceSync(); + Fight.replaceSync(); new WinconditionAllDead(); new WinconditionCaptainDead(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index 9fab60b..020f896 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -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); + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 9d14e6b..a6a7e43 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -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); } } } -- 2.39.5 From ef78fd72804ff3d054fbba9a6804482d24fb83fd Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 9 Dec 2019 20:40:07 +0100 Subject: [PATCH 4/4] code cleanup --- .../src/de/steamwar/fightsystem/fight/Fight.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index 020f896..a1b820d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -69,13 +69,10 @@ public class Fight { } 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); - } + Fight.getRedTeam().replaceSync(Config.ReplaceObsidian, Material.OBSIDIAN, Material.TNT); + Fight.getBlueTeam().replaceSync(Config.ReplaceObsidian, Material.OBSIDIAN, Material.TNT); + + Fight.getRedTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK); + Fight.getBlueTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK); } } -- 2.39.5