diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 972ab7f7..66e07f7e 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.3.0 + uses: actions/setup-java@v3.5.1 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/downstream.yml b/.github/workflows/downstream.yml index ea613917..93fed296 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -17,10 +17,10 @@ jobs: steps: # Step 1: run a standard checkout action, provided by github - - name: Checkout main - uses: actions/checkout@v3 + - name: Checkout current development branch + uses: actions/checkout@v2 with: - ref: main + ref: development # submodules: 'recursive' ### may be needed in your situation # Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch diff --git a/.github/workflows/java17-maven.yml b/.github/workflows/java17-maven.yml index 6f55c804..b2571e94 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.3.0 + uses: actions/setup-java@v3.5.1 with: java-version: 17 distribution: 'adopt' diff --git a/pom.xml b/pom.xml index a6d8a95e..18babb6e 100644 --- a/pom.xml +++ b/pom.xml @@ -100,8 +100,7 @@ esentialsx-repo https://repo.essentialsx.net/releases/ - - + @@ -128,8 +127,8 @@ - io.papermc.paper - paper-api + me.totalfreedom.scissors + scissors-api 1.17.1-R0.1-SNAPSHOT provided @@ -151,7 +150,7 @@ com.sk89q.worldedit worldedit-bukkit - 7.2.10 + 7.2.12 provided @@ -193,7 +192,7 @@ net.essentialsx EssentialsX - 2.19.4 + 2.19.6 provided @@ -207,17 +206,10 @@ org.javassist javassist - 3.29.0-GA + 3.29.1-GA compile - - me.totalfreedom - tfguilds - 2021.06-RC2 - provided - - org.jetbrains annotations @@ -235,7 +227,7 @@ org.junit.jupiter junit-jupiter - 5.8.2 + 5.9.0 compile diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java index 2156af99..fd8c3d8d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java @@ -136,7 +136,7 @@ public class ChatManager extends FreedomService event.setFormat(format); // Send to discord - if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player)) + if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted()) { plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message)); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 31dff85b..bcab4b04 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -19,7 +19,6 @@ import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge; import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge; import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge; import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge; -import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge; import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge; import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge; import me.totalfreedom.totalfreedommod.caging.Cager; @@ -128,7 +127,6 @@ public class TotalFreedomMod extends JavaPlugin public EssentialsBridge esb; public LibsDisguisesBridge ldb; public CoreProtectBridge cpb; - public TFGuildsBridge tfg; public WorldEditBridge web; public WorldGuardBridge wgb; @@ -342,7 +340,6 @@ public class TotalFreedomMod extends JavaPlugin cpb = new CoreProtectBridge(); esb = new EssentialsBridge(); ldb = new LibsDisguisesBridge(); - tfg = new TFGuildsBridge(); web = new WorldEditBridge(); wgb = new WorldGuardBridge(); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index 746ce186..492deea9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -71,7 +71,7 @@ public class BlockBlocker extends FreedomService } case STRUCTURE_BLOCK: { - if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean()) + if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean()) { player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled."); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); @@ -81,7 +81,7 @@ public class BlockBlocker extends FreedomService } case JIGSAW: { - if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean()) + if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean()) { player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled."); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); @@ -89,6 +89,16 @@ public class BlockBlocker extends FreedomService } break; } + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: + case COMMAND_BLOCK: + if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean()) + { + player.sendMessage(ChatColor.GRAY + "Command blocks are disabled."); + player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); + event.setCancelled(true); + } + break; case GRINDSTONE: { if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean()) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java index fb3713cd..bc2ec9ba 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java @@ -4,7 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; - +/* TODO This will have to be changed from com.github.atlasmediagroup.scissors to me.totalfreedom.scissors when we migrate to 1.19 */ +import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent; import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; @@ -20,15 +21,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockGrowEvent; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.block.*; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; @@ -117,6 +110,28 @@ public class EventBlocker extends FreedomService event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue()); } + @EventHandler(priority = EventPriority.HIGH) + public void onBlockExplode(BlockExplodeEvent event) + { + if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) + { + event.setCancelled(true); + return; + } + + event.setYield(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onMasterBlockFire(MasterBlockFireEvent event) + { + if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean()) + { + event.setCancelled(true); + event.getAt().getBlock().setType(Material.CAKE); + } + } + @EventHandler(priority = EventPriority.HIGH) public void onEntityCombust(EntityCombustEvent event) { @@ -150,7 +165,7 @@ public class EventBlocker extends FreedomService Entity entity = event.getEntity(); if (entity instanceof Tameable) { - if (((Tameable)entity).isTamed()) + if (((Tameable) entity).isTamed()) { event.setCancelled(true); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 17f6c5fe..6a70f7d4 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -69,24 +69,17 @@ public class InteractBlocker extends FreedomService private void handleRightClick(PlayerInteractEvent event) { final Player player = event.getPlayer(); + final Block clickedBlock = event.getClickedBlock(); - if (event.getClickedBlock() != null) + if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean()) { - if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR)) - { - event.setCancelled(true); - event.getPlayer().closeInventory(); - } + event.setCancelled(true); + return; } if (Groups.SPAWN_EGGS.contains(event.getMaterial())) { event.setCancelled(true); - Block clickedBlock = event.getClickedBlock(); - if (clickedBlock == null) - { - return; - } EntityType eggType = null; try { @@ -104,7 +97,7 @@ public class InteractBlocker extends FreedomService { // } - if (eggType != null) + if (eggType != null && clickedBlock != null) { clickedBlock.getWorld().spawnEntity(clickedBlock.getLocation().add(event.getBlockFace().getDirection()).add(0.5, 0.5, 0.5), eggType); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/TFGuildsBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/TFGuildsBridge.java deleted file mode 100644 index e315b15c..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/TFGuildsBridge.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.totalfreedom.totalfreedommod.bridge; - -import me.totalfreedom.tfguilds.Common; -import me.totalfreedom.tfguilds.TFGuilds; -import me.totalfreedom.totalfreedommod.FreedomService; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -public class TFGuildsBridge extends FreedomService -{ - public boolean enabled = false; - - @Override - public void onStart() - { - } - - @Override - public void onStop() - { - } - - public boolean isTFGuildsEnabled() - { - if (enabled) - { - return true; - } - - try - { - final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds"); - if (tfGuilds != null && tfGuilds.isEnabled()) - { - if (tfGuilds instanceof TFGuilds) - { - enabled = true; - return true; - } - } - } - catch (NoClassDefFoundError ex) - { - return false; - } - - return false; - } - - public boolean inGuildChat(Player player) - { - if (!isTFGuildsEnabled()) - { - return false; - } - return Common.GUILD_CHAT.contains(player); - } -} \ No newline at end of file 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 712ff7ff..2639b9d5 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", "structureblocks", "jigsaws", "grindstones", + "explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "grindstones", "jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity"); @@ -193,15 +193,9 @@ public class Command_toggle extends FreedomCommand break; } - case "structureblocks": + case "masterblocks": { - toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS); - break; - } - - case "jigsaws": - { - toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS); + toggle("Master blocks are", ConfigEntry.ALLOW_MASTERBLOCKS); break; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java index 598c3d1f..4c58eb10 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java @@ -25,8 +25,6 @@ public enum ConfigEntry ALLOW_BELLS(Boolean.class, "allow.bells"), ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"), ALLOW_MINECARTS(Boolean.class, "allow.minecarts"), - ALLOW_STRUCTURE_BLOCKS(Boolean.class, "allow.structureblocks"), - ALLOW_JIGSAWS(Boolean.class, "allow.jigsaws"), ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"), ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"), ALLOW_SPAWNERS(Boolean.class, "allow.spawners"), @@ -35,6 +33,7 @@ public enum ConfigEntry AUTO_TP(Boolean.class, "allow.auto_tp"), AUTO_CLEAR(Boolean.class, "allow.auto_clear"), ALLOW_GRAVITY(Boolean.class, "allow.gravity"), + ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"), // BLOCKED_CHATCODES(String.class, "blocked_chatcodes"), // diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d0f9ff4d..2aa7a488 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -224,8 +224,6 @@ allow: minecarts: true clearonjoin: false tpronjoin: false - structureblocks: false - jigsaws: false grindstones: true jukeboxes: true spawners: false @@ -234,6 +232,7 @@ allow: auto_tp: false auto_clear: false gravity: false + masterblocks: false blocked_commands: #