Browse Source

Improving config option & spelling for replacer-block

RedstoneFuture 10 months ago
parent
commit
7696bfdaf9

+ 8 - 6
FAWE_Paster/src/main/java/de/butzlabben/missilewars/missile/paste/v1_20/fawe/FAWE_Paster.java

@@ -44,12 +44,13 @@ import java.util.logging.Level;
  */
 public class FAWE_Paster {
 
-    public void pasteMissile(File schematic, Vector locationVec, int rotation, org.bukkit.World world,
-                             Material glassBlockReplace, int replaceRadius, Material replaceMaterial, int replaceTicks, JavaPlugin plugin) {
+    public void pasteMissile(File schematic, Vector locationVec, int rotation, org.bukkit.World world, Material glassBlockReplace, 
+                             int replaceRadius, Material replaceMaterial, int replaceTicks, JavaPlugin plugin, boolean blockUpdate) {
         
         pasteSchematic(schematic, locationVec, rotation, world, plugin);
         
-        // Remove "Replacer-Block" after a short time to update the pasted schematic structure via (normal) WorldEdit:
+        if (!blockUpdate) return;
+        
         new BukkitRunnable() {
             @Override
             public void run() {
@@ -92,12 +93,13 @@ public class FAWE_Paster {
     }
     
     /**
-     * This method removes the temporary "Replacer-Block", so that the (asynchronously) 
-     * paste structure via FAWE gets an update.
+     * This method removes the temporary "Starter-Block", so that the 
+     * (asynchronously on FAWE) pasted schematic structure gets a 
+     * block-update. This remove process happens synchronously for this.
      * 
      * @param locationVec (Vector) the abstract block location
      * @param world (World) the target world for the WorldEdit action
-     * @param replaceRadius (int) the configured "Replace radius" (= half diagonals)
+     * @param replaceRadius (int) the configured "Replace radius" (is calculated like a half-diagonal line here)
      * @param replaceMaterial (Material) the target material for the replacement
      */
     public void removeTempBlock(Vector locationVec, org.bukkit.World world, int replaceRadius, Material replaceMaterial) {

+ 16 - 15
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/Config.java

@@ -31,8 +31,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
 import java.io.File;
 import java.util.*;
 
-import static org.bukkit.Material.JUKEBOX;
-import static org.bukkit.Material.valueOf;
+import static org.bukkit.Material.*;
 
 /**
  * @author Butzlabben
@@ -89,9 +88,10 @@ public class Config {
         cfg.addDefault("missiles.folder", "plugins/MissileWars/missiles");
         cfg.addDefault("shields.folder", "plugins/MissileWars/shields");
 
-        cfg.addDefault("replace.material", JUKEBOX.name());
-        cfg.addDefault("replace.after_ticks", 2);
-        cfg.addDefault("replace.radius", 15);
+        cfg.addDefault("temp_block.enable", false);
+        cfg.addDefault("temp_block.material", NOTE_BLOCK.name());
+        cfg.addDefault("temp_block.remove_after_ticks", 2);
+        cfg.addDefault("temp_block.radius", 8);
         
         cfg.addDefault("game_result.firework", true);
 
@@ -308,25 +308,26 @@ public class Config {
         return cfg.getString("shields.folder");
     }
     
-    /**
-     * This method gets the minecraft material type of the block to start missiles.
-     */
-    public static Material getStartReplace() {
-        String name = cfg.getString("replace.material").toUpperCase();
+    public static boolean isTempBlockEnabled() {
+        return cfg.getBoolean("temp_block.enable");
+    }
+    
+    public static Material getTempBlockMaterial() {
+        String name = cfg.getString("temp_block.material").toUpperCase();
         try {
             return valueOf(name);
         } catch (Exception e) {
-            Logger.WARN.log("Could not use " + name + " as start material!");
+            Logger.WARN.log("Could not use '" + name + "' as temp-block material!");
         }
         return null;
     }
 
-    public static int getReplaceTicks() {
-        return cfg.getInt("replace.after_ticks");
+    public static int getUpdateDelay() {
+        return cfg.getInt("temp_block.remove_after_ticks");
     }
 
-    public static int getReplaceRadius() {
-        return cfg.getInt("replace.radius");
+    public static int getUpdateRadius() {
+        return cfg.getInt("temp_block.radius");
     }
     
     public static boolean isGameResultFirework() {

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/objects/Missile.java

@@ -80,7 +80,7 @@ public class Missile extends SchematicObject {
             }
 
             PasteProvider.getPaster().pasteMissile(getSchematic(), pastePos, rotation, loc.getWorld(),
-                    game.getPlayer(p).getTeam());
+                    game.getPlayer(p).getTeam(), Config.isTempBlockEnabled());
         } catch (Exception e) {
             Logger.ERROR.log("Could not load " + getDisplayName());
             e.printStackTrace();

+ 2 - 2
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/FawePasteProvider.java

@@ -37,9 +37,9 @@ public class FawePasteProvider implements Paster {
     FAWE_Paster paster = new FAWE_Paster();
 
     @Override
-    public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team) {
+    public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team, boolean blockUpdate) {
         paster.pasteMissile(schematic, position, rotation, world, ColorConverter.getGlassFromColorCode(team.getColorCode()),
-                Config.getReplaceRadius(), Config.getStartReplace(), Config.getReplaceTicks(), MissileWars.getInstance());
+                Config.getUpdateRadius(), Config.getTempBlockMaterial(), Config.getUpdateDelay(), MissileWars.getInstance(), blockUpdate);
     }
 
     @Override

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/schematics/paste/Paster.java

@@ -29,7 +29,7 @@ import java.io.File;
  */
 public interface Paster {
 
-    void pasteMissile(File schematic, Vector position, int rotation, org.bukkit.World world, Team team);
+    void pasteMissile(File schematic, Vector position, int rotation, org.bukkit.World world, Team team, boolean blockUpdate);
 
     void pasteSchematic(File schematic, Vector position, int rotation, org.bukkit.World world);
 }