Stackable consistency, ender pearls not working, lava/water check fixes

This commit is contained in:
Esophose 2019-08-13 11:35:28 -06:00
parent 3265fcc15c
commit b281f61eef
3 changed files with 13 additions and 132 deletions

View File

@ -75,11 +75,11 @@ public class GeneratorManager {
}
private boolean isLava(Block block) {
return block.getType().equals(Materials.LAVA.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_LAVA.parseMaterial());
return block.getType().name().contains("LAVA");
}
private boolean isWater(Block block) {
return block.getType().equals(Materials.WATER.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_WATER.parseMaterial());
return block.getType().name().contains("WATER");
}
public boolean isGenerator(Block block) {
@ -98,122 +98,6 @@ public class GeneratorManager {
}
return false;
//region GoodAndEvil his old code (garbage)
/*
if (block.getRelative(BlockFace.UP).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
&& block.getRelative(BlockFace.UP).getType() != Materials.WATER.parseMaterial()) {
Block flowBlock = null;
if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(BlockFace.EAST).getType() == Materials.WATER.parseMaterial())
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.WEST).getType() == Materials.LAVA.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.EAST)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.EAST)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
return false;
}
flowBlock = block.getRelative(BlockFace.EAST);
} else if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial() || block.getRelative(BlockFace.EAST).getType() == Materials.LAVA.parseMaterial())
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.WEST).getType() == Materials.WATER.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.WEST)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.WEST)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
return false;
}
flowBlock = block.getRelative(BlockFace.WEST);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == Materials.WATER.parseMaterial()))
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.LAVA.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.NORTH)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.NORTH)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
return false;
}
flowBlock = block.getRelative(BlockFace.NORTH);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == Materials.LAVA.parseMaterial()))
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.WATER.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.SOUTH)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.SOUTH)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
return false;
}
flowBlock = block.getRelative(BlockFace.SOUTH);
}
if (flowBlock != null) {
return isFlowingBlock(flowBlock);
}
}
return false;
}
private boolean isFlowingTowardsBlock(Block block, BlockFace blockFace1, BlockFace blockFace2) {
if (block.getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(blockFace1).getType() == Materials.WATER.parseMaterial()) {
if (isFlowingBlock(block.getRelative(blockFace1)) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D)
.getBlock().getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace1)
.getType() == Materials.WATER.parseMaterial())) {
if (block.getRelative(blockFace2).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(blockFace2).getType() == Materials.WATER.parseMaterial()) {
if (isFlowingBlock(block.getRelative(blockFace2)) && (block.getLocation().clone()
.subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
.getType() == Materials.WATER.parseMaterial())) {
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
return true;
*/
//endregion
}
@SuppressWarnings("deprecation")

View File

@ -77,7 +77,7 @@ public class Teleport implements Listener {
return;
}
if (isCause) {
if (isCause && event.getCause() != TeleportCause.ENDER_PEARL) {
event.setCancelled(true);
return;
}

View File

@ -31,7 +31,7 @@ public class Stackable {
public Stackable(Location location, Material material) {
this.uuid = UUID.randomUUID();
this.location = location;
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.material = material;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@ -40,7 +40,7 @@ public class Stackable {
public Stackable(UUID uuid, Location location, Material material, int size) {
this.uuid = uuid;
this.location = location;
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.material = material;
this.size = size;
this.updateDisplay();
@ -78,14 +78,14 @@ public class Stackable {
}
public void addOne() {
this.size ++;
this.size++;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
this.save();
}
public void takeOne() {
this.size --;
this.size--;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
this.save();
@ -93,7 +93,6 @@ public class Stackable {
private void updateDisplay() {
if (this.size > 1) {
this.removeDisplay();
this.createDisplay();
this.display.setCustomName(this.getCustomName());
this.display.setCustomNameVisible(true);
@ -101,10 +100,10 @@ public class Stackable {
this.removeDisplay();
}
}
private void createDisplay() {
this.removeDisplay();
Location dropLocation = this.location.clone().add(0.5, 1, 0.5);
ArmorStand as = (ArmorStand) this.location.getWorld().spawnEntity(dropLocation, EntityType.ARMOR_STAND);
as.setVisible(false);
@ -124,13 +123,11 @@ public class Stackable {
if (this.display != null) {
this.display.remove();
}
// Find any stragglers
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.1, 0.5, 0.1)) {
if (entity instanceof ArmorStand && entity.isValid()) {
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.1, 0.5, 0.1))
if (entity instanceof ArmorStand)
entity.remove();
}
}
}
private void save() {
@ -138,7 +135,7 @@ public class Stackable {
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(configFile,
SkyBlock.getInstance().getIslandManager().getIslandAtLocation(this.location).getOwnerUUID() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (this.getSize() == 0) {
configLoad.set("Stackables." + this.getUuid().toString(), null);
} else {