mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 02:35:25 +01:00
Closes SD-1182.
This commit is contained in:
parent
a175fe0747
commit
e6e420bdd1
@ -70,7 +70,43 @@ public class GeneratorManager {
|
||||
generatorStorage.clear();
|
||||
}
|
||||
|
||||
private boolean isFlowingTowardsBlock(Block from){
|
||||
if(!from.isLiquid())
|
||||
return false;
|
||||
|
||||
if(isWater(from) && isFlowingBlock(from))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isLava(Block block){
|
||||
return block.getType().equals(Materials.LAVA.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_LAVA.parseMaterial());
|
||||
}
|
||||
|
||||
private boolean isWater(Block block){
|
||||
return block.getType().equals(Materials.WATER.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_WATER.parseMaterial());
|
||||
}
|
||||
|
||||
public boolean isGenerator(Block block) {
|
||||
BlockFace[] blockFaces = new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
|
||||
for(BlockFace blockFace1 : blockFaces){
|
||||
for(BlockFace blockFace2 : blockFaces){
|
||||
if(blockFace1.equals(blockFace2))
|
||||
continue;
|
||||
|
||||
Block from1 = block.getRelative(blockFace1);
|
||||
Block from2 = block.getRelative(blockFace2);
|
||||
if(isLava(from1) && isWater(from2) && isFlowingTowardsBlock(from2))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -182,23 +218,23 @@ public class GeneratorManager {
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
//endregion
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isFlowingBlock(Block block) {
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
if (block.getState().getBlockData() instanceof Levelled) {
|
||||
if (((Levelled) block.getState().getBlockData()).getLevel() != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (block.getData() != 0) {
|
||||
return true;
|
||||
}
|
||||
private int getLiquidLevel(Block block){
|
||||
if (NMSUtil.getVersionNumber() > 12 && block.getState().getBlockData() instanceof Levelled) {
|
||||
Levelled levelled = (Levelled) block.getState().getBlockData();
|
||||
return levelled.getLevel();
|
||||
}
|
||||
else {
|
||||
return block.getData();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
private boolean isFlowingBlock(Block block) {
|
||||
return getLiquidLevel(block) != 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -73,7 +73,6 @@ public class Block implements Listener {
|
||||
if (NMSUtil.getVersionNumber() < 13) {
|
||||
BlockFace[] blockFaces = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST,
|
||||
BlockFace.SOUTH, BlockFace.WEST };
|
||||
|
||||
for (BlockFace blockFaceList : blockFaces) {
|
||||
if (event.getBlock().getRelative(blockFaceList)
|
||||
.getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial()
|
||||
@ -84,7 +83,6 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setGenerator(new GeneratorLocation(world, block, liquid));
|
||||
|
||||
@ -261,10 +259,8 @@ public class Block implements Listener {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (playerDataManager.hasPlayerData(all)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(all);
|
||||
|
||||
if (playerData.getGenerator() != null) {
|
||||
GeneratorLocation generatorLocation = playerData.getGenerator();
|
||||
|
||||
if (generatorLocation.getWorld() == worldManager.getIslandWorld(block.getWorld())) {
|
||||
if (location.getBlockX() == generatorLocation.getBlockX()
|
||||
&& location.getBlockY() == generatorLocation.getBlockY()
|
||||
@ -272,7 +268,6 @@ public class Block implements Listener {
|
||||
event.setCancelled(true);
|
||||
generatorManager.generateBlock(all, block);
|
||||
playerData.setGenerator(null);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ version: 59
|
||||
api-version: 1.13
|
||||
description: A unique SkyBlock plugin
|
||||
author: GoodAndEvil
|
||||
authors: [GoodAndEvil, Tabuu]
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Coins, LeaderHeads]
|
||||
loadbefore: [Multiverse-Core]
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user