Skip to content

Commit

Permalink
Finished updating source code to 1.13 API
Browse files Browse the repository at this point in the history
Test units still need to be updated.
  • Loading branch information
Poslovitch committed Aug 1, 2018
1 parent efb2adb commit e6418f0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void setHead(PanelItem item) {
items.values().stream().filter(i -> i.getName().equals(item.getName())).forEach(i -> i = item);
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack it = inventory.getItem(i);
if (it != null && it.getType().equals(Material.SKULL_ITEM)) {
if (it != null && it.getType().equals(Material.PLAYER_HEAD)) {
ItemMeta meta = it.getItemMeta();
if (item.getName().equals(meta.getLocalizedName())) {
inventory.setItem(i, item.getItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,21 @@ private void setBlock(Island island, Block block, ConfigurationSection config, M
if (rel.isEmpty() || rel.isLiquid()) {
rel.setType(Material.STONE);
block.setType(material);
block.setBlockData(new BlockData(d.ordinal()));
// FIXME block.setBlockData(new BlockData(d.ordinal()));
// Set the block back to what it was
rel.setType(rm);
rel.setBlockData(data);
} else {
block.setType(material);
block.setBlockData((byte)d.ordinal());
// FIXME block.setBlockData((byte)d.ordinal());
}
return;
}
// Set the block type
block.setType(material, false);
// Set the block data
byte data = (byte)config.getInt("data");
block.setBlockData(data);
// FIXME block.setBlockData(data);

// Get the block state
BlockState bs = block.getState();
Expand Down Expand Up @@ -506,10 +506,6 @@ private boolean copyBlock(Block block, Location copyOrigin, boolean copyAir, Col
Colorable c = (Colorable)md;
s.set(COLOR, c.getColor().name());
}
if (block.getType().equals(Material.CARPET)) {
DyeColor c = DyeColor.getByWoolData(block.getData());
s.set(COLOR, c.name());
}
if (md instanceof Redstone) {
Redstone r = (Redstone)md;
blockConfig.set(POWERED, r.isPowered());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,18 @@ public void onPlayerInteract(final PlayerInteractEvent e) {
Block lastBlock = iter.next();
while (iter.hasNext()) {
lastBlock = iter.next();
if (lastBlock.getType().equals(Material.SKULL)) {
if (lastBlock.getType().toString().endsWith("_SKULL") || (lastBlock.getType().toString().endsWith("_HEAD") && !lastBlock.getType().equals(Material.PISTON_HEAD))) {
checkIsland(e, lastBlock.getLocation(), Flags.BREAK_BLOCKS);
return;
}
}
} catch (Exception ignored) {}

switch (e.getClickedBlock().getType()) {
case CAKE_BLOCK:
case CAKE:
case DRAGON_EGG:
case MOB_SPAWNER:
case SPAWNER:
checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS);
return;
case BED_BLOCK:
if (e.getPlayer().getWorld().getEnvironment().equals(Environment.NETHER)) {
// Prevent explosions checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS);
return;
}
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package world.bentobox.bentobox.listeners.flags;

import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -55,15 +56,15 @@ public void onPlayerInteract(final PlayerInteractEvent e) {
return;
}
switch (e.getClickedBlock().getType()) {
case FIREWORK:
case FIREWORK_ROCKET:
checkIsland(e, e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
return;
case RAILS:
case RAIL:
case POWERED_RAIL:
case DETECTOR_RAIL:
case ACTIVATOR_RAIL:
if (e.getMaterial() != null && (e.getMaterial() == Material.MINECART || e.getMaterial() == Material.STORAGE_MINECART || e.getMaterial() == Material.HOPPER_MINECART
|| e.getMaterial() == Material.EXPLOSIVE_MINECART || e.getMaterial() == Material.POWERED_MINECART)) {
if (e.getMaterial() != null && (e.getMaterial() == Material.MINECART || e.getMaterial() == Material.CHEST_MINECART || e.getMaterial() == Material.HOPPER_MINECART
|| e.getMaterial() == Material.TNT_MINECART || e.getMaterial() == Material.FURNACE_MINECART)) {
checkIsland(e, e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
}
return;
Expand All @@ -72,9 +73,9 @@ public void onPlayerInteract(final PlayerInteractEvent e) {
// This check protects against an exploit in 1.7.9 against cactus
// and sugar cane and placing boats on non-liquids
if (e.getMaterial() != null
&& (e.getMaterial().equals(Material.END_CRYSTAL) || e.getMaterial().equals(Material.WOOD_DOOR)
&& (e.getMaterial().equals(Material.END_CRYSTAL) || Tag.DOORS.isTagged(e.getMaterial())
|| e.getMaterial().equals(Material.CHEST) || e.getMaterial().equals(Material.TRAPPED_CHEST)
|| e.getMaterial().equals(Material.IRON_DOOR) || (e.getMaterial().name().contains("BOAT")
|| (e.getMaterial().name().contains("BOAT")
&& !e.getClickedBlock().isLiquid()))) {
checkIsland(e, e.getPlayer().getLocation(), Flags.PLACE_BLOCKS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ public boolean isSafeLocation(Location l) {
return false;
}
}
if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().toString().contains("FENCE")
|| ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
if (ground.getType().equals(Material.CACTUS) || ground.getType().toString().contains("BOAT") || ground.getType().toString().contains("FENCE")
|| ground.getType().equals(Material.SIGN) || ground.getType().equals(Material.WALL_SIGN)) {
return false;
}
// Check that the space is not solid
// The isSolid function is not fully accurate (yet) so we have to
// check
// a few other items
// isSolid thinks that PLATEs and SIGNS are solid, but they are not
return (!space1.getType().isSolid() || space1.getType().equals(Material.SIGN_POST) || space1.getType().equals(Material.WALL_SIGN)) && (!space2.getType().isSolid() || space2.getType().equals(Material.SIGN_POST) || space2.getType().equals(Material.WALL_SIGN));
return (!space1.getType().isSolid() || space1.getType().equals(Material.SIGN) || space1.getType().equals(Material.WALL_SIGN)) && (!space2.getType().isSolid() || space2.getType().equals(Material.SIGN) || space2.getType().equals(Material.WALL_SIGN));
}

/**
Expand Down Expand Up @@ -531,7 +531,7 @@ public void homeTeleport(World world, Player player, int number, boolean newIsla
player.leaveVehicle();
// Remove the boat so they don't lie around everywhere
boat.remove();
player.getInventory().addItem(new ItemStack(Material.BOAT, 1));
player.getInventory().addItem(new ItemStack(Material.getMaterial(((Boat) boat).getWoodType().toString() + "_BOAT"), 1));
player.updateInventory();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static void setupHeader(User user, PanelBuilder panelBuilder, Flag.Type
}

while(panelBuilder.nextSlot() < 9) {
panelBuilder.item(new PanelItemBuilder().icon(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15)).build());
panelBuilder.item(new PanelItemBuilder().icon(new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE, 1)).build());
}
}
}
18 changes: 3 additions & 15 deletions src/main/java/world/bentobox/bentobox/util/ItemParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ private static ItemStack two(String[] part) {
return null;
}

Material reqItem = Material.getMaterial(part[0].toUpperCase() + "_ITEM");
if (reqItem == null) {
// Try the item
reqItem = Material.getMaterial(part[0].toUpperCase());
}

Material reqItem = Material.getMaterial(part[0].toUpperCase());
if (reqItem == null) {
return null;
}
Expand All @@ -76,12 +71,6 @@ private static ItemStack three(String[] part) {
}
if (StringUtils.isNumeric(part[1])) {
result.setDurability((short) Integer.parseInt(part[1]));
} else if (result.getType().equals(Material.MONSTER_EGG)) {
// Check if this is a string
EntityType entityType = EntityType.valueOf(part[1]);
SpawnEggMeta meta = ((SpawnEggMeta)result.getItemMeta());
meta.setSpawnedType(entityType);
result.setItemMeta(meta);
}
return result;
}
Expand Down Expand Up @@ -130,13 +119,12 @@ private static ItemStack potion(String[] part) {
private static ItemStack banner(String[] part) {
try {
if (part.length == 2) {
return new ItemStack(Material.BANNER, Integer.parseInt(part[1]));
return new ItemStack(Material.WHITE_BANNER, Integer.parseInt(part[1]));
}
if (part.length >= 3) {
int reqAmount = Integer.parseInt(part[1]);

@SuppressWarnings("deprecation")
ItemStack result = new ItemStack(Material.BANNER, reqAmount, DyeColor.valueOf(part[2]).getDyeData());
ItemStack result = new ItemStack(Material.getMaterial(part[2] + "_BANNER"), reqAmount);

BannerMeta meta = (BannerMeta) result.getItemMeta();
for (int i = 3; i < part.length; i += 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z, int worldHe
case LEVER:
case TALL_GRASS:
case PISTON_HEAD:
case MOVING_PISTON:
case SIGN:
case STONE_BUTTON:
case TORCH:
Expand Down

0 comments on commit e6418f0

Please sign in to comment.