remove some old unused/deprecated stuff

This commit is contained in:
Bixilon 2021-05-27 18:27:03 +02:00
parent a060c46982
commit 61a72961f5
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
10 changed files with 30 additions and 193 deletions

View File

@ -10,18 +10,20 @@
* *
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.data
package de.bixilon.minosoft.data; import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.enum.ValuesEnum
public enum Difficulties { enum class Difficulties {
PEACEFUL, PEACEFUL,
EASY, EASY,
NORMAL, NORMAL,
HARD; HARD,
;
private static final Difficulties[] DIFFICULTIES = values(); companion object : ValuesEnum<Difficulties> {
override val VALUES: Array<Difficulties> = values()
public static Difficulties byId(int id) { override val NAME_MAP: Map<String, Difficulties> = KUtil.getEnumValues(VALUES)
return DIFFICULTIES[id];
} }
} }

View File

@ -1,43 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data;
public enum LevelTypes {
DEFAULT("default"),
FLAT("flat"),
LARGE_BIOMES("largeBiomes"),
AMPLIFIED("amplified"),
DEFAULT_1_1("default_1_1"),
CUSTOMIZED("customized"),
BUFFET("buffet"),
UNKNOWN("unknown");
private final String type;
LevelTypes(String type) {
this.type = type;
}
public static LevelTypes byType(String type) {
for (LevelTypes levelType : values()) {
if (levelType.getId().equals(type)) {
return levelType;
}
}
return null;
}
public String getId() {
return this.type;
}
}

View File

@ -1,46 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.inventory;
import de.bixilon.minosoft.data.text.ChatComponent;
public class InventoryProperties {
private final int windowId;
private final InventoryTypes type;
private final ChatComponent title;
private final byte slotCount;
public InventoryProperties(int windowId, InventoryTypes type, ChatComponent title, byte slotCount) {
this.windowId = windowId;
this.type = type;
this.title = title;
this.slotCount = slotCount;
}
public int getWindowId() {
return this.windowId;
}
public InventoryTypes getType() {
return this.type;
}
public ChatComponent getTitle() {
return this.title;
}
public byte getSlotCount() {
return this.slotCount;
}
}

View File

@ -1,60 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.inventory;
import com.google.common.collect.HashBiMap;
import de.bixilon.minosoft.data.mappings.ResourceLocation;
@Deprecated
public enum InventoryTypes {
CHEST(new ResourceLocation("minecraft:chest")),
WORKBENCH(new ResourceLocation("minecraft:crafting_table")),
FURNACE(new ResourceLocation("minecraft:furnace")),
DISPENSER(new ResourceLocation("minecraft:dispenser")),
ENCHANTMENT_TABLE(new ResourceLocation("minecraft:enchanting_table")),
BREWING_STAND(new ResourceLocation("minecraft:brewing_stand")),
NPC_TRACE(new ResourceLocation("minecraft:villager")),
BEACON(new ResourceLocation("minecraft:beacon")),
ANVIL(new ResourceLocation("minecraft:anvil")),
HOPPER(new ResourceLocation("minecraft:hopper")),
DROPPER(new ResourceLocation("minecraft:dropper")),
HORSE(new ResourceLocation("EntityHorse"));
private static final InventoryTypes[] INVENTORY_TYPES = values();
private static final HashBiMap<ResourceLocation, InventoryTypes> RESOURCE_LOCATION_TYPE_MAP = HashBiMap.create();
static {
for (InventoryTypes type : INVENTORY_TYPES) {
RESOURCE_LOCATION_TYPE_MAP.put(type.getResourceLocation(), type);
}
}
private final ResourceLocation resourceLocation;
InventoryTypes(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
}
public static InventoryTypes byId(int id) {
return INVENTORY_TYPES[id];
}
public static InventoryTypes byResourceLocation(ResourceLocation resourceLocation) {
return RESOURCE_LOCATION_TYPE_MAP.get(resourceLocation);
}
public ResourceLocation getResourceLocation() {
return this.resourceLocation;
}
}

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.modding.event.events;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import de.bixilon.minosoft.data.Difficulties; import de.bixilon.minosoft.data.Difficulties;
import de.bixilon.minosoft.data.LevelTypes;
import de.bixilon.minosoft.data.abilities.Gamemodes; import de.bixilon.minosoft.data.abilities.Gamemodes;
import de.bixilon.minosoft.data.mappings.Dimension; import de.bixilon.minosoft.data.mappings.Dimension;
import de.bixilon.minosoft.data.mappings.ResourceLocation; import de.bixilon.minosoft.data.mappings.ResourceLocation;
@ -30,13 +29,12 @@ public class JoinGameEvent extends CancelableEvent {
private final Difficulties difficulty; private final Difficulties difficulty;
private final int viewDistance; private final int viewDistance;
private final int maxPlayers; private final int maxPlayers;
private final LevelTypes levelType;
private final boolean reducedDebugScreen; private final boolean reducedDebugScreen;
private final boolean enableRespawnScreen; private final boolean enableRespawnScreen;
private final long hashedSeed; private final long hashedSeed;
private final HashBiMap<ResourceLocation, Dimension> dimensions; private final HashBiMap<ResourceLocation, Dimension> dimensions;
public JoinGameEvent(PlayConnection connection, int entityId, boolean hardcore, Gamemodes gamemode, Dimension dimension, Difficulties difficulty, int viewDistance, int maxPlayers, LevelTypes levelType, boolean reducedDebugScreen, boolean enableRespawnScreen, long hashedSeed, HashBiMap<ResourceLocation, Dimension> dimensions) { public JoinGameEvent(PlayConnection connection, int entityId, boolean hardcore, Gamemodes gamemode, Dimension dimension, Difficulties difficulty, int viewDistance, int maxPlayers, boolean reducedDebugScreen, boolean enableRespawnScreen, long hashedSeed, HashBiMap<ResourceLocation, Dimension> dimensions) {
super(connection); super(connection);
this.entityId = entityId; this.entityId = entityId;
this.hardcore = hardcore; this.hardcore = hardcore;
@ -45,7 +43,6 @@ public class JoinGameEvent extends CancelableEvent {
this.difficulty = difficulty; this.difficulty = difficulty;
this.viewDistance = viewDistance; this.viewDistance = viewDistance;
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
this.levelType = levelType;
this.reducedDebugScreen = reducedDebugScreen; this.reducedDebugScreen = reducedDebugScreen;
this.enableRespawnScreen = enableRespawnScreen; this.enableRespawnScreen = enableRespawnScreen;
this.hashedSeed = hashedSeed; this.hashedSeed = hashedSeed;
@ -61,7 +58,6 @@ public class JoinGameEvent extends CancelableEvent {
this.difficulty = pkg.getDifficulty(); this.difficulty = pkg.getDifficulty();
this.viewDistance = pkg.getViewDistance(); this.viewDistance = pkg.getViewDistance();
this.maxPlayers = pkg.getMaxPlayers(); this.maxPlayers = pkg.getMaxPlayers();
this.levelType = pkg.getLevelType();
this.reducedDebugScreen = pkg.isReducedDebugScreen(); this.reducedDebugScreen = pkg.isReducedDebugScreen();
this.enableRespawnScreen = pkg.isEnableRespawnScreen(); this.enableRespawnScreen = pkg.isEnableRespawnScreen();
this.hashedSeed = pkg.getHashedSeed(); this.hashedSeed = pkg.getHashedSeed();
@ -96,10 +92,6 @@ public class JoinGameEvent extends CancelableEvent {
return this.maxPlayers; return this.maxPlayers;
} }
public LevelTypes getLevelType() {
return this.levelType;
}
public boolean isReducedDebugScreen() { public boolean isReducedDebugScreen() {
return this.reducedDebugScreen; return this.reducedDebugScreen;
} }

View File

@ -14,7 +14,6 @@
package de.bixilon.minosoft.modding.event.events; package de.bixilon.minosoft.modding.event.events;
import de.bixilon.minosoft.data.Difficulties; import de.bixilon.minosoft.data.Difficulties;
import de.bixilon.minosoft.data.LevelTypes;
import de.bixilon.minosoft.data.abilities.Gamemodes; import de.bixilon.minosoft.data.abilities.Gamemodes;
import de.bixilon.minosoft.data.mappings.Dimension; import de.bixilon.minosoft.data.mappings.Dimension;
import de.bixilon.minosoft.protocol.network.connection.PlayConnection; import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
@ -24,14 +23,12 @@ public class RespawnEvent extends PlayConnectionEvent {
private final Gamemodes gamemode; private final Gamemodes gamemode;
private final Dimension dimension; private final Dimension dimension;
private final Difficulties difficulty; private final Difficulties difficulty;
private final LevelTypes levelType;
public RespawnEvent(PlayConnection connection, Gamemodes gamemode, Dimension dimension, Difficulties difficulty, LevelTypes levelType) { public RespawnEvent(PlayConnection connection, Gamemodes gamemode, Dimension dimension, Difficulties difficulty) {
super(connection); super(connection);
this.gamemode = gamemode; this.gamemode = gamemode;
this.dimension = dimension; this.dimension = dimension;
this.difficulty = difficulty; this.difficulty = difficulty;
this.levelType = levelType;
} }
public RespawnEvent(PlayConnection connection, RespawnS2CP pkg) { public RespawnEvent(PlayConnection connection, RespawnS2CP pkg) {
@ -39,7 +36,6 @@ public class RespawnEvent extends PlayConnectionEvent {
this.gamemode = pkg.getGamemode(); this.gamemode = pkg.getGamemode();
this.dimension = pkg.getDimension(); this.dimension = pkg.getDimension();
this.difficulty = pkg.getDifficulty(); this.difficulty = pkg.getDifficulty();
this.levelType = pkg.getLevelType();
} }
public Gamemodes getGamemode() { public Gamemodes getGamemode() {
@ -53,8 +49,4 @@ public class RespawnEvent extends PlayConnectionEvent {
public Difficulties getDifficulty() { public Difficulties getDifficulty() {
return this.difficulty; return this.difficulty;
} }
public LevelTypes getLevelType() {
return this.levelType;
}
} }

View File

@ -14,7 +14,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
import com.google.common.collect.HashBiMap import com.google.common.collect.HashBiMap
import de.bixilon.minosoft.data.Difficulties import de.bixilon.minosoft.data.Difficulties
import de.bixilon.minosoft.data.LevelTypes
import de.bixilon.minosoft.data.abilities.Gamemodes import de.bixilon.minosoft.data.abilities.Gamemodes
import de.bixilon.minosoft.data.mappings.Dimension import de.bixilon.minosoft.data.mappings.Dimension
import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.data.mappings.ResourceLocation
@ -48,7 +47,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
private set private set
var maxPlayers = 0 var maxPlayers = 0
private set private set
var levelType: LevelTypes = LevelTypes.UNKNOWN var levelType: String? = null
private set private set
var isReducedDebugScreen = false var isReducedDebugScreen = false
private set private set
@ -74,10 +73,10 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
if (buffer.versionId < ProtocolVersions.V_1_9_1) { if (buffer.versionId < ProtocolVersions.V_1_9_1) {
dimension = buffer.connection.registries.dimensionRegistry[buffer.readByte().toInt()] dimension = buffer.connection.registries.dimensionRegistry[buffer.readByte().toInt()]
difficulty = Difficulties.byId(buffer.readUnsignedByte().toInt()) difficulty = Difficulties[buffer.readUnsignedByte()]
maxPlayers = buffer.readByte().toInt() maxPlayers = buffer.readByte().toInt()
if (buffer.versionId >= ProtocolVersions.V_13W42B) { if (buffer.versionId >= ProtocolVersions.V_13W42B) {
levelType = LevelTypes.byType(buffer.readString()) levelType = buffer.readString()
} }
if (buffer.versionId >= ProtocolVersions.V_14W29A) { if (buffer.versionId >= ProtocolVersions.V_14W29A) {
isReducedDebugScreen = buffer.readBoolean() isReducedDebugScreen = buffer.readBoolean()
@ -107,7 +106,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
hashedSeed = buffer.readLong() hashedSeed = buffer.readLong()
} }
if (buffer.versionId < ProtocolVersions.V_19W11A) { if (buffer.versionId < ProtocolVersions.V_19W11A) {
difficulty = Difficulties.byId(buffer.readUnsignedByte()) difficulty = Difficulties[buffer.readUnsignedByte()]
} }
maxPlayers = if (buffer.versionId < ProtocolVersions.V_1_16_2_RC1) { maxPlayers = if (buffer.versionId < ProtocolVersions.V_1_16_2_RC1) {
buffer.readByte().toInt() buffer.readByte().toInt()
@ -115,7 +114,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
buffer.readVarInt() buffer.readVarInt()
} }
if (buffer.versionId < ProtocolVersions.V_20W20A) { if (buffer.versionId < ProtocolVersions.V_20W20A) {
levelType = LevelTypes.byType(buffer.readString()) levelType = buffer.readString()
} }
if (buffer.versionId >= ProtocolVersions.V_19W13A) { if (buffer.versionId >= ProtocolVersions.V_19W13A) {
viewDistance = buffer.readVarInt() viewDistance = buffer.readVarInt()
@ -123,7 +122,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
if (buffer.versionId >= ProtocolVersions.V_20W20A) { if (buffer.versionId >= ProtocolVersions.V_20W20A) {
buffer.readBoolean() // isDebug buffer.readBoolean() // isDebug
if (buffer.readBoolean()) { if (buffer.readBoolean()) {
levelType = LevelTypes.FLAT levelType = "flat"
} }
} }
isReducedDebugScreen = buffer.readBoolean() isReducedDebugScreen = buffer.readBoolean()

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.protocol.packets.s2c.play package de.bixilon.minosoft.protocol.packets.s2c.play
import de.bixilon.minosoft.data.Difficulties import de.bixilon.minosoft.data.Difficulties
import de.bixilon.minosoft.data.LevelTypes
import de.bixilon.minosoft.data.abilities.Gamemodes import de.bixilon.minosoft.data.abilities.Gamemodes
import de.bixilon.minosoft.data.mappings.Dimension import de.bixilon.minosoft.data.mappings.Dimension
import de.bixilon.minosoft.modding.event.events.RespawnEvent import de.bixilon.minosoft.modding.event.events.RespawnEvent
@ -33,7 +32,7 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
var difficulty: Difficulties = Difficulties.NORMAL var difficulty: Difficulties = Difficulties.NORMAL
private set private set
val gamemode: Gamemodes val gamemode: Gamemodes
var levelType: LevelTypes = LevelTypes.UNKNOWN var levelType: String? = null
private set private set
var hashedSeed = 0L var hashedSeed = 0L
private set private set
@ -61,7 +60,7 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
} }
} }
if (buffer.versionId < ProtocolVersions.V_19W11A) { if (buffer.versionId < ProtocolVersions.V_19W11A) {
difficulty = Difficulties.byId(buffer.readUnsignedByte()) difficulty = Difficulties[buffer.readUnsignedByte()]
} }
if (buffer.versionId >= ProtocolVersions.V_20W22A) { if (buffer.versionId >= ProtocolVersions.V_20W22A) {
dimension = buffer.connection.registries.dimensionRegistry[buffer.readResourceLocation()]!! dimension = buffer.connection.registries.dimensionRegistry[buffer.readResourceLocation()]!!
@ -74,7 +73,7 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
buffer.readByte() // previous game mode buffer.readByte() // previous game mode
} }
if (buffer.versionId >= ProtocolVersions.V_13W42B && buffer.versionId < ProtocolVersions.V_20W20A) { if (buffer.versionId >= ProtocolVersions.V_13W42B && buffer.versionId < ProtocolVersions.V_20W20A) {
levelType = LevelTypes.byType(buffer.readString()) levelType = buffer.readString()
} }
if (buffer.versionId >= ProtocolVersions.V_20W20A) { if (buffer.versionId >= ProtocolVersions.V_20W20A) {
isDebug = buffer.readBoolean() isDebug = buffer.readBoolean()

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType import de.bixilon.minosoft.util.logging.LogMessageType
class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() { class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
val difficulty: Difficulties = Difficulties.byId(buffer.readUnsignedByte()) val difficulty: Difficulties = Difficulties[buffer.readUnsignedByte()]
var locked = false var locked = false
private set private set

View File

@ -10,10 +10,12 @@
* *
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
package de.bixilon.minosoft.protocol.protocol
package de.bixilon.minosoft.protocol.protocol; import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.enum.ValuesEnum
public enum ConnectionStates { enum class ConnectionStates {
HANDSHAKING, HANDSHAKING,
STATUS, STATUS,
LOGIN, LOGIN,
@ -22,11 +24,11 @@ public enum ConnectionStates {
DISCONNECTING, DISCONNECTING,
DISCONNECTED, DISCONNECTED,
FAILED, FAILED,
FAILED_NO_RETRY; FAILED_NO_RETRY,
;
private static final ConnectionStates[] CONNECTION_STATES = values(); companion object : ValuesEnum<ConnectionStates> {
override val VALUES: Array<ConnectionStates> = values()
public static ConnectionStates byId(int id) { override val NAME_MAP: Map<String, ConnectionStates> = KUtil.getEnumValues(VALUES)
return CONNECTION_STATES[id];
} }
} }