mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
refactor code
This commit is contained in:
parent
072be1549c
commit
6560a704c9
@ -34,7 +34,6 @@ import javafx.util.Callback;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Launcher extends Application {
|
||||
|
||||
public static void start() {
|
||||
|
@ -69,7 +69,6 @@ public class Minosoft {
|
||||
accountList = config.getMojangAccounts();
|
||||
selectAccount(accountList.get(config.getString(GameConfiguration.ACCOUNT_SELECTED)));
|
||||
|
||||
|
||||
serverList = config.getServers();
|
||||
Launcher.start();
|
||||
}
|
||||
|
@ -233,4 +233,3 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,6 @@ public enum ChatTextPositions {
|
||||
SYSTEM_MESSAGE,
|
||||
ABOVE_HOTBAR;
|
||||
|
||||
|
||||
public static ChatTextPositions byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ public enum Colors {
|
||||
RED,
|
||||
BLACK;
|
||||
|
||||
|
||||
public static Colors byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -30,20 +30,20 @@ import java.util.UUID;
|
||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolDefinition.PLAYER_INVENTORY_ID;
|
||||
|
||||
public class Player {
|
||||
public final HashMap<UUID, PlayerListItem> playerList = new HashMap<>();
|
||||
final MojangAccount account;
|
||||
final ScoreboardManager scoreboardManager = new ScoreboardManager();
|
||||
public final HashMap<UUID, PlayerListItem> playerList = new HashMap<>();
|
||||
final World world = new World("world");
|
||||
final HashMap<Integer, Inventory> inventories = new HashMap<>();
|
||||
float health;
|
||||
int food;
|
||||
float saturation;
|
||||
BlockPosition spawnLocation;
|
||||
GameModes gameMode;
|
||||
final World world = new World("world");
|
||||
byte selectedSlot;
|
||||
int level;
|
||||
int totalExperience;
|
||||
OtherPlayer player;
|
||||
final HashMap<Integer, Inventory> inventories = new HashMap<>();
|
||||
boolean spawnConfirmed = false;
|
||||
|
||||
TextComponent tabHeader;
|
||||
|
@ -248,7 +248,6 @@ public class TextComponent {
|
||||
final ChatColors color;
|
||||
final String prefix;
|
||||
|
||||
|
||||
ChatAttributes(String consolePrefix, ChatColors color) {
|
||||
this.consolePrefix = consolePrefix;
|
||||
this.color = color;
|
||||
|
@ -76,7 +76,6 @@ public class HorseMetaData extends AbstractHorseMetaData {
|
||||
GOLD_ARMOR,
|
||||
DIAMOND_ARMOR;
|
||||
|
||||
|
||||
public static HorseArmors byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
@ -95,7 +94,6 @@ public class HorseMetaData extends AbstractHorseMetaData {
|
||||
GRAY,
|
||||
DARK_BROWN;
|
||||
|
||||
|
||||
public static HorseColors byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
@ -112,7 +110,6 @@ public class HorseMetaData extends AbstractHorseMetaData {
|
||||
WHITE_DOTS,
|
||||
BLACK_DOTS;
|
||||
|
||||
|
||||
public static HorseDots byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public class OtherPlayer extends Mob implements MobInterface {
|
||||
final String name;
|
||||
final PlayerPropertyData[] properties;
|
||||
final short currentItem;
|
||||
HumanMetaData metaData;
|
||||
final Poses status = Poses.STANDING;
|
||||
HumanMetaData metaData;
|
||||
|
||||
public OtherPlayer(int entityId, String name, UUID uuid, PlayerPropertyData[] properties, Location location, int yaw, int pitch, int headYaw, short currentItem, HumanMetaData metaData) {
|
||||
super(entityId, uuid, location, yaw, pitch, headYaw);
|
||||
|
@ -68,7 +68,6 @@ public class InventorySlots {
|
||||
HOTBAR_9,
|
||||
OFF_HAND;
|
||||
|
||||
|
||||
public static PlayerInventorySlots byId(int id, int protocolId) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ public class Version {
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
|
||||
public boolean isGettingLoaded() {
|
||||
return isGettingLoaded;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import java.util.HashSet;
|
||||
|
||||
public class VersionMapping {
|
||||
final Version version;
|
||||
final HashSet<Mappings> loaded = new HashSet<>();
|
||||
HashBiMap<String, Motive> motiveIdentifierMap;
|
||||
HashBiMap<String, Particle> particleIdentifierMap;
|
||||
HashBiMap<String, Statistic> statisticIdentifierMap;
|
||||
@ -45,7 +46,6 @@ public class VersionMapping {
|
||||
HashBiMap<Integer, Enchantment> enchantmentMap;
|
||||
HashBiMap<Integer, Particle> particleIdMap;
|
||||
HashBiMap<Integer, Statistic> statisticIdMap;
|
||||
final HashSet<Mappings> loaded = new HashSet<>();
|
||||
|
||||
public VersionMapping(Version version) {
|
||||
this.version = version;
|
||||
|
@ -19,7 +19,6 @@ public class ScoreboardManager {
|
||||
final HashMap<String, Team> teams = new HashMap<>();
|
||||
final HashMap<String, ScoreboardObjective> objectives = new HashMap<>();
|
||||
|
||||
|
||||
public void addTeam(Team team) {
|
||||
teams.put(team.getName(), team);
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
|
||||
|
||||
public class IndirectPalette implements Palette {
|
||||
int protocolId;
|
||||
CustomMapping mapping;
|
||||
final HashBiMap<Integer, Integer> map = HashBiMap.create();
|
||||
final byte bitsPerBlock;
|
||||
int protocolId;
|
||||
CustomMapping mapping;
|
||||
|
||||
public IndirectPalette(byte bitsPerBlock) {
|
||||
this.bitsPerBlock = bitsPerBlock;
|
||||
|
@ -62,7 +62,6 @@ public class AccountListCell extends ListCell<MojangAccount> implements Initiali
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateItem(MojangAccount account, boolean empty) {
|
||||
super.updateItem(account, empty);
|
||||
|
@ -62,7 +62,6 @@ public class AccountWindow implements Initializable {
|
||||
PasswordField password = new PasswordField();
|
||||
password.setPromptText("Password");
|
||||
|
||||
|
||||
grid.add(new Label("Email:"), 0, 0);
|
||||
grid.add(email, 1, 0);
|
||||
grid.add(new Label("Password:"), 0, 1);
|
||||
@ -100,7 +99,6 @@ public class AccountWindow implements Initializable {
|
||||
Window window = dialog.getDialogPane().getScene().getWindow();
|
||||
window.setOnCloseRequest(windowEvent -> window.hide());
|
||||
|
||||
|
||||
dialog.showAndWait();
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateItem(Server server, boolean empty) {
|
||||
super.updateItem(server, empty);
|
||||
@ -215,7 +214,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
serverAddress.setPromptText("Server address");
|
||||
serverAddress.setText(server.getAddress());
|
||||
|
||||
|
||||
if (server.getDesiredVersion() == -1) {
|
||||
GUITools.versionList.getSelectionModel().select(Versions.getLowestVersionSupported());
|
||||
} else {
|
||||
@ -281,7 +279,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void resetCell() {
|
||||
// clear all cells
|
||||
setStyle(null);
|
||||
@ -336,7 +333,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
Label serverAddressLabel = new Label(server.getAddress());
|
||||
Label forcedVersionLabel = new Label();
|
||||
|
||||
|
||||
if (server.getDesiredVersion() == -1) {
|
||||
forcedVersionLabel.setText(Versions.getLowestVersionSupported().getVersionName());
|
||||
} else {
|
||||
@ -375,7 +371,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
Label motdLabel = new Label(lastPing.getMotd().getRawMessage());
|
||||
Label moddedBrandLabel = new Label(lastPing.getServerModInfo().getBrand());
|
||||
|
||||
|
||||
grid.add(new Label("Real server address:"), 0, ++column);
|
||||
grid.add(realServerAddressLabel, 1, column);
|
||||
grid.add(new Label("Server version:"), 0, ++column);
|
||||
@ -400,7 +395,6 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dialog.getDialogPane().setContent(grid);
|
||||
|
||||
dialog.showAndWait();
|
||||
|
@ -59,7 +59,6 @@ public class SessionListCell extends ListCell<Connection> implements Initializab
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateItem(Connection connection, boolean empty) {
|
||||
super.updateItem(connection, empty);
|
||||
|
@ -44,7 +44,6 @@ public class ServerListPing {
|
||||
}
|
||||
serverBrand = json.getAsJsonObject("version").get("name").getAsString();
|
||||
|
||||
|
||||
if (json.has("modinfo") && json.getAsJsonObject("modinfo").has("type") && json.getAsJsonObject("modinfo").get("type").getAsString().equals("FML")) {
|
||||
serverModInfo = new ForgeModInfo(json.getAsJsonObject("modinfo"));
|
||||
} else {
|
||||
|
@ -146,8 +146,7 @@ public class Network {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// everything sent for now, waiting for data
|
||||
// everything sent for now, waiting for data
|
||||
int numRead = 0;
|
||||
int length = 0;
|
||||
int read;
|
||||
@ -269,7 +268,6 @@ public class Network {
|
||||
Log.debug("Encryption enabled!");
|
||||
}
|
||||
|
||||
|
||||
public void disconnect() {
|
||||
connection.setConnectionState(ConnectionStates.DISCONNECTING);
|
||||
try {
|
||||
|
@ -29,11 +29,10 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PacketAdvancements implements ClientboundPacket {
|
||||
boolean reset;
|
||||
|
||||
final HashMap<String, Advancement> advancements = new HashMap<>();
|
||||
String[] toRemove;
|
||||
final HashMap<String, AdvancementProgress> progresses = new HashMap<>();
|
||||
boolean reset;
|
||||
String[] toRemove;
|
||||
|
||||
@Override
|
||||
public boolean read(InByteBuffer buffer) {
|
||||
|
@ -129,7 +129,6 @@ public class PacketBossBar implements ClientboundPacket {
|
||||
UPDATE_STYLE,
|
||||
UPDATE_FLAGS;
|
||||
|
||||
|
||||
public static BossBarActions byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
@ -164,7 +163,6 @@ public class PacketBossBar implements ClientboundPacket {
|
||||
NOTCHES_12,
|
||||
NOTCHES_20;
|
||||
|
||||
|
||||
public static BossBarDivisions byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ public class PacketCombatEvent implements ClientboundPacket {
|
||||
END_COMBAT,
|
||||
ENTITY_DEAD;
|
||||
|
||||
|
||||
public static CombatEvents byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PacketEntityEquipment implements ClientboundPacket {
|
||||
int entityId;
|
||||
final HashMap<InventorySlots.EntityInventorySlots, Slot> slots = new HashMap<>();
|
||||
int entityId;
|
||||
|
||||
@Override
|
||||
public boolean read(InByteBuffer buffer) {
|
||||
|
@ -82,7 +82,6 @@ public class PacketEntityStatus implements ClientboundPacket {
|
||||
PORTAL_PARTICLE_CHORUS;
|
||||
// ToDo: 1.11+ (for each entity)
|
||||
|
||||
|
||||
public static EntityStates byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -167,7 +167,6 @@ public class PacketMapData implements ClientboundPacket {
|
||||
PLAYERS,
|
||||
SCALE;
|
||||
|
||||
|
||||
public static PacketMapDataDataActions byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ public class PacketClientStatus implements ServerboundPacket {
|
||||
REQUEST_STATISTICS,
|
||||
OPEN_INVENTORY;
|
||||
|
||||
|
||||
public static ClientStates byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ public enum ConnectionStates {
|
||||
FAILED,
|
||||
FAILED_NO_RETRY;
|
||||
|
||||
|
||||
public static ConnectionStates byId(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PacketHandler {
|
||||
if (version == null) {
|
||||
Log.fatal(String.format("Server is running on unknown version or a invalid version was forced (version=%d, brand=\"%s\")", versionId, pkg.getResponse().getServerBrand()));
|
||||
} else {
|
||||
connection.setVersion(version);
|
||||
connection.setVersion(version);
|
||||
}
|
||||
Log.info(String.format("Status response received: %s/%s online. MotD: '%s'", pkg.getResponse().getPlayerOnline(), pkg.getResponse().getMaxPlayers(), pkg.getResponse().getMotd().getColoredMessage()));
|
||||
connection.handlePingCallbacks(pkg.getResponse());
|
||||
|
@ -200,7 +200,6 @@ public class Packets {
|
||||
PLAY_SET_COMPRESSION(PacketSetCompression.class),
|
||||
PLAY_ADVANCEMENT_PROGRESS(null);
|
||||
|
||||
|
||||
final ConnectionStates state;
|
||||
final Class<? extends ClientboundPacket> clazz;
|
||||
|
||||
|
@ -21,7 +21,6 @@ public abstract class Protocol {
|
||||
static final HashMap<ConnectionStates, HashBiMap<Packets.Serverbound, Integer>> serverboundPacketMapping = new HashMap<>();
|
||||
static final HashMap<ConnectionStates, HashBiMap<Packets.Clientbound, Integer>> clientboundPacketMapping = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
serverboundPacketMapping.put(ConnectionStates.HANDSHAKING, HashBiMap.create());
|
||||
serverboundPacketMapping.put(ConnectionStates.STATUS, HashBiMap.create());
|
||||
@ -52,9 +51,8 @@ public abstract class Protocol {
|
||||
clientboundPacketMapping.get(ConnectionStates.LOGIN).put(Packets.Clientbound.LOGIN_PLUGIN_REQUEST, 0x04);
|
||||
}
|
||||
|
||||
|
||||
public static int getPacketCommand(Packets.Serverbound packet) {
|
||||
return serverboundPacketMapping.get(packet.getState()).get(packet);
|
||||
return serverboundPacketMapping.get(packet.getState()).get(packet);
|
||||
}
|
||||
|
||||
public static Packets.Clientbound getPacketByCommand(ConnectionStates state, int command) {
|
||||
|
@ -19,7 +19,6 @@ import sys
|
||||
javaPath = "/usr/lib/jvm/java-8-openjdk-amd64/bin/java"
|
||||
print("Minecraft server wrapper")
|
||||
|
||||
|
||||
def download(manifest, version):
|
||||
versionJson = ""
|
||||
for key in manifest["versions"]:
|
||||
@ -31,7 +30,6 @@ def download(manifest, version):
|
||||
return
|
||||
downloadVersion(requests.get(versionJson).json())
|
||||
|
||||
|
||||
def downloadVersion(versionJson):
|
||||
server = versionJson["downloads"]["server"]["url"]
|
||||
if server == "":
|
||||
@ -48,7 +46,6 @@ def downloadVersion(versionJson):
|
||||
f.write(server.content)
|
||||
print("done")
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
# check args
|
||||
if sys.argv[1] == "download-all":
|
||||
|
Loading…
x
Reference in New Issue
Block a user