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