Merge branch 'version/7.0.x'

# Conflicts:
#	buildSrc/src/main/kotlin/Versions.kt
#	gradle/wrapper/gradle-wrapper.jar
#	gradle/wrapper/gradle-wrapper.properties
#	gradlew.bat
#	worldguard-core/build.gradle.kts
This commit is contained in:
Joo200 2023-03-26 15:17:06 +02:00
commit b67fd01ebd
30 changed files with 411 additions and 491 deletions

View File

@ -1,10 +1,10 @@
object Versions { object Versions {
const val WORLDEDIT = "7.2.10" // const val PISTON = "0.4.3"
const val PISTON = "0.5.7" // const val AUTO_VALUE = "1.6.5"
const val AUTO_VALUE = "1.9" const val WORLDEDIT = "7.2.12"
const val JUNIT = "5.8.1" const val JUNIT = "5.9.1"
const val MOCKITO = "4.3.1" const val MOCKITO = "4.9.0"
const val SQUIRRELID = "0.3.0" const val SQUIRRELID = "0.3.2"
const val GUAVA = "31.0.1-jre" const val GUAVA = "31.1-jre"
const val FINDBUGS = "3.0.2" const val FINDBUGS = "3.0.2"
} }

View File

@ -30,6 +30,7 @@
<allow pkg="org.bstats.charts"/> <allow pkg="org.bstats.charts"/>
<allow pkg="io.papermc.lib"/> <allow pkg="io.papermc.lib"/>
<allow pkg="com.destroystokyo.paper"/> <allow pkg="com.destroystokyo.paper"/>
<allow pkg="io.papermc.paper"/>
<allow pkg="co.aikar.timings.lib" /> <allow pkg="co.aikar.timings.lib" />
<allow pkg="org.spigotmc" /> <allow pkg="org.spigotmc" />
</subpackage> </subpackage>

Binary file not shown.

View File

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

18
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,10 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

181
gradlew.bat vendored
View File

@ -1,89 +1,92 @@
@rem @rem
@rem Copyright 2015 the original author or authors. @rem Copyright 2015 the original author or authors.
@rem @rem
@rem Licensed under the Apache License, Version 2.0 (the "License"); @rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License. @rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at @rem You may obtain a copy of the License at
@rem @rem
@rem https://www.apache.org/licenses/LICENSE-2.0 @rem https://www.apache.org/licenses/LICENSE-2.0
@rem @rem
@rem Unless required by applicable law or agreed to in writing, software @rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS, @rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0 @rem This is normally unused
set APP_HOME=%DIRNAME% set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 set JAVA_EXE=java.exe
if "%ERRORLEVEL%" == "0" goto execute %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo.
echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo Please set the JAVA_HOME variable in your environment to match the echo.
echo location of your Java installation. echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% :findJavaFromJavaHome
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo.
echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo Please set the JAVA_HOME variable in your environment to match the echo.
echo location of your Java installation. echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
goto fail
:execute
@rem Setup the command line :execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell :end
if "%ERRORLEVEL%"=="0" goto mainEnd @rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of :fail
rem the _cmd.exe /c_ return code! rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 rem the _cmd.exe /c_ return code!
exit /b 1 set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
:mainEnd if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
if "%OS%"=="Windows_NT" endlocal exit /b %EXIT_CODE%
:omega :mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -10,11 +10,7 @@
repositories { repositories {
maven { maven {
name = "paper" name = "paper"
url = uri("https://papermc.io/repo/repository/maven-public/") url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "bstats"
url = uri("https://repo.codemc.org/repository/maven-public")
} }
maven { maven {
name = "aikar-timings" name = "aikar-timings"
@ -28,15 +24,15 @@
dependencies { dependencies {
"api"(project(":worldguard-core")) "api"(project(":worldguard-core"))
"compileOnly"("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT") "compileOnly"("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
"runtimeOnly"("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT") { "runtimeOnly"("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT") {
exclude("junit", "junit") exclude("junit", "junit")
} }
"api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false } "api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false }
"implementation"("com.google.guava:guava:${Versions.GUAVA}") "implementation"("com.google.guava:guava:${Versions.GUAVA}")
"compileOnly"("com.sk89q:commandbook:2.3") { isTransitive = false } "compileOnly"("com.sk89q:commandbook:2.3") { isTransitive = false }
"shadeOnly"("io.papermc:paperlib:1.0.7") "shadeOnly"("io.papermc:paperlib:1.0.8")
"shadeOnly"("org.bstats:bstats-bukkit:2.1.0") "shadeOnly"("org.bstats:bstats-bukkit:3.0.1")
"shadeOnly"("co.aikar:minecraft-timings:1.0.4") "shadeOnly"("co.aikar:minecraft-timings:1.0.4")
} }

View File

@ -281,6 +281,7 @@ public void loadConfiguration() {
disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false); disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false); disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false); disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);
disableCopperBlockFade = getBoolean("dynamics.disable-copper-block-fade", false);
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null))); allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
useRegions = getBoolean("regions.enable", true); useRegions = getBoolean("regions.enable", true);

View File

@ -34,6 +34,7 @@
import com.sk89q.worldguard.util.profile.resolver.PaperPlayerService; import com.sk89q.worldguard.util.profile.resolver.PaperPlayerService;
import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent; import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent;
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager; import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
import com.sk89q.worldguard.bukkit.util.report.DatapackReport;
import com.sk89q.worldguard.bukkit.util.report.PerformanceReport; import com.sk89q.worldguard.bukkit.util.report.PerformanceReport;
import com.sk89q.worldguard.bukkit.util.report.PluginReport; import com.sk89q.worldguard.bukkit.util.report.PluginReport;
import com.sk89q.worldguard.bukkit.util.report.SchedulerReport; import com.sk89q.worldguard.bukkit.util.report.SchedulerReport;
@ -239,6 +240,7 @@ public void addPlatformReports(ReportList report) {
report.add(new ServicesReport()); report.add(new ServicesReport());
report.add(new WorldReport()); report.add(new WorldReport());
report.add(new PerformanceReport()); report.add(new PerformanceReport());
if (PaperLib.isPaper()) report.add(new DatapackReport());
} }
@Override @Override

View File

@ -60,6 +60,7 @@
import com.sk89q.worldguard.bukkit.listener.WorldRulesListener; import com.sk89q.worldguard.bukkit.listener.WorldRulesListener;
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager; import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
import com.sk89q.worldguard.bukkit.util.ClassSourceValidator; import com.sk89q.worldguard.bukkit.util.ClassSourceValidator;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.bukkit.util.Events; import com.sk89q.worldguard.bukkit.util.Events;
import com.sk89q.worldguard.commands.GeneralCommands; import com.sk89q.worldguard.commands.GeneralCommands;
import com.sk89q.worldguard.commands.ProtectionCommands; import com.sk89q.worldguard.commands.ProtectionCommands;
@ -419,8 +420,9 @@ public LocalPlayer wrapPlayer(Player player, boolean silenced) {
} }
public Actor wrapCommandSender(CommandSender sender) { public Actor wrapCommandSender(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof Player player) {
return wrapPlayer((Player) sender); if (Entities.isNPC(player)) return null;
return wrapPlayer(player);
} }
try { try {

View File

@ -24,6 +24,7 @@
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration; import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.internal.WGMetadata; import com.sk89q.worldguard.bukkit.internal.WGMetadata;
import com.sk89q.worldguard.bukkit.util.Entities;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -134,8 +135,8 @@ public Object getRootCause() {
@Nullable @Nullable
public Player getFirstPlayer() { public Player getFirstPlayer() {
for (Object object : causes) { for (Object object : causes) {
if (object instanceof Player) { if (object instanceof Player p && !Entities.isNPC(p)) {
return (Player) object; return p;
} }
} }
@ -145,8 +146,8 @@ public Player getFirstPlayer() {
@Nullable @Nullable
public Entity getFirstEntity() { public Entity getFirstEntity() {
for (Object object : causes) { for (Object object : causes) {
if (object instanceof Entity) { if (object instanceof Entity e) {
return (Entity) object; return e;
} }
} }
@ -156,8 +157,8 @@ public Entity getFirstEntity() {
@Nullable @Nullable
public Entity getFirstNonPlayerEntity() { public Entity getFirstNonPlayerEntity() {
for (Object object : causes) { for (Object object : causes) {
if (object instanceof Entity && !(object instanceof Player)) { if (object instanceof Entity e && (!(object instanceof Player) || Entities.isNPC(e))) {
return (Entity) object; return e;
} }
} }
@ -167,8 +168,8 @@ public Entity getFirstNonPlayerEntity() {
@Nullable @Nullable
public Block getFirstBlock() { public Block getFirstBlock() {
for (Object object : causes) { for (Object object : causes) {
if (object instanceof Block) { if (object instanceof Block b) {
return (Block) object; return b;
} }
} }

View File

@ -29,6 +29,7 @@
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration; import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.cause.Cause; import com.sk89q.worldguard.bukkit.cause.Cause;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.config.WorldConfiguration; import com.sk89q.worldguard.config.WorldConfiguration;
import com.sk89q.worldguard.domains.Association; import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.association.DelayedRegionOverlapAssociation; import com.sk89q.worldguard.protection.association.DelayedRegionOverlapAssociation;
@ -124,13 +125,12 @@ protected RegionAssociable createRegionAssociable(Cause cause) {
if (!cause.isKnown()) { if (!cause.isKnown()) {
return Associables.constant(Association.NON_MEMBER); return Associables.constant(Association.NON_MEMBER);
} else if (rootCause instanceof Player) { } else if (rootCause instanceof Player player && !Entities.isNPC(player)) {
return getPlugin().wrapPlayer((Player) rootCause); return getPlugin().wrapPlayer(player);
} else if (rootCause instanceof OfflinePlayer) { } else if (rootCause instanceof OfflinePlayer offlinePlayer) {
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause); return getPlugin().wrapOfflinePlayer(offlinePlayer);
} else if (rootCause instanceof Entity) { } else if (rootCause instanceof Entity entity) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
final Entity entity = (Entity) rootCause;
BukkitWorldConfiguration config = getWorldConfig(entity.getWorld()); BukkitWorldConfiguration config = getWorldConfig(entity.getWorld());
Location loc; Location loc;
if (PaperLib.isPaper() && config.usePaperEntityOrigin) { if (PaperLib.isPaper() && config.usePaperEntityOrigin) {
@ -144,9 +144,9 @@ protected RegionAssociable createRegionAssociable(Cause cause) {
} }
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc), return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc),
config.useMaxPriorityAssociation); config.useMaxPriorityAssociation);
} else if (rootCause instanceof Block) { } else if (rootCause instanceof Block block) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
Location loc = ((Block) rootCause).getLocation(); Location loc = block.getLocation();
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc), return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc),
getWorldConfig(loc.getWorld()).useMaxPriorityAssociation); getWorldConfig(loc.getWorld()).useMaxPriorityAssociation);
} else { } else {

View File

@ -22,8 +22,6 @@
import static com.sk89q.worldguard.bukkit.cause.Cause.create; import static com.sk89q.worldguard.bukkit.cause.Cause.create;
import com.destroystokyo.paper.event.entity.EntityZapEvent; import com.destroystokyo.paper.event.entity.EntityZapEvent;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.cause.Cause; import com.sk89q.worldguard.bukkit.cause.Cause;
import com.sk89q.worldguard.bukkit.event.DelegateEvent; import com.sk89q.worldguard.bukkit.event.DelegateEvent;
@ -142,7 +140,6 @@
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -165,17 +162,6 @@ public class EventAbstractionListener extends AbstractListener {
private final EventDebounce<BlockPistonRetractKey> pistonRetractDebounce = EventDebounce.create(5000); private final EventDebounce<BlockPistonRetractKey> pistonRetractDebounce = EventDebounce.create(5000);
private final EventDebounce<BlockPistonExtendKey> pistonExtendDebounce = EventDebounce.create(5000); private final EventDebounce<BlockPistonExtendKey> pistonExtendDebounce = EventDebounce.create(5000);
private static final boolean HAS_SNAPSHOT_INVHOLDER;
static {
boolean temp;
try {
Inventory.class.getMethod("getHolder", boolean.class);
temp = true;
} catch (NoSuchMethodException e) {
temp = false;
}
HAS_SNAPSHOT_INVHOLDER = temp;
}
/** /**
* Construct the listener. * Construct the listener.
* *
@ -963,12 +949,7 @@ public void onInventoryOpen(InventoryOpenEvent event) {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onInventoryMoveItem(InventoryMoveItemEvent event) { public void onInventoryMoveItem(InventoryMoveItemEvent event) {
InventoryHolder causeHolder; InventoryHolder causeHolder = PaperLib.getHolder(event.getInitiator(), false).getHolder();
if (HAS_SNAPSHOT_INVHOLDER) {
causeHolder = event.getInitiator().getHolder(false);
} else {
causeHolder = event.getInitiator().getHolder();
}
WorldConfiguration wcfg = null; WorldConfiguration wcfg = null;
if (causeHolder instanceof Hopper if (causeHolder instanceof Hopper
@ -982,15 +963,8 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
Entry entry; Entry entry;
if ((entry = moveItemDebounce.tryDebounce(event)) != null) { if ((entry = moveItemDebounce.tryDebounce(event)) != null) {
InventoryHolder sourceHolder; InventoryHolder sourceHolder = PaperLib.getHolder(event.getSource(), false).getHolder();
InventoryHolder targetHolder; InventoryHolder targetHolder = PaperLib.getHolder(event.getDestination(), false).getHolder();
/*if (HAS_SNAPSHOT_INVHOLDER) {
sourceHolder = event.getSource().getHolder(false);
targetHolder = event.getDestination().getHolder(false);
} else {*/
sourceHolder = event.getSource().getHolder();
targetHolder = event.getDestination().getHolder();
//}
Cause cause; Cause cause;
@ -1197,9 +1171,12 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
} }
// Handle created spawn eggs // Handle created spawn eggs
if (item != null && Materials.isSpawnEgg(item.getType())) { if (item != null) {
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), Materials.getEntitySpawnEgg(item.getType()))); EntityType possibleEntityType = Materials.getEntitySpawnEgg(item.getType());
return; if (possibleEntityType != null) {
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), possibleEntityType));
return;
}
} }
// handle water/lava placement // handle water/lava placement

View File

