Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-09-08 22:02:50 +02:00
Merge branch 'abstraction' of https://github.com/ViaVersion/ViaVersion into portedplayerschange
Dieser Commit ist enthalten in:
Commit
dd5cbb0e4c
63
bukkit-legacy/pom.xml
Normale Datei
63
bukkit-legacy/pom.xml
Normale Datei
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>viaversion-parent</artifactId>
|
||||||
|
<groupId>us.myles</groupId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>viaversion-bukkit-legacy</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bukkitVersion>1.8.8-R0.1-SNAPSHOT</bukkitVersion>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Common Module -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>us.myles</groupId>
|
||||||
|
<artifactId>viaversion-common</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Bukkit API, http://www.spigotmc.org/ or http://bukkit.org/ -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>${bukkitVersion}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>persistence-api</artifactId>
|
||||||
|
<groupId>javax.persistence</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -1,21 +1,16 @@
|
|||||||
package us.myles.ViaVersion.bukkit.listeners;
|
package us.myles.ViaVersion.bukkit.listeners;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
|
||||||
import us.myles.ViaVersion.api.ViaListener;
|
import us.myles.ViaVersion.api.ViaListener;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
|
|
||||||
@Getter(AccessLevel.PROTECTED)
|
|
||||||
public class ViaBukkitListener extends ViaListener implements Listener {
|
public class ViaBukkitListener extends ViaListener implements Listener {
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
||||||
public ViaBukkitListener(ViaVersionPlugin plugin, Class<? extends Protocol> requiredPipeline) {
|
public ViaBukkitListener(Plugin plugin, Class<? extends Protocol> requiredPipeline) {
|
||||||
super(requiredPipeline);
|
super(requiredPipeline);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -26,7 +21,7 @@ public class ViaBukkitListener extends ViaListener implements Listener {
|
|||||||
* @param player Player object
|
* @param player Player object
|
||||||
* @return The UserConnection
|
* @return The UserConnection
|
||||||
*/
|
*/
|
||||||
protected UserConnection getUserConnection(@NonNull Player player) {
|
protected UserConnection getUserConnection(Player player) {
|
||||||
return getUserConnection(player.getUniqueId());
|
return getUserConnection(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +45,8 @@ public class ViaBukkitListener extends ViaListener implements Listener {
|
|||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
setRegistered(true);
|
setRegistered(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.inventory.CraftingInventory;
|
import org.bukkit.inventory.CraftingInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -28,7 +28,7 @@ public class ArmorListener extends ViaBukkitListener {
|
|||||||
|
|
||||||
private static final UUID ARMOR_ATTRIBUTE = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
private static final UUID ARMOR_ATTRIBUTE = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
|
||||||
|
|
||||||
public ArmorListener(ViaVersionPlugin plugin) {
|
public ArmorListener(Plugin plugin) {
|
||||||
super(plugin, Protocol1_9To1_8.class);
|
super(plugin, Protocol1_9To1_8.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,6 @@ public class ArmorListener extends ViaBukkitListener {
|
|||||||
// Ensure that the player is on our pipe
|
// Ensure that the player is on our pipe
|
||||||
if (!isOnPipe(player)) return;
|
if (!isOnPipe(player)) return;
|
||||||
|
|
||||||
|
|
||||||
int armor = 0;
|
int armor = 0;
|
||||||
for (ItemStack stack : player.getInventory().getArmorContents()) {
|
for (ItemStack stack : player.getInventory().getArmorContents()) {
|
||||||
armor += ArmorType.findById(stack.getTypeId()).getArmorPoints();
|
armor += ArmorType.findById(stack.getTypeId()).getArmorPoints();
|
||||||
@ -82,12 +81,7 @@ public class ArmorListener extends ViaBukkitListener {
|
|||||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
// Due to odd bugs it's 3 ticks later
|
// Due to odd bugs it's 3 ticks later
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> sendArmorUpdate(player), 3L);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
sendArmorUpdate(player);
|
|
||||||
}
|
|
||||||
}, 3L);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,11 +108,6 @@ public class ArmorListener extends ViaBukkitListener {
|
|||||||
|
|
||||||
public void sendDelayedArmorUpdate(final Player player) {
|
public void sendDelayedArmorUpdate(final Player player) {
|
||||||
if (!isOnPipe(player)) return; // Don't start a task if the player is not on the pipe
|
if (!isOnPipe(player)) return; // Don't start a task if the player is not on the pipe
|
||||||
Via.getPlatform().runSync(new Runnable() {
|
Via.getPlatform().runSync(() -> sendArmorUpdate(player));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
sendArmorUpdate(player);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
@ -12,7 +12,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
|||||||
|
|
||||||
public class BlockListener extends ViaBukkitListener {
|
public class BlockListener extends ViaBukkitListener {
|
||||||
|
|
||||||
public BlockListener(ViaVersionPlugin plugin) {
|
public BlockListener(Plugin plugin) {
|
||||||
super(plugin, Protocol1_9To1_8.class);
|
super(plugin, Protocol1_9To1_8.class);
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -14,7 +14,8 @@ import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
|
|
||||||
public class DeathListener extends ViaBukkitListener {
|
public class DeathListener extends ViaBukkitListener {
|
||||||
public DeathListener(ViaVersionPlugin plugin) {
|
|
||||||
|
public DeathListener(Plugin plugin) {
|
||||||
super(plugin, Protocol1_9To1_8.class);
|
super(plugin, Protocol1_9To1_8.class);
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +13,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class HandItemCache extends BukkitRunnable {
|
public class HandItemCache extends BukkitRunnable {
|
||||||
|
|
||||||
private final Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
private final Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -6,13 +6,13 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
|
|
||||||
public class PaperPatch extends ViaBukkitListener {
|
public class PaperPatch extends ViaBukkitListener {
|
||||||
|
|
||||||
public PaperPatch(ViaVersionPlugin plugin) {
|
public PaperPatch(Plugin plugin) {
|
||||||
super(plugin, Protocol1_9To1_8.class);
|
super(plugin, Protocol1_9To1_8.class);
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Change Bukkit Version HERE! -->
|
<!-- Change Bukkit Version HERE! -->
|
||||||
<bukkitVersion>1.8.8-R0.1-SNAPSHOT</bukkitVersion>
|
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -60,5 +60,13 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Legacy Support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>us.myles</groupId>
|
||||||
|
<artifactId>viaversion-bukkit-legacy</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package us.myles.ViaVersion.boss;
|
package us.myles.ViaVersion.boss;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import us.myles.ViaVersion.api.boss.BossBar;
|
import us.myles.ViaVersion.api.boss.BossBar;
|
||||||
import us.myles.ViaVersion.api.boss.BossColor;
|
import us.myles.ViaVersion.api.boss.BossColor;
|
||||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class ViaBossBar extends CommonBoss<Player> {
|
public class ViaBossBar extends CommonBoss<Player> {
|
||||||
|
|
||||||
public ViaBossBar(String title, float health, BossColor color, BossStyle style) {
|
public ViaBossBar(String title, float health, BossColor color, BossStyle style) {
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
package us.myles.ViaVersion.bukkit.commands;
|
package us.myles.ViaVersion.bukkit.commands;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BukkitCommandSender implements ViaCommandSender {
|
public class BukkitCommandSender implements ViaCommandSender {
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public BukkitCommandSender(CommandSender sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return sender.hasPermission(permission);
|
return sender.hasPermission(permission);
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package us.myles.ViaVersion.bukkit.listeners.protocol1_15to1_14_4;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class EntityToggleGlideListener extends ViaBukkitListener {
|
||||||
|
|
||||||
|
public EntityToggleGlideListener(ViaVersionPlugin plugin) {
|
||||||
|
super(plugin, Protocol1_15To1_14_4.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void entityToggleGlide(EntityToggleGlideEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
if (!isOnPipe(player)) return;
|
||||||
|
|
||||||
|
// Cancelling can only be done by updating the player's metadata
|
||||||
|
if (event.isGliding() && event.isCancelled()) {
|
||||||
|
PacketWrapper packet = new PacketWrapper(0x44, null, getUserConnection(player));
|
||||||
|
try {
|
||||||
|
packet.write(Type.VAR_INT, player.getEntityId());
|
||||||
|
|
||||||
|
byte bitmask = 0;
|
||||||
|
// Collect other metadata for the mitmask
|
||||||
|
if (player.getFireTicks() > 0) {
|
||||||
|
bitmask |= 0x01;
|
||||||
|
}
|
||||||
|
if (player.isSneaking()) {
|
||||||
|
bitmask |= 0x02;
|
||||||
|
}
|
||||||
|
// 0x04 is unused
|
||||||
|
if (player.isSprinting()) {
|
||||||
|
bitmask |= 0x08;
|
||||||
|
}
|
||||||
|
if (player.isSwimming()) {
|
||||||
|
bitmask |= 0x10;
|
||||||
|
}
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
|
||||||
|
bitmask |= 0x20;
|
||||||
|
}
|
||||||
|
if (player.isGlowing()) {
|
||||||
|
bitmask |= 0x40;
|
||||||
|
}
|
||||||
|
|
||||||
|
// leave 0x80 as 0 to stop gliding
|
||||||
|
packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, MetaType1_14.Byte, bitmask)));
|
||||||
|
packet.send(Protocol1_15To1_14_4.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,16 @@
|
|||||||
package us.myles.ViaVersion.bukkit.platform;
|
package us.myles.ViaVersion.bukkit.platform;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
import us.myles.ViaVersion.api.platform.TaskId;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BukkitTaskId implements TaskId {
|
public class BukkitTaskId implements TaskId {
|
||||||
private final Integer object;
|
private final Integer object;
|
||||||
|
|
||||||
|
public BukkitTaskId(Integer object) {
|
||||||
|
this.object = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getObject() {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.bukkit.platform;
|
package us.myles.ViaVersion.bukkit.platform;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
@ -28,12 +27,12 @@ public class BukkitViaAPI implements ViaAPI<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull Player player) {
|
public int getPlayerVersion(Player player) {
|
||||||
return getPlayerVersion(player.getUniqueId());
|
return getPlayerVersion(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull UUID uuid) {
|
public int getPlayerVersion(UUID uuid) {
|
||||||
if (!isInjected(uuid))
|
if (!isInjected(uuid))
|
||||||
return getExternalVersion(Bukkit.getPlayer(uuid));
|
return getExternalVersion(Bukkit.getPlayer(uuid));
|
||||||
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
||||||
|
@ -17,7 +17,12 @@ import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
|||||||
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.UpdateListener;
|
import us.myles.ViaVersion.bukkit.listeners.UpdateListener;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.multiversion.PlayerSneakListener;
|
import us.myles.ViaVersion.bukkit.listeners.multiversion.PlayerSneakListener;
|
||||||
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.*;
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_15to1_14_4.EntityToggleGlideListener;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.ArmorListener;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.BlockListener;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.DeathListener;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.HandItemCache;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.PaperPatch;
|
||||||
import us.myles.ViaVersion.bukkit.providers.BukkitBlockConnectionProvider;
|
import us.myles.ViaVersion.bukkit.providers.BukkitBlockConnectionProvider;
|
||||||
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
|
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
|
||||||
import us.myles.ViaVersion.bukkit.providers.BukkitViaBulkChunkTranslator;
|
import us.myles.ViaVersion.bukkit.providers.BukkitViaBulkChunkTranslator;
|
||||||
@ -99,6 +104,14 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_15.getId()) {
|
||||||
|
try {
|
||||||
|
Class.forName("org.bukkit.event.entity.EntityToggleGlideEvent");
|
||||||
|
storeListener(new EntityToggleGlideListener(plugin)).register();
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("paper")
|
if ((Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("paper")
|
||||||
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("taco")
|
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("taco")
|
||||||
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("torch"))
|
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("torch"))
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package us.myles.ViaVersion.bungee.commands;
|
package us.myles.ViaVersion.bungee.commands;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BungeeCommandSender implements ViaCommandSender {
|
public class BungeeCommandSender implements ViaCommandSender {
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public BungeeCommandSender(CommandSender sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
|
@ -2,15 +2,12 @@ package us.myles.ViaVersion.bungee.handlers;
|
|||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
|
public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
|
||||||
@Getter
|
|
||||||
private final ChannelInitializer<Channel> original;
|
private final ChannelInitializer<Channel> original;
|
||||||
private Method method;
|
private Method method;
|
||||||
|
|
||||||
@ -40,6 +37,9 @@ public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
|
|||||||
|
|
||||||
socketChannel.pipeline().addBefore("packet-encoder", "via-encoder", encoder);
|
socketChannel.pipeline().addBefore("packet-encoder", "via-encoder", encoder);
|
||||||
socketChannel.pipeline().addBefore("packet-decoder", "via-decoder", decoder);
|
socketChannel.pipeline().addBefore("packet-decoder", "via-decoder", decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelInitializer<Channel> getOriginal() {
|
||||||
|
return original;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package us.myles.ViaVersion.bungee.platform;
|
package us.myles.ViaVersion.bungee.platform;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
import us.myles.ViaVersion.api.platform.TaskId;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BungeeTaskId implements TaskId {
|
public class BungeeTaskId implements TaskId {
|
||||||
private Integer object;
|
private final Integer object;
|
||||||
|
|
||||||
|
public BungeeTaskId(Integer object) {
|
||||||
|
this.object = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getObject() {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ import us.myles.ViaVersion.util.PipelineUtil;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UserConnection {
|
public class UserConnection {
|
||||||
@ -156,12 +154,12 @@ public class UserConnection {
|
|||||||
if (conf.getMaxWarnings() > 0 && conf.getTrackingPeriod() > 0) {
|
if (conf.getMaxWarnings() > 0 && conf.getTrackingPeriod() > 0) {
|
||||||
if (secondsObserved > conf.getTrackingPeriod()) {
|
if (secondsObserved > conf.getTrackingPeriod()) {
|
||||||
// Reset
|
// Reset
|
||||||
setWarnings(0);
|
warnings = 0;
|
||||||
setSecondsObserved(1);
|
secondsObserved = 1;
|
||||||
} else {
|
} else {
|
||||||
setSecondsObserved(secondsObserved + 1);
|
secondsObserved++;
|
||||||
if (packetsPerSecond >= conf.getWarningPPS()) {
|
if (packetsPerSecond >= conf.getWarningPPS()) {
|
||||||
setWarnings(warnings + 1);
|
warnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warnings >= conf.getMaxWarnings()) {
|
if (warnings >= conf.getMaxWarnings()) {
|
||||||
|
@ -2,11 +2,7 @@ package us.myles.ViaVersion.api.minecraft.item;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Item {
|
public class Item {
|
||||||
@SerializedName(value = "identifier", alternate = "id")
|
@SerializedName(value = "identifier", alternate = "id")
|
||||||
private int identifier;
|
private int identifier;
|
||||||
@ -14,6 +10,16 @@ public class Item {
|
|||||||
private short data;
|
private short data;
|
||||||
private CompoundTag tag;
|
private CompoundTag tag;
|
||||||
|
|
||||||
|
public Item() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item(int identifier, byte amount, short data, CompoundTag tag) {
|
||||||
|
this.identifier = identifier;
|
||||||
|
this.amount = amount;
|
||||||
|
this.data = data;
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
public Item(Item toCopy) {
|
public Item(Item toCopy) {
|
||||||
this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag());
|
this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag());
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package us.myles.ViaVersion.boss;
|
package us.myles.ViaVersion.boss;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.boss.BossBar;
|
import us.myles.ViaVersion.api.boss.BossBar;
|
||||||
@ -14,9 +12,12 @@ import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public abstract class CommonBoss<T> extends BossBar<T> {
|
public abstract class CommonBoss<T> extends BossBar<T> {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private String title;
|
private String title;
|
||||||
@ -42,7 +43,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setTitle(@NonNull String title) {
|
public BossBar setTitle(String title) {
|
||||||
|
Preconditions.checkNotNull(title);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
sendPacket(CommonBoss.UpdateAction.UPDATE_TITLE);
|
sendPacket(CommonBoss.UpdateAction.UPDATE_TITLE);
|
||||||
return this;
|
return this;
|
||||||
@ -62,14 +64,16 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setColor(@NonNull BossColor color) {
|
public BossBar setColor(BossColor color) {
|
||||||
|
Preconditions.checkNotNull(color);
|
||||||
this.color = color;
|
this.color = color;
|
||||||
sendPacket(CommonBoss.UpdateAction.UPDATE_STYLE);
|
sendPacket(CommonBoss.UpdateAction.UPDATE_STYLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar setStyle(@NonNull BossStyle style) {
|
public BossBar setStyle(BossStyle style) {
|
||||||
|
Preconditions.checkNotNull(style);
|
||||||
this.style = style;
|
this.style = style;
|
||||||
sendPacket(CommonBoss.UpdateAction.UPDATE_STYLE);
|
sendPacket(CommonBoss.UpdateAction.UPDATE_STYLE);
|
||||||
return this;
|
return this;
|
||||||
@ -98,7 +102,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar addFlag(@NonNull BossFlag flag) {
|
public BossBar addFlag(BossFlag flag) {
|
||||||
|
Preconditions.checkNotNull(flag);
|
||||||
if (!hasFlag(flag))
|
if (!hasFlag(flag))
|
||||||
flags.add(flag);
|
flags.add(flag);
|
||||||
sendPacket(CommonBoss.UpdateAction.UPDATE_FLAGS);
|
sendPacket(CommonBoss.UpdateAction.UPDATE_FLAGS);
|
||||||
@ -106,7 +111,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BossBar removeFlag(@NonNull BossFlag flag) {
|
public BossBar removeFlag(BossFlag flag) {
|
||||||
|
Preconditions.checkNotNull(flag);
|
||||||
if (hasFlag(flag))
|
if (hasFlag(flag))
|
||||||
flags.remove(flag);
|
flags.remove(flag);
|
||||||
sendPacket(CommonBoss.UpdateAction.UPDATE_FLAGS);
|
sendPacket(CommonBoss.UpdateAction.UPDATE_FLAGS);
|
||||||
@ -114,7 +120,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFlag(@NonNull BossFlag flag) {
|
public boolean hasFlag(BossFlag flag) {
|
||||||
|
Preconditions.checkNotNull(flag);
|
||||||
return flags.contains(flag);
|
return flags.contains(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +152,29 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getHealth() {
|
||||||
|
return health;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BossStyle getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<BossFlag> getFlags() {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
private void setVisible(boolean value) {
|
private void setVisible(boolean value) {
|
||||||
if (visible != value) {
|
if (visible != value) {
|
||||||
visible = value;
|
visible = value;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.commands;
|
package us.myles.ViaVersion.commands;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import lombok.NonNull;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||||
@ -24,7 +23,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerSubCommand(@NonNull ViaSubCommand command) throws Exception {
|
public void registerSubCommand(ViaSubCommand command) throws Exception {
|
||||||
Preconditions.checkArgument(command.name().matches("^[a-z0-9_-]{3,15}$"), command.name() + " is not a valid sub-command name.");
|
Preconditions.checkArgument(command.name().matches("^[a-z0-9_-]{3,15}$"), command.name() + " is not a valid sub-command name.");
|
||||||
if (hasSubCommand(command.name()))
|
if (hasSubCommand(command.name()))
|
||||||
throw new Exception("ViaSubCommand " + command.name() + " does already exists!"); //Maybe another exception later.
|
throw new Exception("ViaSubCommand " + command.name() + " does already exists!"); //Maybe another exception later.
|
||||||
@ -163,7 +162,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
|
|||||||
* @param message The message
|
* @param message The message
|
||||||
* @param args The objects to replace
|
* @param args The objects to replace
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(@NonNull ViaCommandSender sender, String message, Object... args) {
|
public static void sendMessage(ViaCommandSender sender, String message, Object... args) {
|
||||||
sender.sendMessage(color(args == null ? message : String.format(message, args)));
|
sender.sendMessage(color(args == null ? message : String.format(message, args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,35 @@
|
|||||||
package us.myles.ViaVersion.dump;
|
package us.myles.ViaVersion.dump;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DumpTemplate {
|
public class DumpTemplate {
|
||||||
private VersionInfo versionInfo;
|
private final VersionInfo versionInfo;
|
||||||
private Map<String, Object> configuration;
|
private final Map<String, Object> configuration;
|
||||||
private JsonObject platformDump;
|
private final JsonObject platformDump;
|
||||||
private JsonObject injectionDump;
|
private final JsonObject injectionDump;
|
||||||
|
|
||||||
|
public DumpTemplate(VersionInfo versionInfo, Map<String, Object> configuration, JsonObject platformDump, JsonObject injectionDump) {
|
||||||
|
this.versionInfo = versionInfo;
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.platformDump = platformDump;
|
||||||
|
this.injectionDump = injectionDump;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionInfo getVersionInfo() {
|
||||||
|
return versionInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getConfiguration() {
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonObject getPlatformDump() {
|
||||||
|
return platformDump;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonObject getInjectionDump() {
|
||||||
|
return injectionDump;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,39 @@
|
|||||||
package us.myles.ViaVersion.dump;
|
package us.myles.ViaVersion.dump;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PluginInfo {
|
public class PluginInfo {
|
||||||
private boolean enabled;
|
private final boolean enabled;
|
||||||
private String name;
|
private final String name;
|
||||||
private String version;
|
private final String version;
|
||||||
private String main;
|
private final String main;
|
||||||
private List<String> authors;
|
private final List<String> authors;
|
||||||
|
|
||||||
|
public PluginInfo(boolean enabled, String name, String version, String main, List<String> authors) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.name = name;
|
||||||
|
this.version = version;
|
||||||
|
this.main = main;
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMain() {
|
||||||
|
return main;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,52 @@
|
|||||||
package us.myles.ViaVersion.dump;
|
package us.myles.ViaVersion.dump;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class VersionInfo {
|
public class VersionInfo {
|
||||||
private String javaVersion;
|
private final String javaVersion;
|
||||||
private String operatingSystem;
|
private final String operatingSystem;
|
||||||
private int serverProtocol;
|
private final int serverProtocol;
|
||||||
private Set<Integer> enabledProtocols;
|
private final Set<Integer> enabledProtocols;
|
||||||
private String platformName;
|
private final String platformName;
|
||||||
private String platformVersion;
|
private final String platformVersion;
|
||||||
private String pluginVersion;
|
private final String pluginVersion;
|
||||||
|
|
||||||
|
public VersionInfo(String javaVersion, String operatingSystem, int serverProtocol, Set<Integer> enabledProtocols, String platformName, String platformVersion, String pluginVersion) {
|
||||||
|
this.javaVersion = javaVersion;
|
||||||
|
this.operatingSystem = operatingSystem;
|
||||||
|
this.serverProtocol = serverProtocol;
|
||||||
|
this.enabledProtocols = enabledProtocols;
|
||||||
|
this.platformName = platformName;
|
||||||
|
this.platformVersion = platformVersion;
|
||||||
|
this.pluginVersion = pluginVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaVersion() {
|
||||||
|
return javaVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperatingSystem() {
|
||||||
|
return operatingSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServerProtocol() {
|
||||||
|
return serverProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getEnabledProtocols() {
|
||||||
|
return enabledProtocols;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlatformName() {
|
||||||
|
return platformName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlatformVersion() {
|
||||||
|
return platformVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPluginVersion() {
|
||||||
|
return pluginVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.base;
|
package us.myles.ViaVersion.protocols.base;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||||
@ -9,8 +7,6 @@ import us.myles.ViaVersion.packets.State;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class ProtocolInfo extends StoredObject {
|
public class ProtocolInfo extends StoredObject {
|
||||||
private State state = State.HANDSHAKE;
|
private State state = State.HANDSHAKE;
|
||||||
private int protocolVersion = -1;
|
private int protocolVersion = -1;
|
||||||
@ -22,4 +18,52 @@ public class ProtocolInfo extends StoredObject {
|
|||||||
public ProtocolInfo(UserConnection user) {
|
public ProtocolInfo(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(State state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProtocolVersion() {
|
||||||
|
return protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolVersion(int protocolVersion) {
|
||||||
|
this.protocolVersion = protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServerProtocolVersion() {
|
||||||
|
return serverProtocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerProtocolVersion(int serverProtocolVersion) {
|
||||||
|
this.serverProtocolVersion = serverProtocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolPipeline getPipeline() {
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPipeline(ProtocolPipeline pipeline) {
|
||||||
|
this.pipeline = pipeline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage;
|
package us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
public class ResourcePackTracker extends StoredObject {
|
public class ResourcePackTracker extends StoredObject {
|
||||||
private String lastHash = "";
|
private String lastHash = "";
|
||||||
|
|
||||||
public ResourcePackTracker(UserConnection user) {
|
public ResourcePackTracker(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLastHash() {
|
||||||
|
return lastHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastHash(String lastHash) {
|
||||||
|
this.lastHash = lastHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ResourcePackTracker{" +
|
||||||
|
"lastHash='" + lastHash + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,34 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage;
|
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@ToString
|
|
||||||
@Getter
|
|
||||||
public class ItemTransaction {
|
public class ItemTransaction {
|
||||||
private short windowId;
|
private final short windowId;
|
||||||
private short slotId;
|
private final short slotId;
|
||||||
private short actionId;
|
private final short actionId;
|
||||||
|
|
||||||
|
public ItemTransaction(short windowId, short slotId, short actionId) {
|
||||||
|
this.windowId = windowId;
|
||||||
|
this.slotId = slotId;
|
||||||
|
this.actionId = actionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getWindowId() {
|
||||||
|
return windowId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getSlotId() {
|
||||||
|
return slotId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getActionId() {
|
||||||
|
return actionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ItemTransaction{" +
|
||||||
|
"windowId=" + windowId +
|
||||||
|
", slotId=" + slotId +
|
||||||
|
", actionId=" + actionId +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -162,18 +160,27 @@ public class ParticleRewriter {
|
|||||||
Particle handler(Particle particle, Integer[] data);
|
Particle handler(Particle particle, Integer[] data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
private static class NewParticle {
|
private static class NewParticle {
|
||||||
private final int id;
|
private final int id;
|
||||||
private final ParticleDataHandler handler;
|
private final ParticleDataHandler handler;
|
||||||
|
|
||||||
|
public NewParticle(int id, ParticleDataHandler handler) {
|
||||||
|
this.id = id;
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
public Particle handle(Particle particle, Integer[] data) {
|
public Particle handle(Particle particle, Integer[] data) {
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
return handler.handler(particle, data);
|
return handler.handler(particle, data);
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticleDataHandler getHandler() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
@ -33,9 +31,7 @@ public class RecipeData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Recipe {
|
public static class Recipe {
|
||||||
@NonNull
|
|
||||||
private String type;
|
private String type;
|
||||||
private String group;
|
private String group;
|
||||||
private int width;
|
private int width;
|
||||||
@ -45,5 +41,77 @@ public class RecipeData {
|
|||||||
private Item[] ingredient;
|
private Item[] ingredient;
|
||||||
private Item[][] ingredients;
|
private Item[][] ingredients;
|
||||||
private Item result;
|
private Item result;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup(String group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(int width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(int height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getExperience() {
|
||||||
|
return experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExperience(float experience) {
|
||||||
|
this.experience = experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCookingTime() {
|
||||||
|
return cookingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCookingTime(int cookingTime) {
|
||||||
|
this.cookingTime = cookingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item[] getIngredient() {
|
||||||
|
return ingredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngredient(Item[] ingredient) {
|
||||||
|
this.ingredient = ingredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item[][] getIngredients() {
|
||||||
|
return ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngredients(Item[][] ingredients) {
|
||||||
|
this.ingredients = ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(Item result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,7 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum SoundSource {
|
public enum SoundSource {
|
||||||
MASTER("master", 0),
|
MASTER("master", 0),
|
||||||
MUSIC("music", 1),
|
MUSIC("music", 1),
|
||||||
@ -22,10 +17,23 @@ public enum SoundSource {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
|
SoundSource(String name, int id) {
|
||||||
|
this.name = name;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<SoundSource> findBySource(String source) {
|
public static Optional<SoundSource> findBySource(String source) {
|
||||||
for (SoundSource item : SoundSource.values())
|
for (SoundSource item : SoundSource.values())
|
||||||
if (item.name.equalsIgnoreCase(source))
|
if (item.name.equalsIgnoreCase(source))
|
||||||
return Optional.of(item);
|
return Optional.of(item);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
@ -68,11 +66,29 @@ public class BlockStorage extends StoredObject {
|
|||||||
return blocks.remove(position);
|
return blocks.remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class ReplacementData {
|
public static class ReplacementData {
|
||||||
private int original;
|
private int original;
|
||||||
private int replacement;
|
private int replacement;
|
||||||
}
|
|
||||||
|
|
||||||
|
public ReplacementData(int original, int replacement) {
|
||||||
|
this.original = original;
|
||||||
|
this.replacement = replacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOriginal() {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginal(int original) {
|
||||||
|
this.original = original;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReplacement() {
|
||||||
|
return replacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplacement(int replacement) {
|
||||||
|
this.replacement = replacement;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class TabCompleteTracker extends StoredObject {
|
public class TabCompleteTracker extends StoredObject {
|
||||||
private int transactionId;
|
private int transactionId;
|
||||||
private String input;
|
private String input;
|
||||||
@ -33,4 +29,36 @@ public class TabCompleteTracker extends StoredObject {
|
|||||||
}
|
}
|
||||||
lastTabComplete = null;
|
lastTabComplete = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTransactionId() {
|
||||||
|
return transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionId(int transactionId) {
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(final String input) {
|
||||||
|
this.input = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastTabComplete() {
|
||||||
|
return lastTabComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastTabComplete(String lastTabComplete) {
|
||||||
|
this.lastTabComplete = lastTabComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeToSend() {
|
||||||
|
return timeToSend;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeToSend(long timeToSend) {
|
||||||
|
this.timeToSend = timeToSend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class ClientWorld extends StoredObject {
|
public class ClientWorld extends StoredObject {
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
@ -13,6 +11,10 @@ public class ClientWorld extends StoredObject {
|
|||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Environment getEnvironment() {
|
||||||
|
return environment;
|
||||||
|
}
|
||||||
|
|
||||||
public void setEnvironment(int environmentId) {
|
public void setEnvironment(int environmentId) {
|
||||||
this.environment = getEnvFromId(environmentId);
|
this.environment = getEnvFromId(environmentId);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum ArmorType {
|
public enum ArmorType {
|
||||||
|
|
||||||
LEATHER_HELMET(1, 298, "minecraft:leather_helmet"),
|
LEATHER_HELMET(1, 298, "minecraft:leather_helmet"),
|
||||||
@ -32,7 +27,7 @@ public enum ArmorType {
|
|||||||
GOLD_BOOTS(1, 317, "minecraft:gold_boots"),
|
GOLD_BOOTS(1, 317, "minecraft:gold_boots"),
|
||||||
NONE(0, 0, "none");
|
NONE(0, 0, "none");
|
||||||
|
|
||||||
private static Map<Integer, ArmorType> armor;
|
private static final Map<Integer, ArmorType> armor;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
armor = new HashMap<>();
|
armor = new HashMap<>();
|
||||||
@ -45,6 +40,20 @@ public enum ArmorType {
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
|
ArmorType(int armorPoints, int id, String type) {
|
||||||
|
this.armorPoints = armorPoints;
|
||||||
|
this.id = id;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArmorPoints() {
|
||||||
|
return armorPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find an armour type by the item id
|
* Find an armour type by the item id
|
||||||
*
|
*
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.chat;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.chat;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum GameMode {
|
public enum GameMode {
|
||||||
SURVIVAL(0, "Survival Mode"),
|
SURVIVAL(0, "Survival Mode"),
|
||||||
CREATIVE(1, "Creative Mode"),
|
CREATIVE(1, "Creative Mode"),
|
||||||
@ -14,6 +9,19 @@ public enum GameMode {
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
|
GameMode(int id, String text) {
|
||||||
|
this.id = id;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
public static GameMode getById(int id) {
|
public static GameMode getById(int id) {
|
||||||
for (GameMode gm : GameMode.values())
|
for (GameMode gm : GameMode.values())
|
||||||
if (gm.getId() == id)
|
if (gm.getId() == id)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_10Types;
|
import us.myles.ViaVersion.api.entities.Entity1_10Types;
|
||||||
import us.myles.ViaVersion.api.entities.EntityType;
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
@ -12,7 +11,6 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import static us.myles.ViaVersion.api.entities.Entity1_10Types.EntityType.*;
|
import static us.myles.ViaVersion.api.entities.Entity1_10Types.EntityType.*;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum MetaIndex {
|
public enum MetaIndex {
|
||||||
|
|
||||||
// entity
|
// entity
|
||||||
@ -172,6 +170,26 @@ public enum MetaIndex {
|
|||||||
this.newType = newType;
|
this.newType = newType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity1_10Types.EntityType getClazz() {
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNewIndex() {
|
||||||
|
return newIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaType1_9 getNewType() {
|
||||||
|
return newType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaType1_8 getOldType() {
|
||||||
|
return oldType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
private static Optional<MetaIndex> getIndex(EntityType type, int index) {
|
private static Optional<MetaIndex> getIndex(EntityType type, int index) {
|
||||||
Pair pair = new Pair<>(type, index);
|
Pair pair = new Pair<>(type, index);
|
||||||
return Optional.ofNullable(metadataRewrites.get(pair));
|
return Optional.ofNullable(metadataRewrites.get(pair));
|
||||||
|
@ -291,8 +291,8 @@ public class WorldPackets {
|
|||||||
wrapper.clearInputBuffer();
|
wrapper.clearInputBuffer();
|
||||||
// First set this packet ID to Block placement
|
// First set this packet ID to Block placement
|
||||||
wrapper.setId(0x08);
|
wrapper.setId(0x08);
|
||||||
wrapper.write(Type.LONG, -1L);
|
wrapper.write(Type.POSITION, new Position(-1, (short) -1, -1));
|
||||||
wrapper.write(Type.BYTE, (byte) 255);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 255);
|
||||||
// Write item in hand
|
// Write item in hand
|
||||||
Item item = Protocol1_9To1_8.getHandItem(wrapper.user());
|
Item item = Protocol1_9To1_8.getHandItem(wrapper.user());
|
||||||
// Blocking patch
|
// Blocking patch
|
||||||
@ -315,9 +315,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
wrapper.write(Type.ITEM, item);
|
wrapper.write(Type.ITEM, item);
|
||||||
|
|
||||||
wrapper.write(Type.BYTE, (byte) 0);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
wrapper.write(Type.BYTE, (byte) 0);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
wrapper.write(Type.BYTE, (byte) 0);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.providers;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.providers;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.platform.providers.Provider;
|
import us.myles.ViaVersion.api.platform.providers.Provider;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -74,7 +73,6 @@ public class BulkChunkTranslatorProvider implements Provider {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
private static class ChunkBulkSection {
|
private static class ChunkBulkSection {
|
||||||
private int x;
|
private int x;
|
||||||
private int z;
|
private int z;
|
||||||
@ -93,5 +91,45 @@ public class BulkChunkTranslatorProvider implements Provider {
|
|||||||
|
|
||||||
return bulkSection;
|
return bulkSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(int z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBitMask() {
|
||||||
|
return bitMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitMask(int bitMask) {
|
||||||
|
this.bitMask = bitMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(byte[] data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum SoundCategory {
|
public enum SoundCategory {
|
||||||
|
|
||||||
|
|
||||||
MASTER("master", 0),
|
MASTER("master", 0),
|
||||||
MUSIC("music", 1),
|
MUSIC("music", 1),
|
||||||
RECORD("record", 2),
|
RECORD("record", 2),
|
||||||
@ -22,4 +16,16 @@ public enum SoundCategory {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
|
SoundCategory(String name, int id) {
|
||||||
|
this.name = name;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum SoundEffect {
|
public enum SoundEffect {
|
||||||
|
|
||||||
MOB_HORSE_ZOMBIE_IDLE("mob.horse.zombie.idle", "entity.zombie_horse.ambient", SoundCategory.NEUTRAL),
|
MOB_HORSE_ZOMBIE_IDLE("mob.horse.zombie.idle", "entity.zombie_horse.ambient", SoundCategory.NEUTRAL),
|
||||||
@ -261,7 +258,7 @@ public enum SoundEffect {
|
|||||||
private final SoundCategory category;
|
private final SoundCategory category;
|
||||||
private final boolean breaksound;
|
private final boolean breaksound;
|
||||||
|
|
||||||
private static Map<String, SoundEffect> effects;
|
private static final Map<String, SoundEffect> effects;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
effects = new HashMap<>();
|
effects = new HashMap<>();
|
||||||
@ -289,4 +286,19 @@ public enum SoundEffect {
|
|||||||
return effects.get(name);
|
return effects.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewName() {
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SoundCategory getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBreaksound() {
|
||||||
|
return breaksound;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -10,7 +9,6 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTransla
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class ClientChunks extends StoredObject {
|
public class ClientChunks extends StoredObject {
|
||||||
private final Set<Long> loadedChunks = Sets.newConcurrentHashSet();
|
private final Set<Long> loadedChunks = Sets.newConcurrentHashSet();
|
||||||
private final Set<Long> bulkChunks = Sets.newConcurrentHashSet();
|
private final Set<Long> bulkChunks = Sets.newConcurrentHashSet();
|
||||||
@ -26,4 +24,12 @@ public class ClientChunks extends StoredObject {
|
|||||||
public List<Object> transformMapChunkBulk(Object packet) throws Exception {
|
public List<Object> transformMapChunkBulk(Object packet) throws Exception {
|
||||||
return Via.getManager().getProviders().get(BulkChunkTranslatorProvider.class).transformMapChunkBulk(packet, this);
|
return Via.getManager().getProviders().get(BulkChunkTranslatorProvider.class).transformMapChunkBulk(packet, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Long> getLoadedChunks() {
|
||||||
|
return loadedChunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Long> getBulkChunks() {
|
||||||
|
return bulkChunks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -14,9 +12,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class CommandBlockStorage extends StoredObject {
|
public class CommandBlockStorage extends StoredObject {
|
||||||
private Map<Pair<Integer, Integer>, Map<Position, CompoundTag>> storedCommandBlocks = new ConcurrentHashMap<>();
|
private final Map<Pair<Integer, Integer>, Map<Position, CompoundTag>> storedCommandBlocks = new ConcurrentHashMap<>();
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private boolean permissions = false;
|
private boolean permissions = false;
|
||||||
|
|
||||||
public CommandBlockStorage(UserConnection user) {
|
public CommandBlockStorage(UserConnection user) {
|
||||||
@ -71,4 +67,12 @@ public class CommandBlockStorage extends StoredObject {
|
|||||||
public void unloadChunks() {
|
public void unloadChunks() {
|
||||||
storedCommandBlocks.clear();
|
storedCommandBlocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPermissions() {
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissions(boolean permissions) {
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.boss.BossBar;
|
import us.myles.ViaVersion.api.boss.BossBar;
|
||||||
@ -26,11 +23,15 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class EntityTracker1_9 extends EntityTracker {
|
public class EntityTracker1_9 extends EntityTracker {
|
||||||
private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>();
|
private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>();
|
||||||
private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>();
|
private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>();
|
||||||
@ -43,16 +44,11 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
.expireAfterAccess(250, TimeUnit.MILLISECONDS)
|
.expireAfterAccess(250, TimeUnit.MILLISECONDS)
|
||||||
.<Position, Boolean>build()
|
.<Position, Boolean>build()
|
||||||
.asMap());
|
.asMap());
|
||||||
@Setter
|
|
||||||
private boolean blocking = false;
|
private boolean blocking = false;
|
||||||
@Setter
|
|
||||||
private boolean autoTeam = false;
|
private boolean autoTeam = false;
|
||||||
@Setter
|
|
||||||
private Position currentlyDigging = null;
|
private Position currentlyDigging = null;
|
||||||
private boolean teamExists = false;
|
private boolean teamExists = false;
|
||||||
@Setter
|
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
@Setter
|
|
||||||
private String currentTeam;
|
private String currentTeam;
|
||||||
|
|
||||||
public EntityTracker1_9(UserConnection user) {
|
public EntityTracker1_9(UserConnection user) {
|
||||||
@ -104,7 +100,7 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean interactedBlockRecently(int x, int y, int z) {
|
public boolean interactedBlockRecently(int x, int y, int z) {
|
||||||
return blockInteractions.contains(new Position(x, (short) y , z));
|
return blockInteractions.contains(new Position(x, (short) y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockInteraction(Position p) {
|
public void addBlockInteraction(Position p) {
|
||||||
@ -308,4 +304,76 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
return getClientEntityId();
|
return getClientEntityId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Integer, UUID> getUuidMap() {
|
||||||
|
return uuidMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, List<Metadata>> getMetadataBuffer() {
|
||||||
|
return metadataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getVehicleMap() {
|
||||||
|
return vehicleMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, BossBar> getBossBarMap() {
|
||||||
|
return bossBarMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getValidBlocking() {
|
||||||
|
return validBlocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getKnownHolograms() {
|
||||||
|
return knownHolograms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Position> getBlockInteractions() {
|
||||||
|
return blockInteractions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlocking() {
|
||||||
|
return blocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlocking(boolean blocking) {
|
||||||
|
this.blocking = blocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoTeam() {
|
||||||
|
return autoTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoTeam(boolean autoTeam) {
|
||||||
|
this.autoTeam = autoTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getCurrentlyDigging() {
|
||||||
|
return currentlyDigging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentlyDigging(Position currentlyDigging) {
|
||||||
|
this.currentlyDigging = currentlyDigging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTeamExists() {
|
||||||
|
return teamExists;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
return gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameMode(GameMode gameMode) {
|
||||||
|
this.gameMode = gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrentTeam() {
|
||||||
|
return currentTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentTeam(String currentTeam) {
|
||||||
|
this.currentTeam = currentTeam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class InventoryTracker extends StoredObject {
|
public class InventoryTracker extends StoredObject {
|
||||||
private String inventory;
|
private String inventory;
|
||||||
|
|
||||||
public InventoryTracker(UserConnection user) {
|
public InventoryTracker(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInventory(String inventory) {
|
||||||
|
this.inventory = inventory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
public class MovementTracker extends StoredObject {
|
public class MovementTracker extends StoredObject {
|
||||||
private static final long IDLE_PACKET_DELAY = 50L; // Update every 50ms (20tps)
|
private static final long IDLE_PACKET_DELAY = 50L; // Update every 50ms (20tps)
|
||||||
private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind
|
private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind
|
||||||
@Getter
|
|
||||||
private long nextIdlePacket = 0L;
|
private long nextIdlePacket = 0L;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean ground = true;
|
private boolean ground = true;
|
||||||
|
|
||||||
public MovementTracker(UserConnection user) {
|
public MovementTracker(UserConnection user) {
|
||||||
@ -23,4 +18,16 @@ public class MovementTracker extends StoredObject {
|
|||||||
// Allow a maximum lag spike of 1 second (20 ticks/updates)
|
// Allow a maximum lag spike of 1 second (20 ticks/updates)
|
||||||
this.nextIdlePacket = Math.max(nextIdlePacket + IDLE_PACKET_DELAY, System.currentTimeMillis() - IDLE_PACKET_DELAY * IDLE_PACKET_LIMIT);
|
this.nextIdlePacket = Math.max(nextIdlePacket + IDLE_PACKET_DELAY, System.currentTimeMillis() - IDLE_PACKET_DELAY * IDLE_PACKET_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getNextIdlePacket() {
|
||||||
|
return nextIdlePacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGround() {
|
||||||
|
return ground;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGround(boolean ground) {
|
||||||
|
this.ground = ground;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class PlaceBlockTracker extends StoredObject {
|
public class PlaceBlockTracker extends StoredObject {
|
||||||
private long lastPlaceTimestamp = 0;
|
private long lastPlaceTimestamp = 0;
|
||||||
@Setter
|
|
||||||
private Position lastPlacedPosition = null;
|
private Position lastPlacedPosition = null;
|
||||||
|
|
||||||
public PlaceBlockTracker(UserConnection user) {
|
public PlaceBlockTracker(UserConnection user) {
|
||||||
@ -32,4 +28,16 @@ public class PlaceBlockTracker extends StoredObject {
|
|||||||
public void updateTime() {
|
public void updateTime() {
|
||||||
lastPlaceTimestamp = System.currentTimeMillis();
|
lastPlaceTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLastPlaceTimestamp() {
|
||||||
|
return lastPlaceTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getLastPlacedPosition() {
|
||||||
|
return lastPlacedPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastPlacedPosition(Position lastPlacedPosition) {
|
||||||
|
this.lastPlacedPosition = lastPlacedPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,16 @@ package us.myles.ViaVersion.util;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
public final class GsonUtil {
|
||||||
public class GsonUtil {
|
private static final Gson gson = getGsonBuilder().create();
|
||||||
private final Gson gson = getGsonBuilder().create();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get google's Gson magic
|
* Get google's Gson magic
|
||||||
*
|
*
|
||||||
* @return Gson instance
|
* @return Gson instance
|
||||||
*/
|
*/
|
||||||
public Gson getGson() {
|
public static Gson getGson() {
|
||||||
return gson;
|
return gson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ public class GsonUtil {
|
|||||||
*
|
*
|
||||||
* @return GsonBuilder instance
|
* @return GsonBuilder instance
|
||||||
*/
|
*/
|
||||||
public GsonBuilder getGsonBuilder() {
|
public static GsonBuilder getGsonBuilder() {
|
||||||
return new GsonBuilder();
|
return new GsonBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
13
pom.xml
13
pom.xml
@ -18,6 +18,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
<module>bukkit</module>
|
<module>bukkit</module>
|
||||||
|
<module>bukkit-legacy</module>
|
||||||
<module>bungee</module>
|
<module>bungee</module>
|
||||||
<module>fabric</module>
|
<module>fabric</module>
|
||||||
<module>sponge</module>
|
<module>sponge</module>
|
||||||
@ -52,6 +53,18 @@
|
|||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- Velocity repository -->
|
||||||
|
<repository>
|
||||||
|
<id>velocity</id>
|
||||||
|
<url>https://repo.velocitypowered.com/snapshots</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!-- Sponge repository -->
|
||||||
|
<repository>
|
||||||
|
<id>sponge</id>
|
||||||
|
<url>https://repo.spongepowered.org/maven</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<!-- ViaVersion Repository -->
|
<!-- ViaVersion Repository -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>viaversion-repo</id>
|
<id>viaversion-repo</id>
|
||||||
|
@ -12,13 +12,6 @@
|
|||||||
<artifactId>viaversion-sponge-legacy</artifactId>
|
<artifactId>viaversion-sponge-legacy</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>sponge</id>
|
|
||||||
<url>https://repo.spongepowered.org/maven</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
@ -11,13 +11,6 @@
|
|||||||
|
|
||||||
<artifactId>viaversion-sponge</artifactId>
|
<artifactId>viaversion-sponge</artifactId>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>sponge</id>
|
|
||||||
<url>https://repo.spongepowered.org/maven</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion.sponge.commands;
|
package us.myles.ViaVersion.sponge.commands;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
@ -10,9 +9,12 @@ import us.myles.ViaVersion.api.command.ViaCommandSender;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SpongeCommandSender implements ViaCommandSender {
|
public class SpongeCommandSender implements ViaCommandSender {
|
||||||
private CommandSource source;
|
private final CommandSource source;
|
||||||
|
|
||||||
|
public SpongeCommandSender(CommandSource source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
|
@ -5,7 +5,6 @@ import io.netty.channel.ChannelInitializer;
|
|||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
@ -14,7 +13,6 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
public class SpongeChannelInitializer extends ChannelInitializer<Channel> {
|
public class SpongeChannelInitializer extends ChannelInitializer<Channel> {
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final ChannelInitializer<Channel> original;
|
private final ChannelInitializer<Channel> original;
|
||||||
private Method method;
|
private Method method;
|
||||||
|
|
||||||
@ -51,4 +49,8 @@ public class SpongeChannelInitializer extends ChannelInitializer<Channel> {
|
|||||||
this.method.invoke(this.original, channel);
|
this.method.invoke(this.original, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChannelInitializer<Channel> getOriginal() {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion.sponge.listeners;
|
package us.myles.ViaVersion.sponge.listeners;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import us.myles.ViaVersion.SpongePlugin;
|
import us.myles.ViaVersion.SpongePlugin;
|
||||||
@ -13,7 +12,6 @@ import java.lang.reflect.Field;
|
|||||||
public class ViaSpongeListener extends ViaListener {
|
public class ViaSpongeListener extends ViaListener {
|
||||||
private static Field entityIdField;
|
private static Field entityIdField;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final SpongePlugin plugin;
|
private final SpongePlugin plugin;
|
||||||
|
|
||||||
public ViaSpongeListener(SpongePlugin plugin, Class<? extends Protocol> requiredPipeline) {
|
public ViaSpongeListener(SpongePlugin plugin, Class<? extends Protocol> requiredPipeline) {
|
||||||
@ -46,4 +44,8 @@ public class ViaSpongeListener extends ViaListener {
|
|||||||
Via.getPlatform().getLogger().severe("Could not get the entity id, please report this on our Github");
|
Via.getPlatform().getLogger().severe("Could not get the entity id, please report this on our Github");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpongePlugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package us.myles.ViaVersion.sponge.platform;
|
package us.myles.ViaVersion.sponge.platform;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.spongepowered.api.scheduler.Task;
|
import org.spongepowered.api.scheduler.Task;
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
import us.myles.ViaVersion.api.platform.TaskId;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SpongeTaskId implements TaskId {
|
public class SpongeTaskId implements TaskId {
|
||||||
private Task object;
|
private final Task object;
|
||||||
|
|
||||||
|
public SpongeTaskId(Task object) {
|
||||||
|
this.object = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Task getObject() {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.sponge.platform;
|
package us.myles.ViaVersion.sponge.platform;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.ViaAPI;
|
import us.myles.ViaVersion.api.ViaAPI;
|
||||||
@ -19,12 +18,12 @@ import java.util.UUID;
|
|||||||
public class SpongeViaAPI implements ViaAPI<Player> {
|
public class SpongeViaAPI implements ViaAPI<Player> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull Player player) {
|
public int getPlayerVersion(Player player) {
|
||||||
return getPlayerVersion(player.getUniqueId());
|
return getPlayerVersion(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull UUID uuid) {
|
public int getPlayerVersion(UUID uuid) {
|
||||||
if (!isInjected(uuid))
|
if (!isInjected(uuid))
|
||||||
return ProtocolRegistry.SERVER_PROTOCOL;
|
return ProtocolRegistry.SERVER_PROTOCOL;
|
||||||
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
||||||
|
@ -11,13 +11,6 @@
|
|||||||
|
|
||||||
<artifactId>viaversion-velocity</artifactId>
|
<artifactId>viaversion-velocity</artifactId>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>velocity</id>
|
|
||||||
<url>https://repo.velocitypowered.com/snapshots</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -2,7 +2,6 @@ package us.myles.ViaVersion.velocity.command;
|
|||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
@ -10,9 +9,12 @@ import us.myles.ViaVersion.api.command.ViaCommandSender;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class VelocityCommandSender implements ViaCommandSender {
|
public class VelocityCommandSender implements ViaCommandSender {
|
||||||
private CommandSource source;
|
private final CommandSource source;
|
||||||
|
|
||||||
|
public VelocityCommandSender(CommandSource source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
|
@ -2,17 +2,19 @@ package us.myles.ViaVersion.velocity.handlers;
|
|||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class VelocityChannelInitializer extends ChannelInitializer {
|
public class VelocityChannelInitializer extends ChannelInitializer {
|
||||||
private ChannelInitializer original;
|
private final ChannelInitializer original;
|
||||||
private static Method initChannel;
|
private static Method initChannel;
|
||||||
|
|
||||||
|
public VelocityChannelInitializer(ChannelInitializer original) {
|
||||||
|
this.original = original;
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
initChannel = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
|
initChannel = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
|
||||||
|
@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -16,10 +15,13 @@ import us.myles.ViaVersion.util.PipelineUtil;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ChannelHandler.Sharable
|
@ChannelHandler.Sharable
|
||||||
@AllArgsConstructor
|
|
||||||
public class VelocityDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
public class VelocityDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
||||||
private final UserConnection info;
|
private final UserConnection info;
|
||||||
|
|
||||||
|
public VelocityDecodeHandler(UserConnection info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||||
// use transformers
|
// use transformers
|
||||||
|
@ -6,8 +6,6 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -20,11 +18,13 @@ import us.myles.ViaVersion.util.PipelineUtil;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ChannelHandler.Sharable
|
@ChannelHandler.Sharable
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class VelocityEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
public class VelocityEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||||
@NonNull
|
|
||||||
private final UserConnection info;
|
private final UserConnection info;
|
||||||
private boolean handledCompression = false;
|
private boolean handledCompression;
|
||||||
|
|
||||||
|
public VelocityEncodeHandler(UserConnection info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package us.myles.ViaVersion.velocity.platform;
|
package us.myles.ViaVersion.velocity.platform;
|
||||||
|
|
||||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
import us.myles.ViaVersion.api.platform.TaskId;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class VelocityTaskId implements TaskId {
|
public class VelocityTaskId implements TaskId {
|
||||||
private ScheduledTask object;
|
private final ScheduledTask object;
|
||||||
|
|
||||||
|
public VelocityTaskId(ScheduledTask object) {
|
||||||
|
this.object = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScheduledTask getObject() {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package us.myles.ViaVersion.velocity.platform;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.NonNull;
|
|
||||||
import us.myles.ViaVersion.VelocityPlugin;
|
import us.myles.ViaVersion.VelocityPlugin;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.ViaAPI;
|
import us.myles.ViaVersion.api.ViaAPI;
|
||||||
@ -20,15 +19,16 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class VelocityViaAPI implements ViaAPI<Player> {
|
public class VelocityViaAPI implements ViaAPI<Player> {
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull Player player) {
|
public int getPlayerVersion(Player player) {
|
||||||
if (!isInjected(player.getUniqueId()))
|
if (!isInjected(player.getUniqueId()))
|
||||||
return player.getProtocolVersion().getProtocol();
|
return player.getProtocolVersion().getProtocol();
|
||||||
return Via.getManager().getConnection(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull UUID uuid) {
|
public int getPlayerVersion(UUID uuid) {
|
||||||
return getPlayerVersion(VelocityPlugin.PROXY.getPlayer(uuid).orElseThrow(NoSuchElementException::new));
|
return getPlayerVersion(VelocityPlugin.PROXY.getPlayer(uuid).orElseThrow(NoSuchElementException::new));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.velocity.service;
|
package us.myles.ViaVersion.velocity.service;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import lombok.Getter;
|
|
||||||
import us.myles.ViaVersion.VelocityPlugin;
|
import us.myles.ViaVersion.VelocityPlugin;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
@ -13,7 +12,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class ProtocolDetectorService implements Runnable {
|
public class ProtocolDetectorService implements Runnable {
|
||||||
private static final Map<String, Integer> detectedProtocolIds = new ConcurrentHashMap<>();
|
private static final Map<String, Integer> detectedProtocolIds = new ConcurrentHashMap<>();
|
||||||
@Getter
|
|
||||||
private static ProtocolDetectorService instance;
|
private static ProtocolDetectorService instance;
|
||||||
|
|
||||||
public ProtocolDetectorService() {
|
public ProtocolDetectorService() {
|
||||||
@ -79,4 +77,7 @@ public class ProtocolDetectorService implements Runnable {
|
|||||||
return new HashMap<>(detectedProtocolIds);
|
return new HashMap<>(detectedProtocolIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ProtocolDetectorService getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren