Skip to content

Housekeeping: remove unneeded legacy version checks & clean up code. #6676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: dev/feature
Choose a base branch
from
2 changes: 1 addition & 1 deletion skript-aliases
Submodule skript-aliases updated 9 files
+1 −1 README.md
+0 −389 armor-trims.sk
+149 −1 building.sk
+390 −0 combat.sk
+0 −19 doors.sk
+18 −0 redstone.sk
+0 −82 slabs.sk
+0 −70 stairs.sk
+1 −1 transportation.sk
105 changes: 0 additions & 105 deletions src/main/java/ch/njol/skript/bukkitutil/PassengerUtils.java

This file was deleted.

14 changes: 1 addition & 13 deletions src/main/java/ch/njol/skript/classes/data/BukkitClasses.java
Original file line number Diff line number Diff line change
@@ -118,7 +118,6 @@ public BukkitClasses() {}
public static final Pattern UUID_PATTERN = Pattern.compile("(?i)[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}");

static {
final boolean GET_ENTITY_METHOD_EXISTS = Skript.methodExists(Bukkit.class, "getEntity", UUID.class);
Classes.registerClass(new ClassInfo<>(Entity.class, "entity")
.user("entit(y|ies)")
.name("Entity")
@@ -143,18 +142,7 @@ public Entity parse(final String s, final ParseContext context) {
} catch (IllegalArgumentException iae) {
return null;
}
if (GET_ENTITY_METHOD_EXISTS) {
return Bukkit.getEntity(uuid);
} else {
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity.getUniqueId().equals(uuid)) {
return entity;
}
}
}
}
return null;
return Bukkit.getEntity(uuid);
}

