Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Move MetaTypes methods up into abstract class
Dieser Commit ist enthalten in:
Ursprung
6a8aa497b0
Commit
8be1fc9340
@ -46,9 +46,9 @@ public interface MetaType {
|
|||||||
|
|
||||||
final class MetaTypeImpl implements MetaType {
|
final class MetaTypeImpl implements MetaType {
|
||||||
private final int typeId;
|
private final int typeId;
|
||||||
private final Type type;
|
private final Type<?> type;
|
||||||
|
|
||||||
MetaTypeImpl(final int typeId, final Type type) {
|
MetaTypeImpl(final int typeId, final Type<?> type) {
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public interface MetaType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type type() {
|
public Type<?> type() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.minecraft.metadata.types;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
|
public abstract class AbstractMetaTypes implements MetaTypes {
|
||||||
|
|
||||||
|
private final MetaType[] values;
|
||||||
|
|
||||||
|
protected AbstractMetaTypes(final int values) {
|
||||||
|
this.values = new MetaType[values];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaType byId(final int id) {
|
||||||
|
return values[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaType[] values() {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MetaType add(final int typeId, final Type<?> type) {
|
||||||
|
final MetaType metaType = MetaType.create(typeId, type);
|
||||||
|
values[typeId] = metaType;
|
||||||
|
return metaType;
|
||||||
|
}
|
||||||
|
}
|
@ -26,9 +26,8 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
|
|
||||||
public final class MetaTypes1_13 implements MetaTypes {
|
public final class MetaTypes1_13 extends AbstractMetaTypes {
|
||||||
|
|
||||||
private final MetaType[] values = new MetaType[16];
|
|
||||||
public final MetaType byteType = add(0, Type.BYTE);
|
public final MetaType byteType = add(0, Type.BYTE);
|
||||||
public final MetaType varIntType = add(1, Type.VAR_INT);
|
public final MetaType varIntType = add(1, Type.VAR_INT);
|
||||||
public final MetaType floatType = add(2, Type.FLOAT);
|
public final MetaType floatType = add(2, Type.FLOAT);
|
||||||
@ -47,22 +46,7 @@ public final class MetaTypes1_13 implements MetaTypes {
|
|||||||
public final MetaType particleType;
|
public final MetaType particleType;
|
||||||
|
|
||||||
public MetaTypes1_13(final ParticleType particleType) {
|
public MetaTypes1_13(final ParticleType particleType) {
|
||||||
|
super(16);
|
||||||
this.particleType = add(15, particleType);
|
this.particleType = add(15, particleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType byId(final int id) {
|
|
||||||
return values[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType[] values() {
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MetaType add(final int typeId, final Type type) {
|
|
||||||
final MetaType metaType = MetaType.create(typeId, type);
|
|
||||||
values[typeId] = metaType;
|
|
||||||
return metaType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,8 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
|
|
||||||
public final class MetaTypes1_13_2 implements MetaTypes {
|
public final class MetaTypes1_13_2 extends AbstractMetaTypes {
|
||||||
|
|
||||||
private final MetaType[] values = new MetaType[16];
|
|
||||||
public final MetaType byteType = add(0, Type.BYTE);
|
public final MetaType byteType = add(0, Type.BYTE);
|
||||||
public final MetaType varIntType = add(1, Type.VAR_INT);
|
public final MetaType varIntType = add(1, Type.VAR_INT);
|
||||||
public final MetaType floatType = add(2, Type.FLOAT);
|
public final MetaType floatType = add(2, Type.FLOAT);
|
||||||
@ -47,22 +46,7 @@ public final class MetaTypes1_13_2 implements MetaTypes {
|
|||||||
public final MetaType particleType;
|
public final MetaType particleType;
|
||||||
|
|
||||||
public MetaTypes1_13_2(final ParticleType particleType) {
|
public MetaTypes1_13_2(final ParticleType particleType) {
|
||||||
|
super(16);
|
||||||
this.particleType = add(15, particleType);
|
this.particleType = add(15, particleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType byId(final int id) {
|
|
||||||
return values[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType[] values() {
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MetaType add(final int typeId, final Type type) {
|
|
||||||
final MetaType metaType = MetaType.create(typeId, type);
|
|
||||||
values[typeId] = metaType;
|
|
||||||
return metaType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,8 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
|
|
||||||
public final class MetaTypes1_14 implements MetaTypes {
|
public final class MetaTypes1_14 extends AbstractMetaTypes {
|
||||||
|
|
||||||
private final MetaType[] values = new MetaType[19];
|
|
||||||
public final MetaType byteType = add(0, Type.BYTE);
|
public final MetaType byteType = add(0, Type.BYTE);
|
||||||
public final MetaType varIntType = add(1, Type.VAR_INT);
|
public final MetaType varIntType = add(1, Type.VAR_INT);
|
||||||
public final MetaType floatType = add(2, Type.FLOAT);
|
public final MetaType floatType = add(2, Type.FLOAT);
|
||||||
@ -50,22 +49,7 @@ public final class MetaTypes1_14 implements MetaTypes {
|
|||||||
public final MetaType poseType = add(18, Type.VAR_INT);
|
public final MetaType poseType = add(18, Type.VAR_INT);
|
||||||
|
|
||||||
public MetaTypes1_14(final ParticleType particleType) {
|
public MetaTypes1_14(final ParticleType particleType) {
|
||||||
|
super(19);
|
||||||
this.particleType = add(15, particleType);
|
this.particleType = add(15, particleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType byId(final int id) {
|
|
||||||
return values[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetaType[] values() {
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MetaType add(final int typeId, final Type type) {
|
|
||||||
final MetaType metaType = MetaType.create(typeId, type);
|
|
||||||
values[typeId] = metaType;
|
|
||||||
return metaType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren