Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth committed Jun 30, 2024
1 parent 251aa5b commit 15ca3d6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
5 changes: 5 additions & 0 deletions src/main/java/ch/njol/skript/aliases/Aliases.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ public static EntityData<?> getRelatedEntity(ItemData data) {
* <p>Item types provided by this method are updated when aliases are
* reloaded. However, this also means they are tracked by aliases system
* and NOT necessarily garbage-collected.
*
* <p>Relying on this method to create item types is not safe,
* as users can change aliases at any point. ItemTypes should instead be created
* via {@link Material}s, {@link org.bukkit.Tag}s, or any other manual method.
*
* @param name Name of item to search from aliases.
* @return An item.
* @throws IllegalArgumentException When item is not found.
Expand Down
31 changes: 6 additions & 25 deletions src/main/java/ch/njol/skript/entity/BoatChestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,8 @@

public class BoatChestData extends EntityData<ChestBoat> {

private static Material oakBoat = null;
private static Material spruceBoat = null;
private static Material birchBoat = null;
private static Material jungleBoat = null;
private static Material acaciaBoat = null;
private static Material darkOakBoat = null;

static {
if (Skript.classExists("org.bukkit.entity.ChestBoat")) {
//noinspection ConstantConditions
oakBoat = Material.getMaterial("OAK_CHEST_BOAT");
//noinspection ConstantConditions
spruceBoat = Material.getMaterial("SPRUCE_CHEST_BOAT");
//noinspection ConstantConditions
birchBoat = Material.getMaterial("BIRCH_CHEST_BOAT");
//noinspection ConstantConditions
jungleBoat = Material.getMaterial("JUNGLE_CHEST_BOAT");
//noinspection ConstantConditions
acaciaBoat = Material.getMaterial("ACACIA_CHEST_BOAT");
//noinspection ConstantConditions
darkOakBoat = Material.getMaterial("DARK_OAK_CHEST_BOAT");
EntityData.register(BoatChestData.class, "chest boat", ChestBoat.class, 0,
"chest boat", "any chest boat", "oak chest boat", "spruce chest boat", "birch chest boat",
"jungle chest boat", "acacia chest boat", "dark oak chest boat");
Expand Down Expand Up @@ -131,17 +112,17 @@ public boolean isOfItemType(ItemType itemType) {

ItemStack stack = itemType.getRandom();
Material type = stack.getType();
if (oakBoat == type)
if (type == Material.OAK_CHEST_BOAT)
ordinal = 0;
else if (spruceBoat == type)
else if (type == Material.SPRUCE_CHEST_BOAT)
ordinal = TreeSpecies.REDWOOD.ordinal();
else if (birchBoat == type)
else if (type == Material.BIRCH_CHEST_BOAT)
ordinal = TreeSpecies.BIRCH.ordinal();
else if (jungleBoat == type)
else if (type == Material.JUNGLE_CHEST_BOAT)
ordinal = TreeSpecies.JUNGLE.ordinal();
else if (acaciaBoat == type)
else if (type == Material.ACACIA_CHEST_BOAT)
ordinal = TreeSpecies.ACACIA.ordinal();
else if (darkOakBoat == type)
else if (type == Material.DARK_OAK_CHEST_BOAT)
ordinal = TreeSpecies.DARK_OAK.ordinal();
return hashCode_i() == ordinal + 2 || (matchedPattern + ordinal == 0) || ordinal == 0;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprSpawnerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -51,9 +52,12 @@ public class ExprSpawnerType extends SimplePropertyExpression<Block, EntityData>
@Override
@Nullable
public EntityData convert(Block block) {
if (block.getType() != Material.SPAWNER)
if (!(block.getState() instanceof CreatureSpawner))
return null;
return EntityUtils.toSkriptEntityData(((CreatureSpawner) block.getState()).getSpawnedType());
EntityType type = ((CreatureSpawner) block.getState()).getSpawnedType();
if (type == null)
return null;
return EntityUtils.toSkriptEntityData(type);
}

@Nullable
Expand Down

0 comments on commit 15ca3d6

Please sign in to comment.