@Override
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@
public class CondHasResourcePack extends PropertyCondition<Player> {

static {
if (Skript.methodExists(Player.class, "hasResourcePack"))
register(CondHasResourcePack.class, PropertyType.HAVE, "[a] resource pack [(loaded|installed)]", "players");
register(CondHasResourcePack.class, PropertyType.HAVE, "[a] resource pack [(loaded|installed)]", "players");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this still require the check? I can't see the Player#hasResourcePack() in Spigot 1.13.2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the fact @RequiredPlugins state "Paper 1.9 or newer" it is possible. As such I did go and check latest spigot releases and there's no method for hasResourcePack so this check should still remain

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this was only on the list for documentation update

}

@Override
Original file line number Diff line number Diff line change
@@ -42,12 +42,10 @@
public class CondIgnitionProcess extends PropertyCondition<LivingEntity> {

static {
if (Skript.methodExists(Creeper.class, "isIgnited")) {
Skript.registerCondition(CondIgnitionProcess.class,
"[creeper[s]] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) going to explode",
"[creeper[s]] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) in the (ignition|explosion) process",
"creeper[s] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) ignited");
}
Skript.registerCondition(CondIgnitionProcess.class,
"[creeper[s]] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) going to explode",
"[creeper[s]] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) in the (ignition|explosion) process",
"creeper[s] %livingentities% ((is|are)|1¦(isn't|is not|aren't|are not)) ignited");
Comment on lines -45 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well.

}

@SuppressWarnings({"unchecked", "null"})
12 changes: 5 additions & 7 deletions src/main/java/ch/njol/skript/conditions/CondIsFuel.java
Original file line number Diff line number Diff line change
@@ -40,21 +40,19 @@
@Since("2.5.1")
@RequiredPlugins("Minecraft 1.11.2+")
public class CondIsFuel extends PropertyCondition<ItemType> {

static {
if (Skript.methodExists(Material.class, "isFuel")) {
register(CondIsFuel.class, "[furnace] fuel", "itemtypes");
}
register(CondIsFuel.class, "[furnace] fuel", "itemtypes");
}

@Override
public boolean check(ItemType item) {
return item.getMaterial().isFuel();
}

@Override
protected String getPropertyName() {
return "fuel";
}

}
Original file line number Diff line number Diff line change
@@ -39,18 +39,16 @@
@Since("2.5.2")
@RequiredPlugins("Minecraft 1.13+")
public class CondIsInteractable extends PropertyCondition<ItemType> {

static {
if (Skript.methodExists(Material.class, "isInteractable")) {
register(CondIsInteractable.class, "interactable", "itemtypes");
}
register(CondIsInteractable.class, "interactable", "itemtypes");
}

@Override
public boolean check(ItemType item) {
return item.getMaterial().isInteractable();
}

@Override
protected String getPropertyName() {
return "interactable";
12 changes: 5 additions & 7 deletions src/main/java/ch/njol/skript/conditions/CondIsPassable.java
Original file line number Diff line number Diff line change
@@ -38,21 +38,19 @@
@Since("2.5.1")
@RequiredPlugins("Minecraft 1.13.2+")
public class CondIsPassable extends PropertyCondition<Block> {

static {
if (Skript.methodExists(Block.class, "isPassable")) {
register(CondIsPassable.class, "passable", "blocks");
}
register(CondIsPassable.class, "passable", "blocks");
}

@Override
public boolean check(Block block) {
return block.isPassable();
}

@Override
protected String getPropertyName() {
return "passable";
}

}
15 changes: 7 additions & 8 deletions src/main/java/ch/njol/skript/conditions/CondIsSwimming.java
Original file line number Diff line number Diff line change
@@ -34,20 +34,19 @@
@RequiredPlugins("1.13 or newer")
@Since("2.3")
public class CondIsSwimming extends PropertyCondition<LivingEntity> {

static {
if (Skript.methodExists(LivingEntity.class, "isSwimming"))
register(CondIsSwimming.class, "swimming", "livingentities");
register(CondIsSwimming.class, "swimming", "livingentities");
}

@Override
public boolean check(final LivingEntity e) {
return e.isSwimming();
public boolean check(final LivingEntity entity) {
return entity.isSwimming();
}

@Override
protected String getPropertyName() {
return "swimming";
}

}
8 changes: 3 additions & 5 deletions src/main/java/ch/njol/skript/effects/EffMakeFly.java
Original file line number Diff line number Diff line change
@@ -40,11 +40,9 @@
public class EffMakeFly extends Effect {

static {
if (Skript.methodExists(Player.class, "setFlying", boolean.class)) {
Skript.registerEffect(EffMakeFly.class, "force %players% to [(start|1¦stop)] fly[ing]",
"make %players% (start|1¦stop) flying",
"make %players% fly");
}
Skript.registerEffect(EffMakeFly.class, "force %players% to [(start|1¦stop)] fly[ing]",
"make %players% (start|1¦stop) flying",
"make %players% fly");
}

@SuppressWarnings("null")
25 changes: 3 additions & 22 deletions src/main/java/ch/njol/skript/effects/EffSendBlockChange.java
Original file line number Diff line number Diff line change
@@ -18,8 +18,6 @@
*/
package ch.njol.skript.effects;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
@@ -44,19 +42,9 @@
@Since("2.2-dev37c, 2.5.1 (block data support)")
public class EffSendBlockChange extends Effect {

private static final boolean BLOCK_DATA_SUPPORT = Skript.classExists("org.bukkit.block.data.BlockData");
private static final boolean SUPPORTED =
Skript.methodExists(
Player.class,
"sendBlockChange",
Location.class,
Material.class,
byte.class
);

static {
Skript.registerEffect(EffSendBlockChange.class,
BLOCK_DATA_SUPPORT ? "make %players% see %blocks% as %itemtype/blockdata%" : "make %players% see %blocks% as %itemtype%"
"make %players% see %blocks% as %itemtype/blockdata%"
);
}

@@ -68,17 +56,10 @@ public class EffSendBlockChange extends Effect {

@SuppressWarnings("null")
private Expression<Object> as;

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
if (!SUPPORTED) {
Skript.error("The send block change effect is not supported on this version. " +
"If Spigot has added a replacement method without magic values " +
"please open an issue at https://github.com/SkriptLang/Skript/issues " +
"and support will be added for it.");
return false;
}
players = (Expression<Player>) exprs[0];
blocks = (Expression<Block>) exprs[1];
as = (Expression<Object>) exprs[2];
@@ -95,7 +76,7 @@ protected void execute(Event e) {
itemType.sendBlockChange(player, block.getLocation());
}
}
} else if (BLOCK_DATA_SUPPORT && object instanceof BlockData) {
} else if (object instanceof BlockData) {
BlockData blockData = (BlockData) object;
for (Player player : players.getArray(e)) {
for (Block block : blocks.getArray(e)) {
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/effects/EffSendTitle.java
Original file line number Diff line number Diff line change
@@ -136,4 +136,4 @@ public String toString(final @Nullable Event e, final boolean debug) {
" for " + stay + " with fade in " + in + " and fade out" + out : "");
}

}
}
Loading