Skip to content

Commit f3bafd2

Browse files
committed
Update for Minecraft 1.8.4
1 parent ee88cac commit f3bafd2

File tree

5 files changed

+41
-28
lines changed

5 files changed

+41
-28
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.pepsoft</groupId>
66
<artifactId>BukkitScript</artifactId>
7-
<version>0.1.4-1.7.9</version>
7+
<version>0.1.4-1.8.4</version>
88
<packaging>jar</packaging>
99

1010
<name>BukkitScript</name>
@@ -43,12 +43,12 @@
4343
<dependency>
4444
<groupId>org.bukkit</groupId>
4545
<artifactId>bukkit</artifactId>
46-
<version>1.7.9-R0.1-SNAPSHOT</version>
46+
<version>1.8.3-R0.1-SNAPSHOT</version>
4747
</dependency>
4848
<dependency>
4949
<groupId>org.bukkit</groupId>
5050
<artifactId>craftbukkit</artifactId>
51-
<version>1.7.9-R0.1-SNAPSHOT</version>
51+
<version>1.8.3-R0.1-SNAPSHOT</version>
5252
</dependency>
5353
</dependencies>
5454
</project>

src/main/java/org/pepsoft/bukkit/bukkitscript/BukkitScriptPlugin.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
*/
55
package org.pepsoft.bukkit.bukkitscript;
66

7-
import java.util.List;
8-
import java.util.Set;
9-
import java.util.logging.Level;
10-
import java.util.logging.Logger;
117
import org.bukkit.ChatColor;
8+
import org.bukkit.Material;
129
import org.bukkit.World;
1310
import org.bukkit.block.Block;
1411
import org.bukkit.command.Command;
@@ -18,6 +15,10 @@
1815
import org.pepsoft.bukkit.bukkitscript.context.Context;
1916
import org.pepsoft.bukkit.bukkitscript.event.EventSpec;
2017

18+
import java.util.List;
19+
import java.util.Set;
20+
import java.util.logging.Logger;
21+
2122
/**
2223
*
2324
* @author pepijn
@@ -38,7 +39,7 @@ public void onEnable() {
3839

3940
@Override
4041
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
41-
if ((sender instanceof Player) && (! ((Player) sender).isOp())) {
42+
if ((sender instanceof Player) && (! sender.isOp())) {
4243
sender.sendMessage(ChatColor.RED + "You don't have permission to execute that command");
4344
return true;
4445
}
@@ -89,7 +90,7 @@ private boolean setName(CommandSender sender, String[] args) {
8990
}
9091
String name = args[0].trim();
9192
Player player = (Player) sender;
92-
List<Block> lineOfSight = player.getLineOfSight(null, 10);
93+
List<Block> lineOfSight = player.getLineOfSight((Set<Material>) null, 10);
9394
for (Block block: lineOfSight) {
9495
if (! block.isEmpty()) {
9596
World world = player.getWorld();
@@ -179,7 +180,7 @@ private boolean getName(CommandSender sender, String[] args) {
179180
return true;
180181
}
181182
Player player = (Player) sender;
182-
List<Block> lineOfSight = player.getLineOfSight(null, 10);
183+
List<Block> lineOfSight = player.getLineOfSight((Set<Material>) null, 10);
183184
for (Block block: lineOfSight) {
184185
if (! block.isEmpty()) {
185186
World world = player.getWorld();
@@ -284,7 +285,7 @@ private boolean clearName(CommandSender sender, String[] args) {
284285
}
285286
if (identifier == null) {
286287
Player player = (Player) sender;
287-
List<Block> lineOfSight = player.getLineOfSight(null, 10);
288+
List<Block> lineOfSight = player.getLineOfSight((Set<Material>) null, 10);
288289
for (Block block: lineOfSight) {
289290
if (! block.isEmpty()) {
290291
Location location = new Location(player.getWorld().getName(), block.getX(), block.getY(), block.getZ());

src/main/java/org/pepsoft/bukkit/bukkitscript/context/BlockHelper.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
*/
55
package org.pepsoft.bukkit.bukkitscript.context;
66

7-
import net.minecraft.server.v1_7_R3.EntityHuman;
7+
import net.minecraft.server.v1_8_R2.BlockPosition;
8+
import net.minecraft.server.v1_8_R2.EntityHuman;
89
import org.bukkit.Material;
910
import org.bukkit.OfflinePlayer;
1011
import org.bukkit.World;
11-
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
12-
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
12+
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
13+
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
14+
import org.bukkit.material.Lever;
1315

1416
/**
1517
*
@@ -98,6 +100,13 @@ private static void interact(org.bukkit.block.Block realBlock, OfflinePlayer rea
98100
org.bukkit.entity.Player onlinePlayer = (realPlayer != null) ? realPlayer.getPlayer() : null;
99101
EntityHuman entityHuman = (onlinePlayer != null) ? ((CraftPlayer) onlinePlayer).getHandle() : null;
100102
// TODO no idea what the last four parameters are for; they are new in MC 1.3.1:
101-
net.minecraft.server.v1_7_R3.Block.e(realBlock.getTypeId()).interact(((CraftWorld) realBlock.getWorld()).getHandle(), realBlock.getX(), realBlock.getY(), realBlock.getZ(), entityHuman, 0, 0f, 0f, 0f);
103+
net.minecraft.server.v1_8_R2.Block mcBlock = net.minecraft.server.v1_8_R2.Block.getById(realBlock.getTypeId());
104+
mcBlock.interact(
105+
((CraftWorld) realBlock.getWorld()).getHandle(),
106+
new BlockPosition(realBlock.getX(), realBlock.getY(), realBlock.getZ()),
107+
mcBlock.fromLegacyData(realBlock.getData()),
108+
entityHuman,
109+
null,
110+
0.0f, 0.0f, 0.0f);
102111
}
103112
}

src/main/java/org/pepsoft/bukkit/bukkitscript/context/Box.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
*/
55
package org.pepsoft.bukkit.bukkitscript.context;
66

7-
import java.util.logging.Level;
8-
import net.minecraft.server.v1_7_R3.Chunk;
7+
import net.minecraft.server.v1_8_R2.Block;
8+
import net.minecraft.server.v1_8_R2.BlockPosition;
9+
import net.minecraft.server.v1_8_R2.Chunk;
10+
import net.minecraft.server.v1_8_R2.IBlockData;
911
import org.bukkit.Material;
1012
import org.bukkit.OfflinePlayer;
1113
import org.bukkit.World;
12-
import org.bukkit.craftbukkit.v1_7_R3.CraftChunk;
13-
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
14+
import org.bukkit.craftbukkit.v1_8_R2.CraftChunk;
15+
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
1416
import org.bukkit.entity.Entity;
1517
import org.bukkit.event.EventHandler;
1618
import org.bukkit.event.EventPriority;
@@ -21,10 +23,12 @@
2123
import org.pepsoft.bukkit.Constants;
2224
import org.pepsoft.bukkit.bukkitscript.BukkitScriptPlugin;
2325
import org.pepsoft.bukkit.bukkitscript.Location;
24-
import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerVisitor;
2526
import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerProvider;
27+
import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerVisitor;
2628
import org.pepsoft.bukkit.bukkitscript.event.Event;
2729

30+
import java.util.logging.Level;
31+
2832
/**
2933
*
3034
* @author pepijn
@@ -176,20 +180,21 @@ public boolean visitEntity(World world, Entity entity) {
176180

177181
void set(int typeId, byte data) {
178182
// Go chunk by chunk to try to be as efficient as possible
183+
IBlockData blockData = Block.getById(typeId).fromLegacyData(data);
179184
int chunkX1 = corner1.x >> 4;
180185
int chunkX2 = corner2.x >> 4;
181186
int chunkZ1 = corner1.z >> 4;
182187
int chunkZ2 = corner2.z >> 4;
183188
for (int chunkX = chunkX1; chunkX <= chunkX2; chunkX++) {
184189
for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) {
185-
net.minecraft.server.v1_7_R3.World mcWorld = ((CraftWorld) realWorld).getHandle();
190+
net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) realWorld).getHandle();
186191
for (int y = corner1.y; y <= corner2.y; y++) {
187192
for (int dx = 0; dx < 16; dx++) {
188193
for (int dz = 0; dz < 16; dz++) {
189194
int x = (chunkX << 4) | dx;
190195
int z = (chunkZ << 4) | dz;
191196
if ((x >= corner1.x) && (x <= corner2.x) && (z >= corner1.z) && (z <= corner2.z)) {
192-
mcWorld.setTypeAndData(x, y, z, net.minecraft.server.v1_7_R3.Block.e(typeId), data, FLAG_UPDATE | FLAG_MARK_CHUNK_DIRTY | FLAG_ONLY_IF_NOT_STATIC);
197+
mcWorld.setTypeUpdate(new BlockPosition(x, y, z), blockData);
193198
}
194199
}
195200
}
@@ -218,7 +223,7 @@ void visitBlocks(int blockTypeId, BlockVisitor visitor) {
218223
for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) {
219224
Chunk chunk = ((CraftChunk) this.realWorld.getChunkAt(chunkX, chunkZ)).getHandle();
220225
for (int y = corner1.y; y <= corner2.y; y++) {
221-
if (chunk.i()[(y >> 4)] == null) {
226+
if (chunk.getSections()[(y >> 4)] == null) {
222227
if (blockTypeId == 0) {
223228
for (int dx = 0; dx < 16; dx++) {
224229
for (int dz = 0; dz < 16; dz++) {
@@ -263,7 +268,7 @@ void visitBlocks(int blockTypeId, int blockDataMask, int blockDataValue, BlockVi
263268
for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) {
264269
Chunk chunk = ((CraftChunk) this.realWorld.getChunkAt(chunkX, chunkZ)).getHandle();
265270
for (int y = corner1.y; y <= corner2.y; y++) {
266-
if (chunk.i()[(y >> 4)] == null) {
271+
if (chunk.getSections()[(y >> 4)] == null) {
267272
if ((blockTypeId == 0) && (blockDataValue == 0)) {
268273
for (int dx = 0; dx < 16; dx++) {
269274
for (int dz = 0; dz < 16; dz++) {
@@ -320,13 +325,11 @@ void visitEntities(Class<? extends Entity> entityType, EntityVisitor visitor) {
320325
}
321326
}
322327
}
328+
323329
private final org.bukkit.World realWorld;
324330
private final OfflinePlayer realPlayer;
325331
private final Location corner1, corner2;
326332
static final EventListener EVENT_LISTENER = new EventListener();
327-
private static final int FLAG_UPDATE = 0x1;
328-
private static final int FLAG_MARK_CHUNK_DIRTY = 0x2;
329-
private static final int FLAG_ONLY_IF_NOT_STATIC = 0x4;
330333

331334
public interface BlockVisitor {
332335
boolean visitBlock(org.bukkit.World world, int x, int y, int z, int blockTypeId, int blockData);

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: BukkitScript
2-
version: 0.1.4-1.7.9
2+
version: 0.1.4-1.8.4
33
main: org.pepsoft.bukkit.bukkitscript.BukkitScriptPlugin
44
commands:
55
setname:

0 commit comments

Comments
 (0)