mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-04-06 14:30:42 +08:00
Move more public types to records
This commit is contained in:
parent
0df2b6af4c
commit
35e58895f5
@ -136,6 +136,27 @@
|
||||
"changes": [
|
||||
"METHOD_NEW_DEFAULT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.registry.Keyed",
|
||||
"member": "Method com.sk89q.worldedit.registry.Keyed.id()",
|
||||
"changes": [
|
||||
"METHOD_NEW_DEFAULT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.registry.ItemMaterial",
|
||||
"member": "Method com.sk89q.worldedit.world.registry.ItemMaterial.maxDamage()",
|
||||
"changes": [
|
||||
"METHOD_NEW_DEFAULT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.registry.ItemMaterial",
|
||||
"member": "Method com.sk89q.worldedit.world.registry.ItemMaterial.maxStackSize()",
|
||||
"changes": [
|
||||
"METHOD_NEW_DEFAULT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"LazyReference was never publicly extensible": [
|
||||
@ -225,6 +246,132 @@
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.history.change.BiomeChange3D",
|
||||
"member": "Class com.sk89q.worldedit.history.change.BiomeChange3D",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.history.change.BlockChange",
|
||||
"member": "Class com.sk89q.worldedit.history.change.BlockChange",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.biome.BiomeType",
|
||||
"member": "Class com.sk89q.worldedit.world.biome.BiomeType",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.biome.BiomeType",
|
||||
"member": "Method com.sk89q.worldedit.world.biome.BiomeType.equals(java.lang.Object)",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.biome.BiomeType",
|
||||
"member": "Method com.sk89q.worldedit.world.biome.BiomeType.hashCode()",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.entity.EntityType",
|
||||
"member": "Class com.sk89q.worldedit.world.entity.EntityType",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.entity.EntityType",
|
||||
"member": "Method com.sk89q.worldedit.world.entity.EntityType.equals(java.lang.Object)",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.entity.EntityType",
|
||||
"member": "Method com.sk89q.worldedit.world.entity.EntityType.hashCode()",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.fluid.FluidType",
|
||||
"member": "Class com.sk89q.worldedit.world.fluid.FluidType",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.fluid.FluidType",
|
||||
"member": "Method com.sk89q.worldedit.world.fluid.FluidType.equals(java.lang.Object)",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.fluid.FluidType",
|
||||
"member": "Method com.sk89q.worldedit.world.fluid.FluidType.hashCode()",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
|
||||
"member": "Class com.sk89q.worldedit.world.gamemode.GameMode",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
|
||||
"member": "Method com.sk89q.worldedit.world.gamemode.GameMode.equals(java.lang.Object)",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
|
||||
"member": "Method com.sk89q.worldedit.world.gamemode.GameMode.hashCode()",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.registry.SimpleItemMaterial",
|
||||
"member": "Class com.sk89q.worldedit.world.registry.SimpleItemMaterial",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.weather.WeatherType",
|
||||
"member": "Class com.sk89q.worldedit.world.weather.WeatherType",
|
||||
"changes": [
|
||||
"CLASS_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.weather.WeatherType",
|
||||
"member": "Method com.sk89q.worldedit.world.weather.WeatherType.equals(java.lang.Object)",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "com.sk89q.worldedit.world.weather.WeatherType",
|
||||
"member": "Method com.sk89q.worldedit.world.weather.WeatherType.hashCode()",
|
||||
"changes": [
|
||||
"METHOD_NOW_FINAL"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ public class LocalSession {
|
||||
* @param placement the placement.
|
||||
*/
|
||||
public void setPlacement(Placement placement) {
|
||||
if (placement.getPlacementType() == PlacementType.HERE) {
|
||||
if (placement.placementType() == PlacementType.HERE) {
|
||||
throw new IllegalStateException("PlacementType.HERE cannot be used. Use PLAYER or WORLD instead.");
|
||||
}
|
||||
|
||||
@ -610,7 +610,7 @@ public class LocalSession {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPlaceAtPos1() {
|
||||
return this.placement.getPlacementType() == PlacementType.POS1;
|
||||
return this.placement.placementType() == PlacementType.POS1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -623,12 +623,12 @@ public class LocalSession {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean togglePlacementPosition() {
|
||||
if (this.placement.getPlacementType() == PlacementType.POS1) {
|
||||
if (this.placement.placementType() == PlacementType.POS1) {
|
||||
this.placement = new Placement(PlacementType.PLAYER, BlockVector3.ZERO);
|
||||
} else {
|
||||
this.placement = new Placement(PlacementType.POS1, BlockVector3.ZERO);
|
||||
}
|
||||
return this.placement.getPlacementType() == PlacementType.POS1;
|
||||
return this.placement.placementType() == PlacementType.POS1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,7 +442,7 @@ public class GeneralCommands {
|
||||
desc = "Switch between your position and pos1 for placement"
|
||||
)
|
||||
public void togglePlace(Actor actor, LocalSession session) {
|
||||
if (session.getPlacement().getPlacementType() == PlacementType.POS1) {
|
||||
if (session.getPlacement().placementType() == PlacementType.POS1) {
|
||||
placementImpl(actor, session, new Placement(PlacementType.PLAYER, BlockVector3.ZERO));
|
||||
} else {
|
||||
placementImpl(actor, session, new Placement(PlacementType.POS1, BlockVector3.ZERO));
|
||||
|
@ -23,27 +23,10 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
|
||||
/**
|
||||
* Items of metadata about shared clipboards.
|
||||
*
|
||||
* @param format the format of the clipboard
|
||||
* @param name the name of the clipboard
|
||||
* @param author the author of the clipboard
|
||||
*/
|
||||
public class ClipboardShareMetadata {
|
||||
private final ClipboardFormat format;
|
||||
private final String name;
|
||||
private final String author;
|
||||
|
||||
public ClipboardShareMetadata(ClipboardFormat format, String name, String author) {
|
||||
this.format = format;
|
||||
this.name = name;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public ClipboardFormat format() {
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String author() {
|
||||
return this.author;
|
||||
}
|
||||
public record ClipboardShareMetadata(ClipboardFormat format, String name, String author) {
|
||||
}
|
||||
|
@ -156,24 +156,14 @@ public class Deform implements Contextual<Operation> {
|
||||
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
||||
}
|
||||
|
||||
private static final class DeformOperation implements Operation {
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
private final Vector3 zero;
|
||||
private final Vector3 unit;
|
||||
private final Expression expression;
|
||||
private final int timeout;
|
||||
|
||||
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, Expression expression,
|
||||
int timeout) {
|
||||
this.destination = destination;
|
||||
this.region = region;
|
||||
this.zero = zero;
|
||||
this.unit = unit;
|
||||
this.expression = expression;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
private record DeformOperation(
|
||||
Extent destination,
|
||||
Region region,
|
||||
Vector3 zero,
|
||||
Vector3 unit,
|
||||
Expression expression,
|
||||
int timeout
|
||||
) implements Operation {
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
try {
|
||||
|
@ -182,13 +182,7 @@ public final class Masks {
|
||||
}
|
||||
}
|
||||
|
||||
private static class NegatedMask implements Mask {
|
||||
private final Mask mask;
|
||||
|
||||
private NegatedMask(Mask mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
private record NegatedMask(Mask mask) implements Mask {
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !mask.test(vector);
|
||||
@ -205,13 +199,7 @@ public final class Masks {
|
||||
}
|
||||
}
|
||||
|
||||
private static class NegatedMask2D implements Mask2D {
|
||||
private final Mask2D mask;
|
||||
|
||||
private NegatedMask2D(Mask2D mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
private record NegatedMask2D(Mask2D mask) implements Mask2D {
|
||||
@Override
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return !mask.test(vector);
|
||||
|
@ -58,31 +58,16 @@ public class RandomPattern extends AbstractPattern {
|
||||
double offset = 0;
|
||||
|
||||
for (Chance chance : patterns) {
|
||||
if (r <= (offset + chance.getChance()) / max) {
|
||||
return chance.getPattern().applyBlock(position);
|
||||
if (r <= (offset + chance.chance()) / max) {
|
||||
return chance.pattern().applyBlock(position);
|
||||
}
|
||||
offset += chance.getChance();
|
||||
offset += chance.chance();
|
||||
}
|
||||
|
||||
throw new RuntimeException("ProportionalFillPattern");
|
||||
}
|
||||
|
||||
private static class Chance {
|
||||
private final Pattern pattern;
|
||||
private final double chance;
|
||||
|
||||
private Chance(Pattern pattern, double chance) {
|
||||
this.pattern = pattern;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public Pattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
private record Chance(Pattern pattern, double chance) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,34 +33,30 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* <p>This biome change does not have an {@link Extent} assigned to it because
|
||||
* one will be taken from the passed {@link UndoContext}. If the context
|
||||
* does not have an extent (it is null), cryptic errors may occur.</p>
|
||||
*
|
||||
* @param position the position
|
||||
* @param previous the previous biome
|
||||
* @param current the current biome
|
||||
*/
|
||||
public class BiomeChange3D implements Change {
|
||||
|
||||
private final BlockVector3 position;
|
||||
private final BiomeType previous;
|
||||
private final BiomeType current;
|
||||
public record BiomeChange3D(BlockVector3 position, BiomeType previous, BiomeType current) implements Change {
|
||||
|
||||
/**
|
||||
* Create a new biome change.
|
||||
*
|
||||
* @param position the position
|
||||
* @param previous the previous biome
|
||||
* @param current the current biome
|
||||
*/
|
||||
public BiomeChange3D(BlockVector3 position, BiomeType previous, BiomeType current) {
|
||||
public BiomeChange3D {
|
||||
checkNotNull(position);
|
||||
checkNotNull(previous);
|
||||
checkNotNull(current);
|
||||
this.position = position;
|
||||
this.previous = previous;
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position.
|
||||
*
|
||||
* @return the position
|
||||
* @deprecated Use {@link #position()}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BlockVector3 getPosition() {
|
||||
return position;
|
||||
}
|
||||
@ -69,7 +65,9 @@ public class BiomeChange3D implements Change {
|
||||
* Get the previous biome.
|
||||
*
|
||||
* @return the previous biome
|
||||
* @deprecated Use {@link #previous()}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BiomeType getPrevious() {
|
||||
return previous;
|
||||
}
|
||||
@ -78,7 +76,9 @@ public class BiomeChange3D implements Change {
|
||||
* Get the current biome.
|
||||
*
|
||||
* @return the current biome
|
||||
* @deprecated Use {@link #current()}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BiomeType getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
@ -34,12 +34,21 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* <p>This block change does not have an {@link Extent} assigned to it because
|
||||
* one will be taken from the passed {@link UndoContext}. If the context
|
||||
* does not have an extent (it is null), cryptic errors may occur.</p>
|
||||
*
|
||||
* @param position the position
|
||||
* @param previous the previous block
|
||||
* @param current the current block
|
||||
*/
|
||||
public class BlockChange implements Change {
|
||||
public record BlockChange(BlockVector3 position, BaseBlock previous, BaseBlock current) implements Change {
|
||||
|
||||
private final BlockVector3 position;
|
||||
private final BaseBlock previous;
|
||||
private final BaseBlock current;
|
||||
/**
|
||||
* Create a new block change.
|
||||
*/
|
||||
public BlockChange {
|
||||
checkNotNull(position);
|
||||
checkNotNull(previous);
|
||||
checkNotNull(current);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new block change.
|
||||
@ -49,19 +58,16 @@ public class BlockChange implements Change {
|
||||
* @param current the current block
|
||||
*/
|
||||
public <BP extends BlockStateHolder<BP>, BC extends BlockStateHolder<BC>> BlockChange(BlockVector3 position, BP previous, BC current) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(previous);
|
||||
checkNotNull(current);
|
||||
this.position = position;
|
||||
this.previous = previous.toBaseBlock();
|
||||
this.current = current.toBaseBlock();
|
||||
this(position, previous.toBaseBlock(), current.toBaseBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position.
|
||||
*
|
||||
* @return the position
|
||||
* @deprecated use {@link #position()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BlockVector3 getPosition() {
|
||||
return position;
|
||||
}
|
||||
@ -70,7 +76,9 @@ public class BlockChange implements Change {
|
||||
* Get the previous block.
|
||||
*
|
||||
* @return the previous block
|
||||
* @deprecated use {@link #previous()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BaseBlock getPrevious() {
|
||||
return previous;
|
||||
}
|
||||
@ -79,7 +87,9 @@ public class BlockChange implements Change {
|
||||
* Get the current block.
|
||||
*
|
||||
* @return the current block
|
||||
* @deprecated use {@link #current()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BaseBlock getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
@ -88,15 +88,10 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExceptionHandler implements Comparable<ExceptionHandler> {
|
||||
final Class<? extends Throwable> cls;
|
||||
final Method method;
|
||||
|
||||
private ExceptionHandler(Class<? extends Throwable> cls, Method method) {
|
||||
this.cls = cls;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
private record ExceptionHandler(
|
||||
Class<? extends Throwable> cls,
|
||||
Method method
|
||||
) implements Comparable<ExceptionHandler> {
|
||||
@Override
|
||||
public int compareTo(ExceptionHandler o) {
|
||||
if (cls.equals(o.cls)) {
|
||||
|
@ -57,13 +57,6 @@ public class InteractionDebouncer {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static class Interaction {
|
||||
public final long tick;
|
||||
public final boolean result;
|
||||
|
||||
public Interaction(long tick, boolean result) {
|
||||
this.tick = tick;
|
||||
this.result = result;
|
||||
}
|
||||
private record Interaction(long tick, boolean result) {
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.registry;
|
||||
|
||||
import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||
|
||||
/**
|
||||
* Represents an objects that can be added to a registry and referenced by an id which is unique within its registry.
|
||||
*/
|
||||
@ -26,6 +29,22 @@ public interface Keyed {
|
||||
/**
|
||||
* The id of this object in the registry. Must be unique, and lowercase. Certain registries (e.g Namespaced ones) may have additional restrictions.
|
||||
* @return an id
|
||||
* @deprecated Use {@link #id()} instead.
|
||||
*/
|
||||
String getId();
|
||||
@Deprecated(forRemoval = true)
|
||||
default String getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of this object in the registry. Must be unique and lowercase. Certain registries (e.g namespaced ones)
|
||||
* may have additional restrictions.
|
||||
*
|
||||
* @return an id
|
||||
*/
|
||||
@NonAbstractForCompatibility(delegateName = "getId", delegateParams = {})
|
||||
default String id() {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
return getId();
|
||||
}
|
||||
}
|
||||
|
@ -27,24 +27,7 @@ import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
public class Placement {
|
||||
private final PlacementType placementType;
|
||||
|
||||
private final BlockVector3 offset;
|
||||
|
||||
public Placement(PlacementType placementType, BlockVector3 offset) {
|
||||
this.placementType = placementType;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public PlacementType getPlacementType() {
|
||||
return placementType;
|
||||
}
|
||||
|
||||
public BlockVector3 getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public record Placement(PlacementType placementType, BlockVector3 offset) {
|
||||
public BlockVector3 getPlacementPosition(RegionSelector selector, Actor actor) throws IncompleteRegionException {
|
||||
return placementType.getPlacementPosition(selector, actor).add(offset);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public record LocatedBlock(BlockVector3 location, BaseBlock block) {
|
||||
* @return The location
|
||||
* @deprecated This class is now a record. Use {@link #location()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public BlockVector3 getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
@ -51,6 +51,7 @@ public record LocatedBlock(BlockVector3 location, BaseBlock block) {
|
||||
* @return The block
|
||||
* @deprecated This class is now a record. Use {@link #block()} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public BaseBlock getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
@ -168,14 +168,7 @@ public class DataReport implements Report {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Line {
|
||||
private final String key;
|
||||
private final String value;
|
||||
|
||||
public Line(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
private record Line(String key, String value) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,40 +26,16 @@ import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
/**
|
||||
* All the types of biomes in the game.
|
||||
*
|
||||
* @param id the id of the biome
|
||||
*/
|
||||
public class BiomeType implements Keyed, BiomePattern {
|
||||
public record BiomeType(String id) implements Keyed, BiomePattern {
|
||||
|
||||
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type", true);
|
||||
|
||||
private final String id;
|
||||
|
||||
public BiomeType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of this biome.
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof BiomeType && this.id.equals(((BiomeType) obj).id);
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,23 +22,14 @@ package com.sk89q.worldedit.world.entity;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
public class EntityType implements Keyed {
|
||||
|
||||
public record EntityType(String id) implements Keyed {
|
||||
public static final NamespacedRegistry<EntityType> REGISTRY = new NamespacedRegistry<>("entity type", true);
|
||||
|
||||
private final String id;
|
||||
|
||||
public EntityType(String id) {
|
||||
public EntityType {
|
||||
// If it has no namespace, assume minecraft.
|
||||
if (!id.contains(":")) {
|
||||
id = "minecraft:" + id;
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,22 +38,11 @@ public class EntityType implements Keyed {
|
||||
* @return The name, or ID
|
||||
*/
|
||||
public String getName() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof EntityType && this.id.equals(((EntityType) obj).id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,41 +23,16 @@ import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
/**
|
||||
* Minecraft now has a 'fluid' system. This is a
|
||||
* stub class to represent what it may be in the future.
|
||||
* Minecraft now has a 'fluid' system. This is a stub class to represent what it may be in the future.
|
||||
*
|
||||
* @param id the id of the fluid
|
||||
*/
|
||||
public class FluidType implements Keyed {
|
||||
public record FluidType(String id) implements Keyed {
|
||||
|
||||
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>("fluid type");
|
||||
|
||||
private final String id;
|
||||
|
||||
public FluidType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of this block.
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof FluidType && this.id.equals(((FluidType) obj).id);
|
||||
return id();
|
||||
}
|
||||
}
|
||||
|
@ -22,43 +22,21 @@ package com.sk89q.worldedit.world.gamemode;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.Registry;
|
||||
|
||||
public class GameMode implements Keyed {
|
||||
public record GameMode(String id) implements Keyed {
|
||||
|
||||
public static final Registry<GameMode> REGISTRY = new Registry<>("game mode");
|
||||
|
||||
private final String id;
|
||||
|
||||
public GameMode(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this game mode, or the ID if the name cannot be found.
|
||||
*
|
||||
* @return The name, or ID
|
||||
*/
|
||||
public String getName() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof GameMode && this.id.equals(((GameMode) obj).id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,20 +22,9 @@ package com.sk89q.worldedit.world.generation;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
public class ConfiguredFeatureType implements Keyed {
|
||||
public record ConfiguredFeatureType(String id) implements Keyed {
|
||||
public static final NamespacedRegistry<ConfiguredFeatureType> REGISTRY = new NamespacedRegistry<>("configured feature type");
|
||||
|
||||
private final String id;
|
||||
|
||||
public ConfiguredFeatureType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.id;
|
||||
|
@ -22,20 +22,9 @@ package com.sk89q.worldedit.world.generation;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
public class StructureType implements Keyed {
|
||||
public record StructureType(String id) implements Keyed {
|
||||
public static final NamespacedRegistry<StructureType> REGISTRY = new NamespacedRegistry<>("structure type");
|
||||
|
||||
private final String id;
|
||||
|
||||
public StructureType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.id;
|
||||
|
@ -19,18 +19,51 @@
|
||||
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||
|
||||
public interface ItemMaterial {
|
||||
/**
|
||||
* Gets the the maximum quantity of this item that can be in a single stack.
|
||||
*
|
||||
* @return the maximum quantity
|
||||
* @deprecated Use {@link #maxStackSize()} instead.
|
||||
*/
|
||||
int getMaxStackSize();
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getMaxStackSize() {
|
||||
return maxStackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the the maximum quantity of this item that can be in a single stack.
|
||||
*
|
||||
* @return the maximum quantity
|
||||
*/
|
||||
@NonAbstractForCompatibility(delegateName = "getMaxStackSize", delegateParams = {})
|
||||
default int maxStackSize() {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
return getMaxStackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the the maximum damage this item can take before being broken.
|
||||
*
|
||||
* @return the maximum damage, or 0 if not applicable
|
||||
* @deprecated Use {@link #maxDamage()} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default int getMaxDamage() {
|
||||
return maxDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the the maximum damage this item can take before being broken.
|
||||
*
|
||||
* @return the maximum damage, or 0 if not applicable
|
||||
*/
|
||||
int getMaxDamage();
|
||||
@NonAbstractForCompatibility(delegateName = "getMaxDamage", delegateParams = {})
|
||||
default int maxDamage() {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
return getMaxDamage();
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ public class PassthroughItemMaterial implements ItemMaterial {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return itemMaterial.getMaxStackSize();
|
||||
public int maxStackSize() {
|
||||
return itemMaterial.maxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage() {
|
||||
return itemMaterial.getMaxDamage();
|
||||
public int maxDamage() {
|
||||
return itemMaterial.maxDamage();
|
||||
}
|
||||
}
|
||||
|
@ -19,23 +19,5 @@
|
||||
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
public class SimpleItemMaterial implements ItemMaterial {
|
||||
|
||||
private final int maxStackSize;
|
||||
private final int maxDamage;
|
||||
|
||||
public SimpleItemMaterial(int maxStackSize, int maxDamage) {
|
||||
this.maxStackSize = maxStackSize;
|
||||
this.maxDamage = maxDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return maxStackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage() {
|
||||
return maxDamage;
|
||||
}
|
||||
public record SimpleItemMaterial(int maxStackSize, int maxDamage) implements ItemMaterial {
|
||||
}
|
||||
|
@ -22,43 +22,20 @@ package com.sk89q.worldedit.world.weather;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.Registry;
|
||||
|
||||
public class WeatherType implements Keyed {
|
||||
|
||||
public record WeatherType(String id) implements Keyed {
|
||||
public static final Registry<WeatherType> REGISTRY = new Registry<>("weather type");
|
||||
|
||||
private final String id;
|
||||
|
||||
public WeatherType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this weather, or the ID if the name cannot be found.
|
||||
*
|
||||
* @return The name, or ID
|
||||
*/
|
||||
public String getName() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof WeatherType && this.id.equals(((WeatherType) obj).id);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user