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