Fixed materials looking up legacy ones first on 1.13

This commit is contained in:
isokissa3 2018-12-11 18:04:27 +02:00
parent 592ef42741
commit 2eaba09e0b
4 changed files with 26 additions and 2 deletions

View file

@ -87,6 +87,7 @@
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-API</artifactId>
<version>4.4.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,8 +1,12 @@
name: WorldGuardExtraFlags
version: 4.1.2-DEV
description: Adds more flags to WorldGuard to help manage your server easily!
version: 4.1.2-DEV
api-version: 1.13
author: isokissa3
website: https://goldtreevers.net
depend: [ WorldGuard ]
softdepend: [ MythicMobs, FastAsyncWorldEdit, Essentials, ProtocolLib ]

View file

@ -6,6 +6,8 @@ import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
public class MaterialFlag extends Flag<Material>
{
public MaterialFlag(String name)
@ -36,6 +38,12 @@ public class MaterialFlag extends Flag<Material>
@Override
public Material unmarshal(Object o)
{
return Material.matchMaterial(o.toString());
Material material = Material.matchMaterial(o.toString());
if (material == null && SupportedFeatures.isNewMaterial()) //Fallback to legacy on unmarshal only
{
material = Material.matchMaterial(o.toString(), true);
}
return material;
}
}

View file

@ -12,12 +12,14 @@ import lombok.Getter;
/**
* Helper class to decide what features are supported by the server
*/
@SuppressWarnings("deprecation")
public class SupportedFeatures
{
@Getter private static boolean frostwalkerSupported;
@Getter private static boolean stopSoundSupported;
@Getter private static boolean potionEffectEventSupported;
@Getter private static boolean potionEffectParticles;
@Getter private static boolean newMaterial;
static
{
@ -53,5 +55,14 @@ public class SupportedFeatures
{
}
try
{
SupportedFeatures.newMaterial = Material.LEGACY_AIR != null;
}
catch(Throwable ignored)
{
}
}
}