From c288b18afc7a071e01bd0efdcf6add62733346ec Mon Sep 17 00:00:00 2001 From: PryPurity Date: Thu, 2 Jul 2020 02:57:19 -0500 Subject: [PATCH] Cleaned it up a bit more, went back to 3x3 instead of 4 x 4 --- pom.xml | 2 +- .../com/wimbli/WorldBorder/BorderData.java | 10 +++--- .../java/com/wimbli/WorldBorder/Config.java | 5 +-- .../com/wimbli/WorldBorder/WorldFileData.java | 33 ------------------- .../com/wimbli/WorldBorder/WorldFillTask.java | 4 +-- src/main/resources/plugin.yml | 2 +- 6 files changed, 11 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 7a006d7..799a09e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.wimbli.WorldBorder WorldBorder - 2.0.6 + 2.0.7 WorldBorder https://github.com/PryPurity/WorldBorder diff --git a/src/main/java/com/wimbli/WorldBorder/BorderData.java b/src/main/java/com/wimbli/WorldBorder/BorderData.java index 47d95c4..d0c8b7a 100644 --- a/src/main/java/com/wimbli/WorldBorder/BorderData.java +++ b/src/main/java/com/wimbli/WorldBorder/BorderData.java @@ -109,7 +109,7 @@ public class BorderData { safeOpenBlocks.add(Material.OAK_WALL_SIGN); safeOpenBlocks.add(Material.SPRUCE_SIGN); safeOpenBlocks.add(Material.SPRUCE_WALL_SIGN); - } catch (NoSuchFieldError ex) { + } catch (NoSuchFieldError ignored) { } } @@ -390,10 +390,10 @@ public class BorderData { return safe; Material below = world.getBlockAt(X, Y - 1, Z).getType(); - return (safe - && (!safeOpenBlocks.contains(below) || below == Material.WATER) // below target block not open/breathable (so presumably solid), or is water - && !painfulBlocks.contains(below) // below target block not painful - ); + // below target block not open/breathable (so presumably solid), or is water + // below target block not painful + // below target block not painful + return (!safeOpenBlocks.contains(below) || below == Material.WATER) && !painfulBlocks.contains(below); } // find closest safe Y position from the starting position diff --git a/src/main/java/com/wimbli/WorldBorder/Config.java b/src/main/java/com/wimbli/WorldBorder/Config.java index 92a6ff5..572a3f6 100644 --- a/src/main/java/com/wimbli/WorldBorder/Config.java +++ b/src/main/java/com/wimbli/WorldBorder/Config.java @@ -96,8 +96,8 @@ public class Config { public static void setBorderCorners(String world, double x1, double z1, double x2, double z2, Boolean shapeRound, boolean wrap) { double radiusX = Math.abs(x1 - x2) / 2; double radiusZ = Math.abs(z1 - z2) / 2; - double x = ((x1 < x2) ? x1 : x2) + radiusX; - double z = ((z1 < z2) ? z1 : z2) + radiusZ; + double x = (Math.min(x1, x2)) + radiusX; + double z = (Math.min(z1, z2)) + radiusZ; setBorder(world, new BorderData(x, z, (int) Math.round(radiusX), (int) Math.round(radiusZ), shapeRound, wrap), true); } @@ -221,6 +221,7 @@ public class Config { return; World world = loc.getWorld(); + assert world != null; world.playEffect(loc, Effect.ENDER_SIGNAL, 0); world.playEffect(loc, Effect.ENDER_SIGNAL, 0); world.playEffect(loc, Effect.SMOKE, 4); diff --git a/src/main/java/com/wimbli/WorldBorder/WorldFileData.java b/src/main/java/com/wimbli/WorldBorder/WorldFileData.java index e9d7dd4..0a56243 100644 --- a/src/main/java/com/wimbli/WorldBorder/WorldFileData.java +++ b/src/main/java/com/wimbli/WorldBorder/WorldFileData.java @@ -3,13 +3,8 @@ package com.wimbli.WorldBorder; import org.bukkit.World; import org.bukkit.entity.Player; -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; import java.io.File; import java.io.FileFilter; -import java.io.IOException; -import java.util.List; import java.util.*; // image output stuff, for debugging method at bottom of this file @@ -157,7 +152,6 @@ public class WorldFileData { } regionChunkExistence.put(region, data); - testImage(region, data); return data; } @@ -168,33 +162,6 @@ public class WorldFileData { notifyPlayer.sendMessage("[WorldData] " + text); } - // crude chunk map PNG image output, for debugging - private void testImage(CoordXZ region, List data) { - int width = 32; - int height = 32; - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2 = bi.createGraphics(); - int current = 0; - g2.setColor(Color.BLACK); - - for (int x = 0; x < 32; ++x) { - for (int z = 0; z < 32; ++z) { - if (data.get(current)) - g2.fillRect(x, z, x + 1, z + 1); - current++; - } - } - - File f = new File("region_" + region.x + "_" + region.z + "_.png"); - Config.log(f.getAbsolutePath()); - try { - // png is an image format (like gif or jpg) - ImageIO.write(bi, "png", f); - } catch (IOException ex) { - Config.log("[SEVERE]" + ex.getLocalizedMessage()); - } - } - // file filter used for region files private static class ExtFileFilter implements FileFilter { String ext; diff --git a/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java b/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java index 8c68f9c..a6a4960 100644 --- a/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java +++ b/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java @@ -209,7 +209,7 @@ public class WorldFillTask implements Runnable { if (chunksProcessedLastTick > 0 || pendingChunks.size() > 0) { // Note we generally queue 3 chunks, so real numbers are 1/3 of chunksProcessedLastTick and pendingchunks.size // Trying 4 chunks - int chunksExpectedToGetProcessed = (chunksProcessedLastTick - pendingChunks.size()) / 4 + 4; + int chunksExpectedToGetProcessed = (chunksProcessedLastTick - pendingChunks.size()) / 3 + 3; if (chunksExpectedToGetProcessed < chunksToProcess) chunksToProcess = chunksExpectedToGetProcessed; } @@ -542,8 +542,6 @@ public class WorldFillTask implements Runnable { // toggle "force loaded" flag on for chunk to prevent it from being unloaded while we need it world.setChunkForceLoaded(x, z, true); - // alternatively for 1.14.4+ - //world.addPluginChunkTicket(x, z, pluginInstance); } }); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6721470..e5196db 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: WorldBorder authors: [Brettflan, PryPurity] description: Efficient, feature-rich plugin for limiting the size of your worlds. -version: 2.0.6 +version: 2.0.7 api-version: 1.13 main: com.wimbli.WorldBorder.WorldBorder softdepend: