Merge branch 'development' into RELEASE-2023.03

This commit is contained in:
Paul Reilly 2023-03-09 09:13:44 -06:00
commit 3a6e7921cc
7 changed files with 37 additions and 11 deletions

View File

@ -38,7 +38,7 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Java JDK - name: Setup Java JDK
uses: actions/setup-java@v3.6.0 uses: actions/setup-java@v3.9.0
with: 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 # 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 java-version: 17

View File

@ -13,7 +13,7 @@ jobs:
# Java 16 Builds # Java 16 Builds
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v3.6.0 uses: actions/setup-java@v3.9.0
with: with:
java-version: 17 java-version: 17
distribution: 'adopt' distribution: 'adopt'

View File

@ -172,6 +172,11 @@ public class InteractBlocker extends FreedomService
} }
case WRITTEN_BOOK: case WRITTEN_BOOK:
{ {
if (ConfigEntry.ALLOW_BOOKS.getBoolean())
{
break;
}
player.getInventory().clear(player.getInventory().getHeldItemSlot()); player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "Books are currently disabled."); player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -5,6 +5,7 @@ import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import net.coreprotect.CoreProtectAPI;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -22,7 +23,7 @@ import org.bukkit.entity.Player;
public class Command_ro extends FreedomCommand 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; int affected = 0;
@ -35,11 +36,17 @@ public class Command_ro extends FreedomCommand
{ {
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset); Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
BlockData data = block.getBlockData(); BlockData data = block.getBlockData();
CoreProtectAPI cpAPI = plugin.cpb.getCoreProtectAPI();
if (block.getLocation().distanceSquared(center) < (radius * radius)) 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()) if (waterloggedData.isWaterlogged())
{ {
waterloggedData.setWaterlogged(false); waterloggedData.setWaterlogged(false);
@ -47,12 +54,18 @@ public class Command_ro extends FreedomCommand
affected++; affected++;
continue; continue;
} }
block.setType(toMaterial);
block.setType(Material.AIR);
affected++; 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++; affected++;
} }
} }
@ -155,7 +168,7 @@ public class Command_ro extends FreedomCommand
for (final Material material : materials) 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); FUtil.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of " + targetPlayer.getName(), false);
for (Material material : materials) for (Material material : materials)
{ {
affected += replaceBlocks(targetPlayer.getLocation(), material, Material.AIR, radius); affected += removeBlocks(targetPlayer.getLocation(), material, radius, sender.getName());
} }
} }
} }

View File

@ -19,7 +19,7 @@ public class Command_toggle extends FreedomCommand
private final List<String> toggles = Arrays.asList( private final List<String> toggles = Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk", "waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]", "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", "jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
"landmines", "tossmob", "gravity"); "landmines", "tossmob", "gravity");
@ -199,6 +199,12 @@ public class Command_toggle extends FreedomCommand
break; break;
} }
case "books":
{
toggle("Books are", ConfigEntry.ALLOW_BOOKS);
break;
}
case "grindstones": case "grindstones":
{ {
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES); toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);

View File

@ -34,6 +34,7 @@ public enum ConfigEntry
AUTO_CLEAR(Boolean.class, "allow.auto_clear"), AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
ALLOW_GRAVITY(Boolean.class, "allow.gravity"), ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"), ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"),
ALLOW_BOOKS(Boolean.class, "allow.books"),
// //
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"), BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
// //

View File

@ -220,6 +220,7 @@ allow:
auto_clear: false auto_clear: false
gravity: false gravity: false
masterblocks: false masterblocks: false
books: true
blocked_commands: blocked_commands:
# #