Skip to content

Commit acfd9f7

Browse files
committed
add fake block api
1 parent 4db4bf7 commit acfd9f7

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>xyz.webmc</groupId>
55
<artifactId>wlib</artifactId>
6-
<version>1.1.0-SNAPSHOT</version>
6+
<version>1.1.1-SNAPSHOT</version>
77
<distributionManagement>
88
<repository>
99
<id>github</id>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package xyz.webmc.wlib.util;
2+
3+
import org.bukkit.Chunk;
4+
import org.bukkit.Location;
5+
import org.bukkit.Material;
6+
import org.bukkit.World;
7+
import org.bukkit.entity.Player;
8+
9+
import dev.colbster937.reflect.Mirror;
10+
import dev.colbster937.reflect.MirrorSafe;
11+
12+
@SuppressWarnings({ "deprecation" })
13+
public final class MagicUtil {
14+
public static final void sendFakeBlock(final Location loc, final Material mat, final byte dat) {
15+
final World wrld = loc.getWorld();
16+
final Chunk chnk = wrld.getChunkAt(loc);
17+
18+
for (final Player plr : wrld.getPlayers()) {
19+
boolean sent = true;
20+
if (Mirror.hasMethod(plr.getClass(), "isChunkSent", Chunk.class)) {
21+
sent = MirrorSafe.invokeMethod(plr, "isChunkSent", chnk);
22+
}
23+
if (sent) {
24+
plr.sendBlockChange(loc, mat.getId(), dat);
25+
}
26+
}
27+
}
28+
29+
public static final void sendFakeBlock(final Location loc, final Material mat) {
30+
sendFakeBlock(loc, mat, (byte) 0);
31+
}
32+
}

0 commit comments

Comments
 (0)