3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Bai bai to more lombok usage once more

Dieser Commit ist enthalten in:
KennyTV 2020-04-13 20:58:24 +02:00
Ursprung fdb6137339
Commit 8f08a32c5a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
49 geänderte Dateien mit 750 neuen und 224 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,5 @@
package us.myles.ViaVersion.bukkit.listeners; package us.myles.ViaVersion.bukkit.listeners;
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;
@ -22,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());
} }

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
@ -29,12 +28,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 (!isPorted(uuid)) if (!isPorted(uuid))
return getExternalVersion(Bukkit.getPlayer(uuid)); return getExternalVersion(Bukkit.getPlayer(uuid));
return getPortedPlayers().get(uuid).get(ProtocolInfo.class).getProtocolVersion(); return getPortedPlayers().get(uuid).get(ProtocolInfo.class).getProtocolVersion();

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;
} }
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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()) {

Datei anzeigen

@ -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());
} }

Datei anzeigen

@ -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;

Datei anzeigen

@ -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)));
} }
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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 + '\'' +
'}';
}
} }

Datei anzeigen

@ -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 +
'}';
}
} }

Datei anzeigen

@ -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;
}
} }
} }

Datei anzeigen

@ -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;
}
} }
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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);
} }

Datei anzeigen

@ -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
* *

Datei anzeigen

@ -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)

Datei anzeigen

@ -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));

Datei anzeigen

@ -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;
}
} }
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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();
} }
} }

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -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;
@ -20,14 +19,14 @@ 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) {
if (!isPorted(player.getUniqueId())) if (!isPorted(player.getUniqueId()))
return ProtocolRegistry.SERVER_PROTOCOL; return ProtocolRegistry.SERVER_PROTOCOL;
return getPortedPlayers().get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion(); return getPortedPlayers().get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
} }
@Override @Override
public int getPlayerVersion(@NonNull UUID uuid) { public int getPlayerVersion(UUID uuid) {
if (!isPorted(uuid)) if (!isPorted(uuid))
return ProtocolRegistry.SERVER_PROTOCOL; return ProtocolRegistry.SERVER_PROTOCOL;
return getPortedPlayers().get(uuid).get(ProtocolInfo.class).getProtocolVersion(); return getPortedPlayers().get(uuid).get(ProtocolInfo.class).getProtocolVersion();

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);

Datei anzeigen

@ -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

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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;
}
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.InboundConnection; import com.velocitypowered.api.proxy.InboundConnection;
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;
@ -22,14 +21,14 @@ 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 (!isPorted(player.getUniqueId())) if (!isPorted(player.getUniqueId()))
return player.getProtocolVersion().getProtocol(); return player.getProtocolVersion().getProtocol();
return getPortedPlayers().get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion(); return getPortedPlayers().get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
} }
@Override @Override
public int getPlayerVersion(@NonNull UUID uuid) { public int getPlayerVersion(UUID uuid) {
if (!isPorted(uuid)) { if (!isPorted(uuid)) {
return VelocityPlugin.PROXY.getPlayer(uuid) return VelocityPlugin.PROXY.getPlayer(uuid)
.map(InboundConnection::getProtocolVersion) .map(InboundConnection::getProtocolVersion)

Datei anzeigen

@ -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;
}
} }