Skip to content

Commit dc1649b

Browse files
committed
[update] よくわからないから永続マグマだけ直す
1 parent 9c91e5f commit dc1649b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/com/github/elic0de/thejpspit/spigot/listener/BlockPlaceListener.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
import com.github.elic0de.thejpspit.spigot.TheJpsPit;
44
import org.bukkit.Bukkit;
55
import org.bukkit.GameMode;
6+
import org.bukkit.Location;
67
import org.bukkit.block.BlockState;
78
import org.bukkit.entity.Player;
89
import org.bukkit.event.EventHandler;
910
import org.bukkit.event.Listener;
1011
import org.bukkit.event.block.BlockPlaceEvent;
1112
import org.bukkit.event.player.PlayerBucketEmptyEvent;
1213

13-
import java.util.HashSet;
14-
import java.util.Set;
14+
import java.util.HashMap;
1515

1616
public class BlockPlaceListener implements Listener {
1717

1818
private final TheJpsPit pit;
1919

20-
private static final Set<BlockState> replacedStates = new HashSet<>();
20+
private static final HashMap<Location, BlockState> replacedStates = new HashMap<>();
2121

2222
public BlockPlaceListener() {
2323
this.pit = TheJpsPit.getInstance();
@@ -30,12 +30,13 @@ public void on(BlockPlaceEvent event) {
3030
if (player.getGameMode() == GameMode.CREATIVE) return;
3131
final BlockState replacedState = event.getBlockReplacedState();
3232

33-
replacedStates.add(replacedState);
33+
if (replacedStates.containsKey(replacedState.getLocation())) return;
34+
replacedStates.put(replacedState.getLocation(), replacedState);
3435

3536
pit.getServer().getScheduler().runTaskLater(pit, runnable -> {
36-
if (replacedStates.contains(replacedState)) {
37+
if (replacedStates.containsKey(replacedState.getLocation())) {
3738
replacedState.update(true);
38-
replacedStates.remove(replacedState);
39+
replacedStates.remove(replacedState.getLocation());
3940
}
4041
}, (15 * 20));
4142
}
@@ -46,17 +47,18 @@ public void on(PlayerBucketEmptyEvent event) {
4647
if (player.getGameMode() == GameMode.CREATIVE) return;
4748
final BlockState replacedState = event.getBlock().getState();
4849

49-
replacedStates.add(replacedState);
50+
if (replacedStates.containsKey(replacedState.getLocation())) return;
51+
replacedStates.put(replacedState.getLocation(), replacedState);
5052

5153
pit.getServer().getScheduler().runTaskLater(pit, runnable -> {
52-
if (replacedStates.contains(replacedState)) {
54+
if (replacedStates.containsKey(replacedState.getLocation())) {
5355
replacedState.update(true);
54-
replacedStates.remove(replacedState);
56+
replacedStates.remove(replacedState.getLocation());
5557
}
5658
}, (15 * 20));
5759
}
5860

5961
public static void restoreBlocks() {
60-
replacedStates.forEach(b -> b.update(true));
62+
replacedStates.values().forEach(b -> b.update(true));
6163
}
6264
}

0 commit comments

Comments
 (0)