reduce java warnings

This commit is contained in:
bixilon 2020-06-05 20:59:30 +02:00
parent 809c1c4236
commit 841d3bc624
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
26 changed files with 62 additions and 45 deletions

17
.idea/dictionaries/moritz.xml generated Normal file
View File

@ -0,0 +1,17 @@
<component name="ProjectDictionaryState">
<dictionary name="moritz">
<words>
<w>clientbound</w>
<w>cooldown</w>
<w>gamemode</w>
<w>minosoft</w>
<w>mojang</w>
<w>motd</w>
<w>multiblock</w>
<w>notchian</w>
<w>overworld</w>
<w>serverbound</w>
<w>singleplayer</w>
</words>
</dictionary>
</component>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -9,7 +9,7 @@ Multithreaded
Mostly GPU based, not cpu Mostly GPU based, not cpu
Aimed for performance (goal: reach v-sync framerate, dynamically disable effects, ...) Aimed for performance (goal: reach v-sync framerate, dynamically disable effects, ...)
Server support Server support
No original Minecraft workarounds (API: plugin channel): No invisible entities to show holograms, No Scoreboard workarounds, ... (Scoreboard still must be implemented to avoid compatiblity issues) No original Minecraft workarounds (API: plugin channel): No invisible entities to show holograms, No Scoreboard workarounds, ... (Scoreboard still must be implemented to avoid compatibility issues)
Debug settings (stop entity updates, entity limiter, ...) Debug settings (stop entity updates, entity limiter, ...)
No cheat client (only per modding api) No cheat client (only per modding api)
Server GUI API (server can send custom GUIs to client) Server GUI API (server can send custom GUIs to client)

View File

@ -1,5 +1,5 @@
package de.bixilon.minosoft.config; package de.bixilon.minosoft.config;
public interface ConfigEnum { public interface ConfigEnum {
public String getPath(); String getPath();
} }

View File

@ -62,6 +62,7 @@ public class Configuration {
String[] spilt = path.split("\\."); String[] spilt = path.split("\\.");
LinkedHashMap<String, Object> temp = config; LinkedHashMap<String, Object> temp = config;
for (int i = 0; i < spilt.length - 1; i++) { for (int i = 0; i < spilt.length - 1; i++) {
//noinspection unchecked
temp = (LinkedHashMap<String, Object>) temp.get(spilt[i]); temp = (LinkedHashMap<String, Object>) temp.get(spilt[i]);
} }
return temp.get(spilt[spilt.length - 1]); return temp.get(spilt[spilt.length - 1]);

View File

@ -1,9 +1,9 @@
package de.bixilon.minosoft.game.datatypes; package de.bixilon.minosoft.game.datatypes;
public class BlockPosition { public class BlockPosition {
int x; final int x;
int y; final int y;
int z; final int z;
public BlockPosition(int x, short y, int z) { public BlockPosition(int x, short y, int z) {
// y min -2048, max 2047 // y min -2048, max 2047

View File

@ -27,11 +27,14 @@ public class ChatComponent {
return json.getString("text"); return json.getString("text");
} }
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
JSONArray arr = json.getJSONArray("extra"); if (json.has("extra")) {
for (int i = 0; i < arr.length(); i++) { JSONArray arr = json.getJSONArray("extra");
buffer.append(arr.getJSONObject(i).getString("text")); for (int i = 0; i < arr.length(); i++) {
buffer.append(arr.getJSONObject(i).getString("text"));
}
return buffer.toString();
} }
return buffer.toString(); return "";
} }
public JSONObject getRaw() { public JSONObject getRaw() {

View File

@ -4,8 +4,8 @@ package de.bixilon.minosoft.game.datatypes;
* Chunk X and Z location (block position / 16, rounded down) * Chunk X and Z location (block position / 16, rounded down)
*/ */
public class ChunkLocation { public class ChunkLocation {
int x; final int x;
int z; final int z;
public ChunkLocation(int x, int z) { public ChunkLocation(int x, int z) {
this.x = x; this.x = x;

View File

@ -4,9 +4,9 @@ package de.bixilon.minosoft.game.datatypes;
* Chunk X, Y and Z location (max 16x16x16) * Chunk X, Y and Z location (max 16x16x16)
*/ */
public class ChunkNibbleLocation { public class ChunkNibbleLocation {
int x; final int x;
int y; final int y;
int z; final int z;
public ChunkNibbleLocation(int x, int y, int z) { public ChunkNibbleLocation(int x, int y, int z) {
this.x = x; this.x = x;

View File

@ -6,7 +6,7 @@ public enum Difficulty {
NORMAL(2), NORMAL(2),
HARD(3); HARD(3);
int id; final int id;
Difficulty(int id) { Difficulty(int id) {
this.id = id; this.id = id;

View File

@ -5,7 +5,7 @@ public enum Dimension {
OVERWORLD(0), OVERWORLD(0),
END(1); END(1);
int id; final int id;
Dimension(int id) { Dimension(int id) {
this.id = id; this.id = id;

View File

@ -6,7 +6,7 @@ public enum GameMode {
ADVENTURE(2), ADVENTURE(2),
SPECTATOR(3); SPECTATOR(3);
int id; final int id;
GameMode(int id) { GameMode(int id) {
this.id = id; this.id = id;

View File

@ -9,7 +9,7 @@ public enum LevelType {
CUSTOMIZED("customized"), CUSTOMIZED("customized"),
BUFFET("buffet"); BUFFET("buffet");
String type; final String type;
LevelType(String type) { LevelType(String type) {
this.type = type; this.type = type;

View File

@ -5,7 +5,7 @@ public enum Locale {
EN_GB("en_gb"), EN_GB("en_gb"),
DE_DE("de_DE"); DE_DE("de_DE");
String name; final String name;
Locale(String name) { Locale(String name) {
this.name = name; this.name = name;

View File

@ -39,10 +39,8 @@ public class World {
public void setBlock(BlockPosition pos, Block block) { public void setBlock(BlockPosition pos, Block block) {
if (getChunk(pos.getChunkLocation()) != null) { if (getChunk(pos.getChunkLocation()) != null) {
getChunk(pos.getChunkLocation()).setBlock(pos.getX() % 16, pos.getX(), pos.getZ() % 16, block); getChunk(pos.getChunkLocation()).setBlock(pos.getX() % 16, pos.getX(), pos.getZ() % 16, block);
} else {
//throw new IllegalAccessException("Chunk is not loaded!");
// ToDo
} }
// do nothing if chunk is unloaded
} }
public void unloadChunk(ChunkLocation location) { public void unloadChunk(ChunkLocation location) {

View File

@ -48,8 +48,8 @@ public enum Block {
//ToDo all blocks //ToDo all blocks
//ToDo post water update block states //ToDo post water update block states
Identifier identifier; final Identifier identifier;
int legacyId; final int legacyId;
int legacyData; int legacyData;
Block(Identifier identifier, int legacyId, int legacyData) { Block(Identifier identifier, int legacyId, int legacyData) {

View File

@ -4,7 +4,7 @@ import java.text.SimpleDateFormat;
public class Log { public class Log {
static LogLevel level = LogLevel.PROTOCOL; static LogLevel level = LogLevel.PROTOCOL;
static SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); final static SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
public static void log(LogLevel l, String message) { public static void log(LogLevel l, String message) {
if (l.getId() > level.getId()) { if (l.getId() > level.getId()) {

View File

@ -10,8 +10,8 @@ import java.util.UUID;
public class Account { public class Account {
String username; final String username;
String password; final String password;
String playerName; String playerName;
String token; String token;

View File

@ -7,7 +7,7 @@ import de.bixilon.minosoft.game.datatypes.player.Location;
import java.util.UUID; import java.util.UUID;
public class Player { public class Player {
Account acc; final Account acc;
float health; float health;
short food; short food;
float saturation; float saturation;

View File

@ -3,7 +3,7 @@ package de.bixilon.minosoft.objects;
import org.json.JSONObject; import org.json.JSONObject;
public class ServerListPing { public class ServerListPing {
JSONObject raw; final JSONObject raw;
public ServerListPing(JSONObject json) { public ServerListPing(JSONObject json) {
this.raw = json; this.raw = json;

View File

@ -64,7 +64,7 @@ public class PacketChangeGameState implements ClientboundPacket {
FADE_VALUE(7), FADE_VALUE(7),
FADE_TIME(8); FADE_TIME(8);
byte id; final byte id;
Reason(byte id) { Reason(byte id) {
this.id = id; this.id = id;

View File

@ -17,7 +17,7 @@ import de.bixilon.minosoft.util.Util;
import java.util.HashMap; import java.util.HashMap;
public class PacketChunkBulk implements ClientboundPacket { public class PacketChunkBulk implements ClientboundPacket {
HashMap<ChunkLocation, Chunk> chunkMap = new HashMap<>(); final HashMap<ChunkLocation, Chunk> chunkMap = new HashMap<>();
@Override @Override

View File

@ -12,9 +12,9 @@ import java.security.PublicKey;
public class PacketEncryptionResponse implements ServerboundPacket { public class PacketEncryptionResponse implements ServerboundPacket {
byte[] secret; final byte[] secret;
byte[] token; final byte[] token;
SecretKey secretKey; final SecretKey secretKey;
public PacketEncryptionResponse(SecretKey secret, byte[] token, PublicKey key) { public PacketEncryptionResponse(SecretKey secret, byte[] token, PublicKey key) {

View File

@ -20,7 +20,7 @@ import java.math.BigInteger;
import java.security.PublicKey; import java.security.PublicKey;
public class PacketHandler { public class PacketHandler {
Connection connection; final Connection connection;
public PacketHandler(Connection connection) { public PacketHandler(Connection connection) {
this.connection = connection; this.connection = connection;

View File

@ -6,8 +6,8 @@ import java.util.Map;
public class Protocol_1_7_10 implements Protocol { public class Protocol_1_7_10 implements Protocol {
public HashMap<Packets.Serverbound, Integer> serverboundPacketMapping; public final HashMap<Packets.Serverbound, Integer> serverboundPacketMapping;
public HashMap<Packets.Clientbound, Integer> clientboundPacketMapping; public final HashMap<Packets.Clientbound, Integer> clientboundPacketMapping;
Protocol_1_7_10() { Protocol_1_7_10() {
// serverbound // serverbound

View File

@ -8,14 +8,6 @@ public class BitByte {
return bitSet; return bitSet;
} }
public static short[] byteArrayToShortArray(byte[] readBytes) {
short[] ret = new short[readBytes.length];
for (int i = 0; i < readBytes.length; i++) {
ret[0] = readBytes[0];
}
return ret;
}
public static byte getLow4Bits(byte input) { public static byte getLow4Bits(byte input) {
return (byte) (input & 0xF); return (byte) (input & 0xF);
} }