mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Some minor optimization
This commit is contained in:
parent
60e7f8dc1d
commit
6c4c9cdc17
@ -13,6 +13,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -75,10 +76,11 @@ public class ToolListener implements Listener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
boolean supportsPersistentData = e.getBlock().getState() instanceof TileState;
|
BlockState state = e.getBlock().getState();
|
||||||
|
boolean supportsPersistentData = state instanceof TileState;
|
||||||
|
|
||||||
if (supportsPersistentData) {
|
if (supportsPersistentData) {
|
||||||
SlimefunPlugin.getBlockDataService().setBlockData((TileState) e.getBlock().getState(), sfItem.getID());
|
SlimefunPlugin.getBlockDataService().setBlockData((TileState) state, sfItem.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
|
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
|
||||||
@ -200,13 +202,16 @@ public class ToolListener implements Listener {
|
|||||||
if (sensitiveMaterials.contains(block2.getType())) {
|
if (sensitiveMaterials.contains(block2.getType())) {
|
||||||
SlimefunItem sfItem = BlockStorage.check(e.getBlock().getRelative(BlockFace.UP));
|
SlimefunItem sfItem = BlockStorage.check(e.getBlock().getRelative(BlockFace.UP));
|
||||||
|
|
||||||
if (sfItem == null && e.getBlock().getState() instanceof TileState) {
|
if (sfItem == null) {
|
||||||
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) e.getBlock().getState());
|
BlockState state = block2.getState();
|
||||||
|
if (state instanceof TileState) {
|
||||||
|
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) state);
|
||||||
|
|
||||||
if (blockData.isPresent()) {
|
if (blockData.isPresent()) {
|
||||||
sfItem = SlimefunItem.getByID(blockData.get());
|
sfItem = SlimefunItem.getByID(blockData.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
||||||
SlimefunBlockHandler blockHandler = utilities.blockHandlers.get(sfItem.getID());
|
SlimefunBlockHandler blockHandler = utilities.blockHandlers.get(sfItem.getID());
|
||||||
@ -227,13 +232,17 @@ public class ToolListener implements Listener {
|
|||||||
|
|
||||||
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
|
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
|
||||||
|
|
||||||
if (sfItem == null && e.getBlock().getState() instanceof TileState) {
|
if (sfItem == null) {
|
||||||
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) e.getBlock().getState());
|
BlockState state = e.getBlock().getState();
|
||||||
|
|
||||||
|
if (state instanceof TileState) {
|
||||||
|
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) state);
|
||||||
|
|
||||||
if (blockData.isPresent()) {
|
if (blockData.isPresent()) {
|
||||||
sfItem = SlimefunItem.getByID(blockData.get());
|
sfItem = SlimefunItem.getByID(blockData.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
||||||
SlimefunBlockHandler blockHandler = utilities.blockHandlers.get(sfItem.getID());
|
SlimefunBlockHandler blockHandler = utilities.blockHandlers.get(sfItem.getID());
|
||||||
|
Loading…
Reference in New Issue
Block a user