mirror of https://github.com/LOOHP/Limbo.git
Use Adventure Key replacing NamespacedKey
This commit is contained in:
parent
9193d907d1
commit
081776e4fe
2
pom.xml
2
pom.xml
|
|
@ -24,7 +24,7 @@
|
||||||
<groupId>com.loohp</groupId>
|
<groupId>com.loohp</groupId>
|
||||||
<artifactId>Limbo</artifactId>
|
<artifactId>Limbo</artifactId>
|
||||||
<name>Limbo</name>
|
<name>Limbo</name>
|
||||||
<version>0.6.20-ALPHA</version>
|
<version>0.6.21-ALPHA</version>
|
||||||
|
|
||||||
<description>Standalone Limbo Minecraft Server.</description>
|
<description>Standalone Limbo Minecraft Server.</description>
|
||||||
<url>https://github.com/LOOHP/Limbo</url>
|
<url>https://github.com/LOOHP/Limbo</url>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,35 @@
|
||||||
|
|
||||||
package com.loohp.limbo;
|
package com.loohp.limbo;
|
||||||
|
|
||||||
|
import com.loohp.limbo.commands.CommandSender;
|
||||||
|
import com.loohp.limbo.consolegui.ConsoleTextOutput;
|
||||||
|
import com.loohp.limbo.utils.CustomStringUtils;
|
||||||
|
import jline.console.ConsoleReader;
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import net.kyori.adventure.sound.Sound.Emitter;
|
||||||
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import net.kyori.adventure.title.TitlePart;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import org.fusesource.jansi.Ansi;
|
||||||
|
import org.fusesource.jansi.Ansi.Attribute;
|
||||||
|
import org.jline.reader.Candidate;
|
||||||
|
import org.jline.reader.Completer;
|
||||||
|
import org.jline.reader.EndOfFileException;
|
||||||
|
import org.jline.reader.LineReader;
|
||||||
|
import org.jline.reader.LineReader.SuggestionType;
|
||||||
|
import org.jline.reader.LineReaderBuilder;
|
||||||
|
import org.jline.reader.ParsedLine;
|
||||||
|
import org.jline.reader.UserInterruptException;
|
||||||
|
import org.jline.terminal.Terminal;
|
||||||
|
import org.jline.terminal.TerminalBuilder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
@ -35,37 +64,6 @@ import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.fusesource.jansi.Ansi;
|
|
||||||
import org.fusesource.jansi.Ansi.Attribute;
|
|
||||||
import org.jline.reader.Candidate;
|
|
||||||
import org.jline.reader.Completer;
|
|
||||||
import org.jline.reader.EndOfFileException;
|
|
||||||
import org.jline.reader.LineReader;
|
|
||||||
import org.jline.reader.LineReader.SuggestionType;
|
|
||||||
import org.jline.reader.LineReaderBuilder;
|
|
||||||
import org.jline.reader.ParsedLine;
|
|
||||||
import org.jline.reader.UserInterruptException;
|
|
||||||
import org.jline.terminal.Terminal;
|
|
||||||
import org.jline.terminal.TerminalBuilder;
|
|
||||||
|
|
||||||
import com.loohp.limbo.commands.CommandSender;
|
|
||||||
import com.loohp.limbo.consolegui.ConsoleTextOutput;
|
|
||||||
import com.loohp.limbo.utils.CustomStringUtils;
|
|
||||||
|
|
||||||
import jline.console.ConsoleReader;
|
|
||||||
import net.kyori.adventure.audience.MessageType;
|
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
|
||||||
import net.kyori.adventure.identity.Identity;
|
|
||||||
import net.kyori.adventure.inventory.Book;
|
|
||||||
import net.kyori.adventure.sound.Sound;
|
|
||||||
import net.kyori.adventure.sound.Sound.Emitter;
|
|
||||||
import net.kyori.adventure.sound.SoundStop;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import net.kyori.adventure.title.TitlePart;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
|
|
||||||
public class Console implements CommandSender {
|
public class Console implements CommandSender {
|
||||||
|
|
||||||
protected static final Map<ChatColor, String> REPLACEMENTS = new HashMap<>();
|
protected static final Map<ChatColor, String> REPLACEMENTS = new HashMap<>();
|
||||||
|
|
@ -136,7 +134,7 @@ public class Console implements CommandSender {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return CONSOLE;
|
return CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
||||||
|
|
@ -170,7 +168,7 @@ public class Console implements CommandSender {
|
||||||
public void sendMessage(BaseComponent[] component) {
|
public void sendMessage(BaseComponent[] component) {
|
||||||
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(Identity source, Component message, MessageType type) {
|
public void sendMessage(Identity source, Component message, MessageType type) {
|
||||||
sendMessage(PlainTextComponentSerializer.plainText().serialize(message));
|
sendMessage(PlainTextComponentSerializer.plainText().serialize(message));
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,13 @@ import com.loohp.limbo.scheduler.LimboScheduler;
|
||||||
import com.loohp.limbo.scheduler.Tick;
|
import com.loohp.limbo.scheduler.Tick;
|
||||||
import com.loohp.limbo.utils.CustomStringUtils;
|
import com.loohp.limbo.utils.CustomStringUtils;
|
||||||
import com.loohp.limbo.utils.ImageUtils;
|
import com.loohp.limbo.utils.ImageUtils;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.utils.NetworkUtils;
|
import com.loohp.limbo.utils.NetworkUtils;
|
||||||
import com.loohp.limbo.world.DimensionRegistry;
|
import com.loohp.limbo.world.DimensionRegistry;
|
||||||
import com.loohp.limbo.world.Environment;
|
import com.loohp.limbo.world.Environment;
|
||||||
import com.loohp.limbo.world.Schematic;
|
import com.loohp.limbo.world.Schematic;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
@ -146,7 +146,7 @@ public final class Limbo {
|
||||||
private final List<World> worlds = new CopyOnWriteArrayList<>();
|
private final List<World> worlds = new CopyOnWriteArrayList<>();
|
||||||
final Map<String, Player> playersByName = new ConcurrentHashMap<>();
|
final Map<String, Player> playersByName = new ConcurrentHashMap<>();
|
||||||
final Map<UUID, Player> playersByUUID = new ConcurrentHashMap<>();
|
final Map<UUID, Player> playersByUUID = new ConcurrentHashMap<>();
|
||||||
private final Map<NamespacedKey, KeyedBossBar> bossBars = new ConcurrentHashMap<>();
|
private final Map<Key, KeyedBossBar> bossBars = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final ServerProperties properties;
|
private final ServerProperties properties;
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ public final class Limbo {
|
||||||
|
|
||||||
worlds.add(loadDefaultWorld());
|
worlds.add(loadDefaultWorld());
|
||||||
Location spawn = properties.getWorldSpawn();
|
Location spawn = properties.getWorldSpawn();
|
||||||
properties.setWorldSpawn(new Location(getWorld(properties.getLevelName().getKey()), spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getYaw(), spawn.getPitch()));
|
properties.setWorldSpawn(new Location(getWorld(properties.getLevelName().value()), spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getYaw(), spawn.getPitch()));
|
||||||
|
|
||||||
if (!NetworkUtils.available(properties.getServerPort())) {
|
if (!NetworkUtils.available(properties.getServerPort())) {
|
||||||
console.sendMessage("");
|
console.sendMessage("");
|
||||||
|
|
@ -401,7 +401,7 @@ public final class Limbo {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
World world = Schematic.toWorld(properties.getLevelName().getKey(), Environment.fromNamespacedKey(properties.getLevelDimension()), (CompoundTag) NBTUtil.read(schem).getTag());
|
World world = Schematic.toWorld(properties.getLevelName().value(), Environment.fromKey(properties.getLevelDimension()), (CompoundTag) NBTUtil.read(schem).getTag());
|
||||||
console.sendMessage("Loaded world " + properties.getLevelName() + "!");
|
console.sendMessage("Loaded world " + properties.getLevelName() + "!");
|
||||||
return world;
|
return world;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
@ -434,14 +434,14 @@ public final class Limbo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyedBossBar createBossBar(NamespacedKey namespacedKey, Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, BossBar.Flag... flags) {
|
public KeyedBossBar createBossBar(Key Key, Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, BossBar.Flag... flags) {
|
||||||
KeyedBossBar keyedBossBar = new KeyedBossBar(namespacedKey, BossBar.bossBar(name, progress, color, overlay, new HashSet<>(Arrays.asList(flags))));
|
KeyedBossBar keyedBossBar = new KeyedBossBar(Key, BossBar.bossBar(name, progress, color, overlay, new HashSet<>(Arrays.asList(flags))));
|
||||||
bossBars.put(namespacedKey, keyedBossBar);
|
bossBars.put(Key, keyedBossBar);
|
||||||
return keyedBossBar;
|
return keyedBossBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBossBar(NamespacedKey namespacedKey) {
|
public void removeBossBar(Key Key) {
|
||||||
KeyedBossBar keyedBossBar = bossBars.remove(namespacedKey);
|
KeyedBossBar keyedBossBar = bossBars.remove(Key);
|
||||||
keyedBossBar.getProperties().removeListener(keyedBossBar.getUnsafe().getLimboListener());
|
keyedBossBar.getProperties().removeListener(keyedBossBar.getUnsafe().getLimboListener());
|
||||||
keyedBossBar.getUnsafe().invalidate();
|
keyedBossBar.getUnsafe().invalidate();
|
||||||
PacketPlayOutBoss packetPlayOutBoss = new PacketPlayOutBoss(keyedBossBar, PacketPlayOutBoss.BossBarAction.REMOVE);
|
PacketPlayOutBoss packetPlayOutBoss = new PacketPlayOutBoss(keyedBossBar, PacketPlayOutBoss.BossBarAction.REMOVE);
|
||||||
|
|
@ -454,7 +454,7 @@ public final class Limbo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<NamespacedKey, KeyedBossBar> getBossBars() {
|
public Map<Key, KeyedBossBar> getBossBars() {
|
||||||
return Collections.unmodifiableMap(bossBars);
|
return Collections.unmodifiableMap(bossBars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo;
|
package com.loohp.limbo;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
|
|
||||||
import com.loohp.limbo.entity.DataWatcher;
|
import com.loohp.limbo.entity.DataWatcher;
|
||||||
import com.loohp.limbo.entity.Entity;
|
import com.loohp.limbo.entity.Entity;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
|
|
@ -28,6 +26,8 @@ import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class Unsafe {
|
public class Unsafe {
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ package com.loohp.limbo.bossbar;
|
||||||
|
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutBoss;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutBoss;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
public class KeyedBossBar {
|
public class KeyedBossBar {
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final NamespacedKey key;
|
private final Key key;
|
||||||
private final BossBar properties;
|
private final BossBar properties;
|
||||||
private final Set<Player> players;
|
private final Set<Player> players;
|
||||||
protected final LimboBossBarHandler listener;
|
protected final LimboBossBarHandler listener;
|
||||||
|
|
@ -45,7 +45,7 @@ public class KeyedBossBar {
|
||||||
|
|
||||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public KeyedBossBar(NamespacedKey key, BossBar properties) {
|
public KeyedBossBar(Key key, BossBar properties) {
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|
@ -60,7 +60,7 @@ public class KeyedBossBar {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getKey() {
|
public Key getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo.commands;
|
package com.loohp.limbo.commands;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.audience.MessageType;
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
|
@ -32,6 +30,8 @@ import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.title.TitlePart;
|
import net.kyori.adventure.title.TitlePart;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface CommandSender extends Audience {
|
public interface CommandSender extends Audience {
|
||||||
|
|
||||||
void sendMessage(BaseComponent[] component, UUID uuid);
|
void sendMessage(BaseComponent[] component, UUID uuid);
|
||||||
|
|
|
||||||
|
|
@ -19,19 +19,18 @@
|
||||||
|
|
||||||
package com.loohp.limbo.commands;
|
package com.loohp.limbo.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Console;
|
import com.loohp.limbo.Console;
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DefaultCommands implements CommandExecutor, TabCompletor {
|
public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,18 @@
|
||||||
|
|
||||||
package com.loohp.limbo.consolegui;
|
package com.loohp.limbo.consolegui;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTextPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
|
|
@ -32,19 +44,6 @@ import java.awt.event.WindowEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.JTextPane;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class GUI extends JFrame {
|
public class GUI extends JFrame {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.consolegui;
|
package com.loohp.limbo.consolegui;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
|
|
||||||
public class SystemInfo {
|
public class SystemInfo {
|
||||||
|
|
||||||
public static void printInfo() {
|
public static void printInfo() {
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo.entity;
|
package com.loohp.limbo.entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||||
|
|
@ -28,6 +26,8 @@ import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.utils.Rotation3f;
|
import com.loohp.limbo.utils.Rotation3f;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ArmorStand extends LivingEntity {
|
public class ArmorStand extends LivingEntity {
|
||||||
|
|
||||||
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,19 @@
|
||||||
|
|
||||||
package com.loohp.limbo.entity;
|
package com.loohp.limbo.entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class Entity implements Sound.Emitter {
|
public abstract class Entity implements Sound.Emitter {
|
||||||
|
|
||||||
@WatchableField(MetadataIndex = 0, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
@WatchableField(MetadataIndex = 0, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.entity;
|
package com.loohp.limbo.entity;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum EntityType {
|
public enum EntityType {
|
||||||
|
|
||||||
|
|
@ -294,7 +294,7 @@ public enum EntityType {
|
||||||
private final short typeId;
|
private final short typeId;
|
||||||
private final boolean independent;
|
private final boolean independent;
|
||||||
private final boolean living;
|
private final boolean living;
|
||||||
private final NamespacedKey key;
|
private final Key key;
|
||||||
|
|
||||||
private static final Map<String, EntityType> NAME_MAP = new HashMap<>();
|
private static final Map<String, EntityType> NAME_MAP = new HashMap<>();
|
||||||
private static final Map<Short, EntityType> ID_MAP = new HashMap<>();
|
private static final Map<Short, EntityType> ID_MAP = new HashMap<>();
|
||||||
|
|
@ -337,7 +337,7 @@ public enum EntityType {
|
||||||
this.typeId = (short) typeId;
|
this.typeId = (short) typeId;
|
||||||
this.independent = independent;
|
this.independent = independent;
|
||||||
this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz);
|
this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz);
|
||||||
this.key = (name == null) ? null : NamespacedKey.minecraft(name);
|
this.key = (name == null) ? null : Key.key(Key.MINECRAFT_NAMESPACE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -351,7 +351,7 @@ public enum EntityType {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getKey() {
|
public Key getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo.entity;
|
package com.loohp.limbo.entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||||
|
|
@ -29,6 +27,8 @@ import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class LivingEntity extends Entity {
|
public abstract class LivingEntity extends Entity {
|
||||||
|
|
||||||
@WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
@WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package com.loohp.limbo.events;
|
package com.loohp.limbo.events;
|
||||||
|
|
||||||
|
import com.loohp.limbo.plugins.LimboPlugin;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -26,8 +28,6 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.loohp.limbo.plugins.LimboPlugin;
|
|
||||||
|
|
||||||
public class EventsManager {
|
public class EventsManager {
|
||||||
|
|
||||||
private List<ListenerPair> listeners;
|
private List<ListenerPair> listeners;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package com.loohp.limbo.events;
|
package com.loohp.limbo.events;
|
||||||
|
|
||||||
|
import com.loohp.limbo.plugins.LimboPlugin;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -26,8 +28,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.loohp.limbo.plugins.LimboPlugin;
|
|
||||||
|
|
||||||
public class RegisteredCachedListener {
|
public class RegisteredCachedListener {
|
||||||
|
|
||||||
private LimboPlugin plugin;
|
private LimboPlugin plugin;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ package com.loohp.limbo.events.player;
|
||||||
import com.loohp.limbo.events.Cancellable;
|
import com.loohp.limbo.events.Cancellable;
|
||||||
import com.loohp.limbo.events.Event;
|
import com.loohp.limbo.events.Event;
|
||||||
import com.loohp.limbo.network.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
public class PlayerLoginEvent extends Event implements Cancellable {
|
public class PlayerLoginEvent extends Event implements Cancellable {
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.events.status;
|
package com.loohp.limbo.events.status;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import com.loohp.limbo.events.Event;
|
import com.loohp.limbo.events.Event;
|
||||||
import com.loohp.limbo.network.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public class StatusPingEvent extends Event {
|
public class StatusPingEvent extends Event {
|
||||||
|
|
||||||
private ClientConnection connection;
|
private ClientConnection connection;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
package com.loohp.limbo.file;
|
package com.loohp.limbo.file;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.YamlOrder;
|
||||||
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.representer.Representer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
@ -34,12 +39,6 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
|
||||||
import org.yaml.snakeyaml.representer.Representer;
|
|
||||||
|
|
||||||
import com.loohp.limbo.utils.YamlOrder;
|
|
||||||
|
|
||||||
public class FileConfiguration {
|
public class FileConfiguration {
|
||||||
|
|
||||||
private Map<String, Object> mapping;
|
private Map<String, Object> mapping;
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ import com.loohp.limbo.Console;
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
|
@ -57,9 +57,9 @@ public class ServerProperties {
|
||||||
private int maxPlayers;
|
private int maxPlayers;
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
private String serverIp;
|
private String serverIp;
|
||||||
private NamespacedKey levelName;
|
private Key levelName;
|
||||||
private String schemFileName;
|
private String schemFileName;
|
||||||
private NamespacedKey levelDimension;
|
private Key levelDimension;
|
||||||
private GameMode defaultGamemode;
|
private GameMode defaultGamemode;
|
||||||
private Location worldSpawn;
|
private Location worldSpawn;
|
||||||
private boolean reducedDebugInfo;
|
private boolean reducedDebugInfo;
|
||||||
|
|
@ -117,10 +117,10 @@ public class ServerProperties {
|
||||||
serverPort = Integer.parseInt(prop.getProperty("server-port"));
|
serverPort = Integer.parseInt(prop.getProperty("server-port"));
|
||||||
serverIp = prop.getProperty("server-ip");
|
serverIp = prop.getProperty("server-ip");
|
||||||
String[] level = prop.getProperty("level-name").split(";");
|
String[] level = prop.getProperty("level-name").split(";");
|
||||||
levelName = new NamespacedKey(level[0]);
|
levelName = Key.key(level[0]);
|
||||||
schemFileName = level[1];
|
schemFileName = level[1];
|
||||||
levelDimension = new NamespacedKey(prop.getProperty("level-dimension"));
|
levelDimension = Key.key(prop.getProperty("level-dimension"));
|
||||||
defaultGamemode = GameMode.fromName(new NamespacedKey(prop.getProperty("default-gamemode")).getKey());
|
defaultGamemode = GameMode.fromName(Key.key(prop.getProperty("default-gamemode")).value());
|
||||||
String[] locStr = prop.getProperty("world-spawn").split(";");
|
String[] locStr = prop.getProperty("world-spawn").split(";");
|
||||||
World world = Limbo.getInstance().getWorld(locStr[0]);
|
World world = Limbo.getInstance().getWorld(locStr[0]);
|
||||||
double x = Double.parseDouble(locStr[1]);
|
double x = Double.parseDouble(locStr[1]);
|
||||||
|
|
@ -290,7 +290,7 @@ public class ServerProperties {
|
||||||
return serverIp;
|
return serverIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getLevelName() {
|
public Key getLevelName() {
|
||||||
return levelName;
|
return levelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,7 +298,7 @@ public class ServerProperties {
|
||||||
return schemFileName;
|
return schemFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getLevelDimension() {
|
public Key getLevelDimension() {
|
||||||
return levelDimension;
|
return levelDimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.location;
|
package com.loohp.limbo.location;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.primitives.Doubles;
|
import com.google.common.primitives.Doubles;
|
||||||
import com.loohp.limbo.utils.NumberConversions;
|
import com.loohp.limbo.utils.NumberConversions;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mutable vector. Because the components of Vectors are mutable,
|
* Represents a mutable vector. Because the components of Vectors are mutable,
|
||||||
* storing Vectors long term may be dangerous if passing code modifies the
|
* storing Vectors long term may be dangerous if passing code modifies the
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.metrics;
|
package com.loohp.limbo.metrics;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.file.FileConfiguration;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -35,14 +41,6 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.file.FileConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bStats collects some data for plugin authors.
|
* bStats collects some data for plugin authors.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ package com.loohp.limbo.network;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketIn;
|
import com.loohp.limbo.network.protocol.packets.PacketIn;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketOut;
|
import com.loohp.limbo.network.protocol.packets.PacketOut;
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.utils.Pair;
|
import com.loohp.limbo.utils.Pair;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class Channel implements AutoCloseable {
|
public class Channel implements AutoCloseable {
|
||||||
|
|
||||||
private final List<Pair<NamespacedKey, ChannelPacketHandler>> handlers;
|
private final List<Pair<Key, ChannelPacketHandler>> handlers;
|
||||||
private final AtomicBoolean valid;
|
private final AtomicBoolean valid;
|
||||||
protected final DataInputStream input;
|
protected final DataInputStream input;
|
||||||
protected final DataOutputStream output;
|
protected final DataOutputStream output;
|
||||||
|
|
@ -52,15 +52,15 @@ public class Channel implements AutoCloseable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHandlerBefore(NamespacedKey key, ChannelPacketHandler handler) {
|
public void addHandlerBefore(Key key, ChannelPacketHandler handler) {
|
||||||
handlers.add(0, new Pair<>(key, handler));
|
handlers.add(0, new Pair<>(key, handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHandlerAfter(NamespacedKey key, ChannelPacketHandler handler) {
|
public void addHandlerAfter(Key key, ChannelPacketHandler handler) {
|
||||||
handlers.add(new Pair<>(key, handler));
|
handlers.add(new Pair<>(key, handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeHandler(NamespacedKey key) {
|
public void removeHandler(Key key) {
|
||||||
handlers.removeIf(each -> each.getFirst().equals(key));
|
handlers.removeIf(each -> each.getFirst().equals(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class Channel implements AutoCloseable {
|
||||||
size = size < 0 ? DataTypeIO.readVarInt(input) : size;
|
size = size < 0 ? DataTypeIO.readVarInt(input) : size;
|
||||||
int packetId = DataTypeIO.readVarInt(input);
|
int packetId = DataTypeIO.readVarInt(input);
|
||||||
ChannelPacketRead read = new ChannelPacketRead(size, packetId, input);
|
ChannelPacketRead read = new ChannelPacketRead(size, packetId, input);
|
||||||
for (Pair<NamespacedKey, ChannelPacketHandler> pair : handlers) {
|
for (Pair<Key, ChannelPacketHandler> pair : handlers) {
|
||||||
read = pair.getSecond().read(read);
|
read = pair.getSecond().read(read);
|
||||||
if (read == null) {
|
if (read == null) {
|
||||||
packet = null;
|
packet = null;
|
||||||
|
|
@ -91,7 +91,7 @@ public class Channel implements AutoCloseable {
|
||||||
protected boolean writePacket(PacketOut packet) throws IOException {
|
protected boolean writePacket(PacketOut packet) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
ChannelPacketWrite write = new ChannelPacketWrite(packet);
|
ChannelPacketWrite write = new ChannelPacketWrite(packet);
|
||||||
for (Pair<NamespacedKey, ChannelPacketHandler> pair : handlers) {
|
for (Pair<Key, ChannelPacketHandler> pair : handlers) {
|
||||||
write = pair.getSecond().write(write);
|
write = pair.getSecond().write(write);
|
||||||
if (write == null) {
|
if (write == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,9 @@ import com.loohp.limbo.utils.ForwardingUtils;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.utils.MojangAPIUtils;
|
import com.loohp.limbo.utils.MojangAPIUtils;
|
||||||
import com.loohp.limbo.utils.MojangAPIUtils.SkinResponse;
|
import com.loohp.limbo.utils.MojangAPIUtils.SkinResponse;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
@ -126,8 +126,8 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ClientConnection extends Thread {
|
public class ClientConnection extends Thread {
|
||||||
|
|
||||||
private static final NamespacedKey DEFAULT_HANDLER_NAMESPACE = new NamespacedKey("default");
|
private static final Key DEFAULT_HANDLER_NAMESPACE = Key.key("default");
|
||||||
private static final String BRAND_ANNOUNCE_CHANNEL = new NamespacedKey("brand").toString();
|
private static final String BRAND_ANNOUNCE_CHANNEL = Key.key("brand").toString();
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
private final Socket clientSocket;
|
private final Socket clientSocket;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network;
|
package com.loohp.limbo.network;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
|
|
@ -26,8 +28,6 @@ import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
|
|
||||||
public class ServerConnection extends Thread {
|
public class ServerConnection extends Thread {
|
||||||
|
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ package com.loohp.limbo.network.protocol.packets;
|
||||||
import com.loohp.limbo.registry.Registry;
|
import com.loohp.limbo.registry.Registry;
|
||||||
import com.loohp.limbo.utils.BitsUtils;
|
import com.loohp.limbo.utils.BitsUtils;
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.Environment;
|
import com.loohp.limbo.world.Environment;
|
||||||
import com.loohp.limbo.world.GeneratedBlockDataMappings;
|
import com.loohp.limbo.world.GeneratedBlockDataMappings;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
import net.querz.mca.Section;
|
import net.querz.mca.Section;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
@ -253,7 +253,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
|
||||||
int z = each.getInt("z") % 16;
|
int z = each.getInt("z") % 16;
|
||||||
output.writeByte(((x & 15) << 4) | (z & 15));
|
output.writeByte(((x & 15) << 4) | (z & 15));
|
||||||
output.writeShort(y);
|
output.writeShort(y);
|
||||||
Integer id = Registry.BLOCK_ENTITY_TYPE.getId(new NamespacedKey(chunk.getBlockStateAt(x, y, z).getString("Name")));
|
Integer id = Registry.BLOCK_ENTITY_TYPE.getId(Key.key(chunk.getBlockStateAt(x, y, z).getString("Name")));
|
||||||
DataTypeIO.writeVarInt(output, id == null ? -1 : id);
|
DataTypeIO.writeVarInt(output, id == null ? -1 : id);
|
||||||
DataTypeIO.writeCompoundTag(output, each);
|
DataTypeIO.writeCompoundTag(output, each);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class ClientboundSetSubtitleTextPacket extends PacketOut {
|
public class ClientboundSetSubtitleTextPacket extends PacketOut {
|
||||||
|
|
||||||
private Component subTitle;
|
private Component subTitle;
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class ClientboundSetTitleTextPacket extends PacketOut {
|
public class ClientboundSetTitleTextPacket extends PacketOut {
|
||||||
|
|
||||||
private Component titleText;
|
private Component titleText;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketHandshakingIn extends PacketIn {
|
public class PacketHandshakingIn extends PacketIn {
|
||||||
|
|
||||||
public enum HandshakeType {
|
public enum HandshakeType {
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketLoginInLoginStart extends PacketIn {
|
public class PacketLoginInLoginStart extends PacketIn {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketLoginInPluginMessaging extends PacketIn {
|
public class PacketLoginInPluginMessaging extends PacketIn {
|
||||||
|
|
||||||
private int messageId;
|
private int messageId;
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketLoginOutDisconnect extends PacketOut {
|
public class PacketLoginOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
private Component reason;
|
private Component reason;
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketLoginOutLoginSuccess extends PacketOut {
|
public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
|
||||||
|
|
@ -19,25 +19,25 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
|
|
||||||
public class PacketLoginOutPluginMessaging extends PacketOut {
|
public class PacketLoginOutPluginMessaging extends PacketOut {
|
||||||
|
|
||||||
private int messageId;
|
private int messageId;
|
||||||
private NamespacedKey channel;
|
private Key channel;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
|
||||||
public PacketLoginOutPluginMessaging(int messageId, NamespacedKey channel) {
|
public PacketLoginOutPluginMessaging(int messageId, Key channel) {
|
||||||
this(messageId, channel, null);
|
this(messageId, channel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketLoginOutPluginMessaging(int messageId, NamespacedKey channel, byte[] data) {
|
public PacketLoginOutPluginMessaging(int messageId, Key channel, byte[] data) {
|
||||||
this.messageId = messageId;
|
this.messageId = messageId;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
@ -47,7 +47,7 @@ public class PacketLoginOutPluginMessaging extends PacketOut {
|
||||||
return messageId;
|
return messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getChannel() {
|
public Key getChannel() {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.utils.LastSeenMessages;
|
||||||
|
import com.loohp.limbo.utils.MessageSignature;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.utils.LastSeenMessages;
|
|
||||||
import com.loohp.limbo.utils.MessageSignature;
|
|
||||||
|
|
||||||
public class PacketPlayInChat extends PacketIn {
|
public class PacketPlayInChat extends PacketIn {
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayInResourcePackStatus extends PacketIn {
|
public class PacketPlayInResourcePackStatus extends PacketIn {
|
||||||
|
|
||||||
public static enum EnumResourcePackStatus {
|
public static enum EnumResourcePackStatus {
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayInTabComplete extends PacketIn {
|
public class PacketPlayInTabComplete extends PacketIn {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketPlayOutDisconnect extends PacketOut {
|
public class PacketPlayOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
private Component reason;
|
private Component reason;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayOutEntityDestroy extends PacketOut {
|
public class PacketPlayOutEntityDestroy extends PacketOut {
|
||||||
|
|
||||||
private int[] entityIds;
|
private int[] entityIds;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,16 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.entity.DataWatcher.WatchableObject;
|
||||||
|
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||||
|
import com.loohp.limbo.entity.Entity;
|
||||||
|
import com.loohp.limbo.entity.Pose;
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.utils.Rotation3f;
|
||||||
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -32,17 +42,6 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObject;
|
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
|
||||||
import com.loohp.limbo.entity.Entity;
|
|
||||||
import com.loohp.limbo.entity.Pose;
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.utils.Rotation3f;
|
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketPlayOutEntityMetadata extends PacketOut {
|
public class PacketPlayOutEntityMetadata extends PacketOut {
|
||||||
|
|
||||||
public static final int END_OFF_METADATA = 0xff;
|
public static final int END_OFF_METADATA = 0xff;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.Environment;
|
import com.loohp.limbo.world.Environment;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
@ -140,11 +140,11 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||||
output.writeByte(-1);
|
output.writeByte(-1);
|
||||||
DataTypeIO.writeVarInt(output, worlds.size());
|
DataTypeIO.writeVarInt(output, worlds.size());
|
||||||
for (World world : worlds) {
|
for (World world : worlds) {
|
||||||
DataTypeIO.writeString(output, new NamespacedKey(world.getName()).toString(), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, Key.key(world.getName()).toString(), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
DataTypeIO.writeCompoundTag(output, dimensionCodec);
|
DataTypeIO.writeCompoundTag(output, dimensionCodec);
|
||||||
DataTypeIO.writeString(output, world.getEnvironment().getNamespacedKey().toString(), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, world.getEnvironment().getKey().toString(), StandardCharsets.UTF_8);
|
||||||
DataTypeIO.writeString(output, new NamespacedKey(world.getName()).toString(), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, Key.key(world.getName()).toString(), StandardCharsets.UTF_8);
|
||||||
output.writeLong(hashedSeed);
|
output.writeLong(hashedSeed);
|
||||||
DataTypeIO.writeVarInt(output, maxPlayers);
|
DataTypeIO.writeVarInt(output, maxPlayers);
|
||||||
DataTypeIO.writeVarInt(output, viewDistance);
|
DataTypeIO.writeVarInt(output, viewDistance);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -27,10 +31,6 @@ import java.util.EnumSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.utils.GameMode;
|
|
||||||
|
|
||||||
public class PacketPlayOutPlayerInfo extends PacketOut {
|
public class PacketPlayOutPlayerInfo extends PacketOut {
|
||||||
|
|
||||||
public enum PlayerInfoAction {
|
public enum PlayerInfoAction {
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||||
|
|
||||||
private Component header;
|
private Component header;
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,14 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayOutPositionAndLook extends PacketOut {
|
public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketPlayOutResourcePackSend extends PacketOut {
|
public class PacketPlayOutResourcePackSend extends PacketOut {
|
||||||
|
|
||||||
public static final int MAX_HASH_LENGTH = 40;
|
public static final int MAX_HASH_LENGTH = 40;
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,19 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
import com.loohp.limbo.world.Environment;
|
||||||
|
import com.loohp.limbo.world.World;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.utils.GameMode;
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import com.loohp.limbo.world.Environment;
|
|
||||||
import com.loohp.limbo.world.World;
|
|
||||||
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
|
||||||
import net.querz.nbt.tag.ListTag;
|
|
||||||
|
|
||||||
public class PacketPlayOutRespawn extends PacketOut {
|
public class PacketPlayOutRespawn extends PacketOut {
|
||||||
|
|
||||||
private Environment dimension;
|
private Environment dimension;
|
||||||
|
|
@ -47,7 +46,7 @@ public class PacketPlayOutRespawn extends PacketOut {
|
||||||
public PacketPlayOutRespawn(World world, CompoundTag dimensionCodec, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, boolean copyMetaData) {
|
public PacketPlayOutRespawn(World world, CompoundTag dimensionCodec, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, boolean copyMetaData) {
|
||||||
this.dimension = world.getEnvironment();
|
this.dimension = world.getEnvironment();
|
||||||
this.dimensionCodec = dimensionCodec;
|
this.dimensionCodec = dimensionCodec;
|
||||||
this.worldName = new NamespacedKey(world.getName()).toString();
|
this.worldName = Key.key(world.getName()).toString();
|
||||||
this.hashedSeed = hashedSeed;
|
this.hashedSeed = hashedSeed;
|
||||||
this.gamemode = gamemode;
|
this.gamemode = gamemode;
|
||||||
this.isDebug = isDebug;
|
this.isDebug = isDebug;
|
||||||
|
|
@ -96,7 +95,7 @@ public class PacketPlayOutRespawn extends PacketOut {
|
||||||
CompoundTag tag = null;
|
CompoundTag tag = null;
|
||||||
ListTag<CompoundTag> list = dimensionCodec.getCompoundTag("minecraft:dimension_type").getListTag("value").asCompoundTagList();
|
ListTag<CompoundTag> list = dimensionCodec.getCompoundTag("minecraft:dimension_type").getListTag("value").asCompoundTagList();
|
||||||
for (CompoundTag each : list) {
|
for (CompoundTag each : list) {
|
||||||
if (each.getString("name").equals(dimension.getNamespacedKey().toString())) {
|
if (each.getString("name").equals(dimension.getKey().toString())) {
|
||||||
tag = each.getCompoundTag("element");
|
tag = each.getCompoundTag("element");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.entity.EntityType;
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.entity.EntityType;
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayOutSpawnEntity extends PacketOut {
|
public class PacketPlayOutSpawnEntity extends PacketOut {
|
||||||
|
|
||||||
private int entityId;
|
private int entityId;
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
|
||||||
|
|
||||||
public class PacketPlayOutSpawnPosition extends PacketOut {
|
public class PacketPlayOutSpawnPosition extends PacketOut {
|
||||||
|
|
||||||
private BlockPosition position;
|
private BlockPosition position;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
@ -30,15 +30,15 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class PacketPlayOutStopSound extends PacketOut {
|
public class PacketPlayOutStopSound extends PacketOut {
|
||||||
|
|
||||||
private NamespacedKey sound;
|
private Key sound;
|
||||||
private Sound.Source source;
|
private Sound.Source source;
|
||||||
|
|
||||||
public PacketPlayOutStopSound(NamespacedKey sound, Sound.Source source) {
|
public PacketPlayOutStopSound(Key sound, Sound.Source source) {
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getSound() {
|
public Key getSound() {
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,16 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
public class PacketPlayOutTabComplete extends PacketOut {
|
public class PacketPlayOutTabComplete extends PacketOut {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
||||||
|
|
||||||
private int chunkX;
|
private int chunkX;
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.network.protocol.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class PacketStatusOutResponse extends PacketOut {
|
public class PacketStatusOutResponse extends PacketOut {
|
||||||
|
|
||||||
private String json;
|
private String json;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
package com.loohp.limbo.permissions;
|
package com.loohp.limbo.permissions;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Console;
|
||||||
|
import com.loohp.limbo.commands.CommandSender;
|
||||||
|
import com.loohp.limbo.file.FileConfiguration;
|
||||||
|
import com.loohp.limbo.player.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -26,11 +31,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.loohp.limbo.Console;
|
|
||||||
import com.loohp.limbo.commands.CommandSender;
|
|
||||||
import com.loohp.limbo.file.FileConfiguration;
|
|
||||||
import com.loohp.limbo.player.Player;
|
|
||||||
|
|
||||||
public class PermissionsManager {
|
public class PermissionsManager {
|
||||||
|
|
||||||
private Map<String, List<String>> users;
|
private Map<String, List<String>> users;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ import com.loohp.limbo.sounds.SoundEffect;
|
||||||
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.utils.MessageSignature;
|
import com.loohp.limbo.utils.MessageSignature;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
import net.kyori.adventure.audience.MessageType;
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
|
@ -241,7 +240,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
super.teleport(location);
|
super.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPluginMessage(NamespacedKey channel, byte[] data) throws IOException {
|
public void sendPluginMessage(Key channel, byte[] data) throws IOException {
|
||||||
sendPluginMessage(channel.toString(), data);
|
sendPluginMessage(channel.toString(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,8 +453,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopSound(SoundStop stop) {
|
public void stopSound(SoundStop stop) {
|
||||||
Key sound = stop.sound();
|
PacketPlayOutStopSound stopSound = new PacketPlayOutStopSound(stop.sound(), stop.source());
|
||||||
PacketPlayOutStopSound stopSound = new PacketPlayOutStopSound(sound == null ? null : NamespacedKey.fromKey(sound), stop.source());
|
|
||||||
try {
|
try {
|
||||||
clientConnection.sendPacket(stopSound);
|
clientConnection.sendPacket(stopSound);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -471,7 +469,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
@Override
|
@Override
|
||||||
public void playSound(Sound sound, double x, double y, double z) {
|
public void playSound(Sound sound, double x, double y, double z) {
|
||||||
PacketPlayOutNamedSoundEffect namedSoundEffect = new PacketPlayOutNamedSoundEffect(
|
PacketPlayOutNamedSoundEffect namedSoundEffect = new PacketPlayOutNamedSoundEffect(
|
||||||
SoundEffect.createVariableRangeEvent(NamespacedKey.fromKey(sound.name())),
|
SoundEffect.createVariableRangeEvent(sound.name()),
|
||||||
sound.source(), x, y, z, sound.volume(), sound.pitch(), sound.seed().orElse(ThreadLocalRandom.current().nextLong())
|
sound.source(), x, y, z, sound.volume(), sound.pitch(), sound.seed().orElse(ThreadLocalRandom.current().nextLong())
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@
|
||||||
|
|
||||||
package com.loohp.limbo.plugins;
|
package com.loohp.limbo.plugins;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.file.FileConfiguration;
|
import com.loohp.limbo.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class LimboPlugin {
|
public class LimboPlugin {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.plugins;
|
package com.loohp.limbo.plugins;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.commands.CommandExecutor;
|
||||||
|
import com.loohp.limbo.commands.CommandSender;
|
||||||
|
import com.loohp.limbo.commands.DefaultCommands;
|
||||||
|
import com.loohp.limbo.commands.TabCompletor;
|
||||||
|
import com.loohp.limbo.file.FileConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
@ -31,13 +38,6 @@ import java.util.Optional;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.commands.CommandExecutor;
|
|
||||||
import com.loohp.limbo.commands.CommandSender;
|
|
||||||
import com.loohp.limbo.commands.DefaultCommands;
|
|
||||||
import com.loohp.limbo.commands.TabCompletor;
|
|
||||||
import com.loohp.limbo.file.FileConfiguration;
|
|
||||||
|
|
||||||
public class PluginManager {
|
public class PluginManager {
|
||||||
|
|
||||||
private Map<String, LimboPlugin> plugins;
|
private Map<String, LimboPlugin> plugins;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.registry;
|
package com.loohp.limbo.registry;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -32,13 +38,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
|
|
||||||
public class Registry {
|
public class Registry {
|
||||||
|
|
||||||
public static final BlockEntityRegistry BLOCK_ENTITY_TYPE;
|
public static final BlockEntityRegistry BLOCK_ENTITY_TYPE;
|
||||||
|
|
@ -54,7 +53,7 @@ public class Registry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<NamespacedKey, Integer> blockEntityType = new HashMap<>();
|
Map<Key, Integer> blockEntityType = new HashMap<>();
|
||||||
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(reader);
|
JSONObject json = (JSONObject) new JSONParser().parse(reader);
|
||||||
|
|
||||||
|
|
@ -62,7 +61,7 @@ public class Registry {
|
||||||
for (Object obj : blockEntityJson.keySet()) {
|
for (Object obj : blockEntityJson.keySet()) {
|
||||||
String key = obj.toString();
|
String key = obj.toString();
|
||||||
int id = (int) (long) ((JSONObject) blockEntityJson.get(key)).get("protocol_id");
|
int id = (int) (long) ((JSONObject) blockEntityJson.get(key)).get("protocol_id");
|
||||||
blockEntityType.put(new NamespacedKey(key), id);
|
blockEntityType.put(Key.key(key), id);
|
||||||
}
|
}
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -72,26 +71,26 @@ public class Registry {
|
||||||
|
|
||||||
public static class BlockEntityRegistry {
|
public static class BlockEntityRegistry {
|
||||||
|
|
||||||
private Map<NamespacedKey, Integer> blockEntityType;
|
private Map<Key, Integer> blockEntityType;
|
||||||
|
|
||||||
private BlockEntityRegistry(Map<NamespacedKey, Integer> blockEntityType) {
|
private BlockEntityRegistry(Map<Key, Integer> blockEntityType) {
|
||||||
this.blockEntityType = blockEntityType;
|
this.blockEntityType = blockEntityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(NamespacedKey key) {
|
public int getId(Key key) {
|
||||||
Integer exact = blockEntityType.get(key);
|
Integer exact = blockEntityType.get(key);
|
||||||
if (exact != null) {
|
if (exact != null) {
|
||||||
return exact;
|
return exact;
|
||||||
}
|
}
|
||||||
List<String> toTest = new LinkedList<>();
|
List<String> toTest = new LinkedList<>();
|
||||||
toTest.add(key.getKey());
|
toTest.add(key.value());
|
||||||
if (key.getKey().contains("head")) {
|
if (key.value().contains("head")) {
|
||||||
toTest.add("skull");
|
toTest.add("skull");
|
||||||
}
|
}
|
||||||
for (Entry<NamespacedKey, Integer> entry : blockEntityType.entrySet()) {
|
for (Entry<Key, Integer> entry : blockEntityType.entrySet()) {
|
||||||
NamespacedKey namespacedKey = entry.getKey();
|
Key Key = entry.getKey();
|
||||||
for (String each : toTest) {
|
for (String each : toTest) {
|
||||||
if (namespacedKey.getNamespace().equals(key.getNamespace()) && (each.contains(namespacedKey.getKey()) || namespacedKey.getKey().contains(each))) {
|
if (Key.namespace().equals(key.namespace()) && (each.contains(Key.value()) || Key.value().contains(each))) {
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package com.loohp.limbo.scheduler;
|
package com.loohp.limbo.scheduler;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.plugins.LimboPlugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
@ -28,9 +31,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.plugins.LimboPlugin;
|
|
||||||
|
|
||||||
public class LimboScheduler {
|
public class LimboScheduler {
|
||||||
|
|
||||||
private AtomicInteger idProvider = new AtomicInteger(0);
|
private AtomicInteger idProvider = new AtomicInteger(0);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package com.loohp.limbo.scheduler;
|
package com.loohp.limbo.scheduler;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.scheduler.LimboScheduler.CurrentSchedulerTask;
|
||||||
|
import com.loohp.limbo.scheduler.LimboScheduler.LimboSchedulerTask;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -27,10 +31,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.scheduler.LimboScheduler.CurrentSchedulerTask;
|
|
||||||
import com.loohp.limbo.scheduler.LimboScheduler.LimboSchedulerTask;
|
|
||||||
|
|
||||||
public class Tick {
|
public class Tick {
|
||||||
|
|
||||||
private int tickingInterval;
|
private int tickingInterval;
|
||||||
|
|
|
||||||
|
|
@ -19,31 +19,31 @@
|
||||||
|
|
||||||
package com.loohp.limbo.sounds;
|
package com.loohp.limbo.sounds;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SoundEffect {
|
public class SoundEffect {
|
||||||
|
|
||||||
public static SoundEffect createVariableRangeEvent(NamespacedKey namespacedKey) {
|
public static SoundEffect createVariableRangeEvent(Key key) {
|
||||||
return new SoundEffect(namespacedKey, 16.0F, false);
|
return new SoundEffect(key, 16.0F, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SoundEffect createFixedRangeEvent(NamespacedKey namespacedKey, float range) {
|
public static SoundEffect createFixedRangeEvent(Key key, float range) {
|
||||||
return new SoundEffect(namespacedKey, range, true);
|
return new SoundEffect(key, range, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final NamespacedKey sound;
|
private final Key sound;
|
||||||
private final float range;
|
private final float range;
|
||||||
private final boolean newSystem;
|
private final boolean newSystem;
|
||||||
|
|
||||||
private SoundEffect(NamespacedKey sound, float range, boolean newSystem) {
|
private SoundEffect(Key sound, float range, boolean newSystem) {
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.newSystem = newSystem;
|
this.newSystem = newSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getSound() {
|
public Key getSound() {
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,21 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPluginMessaging;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPluginMessaging;
|
|
||||||
|
|
||||||
public class BungeeLoginMessageUtils {
|
public class BungeeLoginMessageUtils {
|
||||||
|
|
||||||
public static final String BUNGEECORD_MAIN = new NamespacedKey("bungeecord", "main").toString();
|
public static final String BUNGEECORD_MAIN = Key.key("bungeecord", "main").toString();
|
||||||
|
|
||||||
public static void sendUUIDRequest(DataOutputStream output) throws IOException {
|
public static void sendUUIDRequest(DataOutputStream output) throws IOException {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import net.querz.nbt.tag.ByteArrayTag;
|
import net.querz.nbt.tag.ByteArrayTag;
|
||||||
import net.querz.nbt.tag.ByteTag;
|
import net.querz.nbt.tag.ByteTag;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
@ -35,6 +32,8 @@ import net.querz.nbt.tag.LongTag;
|
||||||
import net.querz.nbt.tag.ShortTag;
|
import net.querz.nbt.tag.ShortTag;
|
||||||
import net.querz.nbt.tag.StringTag;
|
import net.querz.nbt.tag.StringTag;
|
||||||
import net.querz.nbt.tag.Tag;
|
import net.querz.nbt.tag.Tag;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class CustomNBTUtils {
|
public class CustomNBTUtils {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
|
import net.querz.nbt.io.NBTOutputStream;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import net.querz.nbt.tag.Tag;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -29,12 +34,6 @@ import java.util.BitSet;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
|
||||||
|
|
||||||
import net.querz.nbt.io.NBTOutputStream;
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
|
||||||
import net.querz.nbt.tag.Tag;
|
|
||||||
|
|
||||||
public class DataTypeIO {
|
public class DataTypeIO {
|
||||||
|
|
||||||
public static <E extends Enum<E>> void writeEnumSet(DataOutputStream out, EnumSet<E> enumset, Class<E> oclass) throws IOException {
|
public static <E extends Enum<E>> void writeEnumSet(DataOutputStream out, EnumSet<E> enumset, Class<E> oclass) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,16 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.commands.CommandSender;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDeclareCommands;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.commands.CommandSender;
|
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDeclareCommands;
|
|
||||||
|
|
||||||
public class DeclareCommands {
|
public class DeclareCommands {
|
||||||
|
|
||||||
public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws IOException {
|
public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -28,15 +34,9 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.crypto.Mac;
|
|
||||||
import javax.crypto.SecretKey;
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
|
|
||||||
public class ForwardingUtils {
|
public class ForwardingUtils {
|
||||||
|
|
||||||
public static final NamespacedKey VELOCITY_FORWARDING_CHANNEL = new NamespacedKey("velocity", "player_info");
|
public static final Key VELOCITY_FORWARDING_CHANNEL = Key.key("velocity", "player_info");
|
||||||
|
|
||||||
public static boolean validateVelocityModernResponse(byte[] data) throws IOException {
|
public static boolean validateVelocityModernResponse(byte[] data) throws IOException {
|
||||||
ByteArrayInputStream byteIn = new ByteArrayInputStream(data);
|
ByteArrayInputStream byteIn = new ByteArrayInputStream(data);
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,12 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.RenderedImage;
|
import java.awt.image.RenderedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
public class ImageUtils {
|
public class ImageUtils {
|
||||||
|
|
||||||
public static String imgToBase64String(final RenderedImage img, String formatName) throws IOException {
|
public static String imgToBase64String(final RenderedImage img, String formatName) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
@ -26,8 +27,6 @@ import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
|
|
||||||
public class MojangAPIUtils {
|
public class MojangAPIUtils {
|
||||||
|
|
||||||
public static class SkinResponse {
|
public static class SkinResponse {
|
||||||
|
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Limbo.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022. LoohpJames <jamesloohp@gmail.com>
|
|
||||||
* Copyright (C) 2022. Contributors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
|
||||||
|
|
||||||
import com.loohp.limbo.plugins.LimboPlugin;
|
|
||||||
import net.kyori.adventure.key.Key;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class NamespacedKey {
|
|
||||||
|
|
||||||
public static final String MINECRAFT_KEY = "minecraft";
|
|
||||||
|
|
||||||
public static NamespacedKey minecraft(String key) {
|
|
||||||
return new NamespacedKey(MINECRAFT_KEY, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NamespacedKey fromKey(Key key) {
|
|
||||||
return new NamespacedKey(key.namespace(), key.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String namespace;
|
|
||||||
private final String key;
|
|
||||||
|
|
||||||
public NamespacedKey(String namespacedKey) {
|
|
||||||
int index = namespacedKey.indexOf(":");
|
|
||||||
if (index >= 0) {
|
|
||||||
this.namespace = namespacedKey.substring(0, index);
|
|
||||||
this.key = namespacedKey.substring(index + 1);
|
|
||||||
} else {
|
|
||||||
this.namespace = MINECRAFT_KEY;
|
|
||||||
this.key = namespacedKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamespacedKey(LimboPlugin plugin, String key) {
|
|
||||||
this(plugin.getName().toLowerCase().replace(" ", "_"), key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamespacedKey(String namespace, String key) {
|
|
||||||
this.namespace = namespace;
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key toKey() {
|
|
||||||
return Key.key(namespace, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return namespace + ":" + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
NamespacedKey that = (NamespacedKey) o;
|
|
||||||
return namespace.equals(that.namespace) && key.equals(that.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(namespace, key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -19,9 +19,10 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
public class SchematicConvertionUtils {
|
public class SchematicConversionUtils {
|
||||||
|
|
||||||
public static CompoundTag toTileEntityTag(CompoundTag tag) {
|
public static CompoundTag toTileEntityTag(CompoundTag tag) {
|
||||||
int[] pos = tag.getIntArray("Pos");
|
int[] pos = tag.getIntArray("Pos");
|
||||||
|
|
@ -37,11 +38,11 @@ public class SchematicConvertionUtils {
|
||||||
int index = input.indexOf("[");
|
int index = input.indexOf("[");
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
tag.putString("Name", new NamespacedKey(input).toString());
|
tag.putString("Name", Key.key(input).toString());
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.putString("Name", new NamespacedKey(input.substring(0, index)).toString());
|
tag.putString("Name", Key.key(input.substring(0, index)).toString());
|
||||||
|
|
||||||
String[] states = input.substring(index + 1, input.lastIndexOf("]")).replace(" ", "").split(",");
|
String[] states = input.substring(index + 1, input.lastIndexOf("]")).replace(" ", "").split(",");
|
||||||
|
|
||||||
|
|
@ -19,6 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.utils;
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.error.YAMLException;
|
||||||
|
import org.yaml.snakeyaml.introspector.BeanAccess;
|
||||||
|
import org.yaml.snakeyaml.introspector.FieldProperty;
|
||||||
|
import org.yaml.snakeyaml.introspector.MethodProperty;
|
||||||
|
import org.yaml.snakeyaml.introspector.MissingProperty;
|
||||||
|
import org.yaml.snakeyaml.introspector.Property;
|
||||||
|
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
||||||
|
import org.yaml.snakeyaml.util.PlatformFeatureDetector;
|
||||||
|
|
||||||
import java.beans.FeatureDescriptor;
|
import java.beans.FeatureDescriptor;
|
||||||
import java.beans.IntrospectionException;
|
import java.beans.IntrospectionException;
|
||||||
import java.beans.Introspector;
|
import java.beans.Introspector;
|
||||||
|
|
@ -33,15 +42,6 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.error.YAMLException;
|
|
||||||
import org.yaml.snakeyaml.introspector.BeanAccess;
|
|
||||||
import org.yaml.snakeyaml.introspector.FieldProperty;
|
|
||||||
import org.yaml.snakeyaml.introspector.MethodProperty;
|
|
||||||
import org.yaml.snakeyaml.introspector.MissingProperty;
|
|
||||||
import org.yaml.snakeyaml.introspector.Property;
|
|
||||||
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
|
||||||
import org.yaml.snakeyaml.util.PlatformFeatureDetector;
|
|
||||||
|
|
||||||
public class YamlOrder extends PropertyUtils {
|
public class YamlOrder extends PropertyUtils {
|
||||||
|
|
||||||
private final Map<Class<?>, Map<String, Property>> propertiesCache = new HashMap<Class<?>, Map<String, Property>>();
|
private final Map<Class<?>, Map<String, Property>> propertiesCache = new HashMap<Class<?>, Map<String, Property>>();
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import net.kyori.adventure.key.Key;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
import net.querz.nbt.tag.StringTag;
|
import net.querz.nbt.tag.StringTag;
|
||||||
import net.querz.nbt.tag.Tag;
|
import net.querz.nbt.tag.Tag;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class BlockState {
|
public class BlockState {
|
||||||
|
|
||||||
private CompoundTag tag;
|
private CompoundTag tag;
|
||||||
|
|
@ -41,12 +40,12 @@ public class BlockState {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getType() {
|
public Key getType() {
|
||||||
return new NamespacedKey(tag.getString("Name"));
|
return Key.key(tag.getString("Name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(NamespacedKey namespacedKey) {
|
public void setType(Key Key) {
|
||||||
tag.putString("Name", namespacedKey.toString());
|
tag.putString("Name", Key.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
|
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
|
|
||||||
public class ChunkPosition {
|
public class ChunkPosition {
|
||||||
|
|
|
||||||
|
|
@ -19,23 +19,20 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import com.loohp.limbo.utils.CustomNBTUtils;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
import com.loohp.limbo.utils.CustomNBTUtils;
|
|
||||||
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
|
||||||
|
|
||||||
public class DimensionRegistry {
|
public class DimensionRegistry {
|
||||||
|
|
||||||
private CompoundTag defaultTag;
|
private CompoundTag defaultTag;
|
||||||
|
|
|
||||||
|
|
@ -19,57 +19,57 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
|
|
||||||
public class Environment {
|
public class Environment {
|
||||||
|
|
||||||
public static final Environment NORMAL = new Environment(new NamespacedKey("minecraft:overworld"), true);
|
public static final Environment NORMAL = new Environment(Key.key("minecraft:overworld"), true);
|
||||||
public static final Environment NETHER = new Environment(new NamespacedKey("minecraft:the_nether"), false);
|
public static final Environment NETHER = new Environment(Key.key("minecraft:the_nether"), false);
|
||||||
public static final Environment END = new Environment(new NamespacedKey("minecraft:the_end"), false);
|
public static final Environment END = new Environment(Key.key("minecraft:the_end"), false);
|
||||||
|
|
||||||
public static final Set<Environment> REGISTERED_ENVIRONMENTS = new HashSet<>();
|
public static final Set<Environment> REGISTERED_ENVIRONMENTS = new HashSet<>();
|
||||||
|
|
||||||
public static Environment fromNamespacedKey(NamespacedKey key) {
|
public static Environment fromKey(Key key) {
|
||||||
if (key.equals(NORMAL.getNamespacedKey())) {
|
if (key.equals(NORMAL.getKey())) {
|
||||||
return NORMAL;
|
return NORMAL;
|
||||||
} else if (key.equals(NETHER.getNamespacedKey())) {
|
} else if (key.equals(NETHER.getKey())) {
|
||||||
return NETHER;
|
return NETHER;
|
||||||
} else if (key.equals(END.getNamespacedKey())) {
|
} else if (key.equals(END.getKey())) {
|
||||||
return END;
|
return END;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Environment createCustom(NamespacedKey key) {
|
public static Environment createCustom(Key key) {
|
||||||
return createCustom(key, true);
|
return createCustom(key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Environment createCustom(NamespacedKey key, boolean hasSkyLight) {
|
public static Environment createCustom(Key key, boolean hasSkyLight) {
|
||||||
if (REGISTERED_ENVIRONMENTS.stream().anyMatch(each -> each.getNamespacedKey().equals(key))) {
|
if (REGISTERED_ENVIRONMENTS.stream().anyMatch(each -> each.getKey().equals(key))) {
|
||||||
throw new IllegalArgumentException("An Environment is already created with this NamespacedKey");
|
throw new IllegalArgumentException("An Environment is already created with this Key");
|
||||||
}
|
}
|
||||||
return new Environment(key, hasSkyLight);
|
return new Environment(key, hasSkyLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Environment getCustom(NamespacedKey key) {
|
public static Environment getCustom(Key key) {
|
||||||
return REGISTERED_ENVIRONMENTS.stream().filter(each -> each.getNamespacedKey().equals(key)).findFirst().orElse(null);
|
return REGISTERED_ENVIRONMENTS.stream().filter(each -> each.getKey().equals(key)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================
|
//=========================
|
||||||
|
|
||||||
private NamespacedKey key;
|
private Key key;
|
||||||
private boolean hasSkyLight;
|
private boolean hasSkyLight;
|
||||||
|
|
||||||
private Environment(NamespacedKey key, boolean hasSkyLight) {
|
private Environment(Key key, boolean hasSkyLight) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.hasSkyLight = hasSkyLight;
|
this.hasSkyLight = hasSkyLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getNamespacedKey() {
|
public Key getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -28,15 +35,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
|
||||||
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
|
||||||
|
|
||||||
public class GeneratedBlockDataMappings {
|
public class GeneratedBlockDataMappings {
|
||||||
|
|
||||||
private static JSONObject globalPalette = new JSONObject();
|
private static JSONObject globalPalette = new JSONObject();
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.loohp.limbo.utils.SchematicConversionUtils;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
|
||||||
|
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
import net.querz.nbt.tag.ListTag;
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class Schematic {
|
public class Schematic {
|
||||||
|
|
||||||
|
|
@ -81,7 +80,7 @@ public class Schematic {
|
||||||
|
|
||||||
if (pos[0] == x && pos[1] == y && pos[2] == z) {
|
if (pos[0] == x && pos[1] == y && pos[2] == z) {
|
||||||
ListTag<CompoundTag> newTag = chunk.getTileEntities();
|
ListTag<CompoundTag> newTag = chunk.getTileEntities();
|
||||||
newTag.add(SchematicConvertionUtils.toTileEntityTag(tag));
|
newTag.add(SchematicConversionUtils.toTileEntityTag(tag));
|
||||||
chunk.setTileEntities(newTag);
|
chunk.setTileEntities(newTag);
|
||||||
itr.remove();
|
itr.remove();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,6 @@
|
||||||
|
|
||||||
package com.loohp.limbo.world;
|
package com.loohp.limbo.world;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.ArmorStand;
|
import com.loohp.limbo.entity.ArmorStand;
|
||||||
import com.loohp.limbo.entity.DataWatcher;
|
import com.loohp.limbo.entity.DataWatcher;
|
||||||
|
|
@ -39,12 +29,21 @@ import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
|
||||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
import com.loohp.limbo.utils.SchematicConversionUtils;
|
||||||
|
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
import net.querz.nbt.tag.ListTag;
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class World {
|
public class World {
|
||||||
|
|
||||||
public static final CompoundTag HEIGHT_MAP = new CompoundTag();
|
public static final CompoundTag HEIGHT_MAP = new CompoundTag();
|
||||||
|
|
@ -122,7 +121,7 @@ public class World {
|
||||||
chunk = Chunk.newChunk();
|
chunk = Chunk.newChunk();
|
||||||
this.chunks[(x >> 4)][(z >> 4)] = chunk;
|
this.chunks[(x >> 4)][(z >> 4)] = chunk;
|
||||||
}
|
}
|
||||||
CompoundTag block = SchematicConvertionUtils.toBlockTag(blockdata);
|
CompoundTag block = SchematicConversionUtils.toBlockTag(blockdata);
|
||||||
chunk.setBlockStateAt(x, y, z, block, false);
|
chunk.setBlockStateAt(x, y, z, block, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue