mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Fix PlotItem.
This commit is contained in:
@ -43,7 +43,7 @@ public abstract class PlotBlock implements ConfigurationSerializable {
|
||||
public static PlotBlock deserialize(@NonNull final Map<String, Object> map) {
|
||||
if (map.containsKey("material")) {
|
||||
final Object object = map.get("material");
|
||||
return get(object);
|
||||
return get(object.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -52,6 +52,21 @@ public abstract class PlotBlock implements ConfigurationSerializable {
|
||||
return ImmutableMap.of("material", this.getRawId());
|
||||
}
|
||||
|
||||
public <T> T to(@NonNull final Class<T> clazz) {
|
||||
if (blockRegistry == null) {
|
||||
blockRegistry = PlotSquared.imp().getBlockRegistry();
|
||||
if (blockRegistry == null) {
|
||||
throw new UnsupportedOperationException("The PlotSquared implementation has not registered a custom block registry."
|
||||
+ " This method can't be used.");
|
||||
}
|
||||
conversionType = blockRegistry.getType();
|
||||
}
|
||||
if (!clazz.equals(conversionType)) {
|
||||
throw new UnsupportedOperationException("The PlotSquared implementation has not registered a block registry for this object type");
|
||||
}
|
||||
return clazz.cast(blockRegistry.getItem(this));
|
||||
}
|
||||
|
||||
public abstract boolean isAir();
|
||||
|
||||
public static StringPlotBlock get(@NonNull final String itemId) {
|
||||
|
@ -1,20 +1,22 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.object.schematic;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
|
||||
public class PlotItem {
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final short[] id;
|
||||
public final byte[] data;
|
||||
// public final short[] id;
|
||||
// public final byte[] data;
|
||||
public final PlotBlock[] types;
|
||||
public final byte[] amount;
|
||||
|
||||
public PlotItem(short x, short y, short z, short[] id, byte[] data, byte[] amount) {
|
||||
public PlotItem(short x, short y, short z, PlotBlock[] types, byte[] amount) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.types = types;
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user