Skip to content

Commit

Permalink
Fix crash when pitch is not finite.
Browse files Browse the repository at this point in the history
Also, accept "minecraft:white_dye" type format for item types.
  • Loading branch information
LadyCailin committed Apr 16, 2024
1 parent 4b063b0 commit 986dadb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ public MCItemStack GetItemStack(String type, int qty) {
if(mat == null) {
mat = BukkitMCLegacyMaterial.getMaterial(type);
}
if(mat == null) {
mat = Material.matchMaterial(type);
}
if(mat == null) {
return null;
}
Expand Down Expand Up @@ -679,8 +682,8 @@ public static MCItemMeta BukkitGetCorrectMeta(ItemMeta im) {
public MCInventory GetEntityInventory(MCEntity e) {
Entity entity = ((BukkitMCEntity) e).getHandle();
if(entity instanceof InventoryHolder) {
if(entity instanceof Player) {
return new BukkitMCPlayerInventory(((Player) entity).getInventory());
if(entity instanceof Player p) {
return new BukkitMCPlayerInventory(p.getInventory());
}
return new BukkitMCInventory(((InventoryHolder) entity).getInventory());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
throw new CREFormatException("An array was expected but received " + args[1], t);
}
try {
if(!Float.isFinite(l.getPitch())) {
throw new CREIllegalArgumentException("pitch not finite", t);
}
return CBoolean.get(e.teleport(l));
} catch (IllegalArgumentException ex) {
throw new CREIllegalArgumentException(ex.getMessage(), t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ public Integer[] numArgs() {

@Override
public String docs() {
return "int {specifier, itemArray} Add to inventory the specified item."
return "int {mixed specifier, array itemArray} Add to inventory the specified item."
+ " The specifier must be a location array, entity UUID, or virtual inventory id."
+ " The items are distributed in the inventory, first filling up slots that have the same item type,"
+ " up to the max stack size, then fills up empty slots, until either the entire inventory is filled,"
Expand Down

0 comments on commit 986dadb

Please sign in to comment.