Skip to content

Commit c7ea638

Browse files
authored
Merge pull request #11 from Kooperlol/1.0.0
Alpha 3
2 parents b1e77b3 + 786fa7f commit c7ea638

6 files changed

Lines changed: 22 additions & 9 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group = 'codes.kooper'
7-
version = '1.0.0-alpha-2'
7+
version = '1.0.0-alpha-3'
88

99
repositories {
1010
mavenCentral()

src/main/java/codes/kooper/blockify/managers/BlockChangeManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ private ConcurrentHashMap<BlockifyChunk, ConcurrentHashMap<BlockifyPosition, Blo
309309
for (View view : stage.getViews()) {
310310
for (Map.Entry<BlockifyChunk, ConcurrentHashMap<BlockifyPosition, BlockData>> entry : view.getBlocks().entrySet()) {
311311
if (!chunks.contains(entry.getKey())) continue;
312-
blockChanges.put(entry.getKey(), entry.getValue());
312+
if (blockChanges.containsKey(entry.getKey())) {
313+
blockChanges.get(entry.getKey()).putAll(entry.getValue());
314+
} else {
315+
blockChanges.put(entry.getKey(), new ConcurrentHashMap<>(entry.getValue()));
316+
}
313317
}
314318
}
315319
return blockChanges;

src/main/java/codes/kooper/blockify/managers/StageManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import codes.kooper.blockify.events.DeleteStageEvent;
66
import codes.kooper.blockify.models.Stage;
77
import lombok.Getter;
8+
import org.bukkit.Bukkit;
89
import org.bukkit.entity.Player;
910

1011
import java.util.ArrayList;
@@ -29,7 +30,7 @@ public void createStage(Stage stage) {
2930
Blockify.getInstance().getLogger().warning("Stage with name " + stage.getName() + " already exists!");
3031
return;
3132
}
32-
new CreateStageEvent(stage).callEvent();
33+
Bukkit.getScheduler().runTask(Blockify.getInstance(), () -> new CreateStageEvent(stage).callEvent());
3334
stages.put(stage.getName(), stage);
3435
}
3536

src/main/java/codes/kooper/blockify/models/View.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ public void removeBlocks(Set<BlockifyPosition> positions) {
9999
}
100100
}
101101

102+
/**
103+
* Remove all blocks from the view.
104+
*/
105+
public void removeAllBlocks() {
106+
blocks.clear();
107+
}
108+
102109
/**
103110
* Add a block to the view.
104111
*

src/main/java/codes/kooper/blockify/protocol/BlockDigAdapter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,23 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
5151

5252
// Check if block is breakable, if not, send block change packet to cancel the break
5353
if (!view.isBreakable()) {
54-
player.sendBlockChange(position.toLocation(player.getWorld()), blockData);
54+
event.setCancelled(true);
5555
return;
5656
}
5757

5858
// Block break functionality
5959
if (actionType == DiggingAction.FINISHED_DIGGING || canInstantBreak(player, blockData)) {
6060
Bukkit.getScheduler().runTask(Blockify.getInstance(), () -> {
61+
// Set block to air
62+
view.setBlock(position, Material.AIR.createBlockData());
63+
Blockify.getInstance().getBlockChangeManager().sendBlockChange(view.getStage(), view.getStage().getAudience(), position);
6164
// Call BlockifyBreakEvent
6265
BlockifyBreakEvent blockifyBreakEvent = new BlockifyBreakEvent(player, position, blockData, view, view.getStage());
6366
blockifyBreakEvent.callEvent();
6467
// If block is not cancelled, break the block, otherwise, revert the block
65-
if (!blockifyBreakEvent.isCancelled()) {
66-
view.setBlock(position, Material.AIR.createBlockData());
67-
Blockify.getInstance().getBlockChangeManager().sendBlockChange(view.getStage(), view.getStage().getAudience(), position);
68-
} else {
68+
if (blockifyBreakEvent.isCancelled()) {
6969
player.sendBlockChange(position.toLocation(player.getWorld()), blockData);
70+
view.setBlock(position, blockData);
7071
}
7172
});
7273
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Blockify
2-
version: '1.0.0-alpha-2'
2+
version: '1.0.0-alpha-3'
33
main: codes.kooper.blockify.Blockify
44
api-version: '1.20'
55
depend:

0 commit comments

Comments
 (0)