mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-04 00:46:08 +00:00
Merge branch 'v3.4.3' into iris4
This commit is contained in:
commit
dd98f6f07e
@ -202,9 +202,9 @@ public class IrisBlockData extends IrisRegistrant {
|
|||||||
public TileData tryGetTile(IrisData data) {
|
public TileData tryGetTile(IrisData data) {
|
||||||
//TODO Do like a registry thing with the tile data registry. Also update the parsing of data to include **block** entities.
|
//TODO Do like a registry thing with the tile data registry. Also update the parsing of data to include **block** entities.
|
||||||
var type = getBlockData(data).getMaterial();
|
var type = getBlockData(data).getMaterial();
|
||||||
if (!INMS.get().hasTile(type))
|
if (!INMS.get().hasTile(type) || tileData == null || tileData.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
return new TileData().setMaterial(type).setProperties(this.tileData);
|
return new TileData(type, this.tileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String keyify(String dat) {
|
private String keyify(String dat) {
|
||||||
|
@ -2,6 +2,8 @@ package com.volmit.iris.engine.object;
|
|||||||
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
import org.apache.commons.io.function.IOFunction;
|
import org.apache.commons.io.function.IOFunction;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.block.*;
|
import org.bukkit.block.*;
|
||||||
@ -14,6 +16,8 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class LegacyTileData extends TileData {
|
public class LegacyTileData extends TileData {
|
||||||
private static final Map<Integer, IOFunction<DataInputStream, Handler>> legacy = Map.of(
|
private static final Map<Integer, IOFunction<DataInputStream, Handler>> legacy = Map.of(
|
||||||
0, SignHandler::new,
|
0, SignHandler::new,
|
||||||
@ -41,11 +45,18 @@ public class LegacyTileData extends TileData {
|
|||||||
handler.toBinary(out);
|
handler.toBinary(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileData clone() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private interface Handler {
|
private interface Handler {
|
||||||
void toBinary(DataOutputStream out) throws IOException;
|
void toBinary(DataOutputStream out) throws IOException;
|
||||||
void toBukkit(Block block);
|
void toBukkit(Block block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
private static class SignHandler implements Handler {
|
private static class SignHandler implements Handler {
|
||||||
private final String line1;
|
private final String line1;
|
||||||
private final String line2;
|
private final String line2;
|
||||||
@ -81,7 +92,8 @@ public class LegacyTileData extends TileData {
|
|||||||
sign.update();
|
sign.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
private static class SpawnerHandler implements Handler {
|
private static class SpawnerHandler implements Handler {
|
||||||
private final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
@ -101,7 +113,8 @@ public class LegacyTileData extends TileData {
|
|||||||
spawner.update();
|
spawner.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
private static class BannerHandler implements Handler {
|
private static class BannerHandler implements Handler {
|
||||||
private final KList<Pattern> patterns;
|
private final KList<Pattern> patterns;
|
||||||
private final DyeColor baseColor;
|
private final DyeColor baseColor;
|
||||||
|
@ -23,27 +23,29 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
@Accessors(chain = true)
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
public class TileData implements Cloneable {
|
public class TileData implements Cloneable {
|
||||||
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().setLenient().create();
|
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().setLenient().create();
|
||||||
|
|
||||||
private Material material = null;
|
@NonNull
|
||||||
private KMap<String, Object> properties = new KMap<>();
|
private Material material;
|
||||||
|
@NonNull
|
||||||
|
private KMap<String, Object> properties;
|
||||||
|
|
||||||
public static boolean setTileState(Block block, TileData data) {
|
public static boolean setTileState(Block block, TileData data) {
|
||||||
if (block.getState() instanceof TileState && data.isApplicable(block.getBlockData()))
|
if (block.getState() instanceof TileState && data.isApplicable(block.getBlockData()))
|
||||||
@ -62,14 +64,9 @@ public class TileData implements Cloneable {
|
|||||||
throw new IOException("Mark not supported");
|
throw new IOException("Mark not supported");
|
||||||
in.mark(Integer.MAX_VALUE);
|
in.mark(Integer.MAX_VALUE);
|
||||||
try {
|
try {
|
||||||
TileData d = new TileData();
|
return new TileData(
|
||||||
var material = in.readUTF();
|
Material.matchMaterial(in.readUTF()),
|
||||||
d.material = Material.matchMaterial(material);
|
gson.fromJson(in.readUTF(), KMap.class));
|
||||||
if (d.material == null) throw new IOException("Unknown material: " + material);
|
|
||||||
var properties = in.readUTF();
|
|
||||||
d.properties = gson.fromJson(properties, KMap.class);
|
|
||||||
if (d.properties == null) throw new IOException("Invalid properties: " + properties);
|
|
||||||
return d;
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
in.reset();
|
in.reset();
|
||||||
return new LegacyTileData(in);
|
return new LegacyTileData(in);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user