Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Clean up a bunch
Mostly checked with IntelliJ, but manually performed. The only issue I possibly anticipate is item name/lore issues, but the new method should be technically better.
Dieser Commit ist enthalten in:
Ursprung
683ac1c763
Commit
3a2cff7864
@ -32,17 +32,16 @@ import org.geysermc.connector.common.serializer.AsteriskSerializer;
|
|||||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
|
public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
|
||||||
|
private final String platformName;
|
||||||
private String platformName;
|
private final String platformVersion;
|
||||||
private String platformVersion;
|
private final boolean onlineMode;
|
||||||
private boolean onlineMode;
|
private final List<ListenerInfo> listeners;
|
||||||
private List<ListenerInfo> listeners;
|
private final List<PluginInfo> plugins;
|
||||||
private List<PluginInfo> plugins;
|
|
||||||
|
|
||||||
GeyserBungeeDumpInfo(ProxyServer proxy) {
|
GeyserBungeeDumpInfo(ProxyServer proxy) {
|
||||||
super();
|
super();
|
||||||
@ -63,7 +62,7 @@ public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Plugin plugin : proxy.getPluginManager().getPlugins()) {
|
for (Plugin plugin : proxy.getPluginManager().getPlugins()) {
|
||||||
this.plugins.add(new PluginInfo(true, plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), Arrays.asList(plugin.getDescription().getAuthor())));
|
this.plugins.add(new PluginInfo(true, plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), Collections.singletonList(plugin.getDescription().getAuthor())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
|||||||
import org.geysermc.connector.common.ping.GeyserPingInfo;
|
import org.geysermc.connector.common.ping.GeyserPingInfo;
|
||||||
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -64,9 +63,8 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
|
|||||||
new GeyserPingInfo.Version(response.getVersion().getName(), response.getVersion().getProtocol())
|
new GeyserPingInfo.Version(response.getVersion().getName(), response.getVersion().getProtocol())
|
||||||
);
|
);
|
||||||
if (event.getResponse().getPlayers().getSample() != null) {
|
if (event.getResponse().getPlayers().getSample() != null) {
|
||||||
Arrays.stream(event.getResponse().getPlayers().getSample()).forEach(proxiedPlayer -> {
|
Arrays.stream(event.getResponse().getPlayers().getSample()).forEach(proxiedPlayer ->
|
||||||
geyserPingInfo.getPlayerList().add(proxiedPlayer.getName());
|
geyserPingInfo.getPlayerList().add(proxiedPlayer.getName()));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return geyserPingInfo;
|
return geyserPingInfo;
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,13 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
public class GeyserSpigotDumpInfo extends BootstrapDumpInfo {
|
public class GeyserSpigotDumpInfo extends BootstrapDumpInfo {
|
||||||
|
|
||||||
private String platformName;
|
private final String platformName;
|
||||||
private String platformVersion;
|
private final String platformVersion;
|
||||||
private String platformAPIVersion;
|
private final String platformAPIVersion;
|
||||||
private boolean onlineMode;
|
private final boolean onlineMode;
|
||||||
private String serverIP;
|
private final String serverIP;
|
||||||
private int serverPort;
|
private final int serverPort;
|
||||||
private List<PluginInfo> plugins;
|
private final List<PluginInfo> plugins;
|
||||||
|
|
||||||
GeyserSpigotDumpInfo() {
|
GeyserSpigotDumpInfo() {
|
||||||
super();
|
super();
|
||||||
|
@ -34,6 +34,7 @@ import org.bukkit.util.CachedServerIcon;
|
|||||||
import org.geysermc.connector.common.ping.GeyserPingInfo;
|
import org.geysermc.connector.common.ping.GeyserPingInfo;
|
||||||
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -72,9 +73,10 @@ public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough {
|
|||||||
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
|
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Player> iterator() throws UnsupportedOperationException {
|
public Iterator<Player> iterator() throws UnsupportedOperationException {
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyIterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||||||
this.geyserSpigotPingPassthrough = new GeyserSpigotPingPassthrough(geyserLogger);
|
this.geyserSpigotPingPassthrough = new GeyserSpigotPingPassthrough(geyserLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.geyserCommandManager = new GeyserSpigotCommandManager(this, connector);
|
this.geyserCommandManager = new GeyserSpigotCommandManager(connector);
|
||||||
|
|
||||||
boolean isViaVersion = Bukkit.getPluginManager().getPlugin("ViaVersion") != null;
|
boolean isViaVersion = Bukkit.getPluginManager().getPlugin("ViaVersion") != null;
|
||||||
if (isViaVersion) {
|
if (isViaVersion) {
|
||||||
|
@ -30,7 +30,6 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.command.CommandManager;
|
import org.geysermc.connector.command.CommandManager;
|
||||||
import org.geysermc.platform.spigot.GeyserSpigotPlugin;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
@ -48,12 +47,8 @@ public class GeyserSpigotCommandManager extends CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GeyserSpigotPlugin plugin;
|
public GeyserSpigotCommandManager(GeyserConnector connector) {
|
||||||
|
|
||||||
public GeyserSpigotCommandManager(GeyserSpigotPlugin plugin, GeyserConnector connector) {
|
|
||||||
super(connector);
|
super(connector);
|
||||||
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,7 +93,6 @@ public class GeyserSpigot1_12WorldManager extends GeyserSpigotWorldManager {
|
|||||||
* @param z Z coordinate of block
|
* @param z Z coordinate of block
|
||||||
* @return the block state updated to the latest Minecraft version
|
* @return the block state updated to the latest Minecraft version
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public int getLegacyBlock(BlockStorage storage, int blockId, int x, int y, int z) {
|
public int getLegacyBlock(BlockStorage storage, int blockId, int x, int y, int z) {
|
||||||
// Convert block state from old version (1.12.2) -> 1.13 -> 1.13.1 -> 1.14 -> 1.15 -> 1.16 -> 1.16.2
|
// Convert block state from old version (1.12.2) -> 1.13 -> 1.13.1 -> 1.14 -> 1.15 -> 1.16 -> 1.16.2
|
||||||
blockId = mappingData1_12to1_13.getNewBlockId(blockId);
|
blockId = mappingData1_12to1_13.getNewBlockId(blockId);
|
||||||
|
@ -36,13 +36,12 @@ import java.util.List;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserSpongeDumpInfo extends BootstrapDumpInfo {
|
public class GeyserSpongeDumpInfo extends BootstrapDumpInfo {
|
||||||
|
private final String platformName;
|
||||||
private String platformName;
|
private final String platformVersion;
|
||||||
private String platformVersion;
|
private final boolean onlineMode;
|
||||||
private boolean onlineMode;
|
private final String serverIP;
|
||||||
private String serverIP;
|
private final int serverPort;
|
||||||
private int serverPort;
|
private final List<PluginInfo> plugins;
|
||||||
private List<PluginInfo> plugins;
|
|
||||||
|
|
||||||
GeyserSpongeDumpInfo() {
|
GeyserSpongeDumpInfo() {
|
||||||
super();
|
super();
|
||||||
|
@ -33,7 +33,6 @@ import org.geysermc.connector.common.ChatColor;
|
|||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.utils.LanguageUtils;
|
import org.geysermc.connector.utils.LanguageUtils;
|
||||||
import org.spongepowered.api.command.CommandCallable;
|
import org.spongepowered.api.command.CommandCallable;
|
||||||
import org.spongepowered.api.command.CommandException;
|
|
||||||
import org.spongepowered.api.command.CommandResult;
|
import org.spongepowered.api.command.CommandResult;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
@ -81,7 +80,7 @@ public class GeyserSpongeCommandExecutor extends CommandExecutor implements Comm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException {
|
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) {
|
||||||
if (arguments.split(" ").length == 1) {
|
if (arguments.split(" ").length == 1) {
|
||||||
return connector.getCommandManager().getCommandNames();
|
return connector.getCommandManager().getCommandNames();
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,7 @@ import org.spongepowered.api.command.CommandMapping;
|
|||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
|
|
||||||
public class GeyserSpongeCommandManager extends CommandManager {
|
public class GeyserSpongeCommandManager extends CommandManager {
|
||||||
|
private final org.spongepowered.api.command.CommandManager handle;
|
||||||
private org.spongepowered.api.command.CommandManager handle;
|
|
||||||
|
|
||||||
public GeyserSpongeCommandManager(org.spongepowered.api.command.CommandManager handle, GeyserConnector connector) {
|
public GeyserSpongeCommandManager(org.spongepowered.api.command.CommandManager handle, GeyserConnector connector) {
|
||||||
super(connector);
|
super(connector);
|
||||||
@ -43,6 +42,8 @@ public class GeyserSpongeCommandManager extends CommandManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(String command) {
|
public String getDescription(String command) {
|
||||||
return handle.get(command).map(CommandMapping::getCallable).map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY)).orElse(Text.EMPTY).toPlain();
|
return handle.get(command).map(CommandMapping::getCallable)
|
||||||
|
.map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY))
|
||||||
|
.orElse(Text.EMPTY).toPlain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,7 @@ import org.geysermc.connector.dump.BootstrapDumpInfo;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserStandaloneDumpInfo extends BootstrapDumpInfo {
|
public class GeyserStandaloneDumpInfo extends BootstrapDumpInfo {
|
||||||
|
private final boolean isGui;
|
||||||
private boolean isGui;
|
|
||||||
|
|
||||||
GeyserStandaloneDumpInfo(GeyserStandaloneBootstrap bootstrap) {
|
GeyserStandaloneDumpInfo(GeyserStandaloneBootstrap bootstrap) {
|
||||||
super();
|
super();
|
||||||
|
@ -30,7 +30,6 @@ import org.geysermc.connector.utils.LanguageUtils;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.OpenOption;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class LoopbackUtil {
|
public class LoopbackUtil {
|
||||||
@ -54,7 +53,7 @@ public class LoopbackUtil {
|
|||||||
String result = sb.toString();
|
String result = sb.toString();
|
||||||
|
|
||||||
if (!result.contains("minecraftuwp")) {
|
if (!result.contains("minecraftuwp")) {
|
||||||
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes(), new OpenOption[0]);
|
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes());
|
||||||
Runtime.getRuntime().exec(startScript);
|
Runtime.getRuntime().exec(startScript);
|
||||||
|
|
||||||
geyserLogger.info(ChatColor.AQUA + LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.added"));
|
geyserLogger.info(ChatColor.AQUA + LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.added"));
|
||||||
|
@ -60,8 +60,8 @@ public class ColorPane extends JTextPane {
|
|||||||
*/
|
*/
|
||||||
public void appendANSI(String s) { // convert ANSI color codes first
|
public void appendANSI(String s) { // convert ANSI color codes first
|
||||||
int aPos = 0; // current char position in addString
|
int aPos = 0; // current char position in addString
|
||||||
int aIndex = 0; // index of next Escape sequence
|
int aIndex; // index of next Escape sequence
|
||||||
int mIndex = 0; // index of "m" terminating Escape sequence
|
int mIndex; // index of "m" terminating Escape sequence
|
||||||
String tmpString = "";
|
String tmpString = "";
|
||||||
boolean stillSearching = true; // true until no more Escape sequences
|
boolean stillSearching = true; // true until no more Escape sequences
|
||||||
String addString = remaining + s;
|
String addString = remaining + s;
|
||||||
@ -83,7 +83,6 @@ public class ColorPane extends JTextPane {
|
|||||||
|
|
||||||
|
|
||||||
// while there's text in the input buffer
|
// while there's text in the input buffer
|
||||||
stillSearching = true;
|
|
||||||
while (stillSearching) {
|
while (stillSearching) {
|
||||||
mIndex = addString.indexOf("m", aPos); // find the end of the escape sequence
|
mIndex = addString.indexOf("m", aPos); // find the end of the escape sequence
|
||||||
if (mIndex < 0) { // the buffer ends halfway through the ansi string!
|
if (mIndex < 0) { // the buffer ends halfway through the ansi string!
|
||||||
|
@ -46,7 +46,7 @@ public final class GraphPanel extends JPanel {
|
|||||||
private final static Color pointColor = new Color(100, 100, 100, 255);
|
private final static Color pointColor = new Color(100, 100, 100, 255);
|
||||||
private final static Color gridColor = new Color(200, 200, 200, 255);
|
private final static Color gridColor = new Color(200, 200, 200, 255);
|
||||||
private static final Stroke graphStroke = new BasicStroke(2f);
|
private static final Stroke graphStroke = new BasicStroke(2f);
|
||||||
private List<Integer> values = new ArrayList<>(10);
|
private final List<Integer> values = new ArrayList<>(10);
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private String xLabel = "";
|
private String xLabel = "";
|
||||||
@ -172,6 +172,7 @@ public final class GraphPanel extends JPanel {
|
|||||||
for (Point graphPoint : graphPoints) {
|
for (Point graphPoint : graphPoints) {
|
||||||
final int x = graphPoint.x - pointWidth / 2;
|
final int x = graphPoint.x - pointWidth / 2;
|
||||||
final int y = graphPoint.y - pointWidth / 2;
|
final int y = graphPoint.y - pointWidth / 2;
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
g.fillOval(x, y, pointWidth, pointWidth);
|
g.fillOval(x, y, pointWidth, pointWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,13 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
public class GeyserVelocityDumpInfo extends BootstrapDumpInfo {
|
public class GeyserVelocityDumpInfo extends BootstrapDumpInfo {
|
||||||
|
|
||||||
private String platformName;
|
private final String platformName;
|
||||||
private String platformVersion;
|
private final String platformVersion;
|
||||||
private String platformVendor;
|
private final String platformVendor;
|
||||||
private boolean onlineMode;
|
private final boolean onlineMode;
|
||||||
private String serverIP;
|
private final String serverIP;
|
||||||
private int serverPort;
|
private final int serverPort;
|
||||||
private List<PluginInfo> plugins;
|
private final List<PluginInfo> plugins;
|
||||||
|
|
||||||
GeyserVelocityDumpInfo(ProxyServer proxy) {
|
GeyserVelocityDumpInfo(ProxyServer proxy) {
|
||||||
super();
|
super();
|
||||||
|
@ -38,8 +38,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class HelpCommand extends GeyserCommand {
|
public class HelpCommand extends GeyserCommand {
|
||||||
|
private final GeyserConnector connector;
|
||||||
public GeyserConnector connector;
|
|
||||||
|
|
||||||
public HelpCommand(GeyserConnector connector, String name, String description, String permission) {
|
public HelpCommand(GeyserConnector connector, String name, String description, String permission) {
|
||||||
super(name, description, permission);
|
super(name, description, permission);
|
||||||
|
@ -45,8 +45,7 @@ public class ListCommand extends GeyserCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(GeyserSession session, CommandSender sender, String[] args) {
|
public void execute(GeyserSession session, CommandSender sender, String[] args) {
|
||||||
String message = "";
|
String message = LanguageUtils.getPlayerLocaleString("geyser.commands.list.message", sender.getLocale(),
|
||||||
message = LanguageUtils.getPlayerLocaleString("geyser.commands.list.message", sender.getLocale(),
|
|
||||||
connector.getPlayers().size(),
|
connector.getPlayers().size(),
|
||||||
connector.getPlayers().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
|
connector.getPlayers().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ public class IGeyserMain {
|
|||||||
Class<?> graphicsEnvironment = Class.forName("java.awt.GraphicsEnvironment");
|
Class<?> graphicsEnvironment = Class.forName("java.awt.GraphicsEnvironment");
|
||||||
Method isHeadless = graphicsEnvironment.getDeclaredMethod("isHeadless");
|
Method isHeadless = graphicsEnvironment.getDeclaredMethod("isHeadless");
|
||||||
return (Boolean)isHeadless.invoke(null);
|
return (Boolean)isHeadless.invoke(null);
|
||||||
} catch (Exception ex) { }
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -135,22 +135,27 @@ public class FireworkEntity extends Entity {
|
|||||||
NbtMapBuilder builder = NbtMap.builder();
|
NbtMapBuilder builder = NbtMap.builder();
|
||||||
builder.put("Fireworks", fireworksBuilder.build());
|
builder.put("Fireworks", fireworksBuilder.build());
|
||||||
metadata.put(EntityData.DISPLAY_ITEM, builder.build());
|
metadata.put(EntityData.DISPLAY_ITEM, builder.build());
|
||||||
} else if (entityMetadata.getId() == 9 && !entityMetadata.getValue().equals(OptionalInt.empty()) && ((OptionalInt) entityMetadata.getValue()).getAsInt() == session.getPlayerEntity().getEntityId()) {
|
} else if (entityMetadata.getId() == 9) {
|
||||||
//Checks if the firework has an entity ID (used when a player is gliding) and checks to make sure the player that is gliding is the one getting sent the packet or else every player near the gliding player will boost too.
|
OptionalInt optional = (OptionalInt) entityMetadata.getValue();
|
||||||
PlayerEntity entity = session.getPlayerEntity();
|
// Checks if the firework has an entity ID (used when a player is gliding)
|
||||||
float yaw = entity.getRotation().getX();
|
// and checks to make sure the player that is gliding is the one getting sent the packet
|
||||||
float pitch = entity.getRotation().getY();
|
// or else every player near the gliding player will boost too.
|
||||||
//Uses math from NukkitX
|
if (optional.isPresent() && optional.getAsInt() == session.getPlayerEntity().getEntityId()) {
|
||||||
entity.setMotion(Vector3f.from(
|
PlayerEntity entity = session.getPlayerEntity();
|
||||||
-Math.sin(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 2,
|
float yaw = entity.getRotation().getX();
|
||||||
-Math.sin(Math.toRadians(pitch)) * 2,
|
float pitch = entity.getRotation().getY();
|
||||||
Math.cos(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 2));
|
// Uses math from NukkitX
|
||||||
//Need to update the EntityMotionPacket or else the player won't boost
|
entity.setMotion(Vector3f.from(
|
||||||
SetEntityMotionPacket entityMotionPacket = new SetEntityMotionPacket();
|
-Math.sin(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 2,
|
||||||
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
|
-Math.sin(Math.toRadians(pitch)) * 2,
|
||||||
entityMotionPacket.setMotion(entity.getMotion());
|
Math.cos(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 2));
|
||||||
|
// Need to update the EntityMotionPacket or else the player won't boost
|
||||||
|
SetEntityMotionPacket entityMotionPacket = new SetEntityMotionPacket();
|
||||||
|
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
|
entityMotionPacket.setMotion(entity.getMotion());
|
||||||
|
|
||||||
session.sendUpstreamPacket(entityMotionPacket);
|
session.sendUpstreamPacket(entityMotionPacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
|
@ -53,7 +53,7 @@ public class Inventory {
|
|||||||
@Setter
|
@Setter
|
||||||
protected String title;
|
protected String title;
|
||||||
|
|
||||||
protected GeyserItemStack[] items;
|
protected final GeyserItemStack[] items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the inventory block. Will either be a fake block above the player's head, or the actual block location
|
* The location of the inventory block. Will either be a fake block above the player's head, or the actual block location
|
||||||
|
@ -38,9 +38,8 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||||||
* packets of interest and limit boilerplate code.
|
* packets of interest and limit boilerplate code.
|
||||||
*/
|
*/
|
||||||
public class LoggingPacketHandler implements BedrockPacketHandler {
|
public class LoggingPacketHandler implements BedrockPacketHandler {
|
||||||
|
protected final GeyserConnector connector;
|
||||||
protected GeyserConnector connector;
|
protected final GeyserSession session;
|
||||||
protected GeyserSession session;
|
|
||||||
|
|
||||||
LoggingPacketHandler(GeyserConnector connector, GeyserSession session) {
|
LoggingPacketHandler(GeyserConnector connector, GeyserSession session) {
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
@ -759,9 +758,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
|
|||||||
return defaultHandler(packet);
|
return defaultHandler(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I question if God exists because of this packet - God does not exist if I find out there's a built-in dab
|
|
||||||
// TODO for the future: redirect this as a /me command
|
|
||||||
// TODO for the far future: should we have a client mod that handles skins, handle these too
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(EmoteListPacket packet) {
|
public boolean handle(EmoteListPacket packet) {
|
||||||
return defaultHandler(packet);
|
return defaultHandler(packet);
|
||||||
|
@ -83,7 +83,7 @@ public class QueryPacketHandler {
|
|||||||
* @return if the packet is a query packet
|
* @return if the packet is a query packet
|
||||||
*/
|
*/
|
||||||
private boolean isQueryPacket(ByteBuf buffer) {
|
private boolean isQueryPacket(ByteBuf buffer) {
|
||||||
return (buffer.readableBytes() >= 2) ? buffer.readUnsignedShort() == 0xFEFD : false;
|
return buffer.readableBytes() >= 2 && buffer.readUnsignedShort() == 0xFEFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,15 +37,14 @@ import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BossBar {
|
public class BossBar {
|
||||||
|
private final GeyserSession session;
|
||||||
|
|
||||||
private GeyserSession session;
|
private final long entityId;
|
||||||
|
|
||||||
private long entityId;
|
|
||||||
private Component title;
|
private Component title;
|
||||||
private float health;
|
private float health;
|
||||||
private int color;
|
private final int color;
|
||||||
private int overlay;
|
private final int overlay;
|
||||||
private int darkenSky;
|
private final int darkenSky;
|
||||||
|
|
||||||
public void addBossBar() {
|
public void addBossBar() {
|
||||||
addBossEntity();
|
addBossEntity();
|
||||||
|
@ -39,16 +39,13 @@ public class BedrockMapInfoRequestTranslator extends PacketTranslator<MapInfoReq
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(MapInfoRequestPacket packet, GeyserSession session) {
|
public void translate(MapInfoRequestPacket packet, GeyserSession session) {
|
||||||
long mapID = packet.getUniqueMapId();
|
long mapId = packet.getUniqueMapId();
|
||||||
|
|
||||||
if (session.getStoredMaps().containsKey(mapID)) {
|
ClientboundMapItemDataPacket mapPacket = session.getStoredMaps().remove(mapId);
|
||||||
|
if (mapPacket != null) {
|
||||||
// Delay the packet 100ms to prevent the client from ignoring the packet
|
// Delay the packet 100ms to prevent the client from ignoring the packet
|
||||||
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> session.sendUpstreamPacket(mapPacket),
|
||||||
ClientboundMapItemDataPacket mapPacket = session.getStoredMaps().remove(mapID);
|
100, TimeUnit.MILLISECONDS);
|
||||||
if (mapPacket != null) {
|
|
||||||
session.sendUpstreamPacket(mapPacket);
|
|
||||||
}
|
|
||||||
}, 100, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.geysermc.connector.utils.LocaleUtils;
|
import org.geysermc.connector.utils.LocaleUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -42,7 +43,7 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftTranslationRegistry implements Translator {
|
public class MinecraftTranslationRegistry implements Translator {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Key name() {
|
public @Nonnull Key name() {
|
||||||
return Key.key("geyser", "minecraft_translations");
|
return Key.key("geyser", "minecraft_translations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.network.translators.collision;
|
package org.geysermc.connector.network.translators.collision;
|
||||||
|
|
||||||
import java.lang.annotation.Repeatable;
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@ import org.geysermc.connector.network.translators.world.block.BlockTranslator1_1
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ToString
|
@ToString
|
||||||
public class ItemEntry {
|
public class ItemEntry {
|
||||||
|
public static final ItemEntry AIR = new ItemEntry("minecraft:air", "minecraft:air", 0, 0, 0,
|
||||||
public static ItemEntry AIR = new ItemEntry("minecraft:air", "minecraft:air", 0, 0, 0,
|
|
||||||
BlockTranslator1_17_0.INSTANCE.getBedrockAirId(), 64);
|
BlockTranslator1_17_0.INSTANCE.getBedrockAirId(), 64);
|
||||||
|
|
||||||
private final String javaIdentifier;
|
private final String javaIdentifier;
|
||||||
|
@ -296,7 +296,7 @@ public abstract class ItemTranslator {
|
|||||||
ListTag listTag = (ListTag) tag;
|
ListTag listTag = (ListTag) tag;
|
||||||
|
|
||||||
List<Object> tagList = new ArrayList<>();
|
List<Object> tagList = new ArrayList<>();
|
||||||
for (com.github.steveice10.opennbt.tag.builtin.Tag value : listTag) {
|
for (Tag value : listTag) {
|
||||||
tagList.add(translateToBedrockNBT(value));
|
tagList.add(translateToBedrockNBT(value));
|
||||||
}
|
}
|
||||||
NbtType<?> type = NbtType.COMPOUND;
|
NbtType<?> type = NbtType.COMPOUND;
|
||||||
|
@ -131,8 +131,8 @@ public class BannerTranslator extends ItemTranslator {
|
|||||||
*/
|
*/
|
||||||
public static ListTag convertBannerPattern(List<NbtMap> patterns) {
|
public static ListTag convertBannerPattern(List<NbtMap> patterns) {
|
||||||
List<Tag> tagsList = new ArrayList<>();
|
List<Tag> tagsList = new ArrayList<>();
|
||||||
for (Object patternTag : patterns) {
|
for (NbtMap patternTag : patterns) {
|
||||||
tagsList.add(getJavaBannerPattern((NbtMap) patternTag));
|
tagsList.add(getJavaBannerPattern(patternTag));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ListTag("Patterns", tagsList);
|
return new ListTag("Patterns", tagsList);
|
||||||
|
@ -29,12 +29,9 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.ItemRemapper;
|
import org.geysermc.connector.network.translators.ItemRemapper;
|
||||||
|
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
|
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
|
||||||
|
|
||||||
@ -46,27 +43,17 @@ public class BasicItemTranslator extends NbtItemStackTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemEntry itemEntry) {
|
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemEntry itemEntry) {
|
||||||
if (!itemTag.contains("display")) {
|
CompoundTag displayTag = itemTag.get("display");
|
||||||
|
if (displayTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompoundTag displayTag = itemTag.get("display");
|
|
||||||
if (displayTag.contains("Name")) {
|
|
||||||
StringTag nameTag = displayTag.get("Name");
|
|
||||||
try {
|
|
||||||
displayTag.put(new StringTag("Name", toBedrockMessage(nameTag)));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (displayTag.contains("Lore")) {
|
ListTag loreTag = displayTag.get("Lore");
|
||||||
ListTag loreTag = displayTag.get("Lore");
|
if (loreTag != null) {
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
for (Tag tag : loreTag.getValue()) {
|
for (Tag tag : loreTag.getValue()) {
|
||||||
if (!(tag instanceof StringTag)) return;
|
if (!(tag instanceof StringTag)) continue;
|
||||||
try {
|
lore.add(new StringTag("", MessageTranslator.convertMessageLenient(((StringTag) tag).getValue(), session.getLocale())));
|
||||||
lore.add(new StringTag("", toBedrockMessage((StringTag) tag)));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
displayTag.put(new ListTag("Lore", lore));
|
displayTag.put(new ListTag("Lore", lore));
|
||||||
}
|
}
|
||||||
@ -74,54 +61,24 @@ public class BasicItemTranslator extends NbtItemStackTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
|
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
|
||||||
if (!itemTag.contains("display")) {
|
CompoundTag displayTag = itemTag.get("display");
|
||||||
|
if (displayTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompoundTag displayTag = itemTag.get("display");
|
|
||||||
if (displayTag.contains("Name")) {
|
if (displayTag.contains("Name")) {
|
||||||
StringTag nameTag = displayTag.get("Name");
|
StringTag nameTag = displayTag.get("Name");
|
||||||
displayTag.put(new StringTag("Name", toJavaMessage(nameTag)));
|
displayTag.put(new StringTag("Name", MessageTranslator.convertToJavaMessage(nameTag.getValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayTag.contains("Lore")) {
|
if (displayTag.contains("Lore")) {
|
||||||
ListTag loreTag = displayTag.get("Lore");
|
ListTag loreTag = displayTag.get("Lore");
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
for (Tag tag : loreTag.getValue()) {
|
for (Tag tag : loreTag.getValue()) {
|
||||||
if (!(tag instanceof StringTag)) return;
|
if (!(tag instanceof StringTag)) continue;
|
||||||
lore.add(new StringTag("", "§r" + toJavaMessage((StringTag) tag)));
|
lore.add(new StringTag("", MessageTranslator.convertToJavaMessage(((StringTag) tag).getValue())));
|
||||||
}
|
}
|
||||||
displayTag.put(new ListTag("Lore", lore));
|
displayTag.put(new ListTag("Lore", lore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toJavaMessage(StringTag tag) {
|
|
||||||
String message = tag.getValue();
|
|
||||||
if (message == null) return null;
|
|
||||||
if (message.startsWith("§r")) {
|
|
||||||
message = message.replaceFirst("§r", "");
|
|
||||||
}
|
|
||||||
Component component = Component.text(message);
|
|
||||||
return GsonComponentSerializer.gson().serialize(component);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toBedrockMessage(StringTag tag) {
|
|
||||||
String message = tag.getValue();
|
|
||||||
if (message == null) return null;
|
|
||||||
TextComponent component = (TextComponent) GsonComponentSerializer.gson().deserialize(message);
|
|
||||||
String legacy = LegacyComponentSerializer.legacySection().serialize(component);
|
|
||||||
if (hasFormatting(LegacyComponentSerializer.legacySection().deserialize(legacy))) {
|
|
||||||
return "§r" + legacy;
|
|
||||||
}
|
|
||||||
return legacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasFormatting(Component component) {
|
|
||||||
if (component.hasStyling()) return true;
|
|
||||||
for (Component child : component.children()) {
|
|
||||||
if (hasFormatting(child)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ public class JavaBossBarTranslator extends PacketTranslator<ServerBossBarPacket>
|
|||||||
case UPDATE_STYLE:
|
case UPDATE_STYLE:
|
||||||
case UPDATE_FLAGS:
|
case UPDATE_FLAGS:
|
||||||
//todo
|
//todo
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.world.block.UpdatedTileType;
|
import com.github.steveice10.mc.protocol.data.game.world.block.UpdatedTileType;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
|
import com.nukkitx.nbt.NbtMap;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||||
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -47,7 +48,7 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
|
|||||||
public void translate(ServerUpdateTileEntityPacket packet, GeyserSession session) {
|
public void translate(ServerUpdateTileEntityPacket packet, GeyserSession session) {
|
||||||
String id = BlockEntityUtils.getBedrockBlockEntityId(packet.getType().name());
|
String id = BlockEntityUtils.getBedrockBlockEntityId(packet.getType().name());
|
||||||
if (packet.getNbt().isEmpty()) { // Fixes errors in servers sending empty NBT
|
if (packet.getNbt().isEmpty()) { // Fixes errors in servers sending empty NBT
|
||||||
BlockEntityUtils.updateBlockEntity(session, null, packet.getPosition());
|
BlockEntityUtils.updateBlockEntity(session, NbtMap.EMPTY, packet.getPosition());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.geysermc.connector.utils.ChunkUtils;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateViewPositionPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateViewPositionPacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
|
|
||||||
|
|
||||||
@Translator(packet = ServerUpdateViewPositionPacket.class)
|
@Translator(packet = ServerUpdateViewPositionPacket.class)
|
||||||
public class JavaUpdateViewPositionTranslator extends PacketTranslator<ServerUpdateViewPositionPacket> {
|
public class JavaUpdateViewPositionTranslator extends PacketTranslator<ServerUpdateViewPositionPacket> {
|
||||||
|
@ -70,7 +70,7 @@ public class SoundRegistry {
|
|||||||
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
|
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
|
||||||
brMap.has("extra_data") && brMap.get("extra_data").isInt() ? brMap.get("extra_data").asInt() : -1,
|
brMap.has("extra_data") && brMap.get("extra_data").isInt() ? brMap.get("extra_data").asInt() : -1,
|
||||||
brMap.has("identifier") && brMap.get("identifier").isTextual() ? brMap.get("identifier").asText() : null,
|
brMap.has("identifier") && brMap.get("identifier").isTextual() ? brMap.get("identifier").asText() : null,
|
||||||
brMap.has("level_event") && brMap.get("level_event").isBoolean() ? brMap.get("level_event").asBoolean() : false
|
brMap.has("level_event") && brMap.get("level_event").isBoolean() && brMap.get("level_event").asBoolean()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import com.nukkitx.math.vector.Vector3f;
|
|||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
|
||||||
import org.geysermc.connector.network.translators.sound.BlockSoundInteractionHandler;
|
import org.geysermc.connector.network.translators.sound.BlockSoundInteractionHandler;
|
||||||
import org.geysermc.connector.network.translators.sound.SoundHandler;
|
import org.geysermc.connector.network.translators.sound.SoundHandler;
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ import java.net.SocketTimeoutException;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runnable {
|
public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runnable {
|
||||||
|
private final GeyserConnector connector;
|
||||||
private GeyserConnector connector;
|
|
||||||
|
|
||||||
public GeyserLegacyPingPassthrough(GeyserConnector connector) {
|
public GeyserLegacyPingPassthrough(GeyserConnector connector) {
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
|
@ -58,22 +58,17 @@ public enum BedrockMapIcon {
|
|||||||
|
|
||||||
private static final BedrockMapIcon[] VALUES = values();
|
private static final BedrockMapIcon[] VALUES = values();
|
||||||
|
|
||||||
private MapIconType iconType;
|
private final MapIconType iconType;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int iconID;
|
private final int iconID;
|
||||||
|
|
||||||
private int red;
|
private final int red;
|
||||||
private int green;
|
private final int green;
|
||||||
private int blue;
|
private final int blue;
|
||||||
|
|
||||||
BedrockMapIcon(MapIconType iconType, int iconID) {
|
BedrockMapIcon(MapIconType iconType, int iconID) {
|
||||||
this.iconType = iconType;
|
this(iconType, iconID, 255, 255, 255);
|
||||||
this.iconID = iconID;
|
|
||||||
|
|
||||||
this.red = 255;
|
|
||||||
this.green = 255;
|
|
||||||
this.blue = 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BedrockMapIcon(MapIconType iconType, int iconID, int red, int green, int blue) {
|
BedrockMapIcon(MapIconType iconType, int iconID, int red, int green, int blue) {
|
||||||
@ -107,11 +102,11 @@ public enum BedrockMapIcon {
|
|||||||
* @return ARGB as an int
|
* @return ARGB as an int
|
||||||
*/
|
*/
|
||||||
public int toARGB() {
|
public int toARGB() {
|
||||||
int alpha = 255;
|
final int alpha = 255;
|
||||||
|
|
||||||
return ((alpha & 0xFF) << 24) |
|
return ((alpha & 0xFF) << 24) |
|
||||||
((red & 0xFF) << 16) |
|
((red & 0xFF) << 16) |
|
||||||
((green & 0xFF) << 8) |
|
((green & 0xFF) << 8) |
|
||||||
((blue & 0xFF) << 0);
|
(blue & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
|
|||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
|
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class BlockEntityUtils {
|
public class BlockEntityUtils {
|
||||||
private static final BlockEntityTranslator EMPTY_TRANSLATOR = BlockEntityTranslator.BLOCK_ENTITY_TRANSLATORS.get("Empty");
|
private static final BlockEntityTranslator EMPTY_TRANSLATOR = BlockEntityTranslator.BLOCK_ENTITY_TRANSLATORS.get("Empty");
|
||||||
|
|
||||||
@ -66,11 +68,11 @@ public class BlockEntityUtils {
|
|||||||
return EMPTY_TRANSLATOR;
|
return EMPTY_TRANSLATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateBlockEntity(GeyserSession session, NbtMap blockEntity, Position position) {
|
public static void updateBlockEntity(GeyserSession session, @Nonnull NbtMap blockEntity, Position position) {
|
||||||
updateBlockEntity(session, blockEntity, Vector3i.from(position.getX(), position.getY(), position.getZ()));
|
updateBlockEntity(session, blockEntity, Vector3i.from(position.getX(), position.getY(), position.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateBlockEntity(GeyserSession session, NbtMap blockEntity, Vector3i position) {
|
public static void updateBlockEntity(GeyserSession session, @Nonnull NbtMap blockEntity, Vector3i position) {
|
||||||
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
|
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
|
||||||
blockEntityPacket.setBlockPosition(position);
|
blockEntityPacket.setBlockPosition(position);
|
||||||
blockEntityPacket.setData(blockEntity);
|
blockEntityPacket.setData(blockEntity);
|
||||||
|
@ -205,7 +205,8 @@ public class FileUtils {
|
|||||||
URL resource = FileUtils.class.getClassLoader().getResource("META-INF/reflections/" + path + "-reflections.xml");
|
URL resource = FileUtils.class.getClassLoader().getResource("META-INF/reflections/" + path + "-reflections.xml");
|
||||||
try (InputStream inputStream = resource.openConnection().getInputStream()) {
|
try (InputStream inputStream = resource.openConnection().getInputStream()) {
|
||||||
reflections.merge(serializer.read(inputStream));
|
reflections.merge(serializer.read(inputStream));
|
||||||
} catch (IOException e) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
return reflections;
|
return reflections;
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,13 @@ public enum GameRule {
|
|||||||
private static final GameRule[] VALUES = values();
|
private static final GameRule[] VALUES = values();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private String javaID;
|
private final String javaID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Class<?> type;
|
private final Class<?> type;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Object defaultValue;
|
private final Object defaultValue;
|
||||||
|
|
||||||
GameRule(String javaID, Class<?> type) {
|
GameRule(String javaID, Class<?> type) {
|
||||||
this(javaID, type, null);
|
this(javaID, type, null);
|
||||||
|
@ -136,7 +136,7 @@ public class LocaleUtils {
|
|||||||
// Check if we have already downloaded the locale file
|
// Check if we have already downloaded the locale file
|
||||||
if (localeFile.exists()) {
|
if (localeFile.exists()) {
|
||||||
String curHash = "";
|
String curHash = "";
|
||||||
String targetHash = "";
|
String targetHash;
|
||||||
|
|
||||||
if (locale.equals("en_us")) {
|
if (locale.equals("en_us")) {
|
||||||
try {
|
try {
|
||||||
|
@ -287,6 +287,6 @@ public enum MapColor {
|
|||||||
return ((alpha & 0xFF) << 24) |
|
return ((alpha & 0xFF) << 24) |
|
||||||
((blue & 0xFF) << 16) |
|
((blue & 0xFF) << 16) |
|
||||||
((green & 0xFF) << 8) |
|
((green & 0xFF) << 8) |
|
||||||
((red & 0xFF) << 0);
|
(red & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,8 +34,6 @@ import org.geysermc.cumulus.CustomForm;
|
|||||||
import org.geysermc.cumulus.component.DropdownComponent;
|
import org.geysermc.cumulus.component.DropdownComponent;
|
||||||
import org.geysermc.cumulus.response.CustomFormResponse;
|
import org.geysermc.cumulus.response.CustomFormResponse;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SettingsUtils {
|
public class SettingsUtils {
|
||||||
/**
|
/**
|
||||||
* Build a settings form for the given session and store it for later
|
* Build a settings form for the given session and store it for later
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren