Skip to content

Commit 992f94a

Browse files
authored
Silence unavoidable removal warnings during build & remove getters. (#7346)
* Suppress all removal warnings & remove getters. * Fix casing.
1 parent 59f6dbd commit 992f94a

22 files changed

+168
-171
lines changed

src/main/java/ch/njol/skript/SkriptConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public static String formatDate(final long timestamp) {
219219

220220
public static final Option<Boolean> apiSoftExceptions = new Option<>("soft api exceptions", false);
221221

222+
@SuppressWarnings("removal")
222223
public static final Option<Boolean> enableTimings = new Option<>("enable timings", false)
223224
.setter(t -> {
224225
if (!Skript.classExists("co.aikar.timings.Timings")) { // Check for Timings

src/main/java/ch/njol/skript/bukkitutil/HealthUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import ch.njol.util.Math2;
55
import java.lang.reflect.Constructor;
66
import java.lang.reflect.InvocationTargetException;
7+
8+
import org.bukkit.NamespacedKey;
9+
import org.bukkit.Registry;
710
import org.bukkit.attribute.Attributable;
811
import org.bukkit.attribute.Attribute;
912
import org.bukkit.attribute.AttributeInstance;
@@ -29,7 +32,7 @@ public class HealthUtils {
2932
private static final Attribute MAX_HEALTH;
3033
static {
3134
if (Skript.isRunningMinecraft(1, 21, 3)) { // In 1.21.3, Attribute became an Interface
32-
MAX_HEALTH = Attribute.valueOf("MAX_HEALTH");
35+
MAX_HEALTH = Registry.ATTRIBUTE.get(NamespacedKey.minecraft("max_health"));
3336
} else {
3437
MAX_HEALTH = (Attribute) Enum.valueOf((Class) Attribute.class, "GENERIC_MAX_HEALTH");
3538
}
@@ -133,6 +136,7 @@ public static void setDamage(EntityDamageEvent event, double damage) {
133136
((LivingEntity) event.getEntity()).setLastDamage(damage * 2);
134137
}
135138

139+
@SuppressWarnings("removal")
136140
public static void setDamageCause(Damageable damageable, DamageCause cause) {
137141
if (OLD_DAMAGE_EVENT_CONSTRUCTOR != null) {
138142
try {

src/main/java/ch/njol/skript/bukkitutil/SoundUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public final class SoundUtils {
2222
* @param soundString The enum name to use to find the sound.
2323
* @return The key of the sound.
2424
*/
25+
@SuppressWarnings("removal")
2526
public static @Nullable NamespacedKey getKey(String soundString) {
2627
soundString = soundString.toUpperCase(Locale.ENGLISH);
2728
if (SOUND_IS_INTERFACE) {
2829
try {
29-
//noinspection deprecation,removal
3030
return Sound.valueOf(soundString).getKey();
3131
} catch (Exception ignored) {}
3232
} else {
@@ -44,9 +44,9 @@ public final class SoundUtils {
4444
* @param sound The sound to get the key string of.
4545
* @return The key string of the {@link NamespacedKey} of the sound.
4646
*/
47+
@SuppressWarnings("removal")
4748
public static @NotNull NamespacedKey getKey(Sound sound) {
4849
if (SOUND_IS_INTERFACE) {
49-
//noinspection deprecation,removal
5050
return sound.getKey();
5151
} else {
5252
return ((Keyed) sound).getKey();

src/main/java/ch/njol/skript/classes/SerializableGetter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import ch.njol.skript.util.Getter;
44

5-
/**
6-
* @author Peter Güttinger
7-
*/
8-
@Deprecated
5+
@Deprecated(forRemoval = true)
6+
@SuppressWarnings("removal")
97
public abstract class SerializableGetter<R, A> extends Getter<R, A> {}

src/main/java/ch/njol/skript/command/Commands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static SimpleCommandMap getCommandMap(){
8282
return commandMap;
8383
}
8484

85-
@SuppressWarnings("unchecked")
85+
@SuppressWarnings({"unchecked", "removal"})
8686
private static void init() {
8787
try {
8888
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {

src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5656
}
5757

5858
@Override
59+
@SuppressWarnings("removal")
5960
protected void execute(Event e) {
6061
if (!(e instanceof ServerListPingEvent))
6162
return;
6263

63-
Iterator<Player> it = ((ServerListPingEvent) e).iterator();
64+
Iterator<Player> it = ((ServerListPingEvent) e).iterator();
6465
Iterators.removeAll(it, Arrays.asList(players.getArray(e)));
6566
}
6667

@@ -69,4 +70,4 @@ public String toString(@Nullable Event e, boolean debug) {
6970
return "hide " + players.toString(e, debug) + " from the server list";
7071
}
7172

72-
}
73+
}

0 commit comments

Comments
 (0)