Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Reformat / optimize imports (#344)
Dieser Commit ist enthalten in:
Ursprung
551b5d0654
Commit
f3ea43b1eb
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion;
|
package us.myles.ViaVersion;
|
||||||
|
|
||||||
import io.netty.channel.ChannelHandler;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -34,7 +33,7 @@ public class ViaIdleThread extends BukkitRunnable {
|
|||||||
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
||||||
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
||||||
ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
|
ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
|
||||||
if(info.getChannel().isOpen()) {
|
if (info.getChannel().isOpen()) {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
context.fireChannelRead(idlePacket);
|
context.fireChannelRead(idlePacket);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public interface BossBar {
|
|||||||
* @param players list of players
|
* @param players list of players
|
||||||
* @return the bossbar instance
|
* @return the bossbar instance
|
||||||
*/
|
*/
|
||||||
BossBar addPlayers(Player...players);
|
BossBar addPlayers(Player... players);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the bossbar from a player
|
* Remove the bossbar from a player
|
||||||
|
@ -67,11 +67,11 @@ public abstract class ViaSubCommand {
|
|||||||
/**
|
/**
|
||||||
* Send message formatted / colored
|
* Send message formatted / colored
|
||||||
*
|
*
|
||||||
* @param sender command sender
|
* @param sender command sender
|
||||||
* @param message string message
|
* @param message string message
|
||||||
* @param args optional objects
|
* @param args optional objects
|
||||||
*/
|
*/
|
||||||
public void sendMessage(CommandSender sender, String message, Object... args){
|
public void sendMessage(CommandSender sender, String message, Object... args) {
|
||||||
ViaCommandHandler.sendMessage(sender, message, args);
|
ViaCommandHandler.sendMessage(sender, message, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ package us.myles.ViaVersion.api.protocol;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import us.myles.ViaVersion.exception.CancelException;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
|
import us.myles.ViaVersion.exception.CancelException;
|
||||||
import us.myles.ViaVersion.packets.Direction;
|
import us.myles.ViaVersion.packets.Direction;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class DebugSubCmd extends ViaSubCommand {
|
|||||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
|
|
||||||
plugin.setDebug(!plugin.isDebug());
|
plugin.setDebug(!plugin.isDebug());
|
||||||
sendMessage(sender, "&6Debug mode is now %s" , (plugin.isDebug() ? "&aenabled" : "&cdisabled"));
|
sendMessage(sender, "&6Debug mode is now %s", (plugin.isDebug() ? "&aenabled" : "&cdisabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ public class InformativeException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getSource(Class<?> sourceClazz) {
|
private String getSource(Class<?> sourceClazz) {
|
||||||
if(sourceClazz.isAnonymousClass()){
|
if (sourceClazz.isAnonymousClass()) {
|
||||||
return sourceClazz.getName() + " (Anonymous)";
|
return sourceClazz.getName() + " (Anonymous)";
|
||||||
}else{
|
} else {
|
||||||
return sourceClazz.getName();
|
return sourceClazz.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,10 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
bytebuf.clear();
|
bytebuf.clear();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PacketWrapper wrapper = new PacketWrapper(id, oldPacket, info);
|
PacketWrapper wrapper = new PacketWrapper(id, oldPacket, info);
|
||||||
ProtocolInfo protInfo = info.get(ProtocolInfo.class);
|
ProtocolInfo protInfo = info.get(ProtocolInfo.class);
|
||||||
protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper);
|
protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper);
|
||||||
wrapper.writeToBuffer(bytebuf);
|
wrapper.writeToBuffer(bytebuf);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
bytebuf.clear();
|
bytebuf.clear();
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -100,7 +100,7 @@ public class Protocol1_9TO1_8 extends Protocol {
|
|||||||
Bukkit.getPluginManager().registerEvents(new ArmorListener(plugin), plugin);
|
Bukkit.getPluginManager().registerEvents(new ArmorListener(plugin), plugin);
|
||||||
Bukkit.getPluginManager().registerEvents(new CommandBlockListener(plugin), plugin);
|
Bukkit.getPluginManager().registerEvents(new CommandBlockListener(plugin), plugin);
|
||||||
Bukkit.getPluginManager().registerEvents(new BlockListener(plugin), plugin);
|
Bukkit.getPluginManager().registerEvents(new BlockListener(plugin), plugin);
|
||||||
if(Bukkit.getVersion().toLowerCase().contains("paper")){
|
if (Bukkit.getVersion().toLowerCase().contains("paper")) {
|
||||||
plugin.getLogger().info("Enabling PaperSpigot patch: Fixes block placement.");
|
plugin.getLogger().info("Enabling PaperSpigot patch: Fixes block placement.");
|
||||||
Bukkit.getPluginManager().registerEvents(new PaperPatch(), plugin);
|
Bukkit.getPluginManager().registerEvents(new PaperPatch(), plugin);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void placeBlock(BlockPlaceEvent e) {
|
public void placeBlock(BlockPlaceEvent e) {
|
||||||
if(plugin.isPorted(e.getPlayer())) {
|
if (plugin.isPorted(e.getPlayer())) {
|
||||||
UserConnection c = plugin.getConnection(e.getPlayer());
|
UserConnection c = plugin.getConnection(e.getPlayer());
|
||||||
if (!c.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
|
if (!c.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
|
||||||
Block b = e.getBlockPlaced();
|
Block b = e.getBlockPlaced();
|
||||||
|
@ -32,18 +32,18 @@ public class PaperPatch implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
if (e.getPlayer().getLocation().getBlock().getRelative(BlockFace.UP).equals(e.getBlock())) {
|
if (e.getPlayer().getLocation().getBlock().getRelative(BlockFace.UP).equals(e.getBlock())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}else{
|
} else {
|
||||||
// Within radius of block
|
// Within radius of block
|
||||||
if(Math.abs(diff.getX()) <= 0.8 && Math.abs(diff.getZ()) <= 0.8D){
|
if (Math.abs(diff.getX()) <= 0.8 && Math.abs(diff.getZ()) <= 0.8D) {
|
||||||
// Are they on the edge / shifting ish
|
// Are they on the edge / shifting ish
|
||||||
if(diff.getY() <= 0.1D && diff.getY() >= -0.1D){
|
if (diff.getY() <= 0.1D && diff.getY() >= -0.1D) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlockFace relative = e.getBlockAgainst().getFace(e.getBlock());
|
BlockFace relative = e.getBlockAgainst().getFace(e.getBlock());
|
||||||
// Are they towering up, (handles some latency)
|
// Are they towering up, (handles some latency)
|
||||||
if(relative == BlockFace.UP){
|
if (relative == BlockFace.UP) {
|
||||||
if(diff.getY() < 1D && diff.getY() >= 0D){
|
if (diff.getY() < 1D && diff.getY() >= 0D) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
|
||||||
import us.myles.ViaVersion.api.ViaVersion;
|
import us.myles.ViaVersion.api.ViaVersion;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
@ -207,7 +207,7 @@ public class EntityPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0);
|
List<Metadata> metadataList = wrapper.get(Protocol1_9TO1_8.METADATA_LIST, 0);
|
||||||
if(metadataList.size() == 0)
|
if (metadataList.size() == 0)
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Effect {
|
public class Effect {
|
||||||
@ -37,11 +34,11 @@ public class Effect {
|
|||||||
return effects.get(id);
|
return effects.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(int oldId){
|
public static boolean contains(int oldId) {
|
||||||
return effects.containsKey(oldId);
|
return effects.containsKey(oldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addRewrite(int oldId, int newId){
|
private static void addRewrite(int oldId, int newId) {
|
||||||
effects.put(oldId, newId);
|
effects.put(oldId, newId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,9 +260,10 @@ public enum SoundEffect {
|
|||||||
private final boolean breaksound;
|
private final boolean breaksound;
|
||||||
|
|
||||||
private static HashMap<String, SoundEffect> effects;
|
private static HashMap<String, SoundEffect> effects;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
effects = new HashMap<String, SoundEffect>();
|
effects = new HashMap<>();
|
||||||
for(SoundEffect e : SoundEffect.values()) {
|
for (SoundEffect e : SoundEffect.values()) {
|
||||||
effects.put(e.getName(), e);
|
effects.put(e.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +284,7 @@ public enum SoundEffect {
|
|||||||
|
|
||||||
public static SoundEffect getByName(String name) {
|
public static SoundEffect getByName(String name) {
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
if(effects.containsKey(name))
|
if (effects.containsKey(name))
|
||||||
return effects.get(name);
|
return effects.get(name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package us.myles.ViaVersion.util;
|
package us.myles.ViaVersion.util;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandler;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren