forked from GeyserMC/Geyser
Fix NPE for items with missing mappings (Closes #24)
This commit is contained in:
parent
33c4c115ab
commit
7dae4cbd0f
4 changed files with 18 additions and 9 deletions
|
@ -119,10 +119,6 @@ public class GeyserConnector implements Connector {
|
|||
shutdown();
|
||||
}
|
||||
|
||||
metrics = new Metrics("GeyserMC", instance.getConfig().getUUID(), true, java.util.logging.Logger.getLogger(""));
|
||||
|
||||
addMetrics(metrics);
|
||||
|
||||
logger.setDebug(config.isDebugMode());
|
||||
|
||||
Toolbox.CACHED_PALLETE.array();
|
||||
|
@ -151,6 +147,10 @@ public class GeyserConnector implements Connector {
|
|||
throwable.printStackTrace();
|
||||
}
|
||||
}).join();
|
||||
|
||||
metrics = new Metrics("GeyserMC", instance.getConfig().getUUID(), true, java.util.logging.Logger.getLogger(""));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", Geyser::getPlayerCount));
|
||||
}
|
||||
|
||||
public Collection<Player> getConnectedPlayers() {
|
||||
|
@ -179,9 +179,4 @@ public class GeyserConnector implements Connector {
|
|||
players.remove(player.getAuthenticationData().getName());
|
||||
players.remove(player.getAuthenticationData().getUUID());
|
||||
}
|
||||
|
||||
private static void addMetrics(Metrics m) {
|
||||
m.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1));
|
||||
m.addCustomChart(new Metrics.SingleLineChart("players", Geyser::getPlayerCount));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public class BedrockItem {
|
||||
|
||||
public static BedrockItem AIR = new BedrockItem("minecraft:air", 0, 0);
|
||||
|
||||
private String identifier;
|
||||
private int id;
|
||||
private int data;
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.github.steveice10.opennbt.tag.builtin.ShortTag;
|
|||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
import org.geysermc.connector.console.GeyserLogger;
|
||||
import org.geysermc.connector.utils.MessageUtils;
|
||||
import org.geysermc.connector.utils.Remapper;
|
||||
import org.geysermc.connector.utils.Toolbox;
|
||||
|
@ -78,11 +79,20 @@ public class ItemTranslator {
|
|||
|
||||
public static BedrockItem getBedrockItem(ItemStack stack) {
|
||||
Map<String, Object> m = Remapper.JAVA_TO_BEDROCK.get(stack.getId());
|
||||
if (m == null) {
|
||||
GeyserLogger.DEFAULT.debug("Missing mapping for java item " + stack.getId());
|
||||
return BedrockItem.AIR;
|
||||
}
|
||||
return new BedrockItem((String) m.get("name"), (Integer) m.get("id"), (Integer) m.get("data"));
|
||||
}
|
||||
|
||||
public static JavaItem getJavaItem(ItemData data) {
|
||||
Map<String, Object> m = Remapper.BEDROCK_TO_JAVA.get(data.getId()).get(data.getDamage());
|
||||
if (m == null) {
|
||||
GeyserLogger.DEFAULT.debug("Missing mapping for bedrock item " + data.getId() + ":" + data.getDamage());
|
||||
|
||||
return JavaItem.AIR;
|
||||
}
|
||||
return new JavaItem((String) m.get("name"), (Integer) m.get("id"));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public class JavaItem {
|
||||
|
||||
public static JavaItem AIR = new JavaItem("minecraft:air", 0);
|
||||
|
||||
private String identifier;
|
||||
private int id;
|
||||
|
||||
|
|
Loading…
Reference in a new issue