Skip to content

Commit

Permalink
fix: 清除多余的变量
Browse files Browse the repository at this point in the history
  • Loading branch information
JWJUN233233 committed May 27, 2024
1 parent a5222a2 commit 8ee6959
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ public String getKey() {
}

public abstract void setData(String key, String val);

public abstract boolean isPendingRemove();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners;

import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ASlimefunDataContainer;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunUniversalData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
Expand Down Expand Up @@ -182,12 +183,12 @@ public void onBlockBreak(BlockBreakEvent e) {

var heldItem = e.getPlayer().getInventory().getItemInMainHand();
var block = e.getBlock();
var blockData = StorageCacheUtils.getBlock(block.getLocation());
var universalData = StorageCacheUtils.getUniversalData(block);
ASlimefunDataContainer data = StorageCacheUtils.getBlock(block.getLocation());
if (data == null) data = StorageCacheUtils.getUniversalData(block);

// If there is a Slimefun Block here, call our BreakEvent and, if cancelled, cancel this event
// and return
if (blockData != null) {
if (data instanceof SlimefunBlockData blockData) {
var sfItem = SlimefunItem.getById(blockData.getSfId());
SlimefunBlockBreakEvent breakEvent =
new SlimefunBlockBreakEvent(e.getPlayer(), heldItem, e.getBlock(), sfItem);
Expand All @@ -199,7 +200,7 @@ public void onBlockBreak(BlockBreakEvent e) {
}
}

if (universalData != null) {
if (data instanceof SlimefunUniversalData universalData) {
var sfItem = SlimefunItem.getById(universalData.getSfId());
SlimefunBlockBreakEvent breakEvent =
new SlimefunBlockBreakEvent(e.getPlayer(), heldItem, e.getBlock(), sfItem);
Expand All @@ -223,14 +224,12 @@ public void onBlockBreak(BlockBreakEvent e) {
// TODO: merge this with the vanilla sensitive block check (when 1.18- is dropped)
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock(), heldItem);

if ((blockData == null && universalData == null)
|| (blockData != null && blockData.isPendingRemove())
|| (universalData != null && universalData.isPendingRemove())) {
if (data == null || data.isPendingRemove()) {
dropItems(e, drops);
return;
}

if (blockData != null) {
if (data instanceof SlimefunBlockData blockData) {
blockData.setPendingRemove(true);

if (!blockData.isDataLoaded()) {
Expand Down Expand Up @@ -258,7 +257,7 @@ public void onBlockBreak(BlockBreakEvent e) {
}
}

if (universalData != null) {
if (data instanceof SlimefunUniversalData universalData) {
universalData.setPendingRemove(true);

if (!universalData.isDataLoaded()) {
Expand Down

0 comments on commit 8ee6959

Please sign in to comment.