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