@ -22,6 +22,7 @@
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.util.Entities;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -57,9 +58,9 @@ private boolean isInvincible(LocalPlayer player) {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
Entity victim = event.getEntity(); Entity victim = event.getEntity();
if (Entities.isNPC(victim)) return;
if (victim instanceof Player) { if (victim instanceof Player player) {
Player player = (Player) victim;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (isInvincible(localPlayer)) { if (isInvincible(localPlayer)) {
@ -87,9 +88,9 @@ public void onEntityDamage(EntityDamageEvent event) {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onEntityCombust(EntityCombustEvent event) { public void onEntityCombust(EntityCombustEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (Entities.isNPC(entity)) return;
if (entity instanceof Player) { if (entity instanceof Player player) {
Player player = (Player) entity;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (isInvincible(localPlayer)) { if (isInvincible(localPlayer)) {
@ -100,8 +101,9 @@ public void onEntityCombust(EntityCombustEvent event) {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (event.getEntity() instanceof Player) { if (Entities.isNPC(event.getEntity())) return;
Player player = (Player) event.getEntity();
if (event.getEntity() instanceof Player player) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) { if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) {

View File

@ -25,6 +25,7 @@
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent; import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent; import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.bukkit.util.Materials; import com.sk89q.worldguard.bukkit.util.Materials;
import com.sk89q.worldguard.config.WorldConfiguration; import com.sk89q.worldguard.config.WorldConfiguration;
import com.sk89q.worldguard.protection.association.RegionAssociable; import com.sk89q.worldguard.protection.association.RegionAssociable;
@ -118,24 +119,24 @@ public void onEntityDamage(EntityDamageEvent event) {
World world = entity.getWorld(); World world = entity.getWorld();
if (!isRegionSupportEnabled(world)) return; // Region support disabled if (!isRegionSupportEnabled(world)) return; // Region support disabled
if (Entities.isNPC(entity)) return;
if (!(entity instanceof Player player)) return;
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
if (entity instanceof Player && event.getCause() == DamageCause.FALL) { if (event.getCause() == DamageCause.FALL) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) { if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else { } else if (event.getCause() == DamageCause.FLY_INTO_WALL) {
if (entity instanceof Player && event.getCause() == DamageCause.FLY_INTO_WALL) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity); if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) { event.setCancelled(true);
event.setCancelled(true); return;
return;
}
} }
} }
} }
/** /**

View File

@ -522,8 +522,7 @@ public void onVehicleExit(VehicleExitEvent event) {
if (!isRegionSupportEnabled(vehicle.getWorld())) return; // Region support disabled if (!isRegionSupportEnabled(vehicle.getWorld())) return; // Region support disabled
Entity exited = event.getExited(); Entity exited = event.getExited();
if (vehicle instanceof Tameable && exited instanceof Player) { if (vehicle instanceof Tameable && exited instanceof Player player && !Entities.isNPC(player)) {
Player player = (Player) exited;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (!isWhitelisted(Cause.create(player), vehicle.getWorld(), false)) { if (!isWhitelisted(Cause.create(player), vehicle.getWorld(), false)) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();

View File

@ -697,6 +697,16 @@ public void onBlockFade(BlockFadeEvent event) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (Materials.isUnwaxedCopper(event.getBlock().getType())) {
if (wcfg.disableCopperBlockFade) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.COPPER_FADE))) {
event.setCancelled(true);
return;
}
} }
} }

View File

@ -138,8 +138,7 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (defender instanceof Player) { } else if (defender instanceof Player player && !Entities.isNPC(defender)) {
Player player = (Player) defender;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) { if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
@ -227,8 +226,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
} }
} }
if (defender instanceof Player) { if (defender instanceof Player player && !Entities.isNPC(defender)) {
Player player = (Player) defender;
LocalPlayer localPlayer = getPlugin().wrapPlayer(player); LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
if (wcfg.disableLightningDamage && event.getCause() == DamageCause.LIGHTNING) { if (wcfg.disableLightningDamage && event.getCause() == DamageCause.LIGHTNING) {
@ -289,8 +287,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
} }
WorldConfiguration wcfg = getWorldConfig(defender.getWorld()); WorldConfiguration wcfg = getWorldConfig(defender.getWorld());
if (defender instanceof Player) { if (defender instanceof Player player && !Entities.isNPC(defender)) {
Player player = (Player) defender;
LocalPlayer localPlayer = getPlugin().wrapPlayer(player); LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
@ -363,8 +360,7 @@ public void onEntityDamage(EntityDamageEvent event) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (defender instanceof Player) { } else if (defender instanceof Player player && !Entities.isNPC(defender)) {
Player player = (Player) defender;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (type == DamageCause.WITHER) { if (type == DamageCause.WITHER) {
@ -665,8 +661,8 @@ public void onCreatePortal(PortalCreateEvent event) {
.get(world); .get(world);
if (regionManager == null) return; if (regionManager == null) return;
LocalPlayer associable = null; LocalPlayer associable = null;
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player player) {
associable = getPlugin().wrapPlayer(((Player) event.getEntity())); associable = getPlugin().wrapPlayer(player);
if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(associable, world)) { if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(associable, world)) {
return; return;
} }
@ -745,10 +741,10 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (wcfg.useRegions && ent instanceof Player if (wcfg.useRegions && ent instanceof Player player && !Entities.isNPC(ent)
&& !WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().testState( && !WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().testState(
BukkitAdapter.adapt(ent.getLocation()), BukkitAdapter.adapt(ent.getLocation()),
WorldGuardPlugin.inst().wrapPlayer((Player) ent), WorldGuardPlugin.inst().wrapPlayer(player),
Flags.HEALTH_REGEN)) { Flags.HEALTH_REGEN)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -758,10 +754,11 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
public void onFoodChange(FoodLevelChangeEvent event) { public void onFoodChange(FoodLevelChangeEvent event) {
if (event.getItem() != null) return; if (event.getItem() != null) return;
HumanEntity ent = event.getEntity(); HumanEntity ent = event.getEntity();
if (!(ent instanceof Player)) return; if (Entities.isNPC(ent)) return;
if (!(ent instanceof Player bukkitPlayer)) return;
if (event.getFoodLevel() > ent.getFoodLevel()) return; if (event.getFoodLevel() > ent.getFoodLevel()) return;
LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer((Player) ent); LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer(bukkitPlayer);
WorldConfiguration wcfg = getWorldConfig(ent.getWorld()); WorldConfiguration wcfg = getWorldConfig(ent.getWorld());
if (wcfg.useRegions if (wcfg.useRegions

View File

@ -314,6 +314,7 @@ private void handlePhysicalInteract(PlayerInteractEvent event) {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (com.sk89q.worldguard.bukkit.util.Entities.isNPC(player)) return;
WorldConfiguration wcfg = getWorldConfig(player.getWorld()); WorldConfiguration wcfg = getWorldConfig(player.getWorld());
if (wcfg.useRegions) { if (wcfg.useRegions) {
@ -348,6 +349,7 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (com.sk89q.worldguard.bukkit.util.Entities.isNPC(player)) return;
LocalPlayer localPlayer = getPlugin().wrapPlayer(player); LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
ConfigurationManager cfg = getConfig(); ConfigurationManager cfg = getConfig();
WorldConfiguration wcfg = getWorldConfig(player.getWorld()); WorldConfiguration wcfg = getWorldConfig(player.getWorld());

View File

@ -24,6 +24,7 @@
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.config.WorldConfiguration; import com.sk89q.worldguard.config.WorldConfiguration;
import com.sk89q.worldguard.session.MoveType; import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.util.Locations; import com.sk89q.worldguard.util.Locations;
@ -59,6 +60,7 @@ public void onVehicleMove(VehicleMoveEvent event) {
// Did we move a block? // Did we move a block?
if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) { if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) {
for (Player player : playerPassengers) { for (Player player : playerPassengers) {
if (Entities.isNPC(player)) continue;
LocalPlayer localPlayer = getPlugin().wrapPlayer(player); LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
Location lastValid; Location lastValid;
if ((lastValid = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer) if ((lastValid = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer)

View File

@ -20,6 +20,7 @@
package com.sk89q.worldguard.bukkit.listener.debounce.legacy; package com.sk89q.worldguard.bukkit.listener.debounce.legacy;
import com.sk89q.worldguard.bukkit.listener.debounce.legacy.InventoryMoveItemEventDebounce.Key; import com.sk89q.worldguard.bukkit.listener.debounce.legacy.InventoryMoveItemEventDebounce.Key;
import io.papermc.lib.PaperLib;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -44,18 +45,18 @@ protected static class Key {
private final Object target; private final Object target;
public Key(InventoryMoveItemEvent event) { public Key(InventoryMoveItemEvent event) {
cause = transform(event.getInitiator().getHolder()); cause = transform(PaperLib.getHolder(event.getInitiator(), false).getHolder());
source = transform(event.getSource().getHolder()); source = transform(PaperLib.getHolder(event.getSource(), false).getHolder());
target = transform(event.getDestination().getHolder()); target = transform(PaperLib.getHolder(event.getDestination(), false).getHolder());
} }
private Object transform(InventoryHolder holder) { private Object transform(InventoryHolder holder) {
if (holder instanceof BlockState) { if (holder instanceof BlockState blockState) {
return new BlockMaterialKey(((BlockState) holder).getBlock()); return new BlockMaterialKey(blockState);
} else if (holder instanceof DoubleChest) { } else if (holder instanceof DoubleChest doubleChest) {
InventoryHolder left = ((DoubleChest) holder).getLeftSide(); InventoryHolder left = doubleChest.getLeftSide();
if (left instanceof Chest) { if (left instanceof Chest chest) {
return new BlockMaterialKey(((Chest) left).getBlock()); return new BlockMaterialKey(chest);
} else { } else {
return holder; return holder;
} }
@ -94,8 +95,8 @@ private static class BlockMaterialKey {
private final Block block; private final Block block;
private final Material material; private final Material material;
private BlockMaterialKey(Block block) { private BlockMaterialKey(BlockState block) {
this.block = block; this.block = block.getBlock();
material = block.getType(); material = block.getType();
} }

View File

@ -25,6 +25,7 @@
import com.sk89q.worldguard.bukkit.BukkitPlayer; import com.sk89q.worldguard.bukkit.BukkitPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent; import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.session.AbstractSessionManager; import com.sk89q.worldguard.session.AbstractSessionManager;
import com.sk89q.worldguard.session.Session; import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler; import com.sk89q.worldguard.session.handler.Handler;
@ -81,9 +82,9 @@ public void run() {
@Override @Override
public boolean hasBypass(LocalPlayer player, World world) { public boolean hasBypass(LocalPlayer player, World world) {
if (player instanceof BukkitPlayer) { if (player instanceof BukkitPlayer bukkitPlayer) {
if (((BukkitPlayer) player).getPlayer().hasMetadata("NPC") if (Entities.isNPC(bukkitPlayer.getPlayer())
&& WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).fakePlayerBuildOverride) { && WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).fakePlayerBuildOverride) {
return true; return true;
} }
if (!((BukkitPlayer) player).getPlayer().isOnline()) { if (!((BukkitPlayer) player).getPlayer().isOnline()) {

View File

@ -70,7 +70,7 @@ public static boolean isFakePlayer(Player player) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
String name = player.getName(); String name = player.getName();
if (player.hasMetadata("NPC")) { if (Entities.isNPC(player)) {
return true; return true;
} }

View File

@ -52,6 +52,11 @@ public final class Materials {
private static final Map<Material, Integer> MATERIAL_FLAGS = new EnumMap<>(Material.class); private static final Map<Material, Integer> MATERIAL_FLAGS = new EnumMap<>(Material.class);
private static final Set<PotionEffectType> DAMAGE_EFFECTS = new HashSet<>(); private static final Set<PotionEffectType> DAMAGE_EFFECTS = new HashSet<>();
private static void putMaterialTag(Tag<Material> tag, Integer value) {
tag.getValues().forEach(mat -> MATERIAL_FLAGS.put(mat, value));
}
private static Tag<Material> SIGNS_TAG;
static { static {
ENTITY_ITEMS.put(EntityType.PAINTING, Material.PAINTING); ENTITY_ITEMS.put(EntityType.PAINTING, Material.PAINTING);
ENTITY_ITEMS.put(EntityType.ARROW, Material.ARROW); ENTITY_ITEMS.put(EntityType.ARROW, Material.ARROW);
@ -110,7 +115,7 @@ public final class Materials {
MATERIAL_FLAGS.put(Material.IRON_BLOCK, 0); MATERIAL_FLAGS.put(Material.IRON_BLOCK, 0);
MATERIAL_FLAGS.put(Material.BRICK, 0); MATERIAL_FLAGS.put(Material.BRICK, 0);
MATERIAL_FLAGS.put(Material.TNT, MODIFIED_ON_RIGHT); MATERIAL_FLAGS.put(Material.TNT, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(Material.BOOKSHELF, 0); MATERIAL_FLAGS.put(Material.BOOKSHELF, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(Material.MOSSY_COBBLESTONE, 0); MATERIAL_FLAGS.put(Material.MOSSY_COBBLESTONE, 0);
MATERIAL_FLAGS.put(Material.OBSIDIAN, 0); MATERIAL_FLAGS.put(Material.OBSIDIAN, 0);
MATERIAL_FLAGS.put(Material.TORCH, 0); MATERIAL_FLAGS.put(Material.TORCH, 0);
@ -815,111 +820,54 @@ public final class Materials {
MATERIAL_FLAGS.put(Material.ECHO_SHARD, 0); MATERIAL_FLAGS.put(Material.ECHO_SHARD, 0);
MATERIAL_FLAGS.put(Material.REINFORCED_DEEPSLATE, 0); MATERIAL_FLAGS.put(Material.REINFORCED_DEEPSLATE, 0);
// 1.19.3: Try to register those things
try {
SIGNS_TAG = Tag.ALL_SIGNS;
MATERIAL_FLAGS.put(Material.BAMBOO_MOSAIC, 0);
MATERIAL_FLAGS.put(Material.BAMBOO_BLOCK, 0);
MATERIAL_FLAGS.put(Material.STRIPPED_BAMBOO_BLOCK, 0);
} catch (NoSuchFieldError ignored) {
SIGNS_TAG = Tag.SIGNS;
}
// Generated via tag // Generated via tag
for (Material woodenDoor : Tag.WOODEN_DOORS.getValues()) { putMaterialTag(Tag.WOODEN_DOORS, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(woodenDoor, MODIFIED_ON_RIGHT); putMaterialTag(Tag.WOODEN_TRAPDOORS, MODIFIED_ON_RIGHT);
} putMaterialTag(Tag.SHULKER_BOXES, MODIFIED_ON_RIGHT);
for (Material woodenTrapdoor : Tag.WOODEN_TRAPDOORS.getValues()) { putMaterialTag(Tag.ITEMS_BOATS, 0);
MATERIAL_FLAGS.put(woodenTrapdoor, MODIFIED_ON_RIGHT); putMaterialTag(Tag.BANNERS, 0);
} putMaterialTag(Tag.SLABS, 0);
for (Material shulkerBox : Tag.SHULKER_BOXES.getValues()) { putMaterialTag(Tag.PLANKS, 0);
MATERIAL_FLAGS.put(shulkerBox, MODIFIED_ON_RIGHT); putMaterialTag(Tag.WOOL_CARPETS, 0);
} putMaterialTag(Tag.SAPLINGS, 0);
for (Material boat : Tag.ITEMS_BOATS.getValues()) { putMaterialTag(Tag.LOGS, 0);
MATERIAL_FLAGS.put(boat, 0); putMaterialTag(Tag.LEAVES, 0);
} putMaterialTag(Tag.STAIRS, 0);
for (Material banner : Tag.BANNERS.getValues()) { putMaterialTag(Tag.WOOL, 0);
MATERIAL_FLAGS.put(banner, 0); putMaterialTag(Tag.WOODEN_PRESSURE_PLATES, 0);
} putMaterialTag(Tag.BUTTONS, MODIFIED_ON_RIGHT);
for (Material slab : Tag.SLABS.getValues()) { putMaterialTag(Tag.FLOWER_POTS, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(slab, 0); putMaterialTag(Tag.WALLS, 0);
} putMaterialTag(SIGNS_TAG, 0);
for (Material plank : Tag.PLANKS.getValues()) { putMaterialTag(Tag.SMALL_FLOWERS, 0);
MATERIAL_FLAGS.put(plank, 0); putMaterialTag(Tag.BEDS, MODIFIED_ON_RIGHT);
} putMaterialTag(Tag.ITEMS_MUSIC_DISCS, 0);
for (Material carpet : Tag.WOOL_CARPETS.getValues()) { putMaterialTag(Tag.ITEMS_BANNERS, 0);
MATERIAL_FLAGS.put(carpet, 0); putMaterialTag(Tag.FENCE_GATES, MODIFIED_ON_RIGHT);
} putMaterialTag(Tag.FENCES, 0);
for (Material sapling : Tag.SAPLINGS.getValues()) {
MATERIAL_FLAGS.put(sapling, 0); putMaterialTag(Tag.COAL_ORES, 0);
} putMaterialTag(Tag.IRON_ORES, 0);
for (Material log : Tag.LOGS.getValues()) { putMaterialTag(Tag.GOLD_ORES, 0);
MATERIAL_FLAGS.put(log, 0); putMaterialTag(Tag.DIAMOND_ORES, 0);
} putMaterialTag(Tag.REDSTONE_ORES, 0);
for (Material leaves : Tag.LEAVES.getValues()) { putMaterialTag(Tag.COPPER_ORES, 0);
MATERIAL_FLAGS.put(leaves, 0); putMaterialTag(Tag.EMERALD_ORES, 0);
} putMaterialTag(Tag.LAPIS_ORES, 0);
for (Material stair : Tag.STAIRS.getValues()) { putMaterialTag(Tag.CANDLES, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(stair, 0); putMaterialTag(Tag.CANDLE_CAKES, MODIFIED_ON_RIGHT);
} putMaterialTag(Tag.CAULDRONS, MODIFIED_ON_RIGHT);
for (Material wool : Tag.WOOL.getValues()) {
MATERIAL_FLAGS.put(wool, 0);
}
for (Material plate : Tag.WOODEN_PRESSURE_PLATES.getValues()) {
MATERIAL_FLAGS.put(plate, 0);
}
for (Material button : Tag.BUTTONS.getValues()) {
MATERIAL_FLAGS.put(button, MODIFIED_ON_RIGHT);
}
for (Material pot : Tag.FLOWER_POTS.getValues()) {
MATERIAL_FLAGS.put(pot, MODIFIED_ON_RIGHT);
}
for (Material wall : Tag.WALLS.getValues()) {
MATERIAL_FLAGS.put(wall, 0);
}
for (Material sign : Tag.SIGNS.getValues()) {
MATERIAL_FLAGS.put(sign, 0);
}
for (Material flower : Tag.SMALL_FLOWERS.getValues()) {
MATERIAL_FLAGS.put(flower, 0);
}
for (Material bed : Tag.BEDS.getValues()) {
MATERIAL_FLAGS.put(bed, MODIFIED_ON_RIGHT);
}
for (Material musicDisc : Tag.ITEMS_MUSIC_DISCS.getValues()) {
MATERIAL_FLAGS.put(musicDisc, 0);
}
for (Material bannerPat : Tag.ITEMS_BANNERS.getValues()) {
MATERIAL_FLAGS.put(bannerPat, 0);
}
for (Material fenceGate : Tag.FENCE_GATES.getValues()) {
MATERIAL_FLAGS.put(fenceGate, MODIFIED_ON_RIGHT);
}
for (Material fence : Tag.FENCES.getValues()) {
MATERIAL_FLAGS.put(fence, 0);
} for (Material coalOre : Tag.COAL_ORES.getValues()) {
MATERIAL_FLAGS.put(coalOre, 0);
}
for (Material ironOre : Tag.IRON_ORES.getValues()) {
MATERIAL_FLAGS.put(ironOre, 0);
}
for (Material goldOre : Tag.GOLD_ORES.getValues()) {
MATERIAL_FLAGS.put(goldOre, 0);
}
for (Material diamondOre : Tag.DIAMOND_ORES.getValues()) {
MATERIAL_FLAGS.put(diamondOre, 0);
}
for (Material redstoneOre : Tag.REDSTONE_ORES.getValues()) {
MATERIAL_FLAGS.put(redstoneOre, 0);
}
for (Material copperOre : Tag.COPPER_ORES.getValues()) {
MATERIAL_FLAGS.put(copperOre, 0);
}
for (Material emeraldOre : Tag.EMERALD_ORES.getValues()) {
MATERIAL_FLAGS.put(emeraldOre, 0);
}
for (Material lapisOre : Tag.LAPIS_ORES.getValues()) {
MATERIAL_FLAGS.put(lapisOre, 0);
}
for (Material candle : Tag.CANDLES.getValues()) {
MATERIAL_FLAGS.put(candle, MODIFIED_ON_RIGHT);
}
for (Material candleCakes : Tag.CANDLE_CAKES.getValues()) {
MATERIAL_FLAGS.put(candleCakes, MODIFIED_ON_RIGHT);
}
for (Material cauldron : Tag.CAULDRONS.getValues()) {
MATERIAL_FLAGS.put(cauldron, MODIFIED_ON_RIGHT);
}
Stream.concat(Stream.concat( Stream.concat(Stream.concat(
Tag.CORAL_BLOCKS.getValues().stream(), Tag.CORAL_BLOCKS.getValues().stream(),
@ -1170,173 +1118,89 @@ public static boolean isInventoryBlock(Material material) {
} }
public static boolean isSpawnEgg(Material material) { public static boolean isSpawnEgg(Material material) {
return switch (material) { return getEntitySpawnEgg(material) != null;
case AXOLOTL_SPAWN_EGG, BAT_SPAWN_EGG, BEE_SPAWN_EGG, BLAZE_SPAWN_EGG, CAT_SPAWN_EGG,
CAVE_SPIDER_SPAWN_EGG, CHICKEN_SPAWN_EGG, COD_SPAWN_EGG, COW_SPAWN_EGG, CREEPER_SPAWN_EGG,
DOLPHIN_SPAWN_EGG, DONKEY_SPAWN_EGG, DROWNED_SPAWN_EGG, ELDER_GUARDIAN_SPAWN_EGG,
ENDERMAN_SPAWN_EGG, ENDERMITE_SPAWN_EGG, EVOKER_SPAWN_EGG, FOX_SPAWN_EGG,
GHAST_SPAWN_EGG, GLOW_SQUID_SPAWN_EGG, GOAT_SPAWN_EGG, GUARDIAN_SPAWN_EGG,
HOGLIN_SPAWN_EGG, HORSE_SPAWN_EGG, HUSK_SPAWN_EGG, LLAMA_SPAWN_EGG, MAGMA_CUBE_SPAWN_EGG,
MOOSHROOM_SPAWN_EGG, MULE_SPAWN_EGG, OCELOT_SPAWN_EGG, PANDA_SPAWN_EGG, PARROT_SPAWN_EGG,
PHANTOM_SPAWN_EGG, PIGLIN_BRUTE_SPAWN_EGG, PIGLIN_SPAWN_EGG, PIG_SPAWN_EGG, PILLAGER_SPAWN_EGG,
POLAR_BEAR_SPAWN_EGG, PUFFERFISH_SPAWN_EGG, RABBIT_SPAWN_EGG, RAVAGER_SPAWN_EGG,
SALMON_SPAWN_EGG, SHEEP_SPAWN_EGG, SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG,
SKELETON_HORSE_SPAWN_EGG, SKELETON_SPAWN_EGG, SLIME_SPAWN_EGG, SPIDER_SPAWN_EGG,
SQUID_SPAWN_EGG, STRAY_SPAWN_EGG, STRIDER_SPAWN_EGG, TRADER_LLAMA_SPAWN_EGG,
TROPICAL_FISH_SPAWN_EGG, TURTLE_SPAWN_EGG, VEX_SPAWN_EGG, VILLAGER_SPAWN_EGG,
VINDICATOR_SPAWN_EGG, WANDERING_TRADER_SPAWN_EGG, WITCH_SPAWN_EGG, WITHER_SKELETON_SPAWN_EGG,
WOLF_SPAWN_EGG, ZOGLIN_SPAWN_EGG, ZOMBIE_HORSE_SPAWN_EGG, ZOMBIFIED_PIGLIN_SPAWN_EGG,
ZOMBIE_SPAWN_EGG, ZOMBIE_VILLAGER_SPAWN_EGG, ALLAY_SPAWN_EGG, FROG_SPAWN_EGG, TADPOLE_SPAWN_EGG,
WARDEN_SPAWN_EGG ->
true;
default -> false;
};
} }
public static EntityType getEntitySpawnEgg(Material material) { public static EntityType getEntitySpawnEgg(Material material) {
switch (material) { return switch (material) {
case ALLAY_SPAWN_EGG: case ALLAY_SPAWN_EGG -> EntityType.ALLAY;
return EntityType.ALLAY; case AXOLOTL_SPAWN_EGG -> EntityType.AXOLOTL;
case AXOLOTL_SPAWN_EGG: case SPIDER_SPAWN_EGG -> EntityType.SPIDER;
return EntityType.AXOLOTL; case BAT_SPAWN_EGG -> EntityType.BAT;
case SPIDER_SPAWN_EGG: case BEE_SPAWN_EGG -> EntityType.BEE;
return EntityType.SPIDER; case BLAZE_SPAWN_EGG -> EntityType.BLAZE;
case BAT_SPAWN_EGG: case CAT_SPAWN_EGG -> EntityType.CAT;
return EntityType.BAT; case CAMEL_SPAWN_EGG -> EntityType.CAMEL;
case BEE_SPAWN_EGG: case CAVE_SPIDER_SPAWN_EGG -> EntityType.CAVE_SPIDER;
return EntityType.BEE; case CHICKEN_SPAWN_EGG -> EntityType.CHICKEN;
case BLAZE_SPAWN_EGG: case COD_SPAWN_EGG -> EntityType.COD;
return EntityType.BLAZE; case COW_SPAWN_EGG -> EntityType.COW;
case CAT_SPAWN_EGG: case CREEPER_SPAWN_EGG -> EntityType.CREEPER;
return EntityType.CAT; case DOLPHIN_SPAWN_EGG -> EntityType.DOLPHIN;
case CAVE_SPIDER_SPAWN_EGG: case DONKEY_SPAWN_EGG -> EntityType.DONKEY;
return EntityType.CAVE_SPIDER; case DROWNED_SPAWN_EGG -> EntityType.DROWNED;
case CHICKEN_SPAWN_EGG: case ELDER_GUARDIAN_SPAWN_EGG -> EntityType.ELDER_GUARDIAN;
return EntityType.CHICKEN; case ENDER_DRAGON_SPAWN_EGG -> EntityType.ENDER_DRAGON;
case COD_SPAWN_EGG: case ENDERMAN_SPAWN_EGG -> EntityType.ENDERMAN;
return EntityType.COD; case ENDERMITE_SPAWN_EGG -> EntityType.ENDERMITE;
case COW_SPAWN_EGG: case EVOKER_SPAWN_EGG -> EntityType.EVOKER;
return EntityType.COW; case FOX_SPAWN_EGG -> EntityType.FOX;
case CREEPER_SPAWN_EGG: case FROG_SPAWN_EGG -> EntityType.FROG;
return EntityType.CREEPER; case GHAST_SPAWN_EGG -> EntityType.GHAST;
case DOLPHIN_SPAWN_EGG: case GLOW_SQUID_SPAWN_EGG -> EntityType.GLOW_SQUID;
return EntityType.DOLPHIN; case GOAT_SPAWN_EGG -> EntityType.GOAT;
case DONKEY_SPAWN_EGG: case GUARDIAN_SPAWN_EGG -> EntityType.GUARDIAN;
return EntityType.DONKEY; case HOGLIN_SPAWN_EGG -> EntityType.HOGLIN;
case DROWNED_SPAWN_EGG: case HORSE_SPAWN_EGG -> EntityType.HORSE;
return EntityType.DROWNED; case HUSK_SPAWN_EGG -> EntityType.HUSK;
case ELDER_GUARDIAN_SPAWN_EGG: case IRON_GOLEM_SPAWN_EGG -> EntityType.IRON_GOLEM;
return EntityType.ELDER_GUARDIAN; case LLAMA_SPAWN_EGG -> EntityType.LLAMA;
case ENDERMAN_SPAWN_EGG: case MAGMA_CUBE_SPAWN_EGG -> EntityType.MAGMA_CUBE;
return EntityType.ENDERMAN; case MOOSHROOM_SPAWN_EGG -> EntityType.MUSHROOM_COW;
case ENDERMITE_SPAWN_EGG: case MULE_SPAWN_EGG -> EntityType.MULE;
return EntityType.ENDERMITE; case OCELOT_SPAWN_EGG -> EntityType.OCELOT;
case EVOKER_SPAWN_EGG: case PANDA_SPAWN_EGG -> EntityType.PANDA;
return EntityType.EVOKER; case PARROT_SPAWN_EGG -> EntityType.PARROT;
case FOX_SPAWN_EGG: case PHANTOM_SPAWN_EGG -> EntityType.PHANTOM;
return EntityType.FOX; case PIGLIN_BRUTE_SPAWN_EGG -> EntityType.PIGLIN_BRUTE;
case FROG_SPAWN_EGG: case PIGLIN_SPAWN_EGG -> EntityType.PIGLIN;
return EntityType.FROG; case PILLAGER_SPAWN_EGG -> EntityType.PILLAGER;
case GHAST_SPAWN_EGG: case POLAR_BEAR_SPAWN_EGG -> EntityType.POLAR_BEAR;
return EntityType.GHAST; case PUFFERFISH_SPAWN_EGG -> EntityType.PUFFERFISH;
case GLOW_SQUID_SPAWN_EGG: case RABBIT_SPAWN_EGG -> EntityType.RABBIT;
return EntityType.GLOW_SQUID; case RAVAGER_SPAWN_EGG -> EntityType.RAVAGER;
case GOAT_SPAWN_EGG: case SALMON_SPAWN_EGG -> EntityType.SALMON;
return EntityType.GOAT; case SHEEP_SPAWN_EGG -> EntityType.SHEEP;
case GUARDIAN_SPAWN_EGG: case SHULKER_SPAWN_EGG -> EntityType.SHULKER;
return EntityType.GUARDIAN; case SILVERFISH_SPAWN_EGG -> EntityType.SILVERFISH;
case HOGLIN_SPAWN_EGG: case SKELETON_HORSE_SPAWN_EGG -> EntityType.SKELETON_HORSE;
return EntityType.HOGLIN; case SKELETON_SPAWN_EGG -> EntityType.SKELETON;
case HORSE_SPAWN_EGG: case SLIME_SPAWN_EGG -> EntityType.SLIME;
return EntityType.HORSE; case SNOW_GOLEM_SPAWN_EGG -> EntityType.SNOWMAN;
case HUSK_SPAWN_EGG: case SQUID_SPAWN_EGG -> EntityType.SQUID;
return EntityType.HUSK; case STRAY_SPAWN_EGG -> EntityType.STRAY;
case LLAMA_SPAWN_EGG: case STRIDER_SPAWN_EGG -> EntityType.STRIDER;
return EntityType.LLAMA; case TADPOLE_SPAWN_EGG -> EntityType.TADPOLE;
case MAGMA_CUBE_SPAWN_EGG: case TRADER_LLAMA_SPAWN_EGG -> EntityType.TRADER_LLAMA;
return EntityType.MAGMA_CUBE; case TROPICAL_FISH_SPAWN_EGG -> EntityType.TROPICAL_FISH;
case MOOSHROOM_SPAWN_EGG: case TURTLE_SPAWN_EGG -> EntityType.TURTLE;
return EntityType.MUSHROOM_COW; case VEX_SPAWN_EGG -> EntityType.VEX;
case MULE_SPAWN_EGG: case VILLAGER_SPAWN_EGG -> EntityType.VILLAGER;
return EntityType.MULE; case VINDICATOR_SPAWN_EGG -> EntityType.VINDICATOR;
case OCELOT_SPAWN_EGG: case WANDERING_TRADER_SPAWN_EGG -> EntityType.WANDERING_TRADER;
return EntityType.OCELOT; case WARDEN_SPAWN_EGG -> EntityType.WARDEN;
case PANDA_SPAWN_EGG: case WITCH_SPAWN_EGG -> EntityType.WITCH;
return EntityType.PANDA; case WITHER_SPAWN_EGG -> EntityType.WITHER;
case PARROT_SPAWN_EGG: case WITHER_SKELETON_SPAWN_EGG -> EntityType.WITHER_SKELETON;
return EntityType.PARROT; case WOLF_SPAWN_EGG -> EntityType.WOLF;
case PHANTOM_SPAWN_EGG: case ZOGLIN_SPAWN_EGG -> EntityType.ZOGLIN;
return EntityType.PHANTOM; case ZOMBIE_HORSE_SPAWN_EGG -> EntityType.ZOMBIE_HORSE;
case PIGLIN_BRUTE_SPAWN_EGG: case ZOMBIFIED_PIGLIN_SPAWN_EGG -> EntityType.ZOMBIFIED_PIGLIN;
return EntityType.PIGLIN_BRUTE; case ZOMBIE_SPAWN_EGG -> EntityType.ZOMBIE;
case PIGLIN_SPAWN_EGG: case ZOMBIE_VILLAGER_SPAWN_EGG -> EntityType.ZOMBIE_VILLAGER;
return EntityType.PIGLIN; case PIG_SPAWN_EGG -> EntityType.PIG;
case PILLAGER_SPAWN_EGG: default -> null;
return EntityType.PILLAGER; };
case POLAR_BEAR_SPAWN_EGG:
return EntityType.POLAR_BEAR;
case PUFFERFISH_SPAWN_EGG:
return EntityType.PUFFERFISH;
case RABBIT_SPAWN_EGG:
return EntityType.RABBIT;
case RAVAGER_SPAWN_EGG:
return EntityType.RAVAGER;
case SALMON_SPAWN_EGG:
return EntityType.SALMON;
case SHEEP_SPAWN_EGG:
return EntityType.SHEEP;
case SHULKER_SPAWN_EGG:
return EntityType.SHULKER;
case SILVERFISH_SPAWN_EGG:
return EntityType.SILVERFISH;
case SKELETON_HORSE_SPAWN_EGG:
return EntityType.SKELETON_HORSE;
case SKELETON_SPAWN_EGG:
return EntityType.SKELETON;
case SLIME_SPAWN_EGG:
return EntityType.SLIME;
case SQUID_SPAWN_EGG:
return EntityType.SQUID;
case STRAY_SPAWN_EGG:
return EntityType.STRAY;
case STRIDER_SPAWN_EGG:
return EntityType.STRIDER;
case TADPOLE_SPAWN_EGG:
return EntityType.TADPOLE;
case TRADER_LLAMA_SPAWN_EGG:
return EntityType.TRADER_LLAMA;
case TROPICAL_FISH_SPAWN_EGG:
return EntityType.TROPICAL_FISH;
case TURTLE_SPAWN_EGG:
return EntityType.TURTLE;
case VEX_SPAWN_EGG:
return EntityType.VEX;
case VILLAGER_SPAWN_EGG:
return EntityType.VILLAGER;
case VINDICATOR_SPAWN_EGG:
return EntityType.VINDICATOR;
case WANDERING_TRADER_SPAWN_EGG:
return EntityType.WANDERING_TRADER;
case WARDEN_SPAWN_EGG:
return EntityType.WARDEN;
case WITCH_SPAWN_EGG:
return EntityType.WITCH;
case WITHER_SKELETON_SPAWN_EGG:
return EntityType.WITHER_SKELETON;
case WOLF_SPAWN_EGG:
return EntityType.WOLF;
case ZOMBIE_HORSE_SPAWN_EGG:
return EntityType.ZOMBIE_HORSE;
case ZOMBIFIED_PIGLIN_SPAWN_EGG:
return EntityType.ZOMBIFIED_PIGLIN;
case ZOMBIE_SPAWN_EGG:
return EntityType.ZOMBIE;
case ZOMBIE_VILLAGER_SPAWN_EGG:
return EntityType.ZOMBIE_VILLAGER;
case PIG_SPAWN_EGG:
default: // Uhh
return EntityType.PIG;
}
} }
public static boolean isBed(Material material) { public static boolean isBed(Material material) {
@ -1360,9 +1224,10 @@ public static boolean isCoral(Material material) {
* @return true if the material is a crop * @return true if the material is a crop
*/ */
public static boolean isCrop(Material type) { public static boolean isCrop(Material type) {
if (Tag.CROPS.isTagged(type)) return true;
// yea, that's not all, there are some more
return switch (type) { return switch (type) {
case WHEAT, CARROTS, POTATOES, BEETROOTS, MELON_STEM, PUMPKIN_STEM, case PUMPKIN, MELON, CACTUS, SUGAR_CANE, BAMBOO, BAMBOO_SAPLING,
PUMPKIN, MELON, CACTUS, SUGAR_CANE, BAMBOO, BAMBOO_SAPLING,
SWEET_BERRY_BUSH, NETHER_WART, CAVE_VINES, CAVE_VINES_PLANT -> SWEET_BERRY_BUSH, NETHER_WART, CAVE_VINES, CAVE_VINES_PLANT ->
true; true;
default -> false; default -> false;
@ -1517,7 +1382,6 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case NETHERITE_HOE: case NETHERITE_HOE:
return switch (targetMaterial) { return switch (targetMaterial) {
case GRASS_BLOCK, DIRT, DIRT_PATH, ROOTED_DIRT -> case GRASS_BLOCK, DIRT, DIRT_PATH, ROOTED_DIRT ->
// case COARSE_DIRT: // already handled by the server...
true; true;
default -> false; default -> false;
}; };
@ -1527,11 +1391,10 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case GOLDEN_AXE: case GOLDEN_AXE:
case DIAMOND_AXE: case DIAMOND_AXE:
case NETHERITE_AXE: case NETHERITE_AXE:
if (isWaxedCopper(targetMaterial)) if (isWaxedCopper(targetMaterial)) return true;
return true; if (Tag.LOGS.isTagged(targetMaterial)) return true;
return switch (targetMaterial) { return switch (targetMaterial) {
case OAK_LOG, DARK_OAK_LOG, ACACIA_LOG, BIRCH_LOG, SPRUCE_LOG, JUNGLE_LOG, case OAK_WOOD, DARK_OAK_WOOD, ACACIA_WOOD, BIRCH_WOOD, SPRUCE_WOOD, PUMPKIN, BAMBOO_BLOCK,
OAK_WOOD, DARK_OAK_WOOD, ACACIA_WOOD, BIRCH_WOOD, SPRUCE_WOOD,
JUNGLE_WOOD, CRIMSON_STEM, WARPED_STEM, CRIMSON_HYPHAE, WARPED_HYPHAE -> JUNGLE_WOOD, CRIMSON_STEM, WARPED_STEM, CRIMSON_HYPHAE, WARPED_HYPHAE ->
true; true;
default -> false; default -> false;
@ -1569,7 +1432,7 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case YELLOW_DYE: case YELLOW_DYE:
case GLOW_INK_SAC: case GLOW_INK_SAC:
case INK_SAC: case INK_SAC:
return Tag.SIGNS.isTagged(targetMaterial); return SIGNS_TAG.isTagged(targetMaterial);
case HONEYCOMB: case HONEYCOMB:
return isUnwaxedCopper(targetMaterial); return isUnwaxedCopper(targetMaterial);
default: default:

View File

@ -0,0 +1,48 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit.util.report;
import com.sk89q.worldedit.util.report.DataReport;
import io.papermc.paper.datapack.Datapack;
import org.bukkit.Bukkit;
import java.util.Collection;
/**
* A report for current datapacks with some information. Only available on Paper
*/
public class DatapackReport extends DataReport {
public DatapackReport() {
super("DataPacks");
Collection<Datapack> packs = Bukkit.getDatapackManager().getPacks();
append("Datapack Count", packs.size());
append("Datapack Enabled Count", Bukkit.getDatapackManager().getEnabledPacks().size());
for (Datapack pack : packs) {
DataReport report = new DataReport("DataPack: " + pack.getName());
report.append("Enabled?", pack.isEnabled());
report.append("Name", pack.getName());
report.append("Compatibility", pack.getCompatibility().name());
append(report.getTitle(), report);
}
}
}

View File

@ -42,7 +42,7 @@ public ServerReport() {
onlineMode.append("BungeeCord support?", Bukkit.spigot().getConfig().getBoolean("settings.bungeecord", false)); onlineMode.append("BungeeCord support?", Bukkit.spigot().getConfig().getBoolean("settings.bungeecord", false));
} }
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
onlineMode.append("Velocity support?", Bukkit.spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled", false)); onlineMode.append("Velocity support?", Bukkit.spigot().getPaperConfig().getBoolean("proxies.velocity.enabled", false));
} }
append(onlineMode.getTitle(), onlineMode); append(onlineMode.getTitle(), onlineMode);

View File

@ -8,11 +8,11 @@
"api"(project(":worldguard-libs:core")) "api"(project(":worldguard-libs:core"))
"api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}") "api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}")
"implementation"("org.flywaydb:flyway-core:3.0") "implementation"("org.flywaydb:flyway-core:3.0")
"implementation"("org.yaml:snakeyaml:1.30") "implementation"("org.yaml:snakeyaml:1.33")
"implementation"("com.google.guava:guava:${Versions.GUAVA}") "implementation"("com.google.guava:guava:${Versions.GUAVA}")
"compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}") "compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}")
"testImplementation"("org.hamcrest:hamcrest-library:1.2.1") "testImplementation"("org.hamcrest:hamcrest-library:2.2")
} }
tasks.withType<JavaCompile>().configureEach { tasks.withType<JavaCompile>().configureEach {

View File

@ -165,6 +165,7 @@ public abstract class WorldConfiguration {
public boolean disableSnowmanTrails; public boolean disableSnowmanTrails;
public boolean disableSoilDehydration; public boolean disableSoilDehydration;
public boolean disableCoralBlockFade; public boolean disableCoralBlockFade;
public boolean disableCopperBlockFade;
public Set<String> allowedSnowFallOver; public Set<String> allowedSnowFallOver;
public boolean regionInvinciblityRemovesMobs; public boolean regionInvinciblityRemovesMobs;
public boolean regionCancelEmptyChatEvents; public boolean regionCancelEmptyChatEvents;

View File

@ -125,6 +125,7 @@ public final class Flags {
public static final StateFlag CROP_GROWTH = register(new StateFlag("crop-growth", true)); public static final StateFlag CROP_GROWTH = register(new StateFlag("crop-growth", true));
public static final StateFlag SOIL_DRY = register(new StateFlag("soil-dry", true)); public static final StateFlag SOIL_DRY = register(new StateFlag("soil-dry", true));
public static final StateFlag CORAL_FADE = register(new StateFlag("coral-fade", true)); public static final StateFlag CORAL_FADE = register(new StateFlag("coral-fade", true));
public static final StateFlag COPPER_FADE = register(new StateFlag("copper-fade", true));
public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true)); public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true));
public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true)); public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true));

View File

@ -3,9 +3,7 @@
applyLibrariesConfiguration() applyLibrariesConfiguration()
dependencies { dependencies {
"shade"("org.enginehub:squirrelid:${Versions.SQUIRRELID}") { "shade"("org.enginehub:squirrelid:${Versions.SQUIRRELID}")
exclude(group = "com.destroystokyo.paper", module = "paper-api")
}
"shade"("org.khelekore:prtree:1.5.0") "shade"("org.khelekore:prtree:1.5.0")
} }
@ -17,4 +15,4 @@
include(dependency("org.khelekore:prtree")) include(dependency("org.khelekore:prtree"))
} }
} }