Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Set some object fields to finals, use lambdas
Dieser Commit ist enthalten in:
Ursprung
c4b23b8c87
Commit
4542e9511b
@ -28,17 +28,17 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
||||||
|
|
||||||
private BukkitCommandHandler commandHandler;
|
private final BukkitCommandHandler commandHandler;
|
||||||
private boolean compatSpigotBuild = false;
|
private boolean compatSpigotBuild = false;
|
||||||
private boolean spigot = true;
|
private boolean spigot = true;
|
||||||
private boolean lateBind = false;
|
private boolean lateBind = false;
|
||||||
private boolean protocolSupport = false;
|
private boolean protocolSupport = false;
|
||||||
@Getter
|
@Getter
|
||||||
private BukkitViaConfig conf;
|
private final BukkitViaConfig conf;
|
||||||
@Getter
|
@Getter
|
||||||
private ViaAPI<Player> api = new BukkitViaAPI(this);
|
private final ViaAPI<Player> api = new BukkitViaAPI(this);
|
||||||
private List<Runnable> queuedTasks = new ArrayList<>();
|
private final List<Runnable> queuedTasks = new ArrayList<>();
|
||||||
private List<Runnable> asyncQueuedTasks = new ArrayList<>();
|
private final List<Runnable> asyncQueuedTasks = new ArrayList<>();
|
||||||
|
|
||||||
public ViaVersionPlugin() {
|
public ViaVersionPlugin() {
|
||||||
// Command handler
|
// Command handler
|
||||||
@ -238,7 +238,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
|||||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib.");
|
getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib.");
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConf().getReloadDisconnectMsg()));
|
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', conf.getReloadDisconnectMsg()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BukkitCommandSender implements ViaCommandSender {
|
public class BukkitCommandSender implements ViaCommandSender {
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
|
@ -23,12 +23,13 @@ public class PlayerSneakListener extends ViaBukkitListener {
|
|||||||
private static final float HEIGHT_1_9 = 1.6F;
|
private static final float HEIGHT_1_9 = 1.6F;
|
||||||
private static final float DEFAULT_WIDTH = 0.6F;
|
private static final float DEFAULT_WIDTH = 0.6F;
|
||||||
|
|
||||||
|
private final boolean is1_9Fix;
|
||||||
|
private final boolean is1_14Fix;
|
||||||
private Map<Player, Boolean> sneaking; // true = 1.14+, else false
|
private Map<Player, Boolean> sneaking; // true = 1.14+, else false
|
||||||
private Set<UUID> sneakingUuids;
|
private Set<UUID> sneakingUuids;
|
||||||
private Method getHandle;
|
private Method getHandle;
|
||||||
private Method setSize;
|
private Method setSize;
|
||||||
private boolean is1_9Fix;
|
|
||||||
private boolean is1_14Fix;
|
|
||||||
private boolean useCache;
|
private boolean useCache;
|
||||||
|
|
||||||
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) {
|
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) {
|
||||||
|
@ -13,12 +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 {
|
||||||
public static boolean CACHE = false;
|
private final Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||||
private static Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public static Item getHandItem(UUID player) {
|
|
||||||
return handCache.get(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -34,6 +29,10 @@ public class HandItemCache extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item getHandItem(UUID player) {
|
||||||
|
return handCache.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
public static Item convert(ItemStack itemInHand) {
|
public static Item convert(ItemStack itemInHand) {
|
||||||
if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null);
|
if (itemInHand == null) return new Item((short) 0, (byte) 0, (short) 0, null);
|
||||||
return new Item((short) itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null);
|
return new Item((short) itemInHand.getTypeId(), (byte) itemInHand.getAmount(), itemInHand.getDurability(), null);
|
||||||
|
@ -7,5 +7,5 @@ import us.myles.ViaVersion.api.platform.TaskId;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BukkitTaskId implements TaskId {
|
public class BukkitTaskId implements TaskId {
|
||||||
private Integer object;
|
private final Integer object;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BukkitViaAPI implements ViaAPI<Player>, ViaVersionAPI {
|
public class BukkitViaAPI implements ViaAPI<Player>, ViaVersionAPI {
|
||||||
private ViaVersionPlugin plugin;
|
private final ViaVersionPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerVersion(@NonNull Player player) {
|
public int getPlayerVersion(@NonNull Player player) {
|
||||||
|
@ -21,8 +21,8 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BukkitViaInjector implements ViaInjector {
|
public class BukkitViaInjector implements ViaInjector {
|
||||||
private List<ChannelFuture> injectedFutures = new ConcurrentList<>();
|
private final List<ChannelFuture> injectedFutures = new ConcurrentList<>();
|
||||||
private List<Pair<Field, Object>> injectedLists = new ConcurrentList<>();
|
private final List<Pair<Field, Object>> injectedLists = new ConcurrentList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inject() throws Exception {
|
public void inject() throws Exception {
|
||||||
|
@ -37,10 +37,12 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class BukkitViaLoader implements ViaPlatformLoader {
|
public class BukkitViaLoader implements ViaPlatformLoader {
|
||||||
private ViaVersionPlugin plugin;
|
private final ViaVersionPlugin plugin;
|
||||||
|
|
||||||
private Set<Listener> listeners = new HashSet<>();
|
private final Set<Listener> listeners = new HashSet<>();
|
||||||
private Set<BukkitTask> tasks = new HashSet<>();
|
private final Set<BukkitTask> tasks = new HashSet<>();
|
||||||
|
|
||||||
|
private HandItemCache handItemCache;
|
||||||
|
|
||||||
public BukkitViaLoader(ViaVersionPlugin plugin) {
|
public BukkitViaLoader(ViaVersionPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -94,8 +96,8 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
storeListener(new PaperPatch(plugin)).register();
|
storeListener(new PaperPatch(plugin)).register();
|
||||||
}
|
}
|
||||||
if (plugin.getConf().isItemCache()) {
|
if (plugin.getConf().isItemCache()) {
|
||||||
tasks.add(new HandItemCache().runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :)
|
handItemCache = new HandItemCache();
|
||||||
HandItemCache.CACHE = true;
|
tasks.add(handItemCache.runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Providers */
|
/* Providers */
|
||||||
@ -110,8 +112,8 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() {
|
Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() {
|
||||||
@Override
|
@Override
|
||||||
public Item getHandItem(final UserConnection info) {
|
public Item getHandItem(final UserConnection info) {
|
||||||
if (HandItemCache.CACHE) {
|
if (handItemCache != null) {
|
||||||
return HandItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid());
|
return handItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<Item>() {
|
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<Item>() {
|
||||||
|
@ -26,8 +26,8 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider {
|
public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider {
|
||||||
|
|
||||||
private static Map<UUID, BukkitInventoryUpdateTask> updateTasks = new ConcurrentHashMap<UUID, BukkitInventoryUpdateTask>();
|
private static final Map<UUID, BukkitInventoryUpdateTask> UPDATE_TASK = new ConcurrentHashMap<>();
|
||||||
private boolean supported;
|
private final boolean supported;
|
||||||
// packet class
|
// packet class
|
||||||
private Class<?> windowClickPacketClass;
|
private Class<?> windowClickPacketClass;
|
||||||
private Object clickTypeEnum;
|
private Object clickTypeEnum;
|
||||||
@ -65,11 +65,11 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
|
|||||||
}
|
}
|
||||||
ProtocolInfo info = userConnection.get(ProtocolInfo.class);
|
ProtocolInfo info = userConnection.get(ProtocolInfo.class);
|
||||||
UUID uuid = info.getUuid();
|
UUID uuid = info.getUuid();
|
||||||
BukkitInventoryUpdateTask updateTask = updateTasks.get(uuid);
|
BukkitInventoryUpdateTask updateTask = UPDATE_TASK.get(uuid);
|
||||||
final boolean registered = updateTask != null;
|
final boolean registered = updateTask != null;
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
updateTask = new BukkitInventoryUpdateTask(this, uuid);
|
updateTask = new BukkitInventoryUpdateTask(this, uuid);
|
||||||
updateTasks.put(uuid, updateTask);
|
UPDATE_TASK.put(uuid, updateTask);
|
||||||
}
|
}
|
||||||
// http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window
|
// http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window
|
||||||
updateTask.addItem(windowId, slotId, actionId);
|
updateTask.addItem(windowId, slotId, actionId);
|
||||||
@ -93,7 +93,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
|
|||||||
if (tinvtype == InventoryType.BREWING) {
|
if (tinvtype == InventoryType.BREWING) {
|
||||||
// 1.9 added the blaze powder slot to brewing stand fix for 1.8 servers
|
// 1.9 added the blaze powder slot to brewing stand fix for 1.8 servers
|
||||||
if (slotId >= 5 && slotId <= 40) {
|
if (slotId >= 5 && slotId <= 40) {
|
||||||
slotId = (short) (slotId - 1);
|
slotId -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTaskExecuted(UUID uuid) {
|
public void onTaskExecuted(UUID uuid) {
|
||||||
updateTasks.remove(uuid);
|
UPDATE_TASK.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupReflection() {
|
private void setupReflection() {
|
||||||
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class BukkitInventoryUpdateTask implements Runnable {
|
public class BukkitInventoryUpdateTask implements Runnable {
|
||||||
|
|
||||||
private BukkitInventoryQuickMoveProvider provider;
|
private final BukkitInventoryQuickMoveProvider provider;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final List<ItemTransaction> items;
|
private final List<ItemTransaction> items;
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package us.myles.ViaVersion.bukkit.util;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class NMSUtil {
|
public class NMSUtil {
|
||||||
private static String BASE = Bukkit.getServer().getClass().getPackage().getName();
|
private static final String BASE = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
private static String NMS = BASE.replace("org.bukkit.craftbukkit", "net.minecraft.server");
|
private static final String NMS = BASE.replace("org.bukkit.craftbukkit", "net.minecraft.server");
|
||||||
|
|
||||||
public static Class<?> nms(String className) throws ClassNotFoundException {
|
public static Class<?> nms(String className) throws ClassNotFoundException {
|
||||||
return Class.forName(NMS + "." + className);
|
return Class.forName(NMS + "." + className);
|
||||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
|
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
|
||||||
|
|
||||||
public AbstractViaConfig(File configFile) {
|
protected AbstractViaConfig(File configFile) {
|
||||||
super(configFile);
|
super(configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
@Getter
|
@Getter
|
||||||
public class ViaManager {
|
public class ViaManager {
|
||||||
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
|
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
|
||||||
private ViaPlatform platform;
|
private final ViaPlatform platform;
|
||||||
private ViaProviders providers = new ViaProviders();
|
private final ViaProviders providers = new ViaProviders();
|
||||||
@Setter
|
@Setter
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
// Internals
|
// Internals
|
||||||
private ViaInjector injector;
|
private final ViaInjector injector;
|
||||||
private ViaCommandHandler commandHandler;
|
private final ViaCommandHandler commandHandler;
|
||||||
private ViaPlatformLoader loader;
|
private final ViaPlatformLoader loader;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
public ViaManager(ViaPlatform platform, ViaInjector injector, ViaCommandHandler commandHandler, ViaPlatformLoader loader) {
|
public ViaManager(ViaPlatform platform, ViaInjector injector, ViaCommandHandler commandHandler, ViaPlatformLoader loader) {
|
||||||
@ -52,19 +52,14 @@ public class ViaManager {
|
|||||||
try {
|
try {
|
||||||
injector.inject();
|
injector.inject();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getPlatform().getLogger().severe("ViaVersion failed to inject:");
|
platform.getLogger().severe("ViaVersion failed to inject:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Mark as injected
|
// Mark as injected
|
||||||
System.setProperty("ViaVersion", getPlatform().getPluginVersion());
|
System.setProperty("ViaVersion", platform.getPluginVersion());
|
||||||
// If successful
|
// If successful
|
||||||
platform.runSync(new Runnable() {
|
platform.runSync(this::onServerLoaded);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
onServerLoaded();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,14 +68,14 @@ public class ViaManager {
|
|||||||
try {
|
try {
|
||||||
ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion();
|
ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getPlatform().getLogger().severe("ViaVersion failed to get the server protocol!");
|
platform.getLogger().severe("ViaVersion failed to get the server protocol!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Check if there are any pipes to this version
|
// Check if there are any pipes to this version
|
||||||
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
|
if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
|
||||||
getPlatform().getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL));
|
platform.getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL));
|
||||||
if (!ProtocolRegistry.isWorkingPipe()) {
|
if (!ProtocolRegistry.isWorkingPipe()) {
|
||||||
getPlatform().getLogger().warning("ViaVersion does not have any compatible versions for this server version, please read our resource page carefully.");
|
platform.getLogger().warning("ViaVersion does not have any compatible versions for this server version, please read our resource page carefully.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load Listeners / Tasks
|
// Load Listeners / Tasks
|
||||||
@ -95,11 +90,11 @@ public class ViaManager {
|
|||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// Uninject
|
// Uninject
|
||||||
getPlatform().getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting.");
|
platform.getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting.");
|
||||||
try {
|
try {
|
||||||
injector.uninject();
|
injector.uninject();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getPlatform().getLogger().severe("ViaVersion failed to uninject:");
|
platform.getLogger().severe("ViaVersion failed to uninject:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class StoredObject {
|
public class StoredObject {
|
||||||
private UserConnection user;
|
private final UserConnection user;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ public abstract class MetadataRewriter<T extends EntityType> {
|
|||||||
metadataMap = Collections.unmodifiableMap(metadataMap);
|
metadataMap = Collections.unmodifiableMap(metadataMap);
|
||||||
|
|
||||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||||
int oldId = metadata.getId();
|
|
||||||
try {
|
try {
|
||||||
handleMetadata(entityId, type, metadata, metadatas, metadataMap, connection);
|
handleMetadata(entityId, type, metadata, metadatas, metadataMap, connection);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -107,7 +107,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
|
|||||||
*/
|
*/
|
||||||
public void showHelp(ViaCommandSender sender) {
|
public void showHelp(ViaCommandSender sender) {
|
||||||
Set<ViaSubCommand> allowed = calculateAllowedCommands(sender);
|
Set<ViaSubCommand> allowed = calculateAllowedCommands(sender);
|
||||||
if (allowed.size() == 0) {
|
if (allowed.isEmpty()) {
|
||||||
sender.sendMessage(color("&cYou are not allowed to use these commands!"));
|
sender.sendMessage(color("&cYou are not allowed to use these commands!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InformativeException extends Exception {
|
public class InformativeException extends Exception {
|
||||||
final Map<String, Object> info = new HashMap<>();
|
private final Map<String, Object> info = new HashMap<>();
|
||||||
int sources = 0;
|
private int sources = 0;
|
||||||
|
|
||||||
public InformativeException(Throwable cause) {
|
public InformativeException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
@ -34,7 +34,7 @@ public class InformativeException extends Exception {
|
|||||||
builder.append("Please post this error to http://github.com/ViaVersion/ViaVersion/issues\n{");
|
builder.append("Please post this error to http://github.com/ViaVersion/ViaVersion/issues\n{");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<String, Object> entry : info.entrySet()) {
|
for (Map.Entry<String, Object> entry : info.entrySet()) {
|
||||||
builder.append((i == 0 ? "" : ", ") + entry.getKey() + ": " + entry.getValue().toString());
|
builder.append(i == 0 ? "" : ", ").append(entry.getKey()).append(": ").append(entry.getValue().toString());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
builder.append("}\nActual Error: ");
|
builder.append("}\nActual Error: ");
|
||||||
|
@ -10,8 +10,8 @@ import io.netty.util.concurrent.EventExecutor;
|
|||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
public class ChannelHandlerContextWrapper implements ChannelHandlerContext {
|
public class ChannelHandlerContextWrapper implements ChannelHandlerContext {
|
||||||
private ChannelHandlerContext base;
|
private final ChannelHandlerContext base;
|
||||||
private ViaHandler handler;
|
private final ViaHandler handler;
|
||||||
|
|
||||||
public ChannelHandlerContextWrapper(ChannelHandlerContext base, ViaHandler handler) {
|
public ChannelHandlerContextWrapper(ChannelHandlerContext base, ViaHandler handler) {
|
||||||
this.base = base;
|
this.base = base;
|
||||||
|
@ -150,10 +150,10 @@ public enum PacketType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private State state;
|
private final State state;
|
||||||
private Direction direction;
|
private final Direction direction;
|
||||||
private int packetID;
|
private final int packetID;
|
||||||
private int newPacketID = -1;
|
private final int newPacketID;
|
||||||
|
|
||||||
PacketType(State state, Direction direction, int packetID) {
|
PacketType(State state, Direction direction, int packetID) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
@ -17,45 +17,25 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class UpdateUtil {
|
public class UpdateUtil {
|
||||||
|
|
||||||
public final static String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
|
public static final String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
|
||||||
private final static String URL = "https://api.spiget.org/v2/resources/";
|
private static final String URL = "https://api.spiget.org/v2/resources/";
|
||||||
private final static int PLUGIN = 19254;
|
private static final int PLUGIN = 19254;
|
||||||
private final static String LATEST_VERSION = "/versions/latest";
|
private static final String LATEST_VERSION = "/versions/latest";
|
||||||
|
|
||||||
public static void sendUpdateMessage(final UUID uuid) {
|
public static void sendUpdateMessage(final UUID uuid) {
|
||||||
Via.getPlatform().runAsync(new Runnable() {
|
Via.getPlatform().runAsync(() -> {
|
||||||
@Override
|
final String message = getUpdateMessage(false);
|
||||||
public void run() {
|
if (message != null) {
|
||||||
final String message = getUpdateMessage(false);
|
Via.getPlatform().runSync(() -> Via.getPlatform().sendMessage(uuid, PREFIX + message));
|
||||||
if (message != null) {
|
|
||||||
Via.getPlatform().runSync(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Via.getPlatform().sendMessage(uuid, PREFIX + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendUpdateMessage() {
|
public static void sendUpdateMessage() {
|
||||||
Via.getPlatform().runAsync(new Runnable() {
|
Via.getPlatform().runAsync(() -> {
|
||||||
@Override
|
final String message = getUpdateMessage(true);
|
||||||
public void run() {
|
if (message != null) {
|
||||||
final String message = getUpdateMessage(true);
|
Via.getPlatform().runSync(() -> Via.getPlatform().getLogger().warning(message));
|
||||||
if (message != null) {
|
|
||||||
Via.getPlatform().runSync(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Via.getPlatform().getLogger().warning(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,15 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
|
||||||
public abstract class Config implements ConfigurationProvider {
|
public abstract class Config implements ConfigurationProvider {
|
||||||
private static final ThreadLocal<Yaml> YAML = new ThreadLocal<Yaml>() {
|
private static final ThreadLocal<Yaml> YAML = ThreadLocal.withInitial(() -> {
|
||||||
@Override
|
DumperOptions options = new DumperOptions();
|
||||||
protected Yaml initialValue() {
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
DumperOptions options = new DumperOptions();
|
options.setPrettyFlow(false);
|
||||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
options.setIndent(2);
|
||||||
options.setPrettyFlow(false);
|
return new Yaml(new YamlConstructor(), new Representer(), options);
|
||||||
options.setIndent(2);
|
});
|
||||||
return new Yaml(new YamlConstructor(), new Representer(), options);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private CommentStore commentStore = new CommentStore('.', 2);
|
private final CommentStore commentStore = new CommentStore('.', 2);
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
private ConcurrentSkipListMap<String, Object> config;
|
private ConcurrentSkipListMap<String, Object> config;
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren