mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-02-15 01:01:28 +01:00
commit
a0e9fa943c
49
pom.xml
49
pom.xml
@ -55,6 +55,7 @@
|
||||
<powermock.version>2.0.9</powermock.version>
|
||||
<!-- More visible way how to change dependency versions -->
|
||||
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
|
||||
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
|
||||
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
|
||||
<!-- Revision variable removes warning about dynamic version -->
|
||||
<revision>${build.version}-SNAPSHOT</revision>
|
||||
@ -111,10 +112,14 @@
|
||||
</profiles>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bentoboxworld</id>
|
||||
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
|
||||
@ -172,14 +177,7 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Spigot NMS. Used for chunk deletion and pasting. -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc....</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
@ -191,24 +189,6 @@
|
||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc.</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc..</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc...</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -318,10 +298,17 @@
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -153,21 +153,16 @@ public class NewAreaListener implements Listener {
|
||||
* Build something in the queue. Structures are built one by one
|
||||
*/
|
||||
private void buildStructure() {
|
||||
//BentoBox.getInstance().logDebug("buildStructure");
|
||||
// Only kick off a build if there is something to build and something isn't
|
||||
// already being built
|
||||
if (!pasting && !itemsToBuild.isEmpty()) {
|
||||
// Build item
|
||||
//BentoBox.getInstance().logDebug("Build item");
|
||||
StructureRecord item = itemsToBuild.poll();
|
||||
placeStructure(item);
|
||||
} else {
|
||||
//BentoBox.getInstance().logDebug("Nothing to do");
|
||||
}
|
||||
}
|
||||
|
||||
private void placeStructure(StructureRecord item) {
|
||||
//BentoBox.getInstance().logDebug("Placing structure");
|
||||
// Set the semaphore - only paste one at a time
|
||||
pasting = true;
|
||||
// Place the structure - this cannot be done async
|
||||
@ -231,14 +226,13 @@ public class NewAreaListener implements Listener {
|
||||
if (!(addon.inWorld(chunk.getWorld()))) {
|
||||
return;
|
||||
}
|
||||
//BentoBox.getInstance().logDebug(e.getEventName());
|
||||
Pair<Integer, Integer> chunkCoords = new Pair<Integer, Integer>(chunk.getX(), chunk.getZ());
|
||||
if (pending.containsKey(chunkCoords)) {
|
||||
Iterator<StructureRecord> it = pending.get(chunkCoords).iterator();
|
||||
while (it.hasNext()) {
|
||||
StructureRecord item = it.next();
|
||||
if (item.location().getWorld().equals(e.getWorld())) {
|
||||
//BentoBox.getInstance().logDebug("Placing structure in itemsToBuild " + item);
|
||||
// Placing structure in itemsToBuild
|
||||
this.itemsToBuild.add(item);
|
||||
it.remove();
|
||||
}
|
||||
@ -247,8 +241,6 @@ public class NewAreaListener implements Listener {
|
||||
ToBePlacedStructures tbd = new ToBePlacedStructures();
|
||||
tbd.setReadyToBuild(pending);
|
||||
toPlace.saveObjectAsync(tbd);
|
||||
} else {
|
||||
//BentoBox.getInstance().logDebug("Nothing to build in this chunk");
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,10 +386,9 @@ public class NewAreaListener implements Listener {
|
||||
int y = Integer.parseInt(coords[1].strip());
|
||||
int z = Integer.parseInt(coords[2].strip()) + center.getBlockZ();
|
||||
Location location = new Location(world, x, y, z);
|
||||
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
|
||||
// Structure will be placed at location
|
||||
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
|
||||
.add(new StructureRecord(name, "minecraft:" + name, location,
|
||||
rotation, mirror, noMobs));
|
||||
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
|
||||
this.itemsToBuild
|
||||
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
|
||||
} else {
|
||||
@ -412,8 +403,6 @@ public class NewAreaListener implements Listener {
|
||||
return list1;
|
||||
}));
|
||||
|
||||
//BentoBox.getInstance().logDebug("mergedMap size = " + mergedMap.size());
|
||||
//BentoBox.getInstance().logDebug("readyToBuild size = " + readyToBuild.size());
|
||||
// Save the list
|
||||
tbd.setReadyToBuild(mergedMap);
|
||||
toPlace.saveObjectAsync(tbd);
|
||||
@ -508,16 +497,20 @@ public class NewAreaListener implements Listener {
|
||||
}
|
||||
|
||||
private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
|
||||
String data = nmsData(b);
|
||||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
|
||||
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
|
||||
BlockData bd = Bukkit.createBlockData(finalState);
|
||||
b.setBlockData(bd);
|
||||
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
|
||||
spawnMob(b, bjb);
|
||||
try {
|
||||
String data = nmsData(b);
|
||||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
|
||||
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
|
||||
BlockData bd = Bukkit.createBlockData(finalState);
|
||||
b.setBlockData(bd);
|
||||
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
|
||||
spawnMob(b, bjb);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,17 +542,12 @@ public class NewAreaListener implements Listener {
|
||||
} else if (bjb.getPool().contains("villagers")) {
|
||||
type = EntityType.VILLAGER;
|
||||
}
|
||||
// if (type == null) {
|
||||
// BentoBox.getInstance().logDebug(bjb.getPool());
|
||||
// }
|
||||
// Spawn it
|
||||
if (type != null) {
|
||||
Entity e = b.getWorld().spawnEntity(b.getRelative(BlockFace.UP).getLocation(), type);
|
||||
if (e != null) {
|
||||
e.setPersistent(true);
|
||||
}
|
||||
// BentoBox.getInstance().logDebug("Spawned a " + type + " at " +
|
||||
// b.getRelative(BlockFace.UP).getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,12 +634,10 @@ public class NewAreaListener implements Listener {
|
||||
|
||||
private ToBePlacedStructures loadToDos() {
|
||||
if (!toPlace.objectExists(TODO)) {
|
||||
//BentoBox.getInstance().logDebug("No TODO list");
|
||||
return new ToBePlacedStructures();
|
||||
}
|
||||
ToBePlacedStructures list = toPlace.loadObject(TODO);
|
||||
if (list == null) {
|
||||
//BentoBox.getInstance().logDebug("TODO list is null");
|
||||
return new ToBePlacedStructures();
|
||||
}
|
||||
if (!list.getReadyToBuild().isEmpty()) {
|
||||
|
@ -8,10 +8,8 @@ import org.bukkit.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractMetaData {
|
||||
|
||||
public abstract String nmsData(Block block);
|
||||
@ -30,7 +28,7 @@ public abstract class AbstractMetaData {
|
||||
Field fieldC = packet.getClass().getDeclaredField(field);
|
||||
fieldC.setAccessible(true);
|
||||
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);
|
||||
|
||||
|
||||
return nbtTag.toString(); // This will show what you want
|
||||
//} else {
|
||||
// throw new ClassNotFoundException(
|
||||
|
@ -1,21 +0,0 @@
|
||||
package world.bentobox.boxed.nms.v1_20_4_R0_1_SNAPSHOT;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import world.bentobox.boxed.nms.AbstractMetaData;
|
||||
|
||||
public class GetMetaData extends AbstractMetaData {
|
||||
|
||||
@Override
|
||||
public String nmsData(Block block) {
|
||||
Location w = block.getLocation();
|
||||
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
|
||||
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
|
||||
|
||||
return getData(te, "j", "c");
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package world.bentobox.boxed.nms.v1_20_6_R0_1_SNAPSHOT;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_20_R4.CraftWorld;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import world.bentobox.boxed.nms.AbstractMetaData;
|
||||
|
||||
public class GetMetaData extends AbstractMetaData {
|
||||
|
||||
@Override
|
||||
public String nmsData(Block block) {
|
||||
Location w = block.getLocation();
|
||||
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
|
||||
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
|
||||
return getData(te, "au_", "tag");
|
||||
}
|
||||
}
|
@ -1,5 +1,22 @@
|
||||
package world.bentobox.boxed.nms.v1_21_3_R0_1_SNAPSHOT;
|
||||
|
||||
public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
|
||||
// Identical to 1.21
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import world.bentobox.boxed.nms.AbstractMetaData;
|
||||
|
||||
public class GetMetaData extends AbstractMetaData {
|
||||
|
||||
@Override
|
||||
public String nmsData(Block block) {
|
||||
Location w = block.getLocation();
|
||||
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
|
||||
// for 1.13+ (we have use WorldServer)
|
||||
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
|
||||
return getData(te, "getUpdatePacket", "tag");
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
public final class ServerMocks {
|
||||
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
public static @NonNull Server newServer() {
|
||||
Server mock = mock(Server.class);
|
||||
|
||||
@ -66,7 +67,7 @@ public final class ServerMocks {
|
||||
doReturn(key).when(keyed).getKey();
|
||||
return keyed;
|
||||
});
|
||||
}).when(registry).get(notNull());
|
||||
}).when(registry).get((NamespacedKey) notNull());
|
||||
return registry;
|
||||
})).when(mock).getRegistry(notNull());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user