From 1c0b768e4f95365d1dc3c0637a53b5ba56a36463 Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Sun, 8 Jan 2023 05:31:11 +1100 Subject: [PATCH 1/3] Add logging to ro command - FS-233 (#282) * Add logging to ro command - FS-233 * Create a variable for API instead of calling method every time Co-authored-by: Paldiu Co-authored-by: Ryan --- .../totalfreedommod/command/Command_ro.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java index e51dc061..90940278 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java @@ -5,6 +5,7 @@ import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.Groups; +import net.coreprotect.CoreProtectAPI; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -22,7 +23,7 @@ import org.bukkit.entity.Player; public class Command_ro extends FreedomCommand { - public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius) + private int removeBlocks(Location center, Material material, int radius, String user) { int affected = 0; @@ -35,11 +36,17 @@ public class Command_ro extends FreedomCommand { Block block = centerBlock.getRelative(xOffset, yOffset, zOffset); BlockData data = block.getBlockData(); + CoreProtectAPI cpAPI = plugin.cpb.getCoreProtectAPI(); + if (block.getLocation().distanceSquared(center) < (radius * radius)) { - if (fromMaterial.equals(Material.WATER) && data instanceof Waterlogged) + if (material.equals(Material.WATER) && data instanceof Waterlogged waterloggedData) { - Waterlogged waterloggedData = (Waterlogged)data; + if (cpAPI != null) + { + cpAPI.logRemoval(user, block.getLocation(), material, data); + } + if (waterloggedData.isWaterlogged()) { waterloggedData.setWaterlogged(false); @@ -47,12 +54,18 @@ public class Command_ro extends FreedomCommand affected++; continue; } - block.setType(toMaterial); + + block.setType(Material.AIR); affected++; } - else if (block.getType().equals(fromMaterial)) + else if (block.getType().equals(material)) { - block.setType(toMaterial); + if (cpAPI != null) + { + cpAPI.logRemoval(user, block.getLocation(), material, data); + } + + block.setType(Material.AIR); affected++; } } @@ -155,7 +168,7 @@ public class Command_ro extends FreedomCommand for (final Material material : materials) { - affected += replaceBlocks(player.getLocation(), material, Material.AIR, radius); + affected += removeBlocks(player.getLocation(), material, radius, sender.getName()); } } } @@ -166,7 +179,7 @@ public class Command_ro extends FreedomCommand FUtil.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of " + targetPlayer.getName(), false); for (Material material : materials) { - affected += replaceBlocks(targetPlayer.getLocation(), material, Material.AIR, radius); + affected += removeBlocks(targetPlayer.getLocation(), material, radius, sender.getName()); } } } From 3bd177ea6f7a6152f3bd6a577008c451e2b5ff46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:21:19 +0000 Subject: [PATCH 2/3] Bump actions/setup-java from 3.6.0 to 3.9.0 (#291) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.6.0 to 3.9.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.6.0...v3.9.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ryan --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/java17-maven.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f78c7f56..3f65d1a0 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@v3 - name: Setup Java JDK - uses: actions/setup-java@v3.6.0 + uses: actions/setup-java@v3.9.0 with: # The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28 java-version: 17 diff --git a/.github/workflows/java17-maven.yml b/.github/workflows/java17-maven.yml index acfd0653..d4f15b30 100644 --- a/.github/workflows/java17-maven.yml +++ b/.github/workflows/java17-maven.yml @@ -13,7 +13,7 @@ jobs: # Java 16 Builds - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 + uses: actions/setup-java@v3.9.0 with: java-version: 17 distribution: 'adopt' From 71127c31520ea72705955aa16c91de176c7e8359 Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Mon, 20 Feb 2023 23:39:40 +0000 Subject: [PATCH 3/3] Add configuration option for disabling books (#275) FS-458 Co-authored-by: Video Co-authored-by: Paldiu --- .../totalfreedommod/blocking/InteractBlocker.java | 5 +++++ .../totalfreedommod/command/Command_toggle.java | 8 +++++++- .../totalfreedom/totalfreedommod/config/ConfigEntry.java | 1 + src/main/resources/config.yml | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 6a70f7d4..08437c25 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -171,6 +171,11 @@ public class InteractBlocker extends FreedomService } case WRITTEN_BOOK: { + if (ConfigEntry.ALLOW_BOOKS.getBoolean()) + { + break; + } + player.getInventory().clear(player.getInventory().getHeldItemSlot()); player.sendMessage(ChatColor.GRAY + "Books are currently disabled."); event.setCancelled(true); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java index 2639b9d5..43a37446 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java @@ -19,7 +19,7 @@ public class Command_toggle extends FreedomCommand private final List toggles = Arrays.asList( "waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk", "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]", - "explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "grindstones", + "explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "books", "grindstones", "jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity"); @@ -199,6 +199,12 @@ public class Command_toggle extends FreedomCommand break; } + case "books": + { + toggle("Books are", ConfigEntry.ALLOW_BOOKS); + break; + } + case "grindstones": { toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java index 019d7843..aad8c8aa 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java @@ -34,6 +34,7 @@ public enum ConfigEntry AUTO_CLEAR(Boolean.class, "allow.auto_clear"), ALLOW_GRAVITY(Boolean.class, "allow.gravity"), ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"), + ALLOW_BOOKS(Boolean.class, "allow.books"), // BLOCKED_CHATCODES(String.class, "blocked_chatcodes"), // diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dea8a9f3..6631fedb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -220,6 +220,7 @@ allow: auto_clear: false gravity: false masterblocks: false + books: true blocked_commands: #