Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8ac54e237 | ||
|
|
089e07fe49 | ||
|
|
1d3b8f802c | ||
|
|
27283e48a2 | ||
|
|
d22584afbc | ||
|
|
249ab01425 | ||
|
|
851097de44 | ||
|
|
c095a51f7c | ||
|
|
5e62b7001e | ||
|
|
8cc4ba168a | ||
|
|
264a21d092 | ||
|
|
e2585db350 | ||
|
|
a2f7a52d31 | ||
|
|
d04121202d | ||
|
|
95517ade2c | ||
|
|
c9441de7e4 | ||
|
|
dc946cb845 | ||
|
|
5fa30d9adb | ||
|
|
a7043424ec | ||
|
|
e1b3d21732 | ||
|
|
8ffc056a7e | ||
|
|
7c274fb03d | ||
|
|
3b533b5138 | ||
|
|
5665510f7e | ||
|
|
47faa21ef4 | ||
|
|
575f457830 | ||
|
|
d5bf7909e8 | ||
|
|
fdf90b7931 | ||
|
|
e3305e4eae | ||
|
|
15fe8d394e | ||
|
|
082db38c40 | ||
|
|
be54dc41d1 | ||
|
|
487e79c043 | ||
|
|
ef6390a0b8 | ||
|
|
9d9fc65633 | ||
|
|
6eac61c912 |
No files matched your search
@@ -1,12 +1,12 @@
|
||||
# ViaVersion 0.8.3
|
||||
# ViaVersion 0.9.2
|
||||
[](https://travis-ci.org/MylesIsCool/ViaVersion)
|
||||
[](https://gitter.im/MylesIsCool/ViaVersion)
|
||||
|
||||
## This is an experimental branch for 1.10, we do not recommend you to use this on a production server
|
||||
**Direct download link:** [Latest builds](https://ci.viaversion.com/job/ViaVersion%201.10%20DEV/)
|
||||
|
||||
**Allows the connection of 1.9 clients to 1.8**
|
||||
|
||||
This plugin modifies netty to allow connection of 1.9 clients to 1.8,
|
||||
|
||||
###*Don't use late bind*
|
||||
**1.10 clients on 1.8 / 1.9 servers**
|
||||
|
||||
This took 100s hours of work, so if you enjoy this consider looking into contacting me and supporting my projects.
|
||||
|
||||
@@ -54,14 +54,13 @@ https://www.spigotmc.org/resources/viaversion.19254/history
|
||||
|
||||
----------
|
||||
|
||||
You can find unofficial dev builds here:
|
||||
You can find official dev builds here:
|
||||
|
||||
**Terrobility's Build Server:** https://ci.terrocidepvp.net/job/ViaVersion/
|
||||
**Jenkins:** https://ci.viaversion.com
|
||||
|
||||
**sgdc3's Build Server:** http://ci.xephi.fr/job/ViaVersion/
|
||||
**sgdc3's Maven:** http://ci.xephi.fr/plugin/repository/everything/
|
||||
**JavaDocs:** https://jd.viaversion.com
|
||||
|
||||
**JavaDocs:** https://jd.matsv.nl/
|
||||
**Maven Repo:** https://repo.viaversion.com
|
||||
|
||||
License:
|
||||
--------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>0.8.4-SNAPSHOT</version>
|
||||
<version>0.9.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ViaVersion</name>
|
||||
@@ -136,6 +136,12 @@
|
||||
<id>spacehq-repo</id>
|
||||
<url>https://repo.spacehq.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
|
||||
<!-- Bungee repo -->
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -205,5 +211,13 @@
|
||||
<version>1.16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Bungeecord-->
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.RED;
|
||||
|
||||
public class Bungee extends Plugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().severe(RED + "===============================================");
|
||||
getLogger().severe(RED + "ViaVersion is NOT a Bungeecord plugin");
|
||||
getLogger().severe(RED + "Install this plugin on all your spigot/bukkit");
|
||||
getLogger().severe(RED + "servers and use the latest Bungeecord version");
|
||||
getLogger().severe(RED + "to make ViaVersion work with BungeeCord.");
|
||||
getLogger().severe(RED + "===============================================");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.util.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ViaConfig implements ViaVersionConfig {
|
||||
private final ViaVersionPlugin plugin;
|
||||
|
||||
public ViaConfig(ViaVersionPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
generateConfig();
|
||||
}
|
||||
|
||||
public void generateConfig() {
|
||||
File file = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (file.exists()) {
|
||||
// Update conf options
|
||||
Configuration oldConfig = new Configuration(file);
|
||||
oldConfig.reload(false); // Load current options from conf
|
||||
file.delete(); // Delete old conf
|
||||
plugin.saveDefaultConfig(); // Generate new conf
|
||||
Configuration newConfig = new Configuration(file);
|
||||
newConfig.reload(true); // Load default options
|
||||
for (String key : oldConfig.getKeys(false)) {
|
||||
// Set option in new conf if exists
|
||||
if (newConfig.contains(key)) {
|
||||
newConfig.set(key, oldConfig.get(key));
|
||||
}
|
||||
}
|
||||
newConfig.save();
|
||||
} else {
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckForUpdates() {
|
||||
return plugin.getConfig().getBoolean("checkforupdates", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventCollision() {
|
||||
return plugin.getConfig().getBoolean("prevent-collision", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewEffectIndicator() {
|
||||
return plugin.getConfig().getBoolean("use-new-effect-indicator", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return plugin.getConfig().getBoolean("use-new-deathmessages", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressMetadataErrors() {
|
||||
return plugin.getConfig().getBoolean("suppress-metadata-errors", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShieldBlocking() {
|
||||
return plugin.getConfig().getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHologramPatch() {
|
||||
return plugin.getConfig().getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return plugin.getConfig().getBoolean("bossbar-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarAntiflicker() {
|
||||
return plugin.getConfig().getBoolean("bossbar-anti-flicker", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnknownEntitiesSuppressed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHologramYOffset() {
|
||||
return plugin.getConfig().getDouble("hologram-y", -1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockBreakPatch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return plugin.getConfig().getInt("max-pps", 140);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxPPSKickMessage() {
|
||||
return plugin.getConfig().getString("max-pps-kick-msg", "Sending packets too fast? lag?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackingPeriod() {
|
||||
return plugin.getConfig().getInt("tracking-period", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningPPS() {
|
||||
return plugin.getConfig().getInt("tracking-warning-pps", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWarnings() {
|
||||
return plugin.getConfig().getInt("tracking-max-warnings", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxWarningsKickMessage() {
|
||||
return plugin.getConfig().getString("tracking-max-kick-msg", "You are sending too many packets, :(");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return plugin.getConfig().getBoolean("anti-xray-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSendSupportedVersions() {
|
||||
return plugin.getConfig().getBoolean("send-supported-versions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStimulatePlayerTick() {
|
||||
return plugin.getConfig().getBoolean("simulate-pt", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemCache() {
|
||||
return plugin.getConfig().getBoolean("item-cache", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSPlayerTicking() {
|
||||
return plugin.getConfig().getBoolean("nms-player-ticking", true);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && plugin.getConfig().getBoolean("auto-team", true);
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,15 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.ViaVersionAPI;
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
@@ -26,11 +27,9 @@ import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.update.UpdateListener;
|
||||
import us.myles.ViaVersion.update.UpdateUtil;
|
||||
import us.myles.ViaVersion.util.Configuration;
|
||||
import us.myles.ViaVersion.util.ListWrapper;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
@@ -39,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVersionConfig {
|
||||
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
|
||||
private final Map<UUID, UserConnection> portedPlayers = new ConcurrentHashMap<>();
|
||||
private List<ChannelFuture> injectedFutures = new ArrayList<>();
|
||||
@@ -48,12 +47,15 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
private boolean debug = false;
|
||||
private boolean compatSpigotBuild = false;
|
||||
private boolean spigot = true;
|
||||
private boolean lateBind = false;
|
||||
@Getter
|
||||
private ViaConfig conf;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
ViaVersion.setInstance(this);
|
||||
// Config magic
|
||||
generateConfig();
|
||||
conf = new ViaConfig(this);
|
||||
ViaVersion.setInstance(this);
|
||||
// Handle reloads
|
||||
if (System.getProperty("ViaVersion") != null) {
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
@@ -69,26 +71,30 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
}
|
||||
// Spigot detector
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
} catch (ClassNotFoundException e) {
|
||||
spigot = false;
|
||||
}
|
||||
// Check if it's a spigot build with a protocol mod
|
||||
try {
|
||||
compatSpigotBuild = ReflectionUtil.nms("PacketEncoder").getDeclaredField("version") != null;
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
compatSpigotBuild = false;
|
||||
}
|
||||
// Generate classes needed (only works if it's compat)
|
||||
ClassGenerator.generate();
|
||||
lateBind = !isBinded();
|
||||
|
||||
getLogger().info("ViaVersion " + getDescription().getVersion() + (compatSpigotBuild ? "compat" : "") + " is now loaded, injecting.");
|
||||
injectPacketHandler();
|
||||
getLogger().info("ViaVersion " + getDescription().getVersion() + (compatSpigotBuild ? "compat" : "") + " is now loaded" + (lateBind ? ", waiting for boot. (late-bind)" : ", injecting!"));
|
||||
if (!lateBind)
|
||||
injectPacketHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (isCheckForUpdates())
|
||||
if (lateBind)
|
||||
injectPacketHandler();
|
||||
if (conf.isCheckForUpdates())
|
||||
UpdateUtil.sendUpdateMessage(this);
|
||||
// Gather version :)
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@@ -116,7 +122,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
ProtocolRegistry.registerListeners();
|
||||
|
||||
// Warn them if they have anti-xray on and they aren't using spigot
|
||||
if(isAntiXRay() && !spigot){
|
||||
if (conf.isAntiXRay() && !spigot) {
|
||||
getLogger().info("You have anti-xray on in your config, since you're not using spigot it won't fix xray!");
|
||||
}
|
||||
}
|
||||
@@ -174,42 +180,25 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
}
|
||||
}
|
||||
|
||||
public void generateConfig() {
|
||||
File file = new File(getDataFolder(), "config.yml");
|
||||
if (file.exists()) {
|
||||
// Update config options
|
||||
Configuration oldConfig = new Configuration(file);
|
||||
oldConfig.reload(false); // Load current options from config
|
||||
file.delete(); // Delete old config
|
||||
saveDefaultConfig(); // Generate new config
|
||||
Configuration newConfig = new Configuration(file);
|
||||
newConfig.reload(true); // Load default options
|
||||
for (String key : oldConfig.getKeys(false)) {
|
||||
// Set option in new config if exists
|
||||
if (newConfig.contains(key)) {
|
||||
newConfig.set(key, oldConfig.get(key));
|
||||
public Object getServerConnection() throws Exception {
|
||||
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
|
||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||
Object connection = null;
|
||||
for (Method m : serverClazz.getDeclaredMethods()) {
|
||||
if (m.getReturnType() != null) {
|
||||
if (m.getReturnType().getSimpleName().equals("ServerConnection")) {
|
||||
if (m.getParameterTypes().length == 0) {
|
||||
connection = m.invoke(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
newConfig.save();
|
||||
} else {
|
||||
saveDefaultConfig();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public void injectPacketHandler() {
|
||||
try {
|
||||
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
|
||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||
Object connection = null;
|
||||
for (Method m : serverClazz.getDeclaredMethods()) {
|
||||
if (m.getReturnType() != null) {
|
||||
if (m.getReturnType().getSimpleName().equals("ServerConnection")) {
|
||||
if (m.getParameterTypes().length == 0) {
|
||||
connection = m.invoke(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Object connection = getServerConnection();
|
||||
if (connection == null) {
|
||||
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?");
|
||||
return;
|
||||
@@ -250,6 +239,33 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBinded() {
|
||||
try {
|
||||
Object connection = getServerConnection();
|
||||
if (connection == null) {
|
||||
return false;
|
||||
}
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
final Object value = field.get(connection);
|
||||
if (value instanceof List) {
|
||||
// Inject the list
|
||||
synchronized (value) {
|
||||
for (Object o : (List) value) {
|
||||
if (o instanceof ChannelFuture) {
|
||||
return true;
|
||||
} else {
|
||||
break; // not the right list.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void inject(ChannelFuture future) {
|
||||
try {
|
||||
ChannelHandler bootstrapAcceptor = future.channel().pipeline().first();
|
||||
@@ -260,11 +276,18 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
ReflectionUtil.set(bootstrapAcceptor, "childHandler", newInit);
|
||||
injectedFutures.add(future);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// field not found
|
||||
throw new Exception("Unable to find childHandler, blame " + bootstrapAcceptor.getClass().getName());
|
||||
// let's find who to blame!
|
||||
ClassLoader cl = bootstrapAcceptor.getClass().getClassLoader();
|
||||
if (cl.getClass().getName().equals("org.bukkit.plugin.java.PluginClassLoader")) {
|
||||
PluginDescriptionFile yaml = ReflectionUtil.get(cl, "description", PluginDescriptionFile.class);
|
||||
throw new Exception("Unable to inject, due to " + bootstrapAcceptor.getClass().getName() + ", try without the plugin " + yaml.getName() + "?");
|
||||
} else {
|
||||
throw new Exception("Unable to find childHandler, weird server version? " + bootstrapAcceptor.getClass().getName());
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Have you got late-bind enabled with something else? (ProtocolLib?)");
|
||||
getLogger().severe("Have you got late-bind enabled with something else?");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -385,100 +408,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
return this.spigot;
|
||||
}
|
||||
|
||||
public boolean isCheckForUpdates() {
|
||||
return getConfig().getBoolean("checkforupdates", true);
|
||||
}
|
||||
|
||||
public boolean isPreventCollision() {
|
||||
return getConfig().getBoolean("prevent-collision", true);
|
||||
}
|
||||
|
||||
public boolean isNewEffectIndicator() {
|
||||
return getConfig().getBoolean("use-new-effect-indicator", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return getConfig().getBoolean("use-new-deathmessages", false);
|
||||
}
|
||||
|
||||
public boolean isSuppressMetadataErrors() {
|
||||
return getConfig().getBoolean("suppress-metadata-errors", false);
|
||||
}
|
||||
|
||||
public boolean isShieldBlocking() {
|
||||
return getConfig().getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
public boolean isHologramPatch() {
|
||||
return getConfig().getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
public boolean isBossbarPatch() {
|
||||
return getConfig().getBoolean("bossbar-patch", true);
|
||||
}
|
||||
|
||||
public boolean isBossbarAntiflicker() {
|
||||
return getConfig().getBoolean("bossbar-anti-flicker", false);
|
||||
}
|
||||
|
||||
public boolean isUnknownEntitiesSuppressed() {
|
||||
return getConfig().getBoolean("suppress-entityid-errors", false);
|
||||
}
|
||||
|
||||
public double getHologramYOffset() {
|
||||
return getConfig().getDouble("hologram-y", -1D);
|
||||
}
|
||||
|
||||
public boolean isBlockBreakPatch() {
|
||||
return getConfig().getBoolean("block-break-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return getConfig().getInt("max-pps", 140);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxPPSKickMessage() {
|
||||
return getConfig().getString("max-pps-kick-msg", "Sending packets too fast? lag?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackingPeriod() {
|
||||
return getConfig().getInt("tracking-period", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningPPS() {
|
||||
return getConfig().getInt("tracking-warning-pps", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWarnings() {
|
||||
return getConfig().getInt("tracking-max-warnings", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxWarningsKickMessage() {
|
||||
return getConfig().getString("tracking-max-kick-msg", "You are sending too many packets, :(");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return getConfig().getBoolean("anti-xray-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSendSupportedVersions() {
|
||||
return getConfig().getBoolean("send-supported-versions", false);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && getConfig().getBoolean("auto-team", true);
|
||||
}
|
||||
|
||||
public void addPortedClient(UserConnection info) {
|
||||
portedPlayers.put(info.get(ProtocolInfo.class).getUuid(), info);
|
||||
}
|
||||
@@ -512,27 +441,27 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
|
||||
public boolean handlePPS(UserConnection info) {
|
||||
// Max PPS Checker
|
||||
if (getMaxPPS() > 0) {
|
||||
if (info.getPacketsPerSecond() >= getMaxPPS()) {
|
||||
info.disconnect(getMaxPPSKickMessage());
|
||||
if (conf.getMaxPPS() > 0) {
|
||||
if (info.getPacketsPerSecond() >= conf.getMaxPPS()) {
|
||||
info.disconnect(conf.getMaxPPSKickMessage());
|
||||
return true; // don't send current packet
|
||||
}
|
||||
}
|
||||
|
||||
// Tracking PPS Checker
|
||||
if (getMaxWarnings() > 0 && getTrackingPeriod() > 0) {
|
||||
if (info.getSecondsObserved() > getTrackingPeriod()) {
|
||||
if (conf.getMaxWarnings() > 0 && conf.getTrackingPeriod() > 0) {
|
||||
if (info.getSecondsObserved() > conf.getTrackingPeriod()) {
|
||||
// Reset
|
||||
info.setWarnings(0);
|
||||
info.setSecondsObserved(1);
|
||||
} else {
|
||||
info.setSecondsObserved(info.getSecondsObserved() + 1);
|
||||
if (info.getPacketsPerSecond() >= getWarningPPS()) {
|
||||
if (info.getPacketsPerSecond() >= conf.getWarningPPS()) {
|
||||
info.setWarnings(info.getWarnings() + 1);
|
||||
}
|
||||
|
||||
if (info.getWarnings() >= getMaxWarnings()) {
|
||||
info.disconnect(getMaxWarningsKickMessage());
|
||||
if (info.getWarnings() >= conf.getMaxWarnings()) {
|
||||
info.disconnect(conf.getMaxWarningsKickMessage());
|
||||
return true; // don't send current packet
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,10 @@ public class PacketWrapper {
|
||||
* Get a part from the output
|
||||
*
|
||||
* @param type The type of the part you wish to get.
|
||||
* @param <T> The return type of the type you wish to get.
|
||||
* @param index The index of the part (relative to the type)
|
||||
* @return The requested type or throws ArrayIndexOutOfBounds
|
||||
* @throws Exception If it fails to find it, an exception will be thrown.
|
||||
*/
|
||||
public <T> T get(Type<T> type, int index) throws Exception {
|
||||
int currentIndex = 0;
|
||||
@@ -80,8 +82,10 @@ public class PacketWrapper {
|
||||
* Set a currently existing part in the output
|
||||
*
|
||||
* @param type The type of the part you wish to set.
|
||||
* @param <T> The return type of the type you wish to set.
|
||||
* @param index The index of the part (relative to the type)
|
||||
* @param value The value of the part you wish to set it to.
|
||||
* @throws Exception If it fails to set it, an exception will be thrown.
|
||||
*/
|
||||
public <T> void set(Type<T> type, int index, T value) throws Exception {
|
||||
int currentIndex = 0;
|
||||
@@ -102,6 +106,7 @@ public class PacketWrapper {
|
||||
* Read a type from the input.
|
||||
*
|
||||
* @param type The type you wish to read
|
||||
* @param <T> The return type of the type you wish to read.
|
||||
* @return The requested type
|
||||
* @throws Exception If it fails to read
|
||||
*/
|
||||
@@ -134,6 +139,7 @@ public class PacketWrapper {
|
||||
* Write a type to the output.
|
||||
*
|
||||
* @param type The type to write.
|
||||
* @param <T> The return type of the type you wish to write.
|
||||
* @param value The value of the type to write.
|
||||
*/
|
||||
public <T> void write(Type<T> type, T value) {
|
||||
@@ -154,6 +160,7 @@ public class PacketWrapper {
|
||||
* Take a value from the input and write to the output.
|
||||
*
|
||||
* @param type The type to read and write.
|
||||
* @param <T> The return type of the type you wish to pass through.
|
||||
* @return The type which was read/written.
|
||||
* @throws Exception If it failed to read or write
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,6 @@ public class ViaVersion {
|
||||
public static void setInstance(ViaVersionPlugin plugin) {
|
||||
Validate.isTrue(instance == null, "Instance is already set");
|
||||
ViaVersion.instance = plugin;
|
||||
ViaVersion.config = plugin;
|
||||
ViaVersion.config = plugin.getConf();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public interface ViaVersionAPI {
|
||||
/**
|
||||
* Is player using 1.9?
|
||||
*
|
||||
* @param playerUUID
|
||||
* @param playerUUID UUID of a player
|
||||
* @return True if the client is on 1.9
|
||||
*/
|
||||
boolean isPorted(UUID playerUUID);
|
||||
|
||||
@@ -2,13 +2,6 @@ package us.myles.ViaVersion.api;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
|
||||
/**
|
||||
* Get if global debug is enabled
|
||||
*
|
||||
* @return true if debug is enabled
|
||||
*/
|
||||
boolean isDebug();
|
||||
|
||||
/**
|
||||
* Get if the plugin should check for updates
|
||||
*
|
||||
@@ -24,14 +17,14 @@ public interface ViaVersionConfig {
|
||||
boolean isPreventCollision();
|
||||
|
||||
/**
|
||||
* Get if 1.9 clients are shown the new effect indicator in the top-right corner
|
||||
* Get if 1.9 & 1.10 clients are shown the new effect indicator in the top-right corner
|
||||
*
|
||||
* @return true if the using of the new effect indicator is enabled
|
||||
*/
|
||||
boolean isNewEffectIndicator();
|
||||
|
||||
/**
|
||||
* Get if 1.9 clients are shown the new death message on the death screen
|
||||
* Get if 1.9 & 1.10 clients are shown the new death message on the death screen
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@@ -45,28 +38,28 @@ public interface ViaVersionConfig {
|
||||
boolean isSuppressMetadataErrors();
|
||||
|
||||
/**
|
||||
* Get if blocking in 1.9 appears as a player holding a shield
|
||||
* Get if blocking in 1.9 & 1.10 appears as a player holding a shield
|
||||
*
|
||||
* @return true if shield blocking is enabled
|
||||
*/
|
||||
boolean isShieldBlocking();
|
||||
|
||||
/**
|
||||
* Get if armor stand positions are fixed so holograms show up at the correct height in 1.9
|
||||
* Get if armor stand positions are fixed so holograms show up at the correct height in 1.9 & 1.10
|
||||
*
|
||||
* @return true if hologram patching is enabled
|
||||
*/
|
||||
boolean isHologramPatch();
|
||||
|
||||
/**
|
||||
* Get if boss bars are fixed for 1.9 clients
|
||||
* Get if boss bars are fixed for 1.9 & 1.10 clients
|
||||
*
|
||||
* @return true if boss bar patching is enabled
|
||||
*/
|
||||
boolean isBossbarPatch();
|
||||
|
||||
/**
|
||||
* Get if the boss bars for 1.9 clients are being stopped from flickering
|
||||
* Get if the boss bars for 1.9 & 1.10 clients are being stopped from flickering
|
||||
* This will keep all boss bars on 100% (not recommended)
|
||||
*
|
||||
* @return true if boss bar anti flickering is enabled
|
||||
@@ -78,6 +71,7 @@ public interface ViaVersionConfig {
|
||||
*
|
||||
* @return true if boss bar patching is enabled
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isUnknownEntitiesSuppressed();
|
||||
|
||||
/**
|
||||
@@ -99,6 +93,7 @@ public interface ViaVersionConfig {
|
||||
*
|
||||
* @return true if it is enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isBlockBreakPatch();
|
||||
|
||||
/**
|
||||
@@ -111,7 +106,7 @@ public interface ViaVersionConfig {
|
||||
/**
|
||||
* Get the kick message sent if the user hits the max packets per second.
|
||||
*
|
||||
* @return Kick message, with colour codes using '&'
|
||||
* @return Kick message, with colour codes using '&'
|
||||
*/
|
||||
String getMaxPPSKickMessage();
|
||||
|
||||
@@ -139,7 +134,7 @@ public interface ViaVersionConfig {
|
||||
/**
|
||||
* Get the kick message sent if the user goes over the warnings in the interval
|
||||
*
|
||||
* @return Kick message, with colour codes using '&'
|
||||
* @return Kick message, with colour codes using '&'
|
||||
*/
|
||||
String getMaxWarningsKickMessage();
|
||||
|
||||
@@ -156,4 +151,25 @@ public interface ViaVersionConfig {
|
||||
* @return If true, enabled
|
||||
*/
|
||||
boolean isSendSupportedVersions();
|
||||
|
||||
/**
|
||||
* Stimulate the player tick
|
||||
*
|
||||
* @return if true, enabled
|
||||
*/
|
||||
boolean isStimulatePlayerTick();
|
||||
|
||||
/**
|
||||
* Use the item cache to prevent high resource usage
|
||||
*
|
||||
* @return if true, enabled
|
||||
*/
|
||||
boolean isItemCache();
|
||||
|
||||
/**
|
||||
* Use the NMS player ticking
|
||||
*
|
||||
* @return if true, enabled
|
||||
*/
|
||||
boolean isNMSPlayerTicking();
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public interface BossBar {
|
||||
* Change the title
|
||||
*
|
||||
* @param title Title can be in either JSON or just text
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar setTitle(String title);
|
||||
|
||||
@@ -31,13 +32,14 @@ public interface BossBar {
|
||||
* Change the health
|
||||
*
|
||||
* @param health this float has to be between 0F - 1F
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar setHealth(float health);
|
||||
|
||||
/**
|
||||
* Get the bossbar color
|
||||
*
|
||||
* @return
|
||||
* @return The colour
|
||||
*/
|
||||
BossColor getColor();
|
||||
|
||||
@@ -45,6 +47,7 @@ public interface BossBar {
|
||||
* Yay colors!
|
||||
*
|
||||
* @param color Whatever color you want!
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar setColor(BossColor color);
|
||||
|
||||
@@ -59,13 +62,15 @@ public interface BossBar {
|
||||
* Change the bosbar style
|
||||
*
|
||||
* @param style BossStyle
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar setStyle(BossStyle style);
|
||||
|
||||
/**
|
||||
* Show the bossbar to a player.
|
||||
*
|
||||
* @param player
|
||||
* @param player The player
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar addPlayer(Player player);
|
||||
|
||||
@@ -73,7 +78,7 @@ public interface BossBar {
|
||||
* Show the bossbar to a player (uuid)
|
||||
*
|
||||
* @param player uuid of the player
|
||||
* @return the BossBar instance
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar addPlayer(UUID player);
|
||||
|
||||
@@ -81,34 +86,37 @@ public interface BossBar {
|
||||
* add multiple players
|
||||
*
|
||||
* @param players list of players
|
||||
* @return the bossbar instance
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar addPlayers(Player... players);
|
||||
|
||||
/**
|
||||
* Remove the bossbar from a player
|
||||
*
|
||||
* @param player
|
||||
* @param player The player
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar removePlayer(Player player);
|
||||
|
||||
/**
|
||||
* Add flags
|
||||
*
|
||||
* @param flag
|
||||
* @param flag The flag to add
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar addFlag(BossFlag flag);
|
||||
|
||||
/**
|
||||
* Remove flags.
|
||||
*
|
||||
* @param flag
|
||||
* @param flag The flag to remove
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar removeFlag(BossFlag flag);
|
||||
|
||||
/**
|
||||
* @param flag
|
||||
* @return
|
||||
* @param flag The flag to check against
|
||||
* @return True if it has the flag
|
||||
*/
|
||||
boolean hasFlag(BossFlag flag);
|
||||
|
||||
@@ -121,11 +129,15 @@ public interface BossBar {
|
||||
|
||||
/**
|
||||
* Show the bossbar to everyone (In the getPlayer set)
|
||||
*
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar show();
|
||||
|
||||
/**
|
||||
* Hide the bossbar from everyone (In the getPlayer set)
|
||||
*
|
||||
* @return The BossBar object
|
||||
*/
|
||||
BossBar hide();
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ public abstract class ViaSubCommand {
|
||||
/**
|
||||
* Subcommand name
|
||||
*
|
||||
* @return your input
|
||||
* @return The command name
|
||||
*/
|
||||
public abstract String name();
|
||||
|
||||
/**
|
||||
* subcommand description, this'll show in /viaversion list
|
||||
*
|
||||
* @return your input
|
||||
* @return The command description
|
||||
*/
|
||||
public abstract String description();
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class ViaSubCommand {
|
||||
* Usage example:
|
||||
* "playerversion [name]"
|
||||
*
|
||||
* @return your input
|
||||
* @return The command usage
|
||||
*/
|
||||
public String usage() {
|
||||
return name();
|
||||
@@ -34,7 +34,7 @@ public abstract class ViaSubCommand {
|
||||
/**
|
||||
* Permission, null for everyone
|
||||
*
|
||||
* @return
|
||||
* @return The permission required to use the command
|
||||
*/
|
||||
public String permission() {
|
||||
return "viaversion.admin";
|
||||
@@ -59,7 +59,7 @@ public abstract class ViaSubCommand {
|
||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public String color(String s) {
|
||||
return ViaCommandHandler.color(s);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public class UserConnection {
|
||||
* Get an object from the storage
|
||||
*
|
||||
* @param objectClass The class of the object to get
|
||||
* @param <T> The type of the class you want to get.
|
||||
* @return The requested object
|
||||
*/
|
||||
public <T extends StoredObject> T get(Class<T> objectClass) {
|
||||
@@ -102,6 +103,8 @@ public class UserConnection {
|
||||
|
||||
/**
|
||||
* Used for incrementing the number of packets received from the client
|
||||
*
|
||||
* @return True if the interval has reset
|
||||
*/
|
||||
public boolean incrementReceived() {
|
||||
// handle stats
|
||||
@@ -125,8 +128,8 @@ public class UserConnection {
|
||||
* @param reason The reason to use, not used if player is not active.
|
||||
*/
|
||||
public void disconnect(final String reason) {
|
||||
if(!getChannel().isOpen()) return;
|
||||
if(pendingDisconnect) return;
|
||||
if (!getChannel().isOpen()) return;
|
||||
if (pendingDisconnect) return;
|
||||
pendingDisconnect = true;
|
||||
if (get(ProtocolInfo.class).getUuid() != null) {
|
||||
final UUID uuid = get(ProtocolInfo.class).getUuid();
|
||||
|
||||
@@ -157,6 +157,7 @@ public class ChunkSection {
|
||||
* Get expected size of this chunk section.
|
||||
*
|
||||
* @return Amount of bytes sent by this section
|
||||
* @throws Exception If it failed to calculate bits properly
|
||||
*/
|
||||
public int getExpectedSize() throws Exception {
|
||||
int bitsPerBlock = palette.size() > 255 ? 16 : 8;
|
||||
|
||||
@@ -5,12 +5,12 @@ import com.google.common.collect.Sets;
|
||||
import org.bukkit.Bukkit;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3.Protocol1_9_1_2TO1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2TO1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.ProtocolSnapshotTo1_9_3;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -33,8 +33,8 @@ public class ProtocolRegistry {
|
||||
registerProtocol(new Protocol1_9_3TO1_9_1_2(), Arrays.asList(ProtocolVersion.v1_9_3.getId()), ProtocolVersion.v1_9_2.getId());
|
||||
// Only supported for 1.9.4 server to 1.9 (nothing else)
|
||||
registerProtocol(new Protocol1_9TO1_9_1(), Arrays.asList(ProtocolVersion.v1_9.getId()), ProtocolVersion.v1_9_2.getId());
|
||||
registerProtocol(new Protocol1_9_1_2TO1_9_3(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
registerProtocol(new ProtocolSnapshotTo1_9_3(), Collections.singletonList(ProtocolVersion.SNAPSHOT.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
registerProtocol(new Protocol1_9_1_2TO1_9_3_4(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
registerProtocol(new Protocol1_10To1_9_3_4(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_9_1;
|
||||
public static final ProtocolVersion v1_9_2;
|
||||
public static final ProtocolVersion v1_9_3;
|
||||
public static final ProtocolVersion SNAPSHOT;
|
||||
public static final ProtocolVersion v1_10;
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
@@ -29,8 +29,7 @@ public class ProtocolVersion {
|
||||
register(v1_9_1 = new ProtocolVersion(108, "1.9.1"));
|
||||
register(v1_9_2 = new ProtocolVersion(109, "1.9.2"));
|
||||
register(v1_9_3 = new ProtocolVersion(110, "1.9.3/4"));
|
||||
register(v1_9_3 = new ProtocolVersion(110, "1.9.3"));
|
||||
register(SNAPSHOT = new ProtocolVersion(201, "16w20a"));
|
||||
register(v1_10 = new ProtocolVersion(210, "1.10"));
|
||||
}
|
||||
|
||||
public static void register(@NonNull ProtocolVersion protocol) {
|
||||
@@ -50,6 +49,6 @@ public class ProtocolVersion {
|
||||
}
|
||||
|
||||
public static List<ProtocolVersion> getProtocols() {
|
||||
return Collections.unmodifiableList(new ArrayList<ProtocolVersion>(versions.values()));
|
||||
return Collections.unmodifiableList(new ArrayList<>(versions.values()));
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,9 @@ public abstract class PacketRemapper {
|
||||
* Map a type from an old type to a transformed new type.
|
||||
*
|
||||
* @param oldType The old type
|
||||
* @param <T1> The old return type.
|
||||
* @param transformer The transformer to use to produce the new type.
|
||||
* @param <T2> The new return type.
|
||||
*/
|
||||
public <T1, T2> void map(Type<T1> oldType, ValueTransformer<T1, T2> transformer) {
|
||||
map(new TypeRemapper(oldType), transformer);
|
||||
@@ -49,7 +51,8 @@ public abstract class PacketRemapper {
|
||||
* Map a type using a basic ValueReader to a ValueWriter
|
||||
*
|
||||
* @param inputReader The reader to read with.
|
||||
* @param outputWriter The writer to write with.
|
||||
* @param outputWriter The writer to write with
|
||||
* @param <T> The return type
|
||||
*/
|
||||
public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter) {
|
||||
valueRemappers.add(new Pair<ValueReader, ValueWriter>(inputReader, outputWriter));
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AutoTeamSubCmd extends ViaSubCommand {
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||
|
||||
boolean newValue = !plugin.isAutoTeam();
|
||||
boolean newValue = !ViaVersion.getConfig().isAutoTeam();
|
||||
plugin.getConfig().set("auto-team", newValue);
|
||||
plugin.saveConfig();
|
||||
sendMessage(sender, "&6We will %s", (newValue ? "&aautomatically team players" : "&cno longer auto team players"));
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DontBugMeSubCmd extends ViaSubCommand {
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||
|
||||
boolean newValue = !plugin.isCheckForUpdates();
|
||||
boolean newValue = !ViaVersion.getConfig().isCheckForUpdates();
|
||||
plugin.getConfig().set("checkforupdates", newValue);
|
||||
plugin.saveConfig();
|
||||
sendMessage(sender, "&6We will %snotify you about updates.", (newValue ? "&a" : "&cnot "));
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ReloadSubCmd extends ViaSubCommand {
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||
|
||||
plugin.generateConfig();
|
||||
plugin.getConf().generateConfig();
|
||||
sendMessage(sender, "&6Configuration successfully reloaded! Some features may need a restart.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
|
||||
boolean second = info.incrementReceived();
|
||||
// Check PPS
|
||||
if(second) {
|
||||
if (((ViaVersionPlugin) ViaVersion.getConfig()).handlePPS(info))
|
||||
if (((ViaVersionPlugin) ViaVersion.getInstance()).handlePPS(info))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+53
-11
@@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_10to1_9_3;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@@ -9,12 +9,15 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.MetaList1_10Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types.Meta1_10Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProtocolSnapshotTo1_9_3 extends Protocol {
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetaListSnapshotType();
|
||||
public static final Type<Metadata> METADATA = new MetaSnapshotType();
|
||||
public class Protocol1_10To1_9_3_4 extends Protocol {
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetaList1_10Type();
|
||||
public static final Type<Metadata> METADATA = new Meta1_10Type();
|
||||
public static ValueTransformer<Short, Float> toNewPitch = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
@@ -104,18 +107,57 @@ public class ProtocolSnapshotTo1_9_3 extends Protocol {
|
||||
map(METADATA_LIST); // 7 - Metadata list
|
||||
}
|
||||
});
|
||||
|
||||
// Packet Send ResourcePack
|
||||
registerOutgoing(State.PLAY, 0x32, 0x32, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - URL
|
||||
map(Type.STRING); // 1 - Hash
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class);
|
||||
tracker.setLastHash(wrapper.get(Type.STRING, 1)); // Store the hash for resourcepack status
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Packet ResourcePack status
|
||||
registerIncoming(State.PLAY, 0x16, 0x16, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class);
|
||||
wrapper.write(Type.STRING, tracker.getLastHash());
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getNewSoundId(int id) { //TODO organize things later
|
||||
if (id >= 24 && id <= 295) //One EnchantTable sound makes everything move between 24 and 295, blame the enchant table.
|
||||
return ++id;
|
||||
else if (id >= 296 && id < 443) //Blame the polar bear
|
||||
return id + 7;
|
||||
return id;
|
||||
public int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now.
|
||||
int newId = id;
|
||||
if (id >= 24) //Blame the enchantment table sound
|
||||
newId += 1;
|
||||
if (id >= 248) //Blame the husk
|
||||
newId += 4;
|
||||
if (id >= 296) //Blame the polar bear
|
||||
newId += 6;
|
||||
if (id >= 354) //Blame the stray
|
||||
newId += 4;
|
||||
if (id >= 372) //Blame the wither skeleton
|
||||
newId += 4;
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
userConnection.put(new ResourcePackTracker(userConnection));
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
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.UserConnection;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ResourcePackTracker extends StoredObject {
|
||||
private String lastHash = "";
|
||||
|
||||
public ResourcePackTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.MetaTypeTemplate;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType;
|
||||
|
||||
public class MetaSnapshotType extends MetaTypeTemplate {
|
||||
public class Meta1_10Type extends MetaTypeTemplate {
|
||||
|
||||
@Override
|
||||
public Metadata read(ByteBuf buffer) throws Exception {
|
||||
+7
-6
@@ -1,22 +1,23 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_10to1_9_3.types;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetaListSnapshotType extends MetaListTypeTemplate {
|
||||
public class MetaList1_10Type extends MetaListTypeTemplate {
|
||||
|
||||
@Override
|
||||
public List<Metadata> read(ByteBuf buffer) throws Exception {
|
||||
List<Metadata> list = new ArrayList<>();
|
||||
Metadata meta;
|
||||
do {
|
||||
meta = ProtocolSnapshotTo1_9_3.METADATA.read(buffer);
|
||||
meta = Protocol1_10To1_9_3_4.METADATA.read(buffer);
|
||||
if (meta != null)
|
||||
list.add(meta);
|
||||
} while (meta != null);
|
||||
@@ -30,11 +31,11 @@ public class MetaListSnapshotType extends MetaListTypeTemplate {
|
||||
if (m.getId() >= 5)
|
||||
m.setId(m.getId() + 1);
|
||||
if (m.getId() == 4)
|
||||
ProtocolSnapshotTo1_9_3.METADATA.write(buffer, new Metadata(5, NewType.Boolean.getTypeID(), Type.BOOLEAN, false)); // No gravity metadata
|
||||
ProtocolSnapshotTo1_9_3.METADATA.write(buffer, m);
|
||||
Protocol1_10To1_9_3_4.METADATA.write(buffer, new Metadata(5, NewType.Boolean.getTypeID(), Type.BOOLEAN, false)); // No gravity metadata
|
||||
Protocol1_10To1_9_3_4.METADATA.write(buffer, m);
|
||||
}
|
||||
|
||||
// Write end of list
|
||||
ProtocolSnapshotTo1_9_3.METADATA.write(buffer, null);
|
||||
Protocol1_10To1_9_3_4.METADATA.write(buffer, null);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Chunk1_9_3 {
|
||||
public class Chunk1_9_3_4 {
|
||||
private int x;
|
||||
private int z;
|
||||
private boolean groundUp;
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
@@ -7,13 +7,13 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_9_3Type extends Type<Chunk1_9_3> {
|
||||
public Chunk1_9_3Type() {
|
||||
super("1.9.3 Chunk", Chunk1_9_3.class);
|
||||
public class Chunk1_9_3_4Type extends Type<Chunk1_9_3_4> {
|
||||
public Chunk1_9_3_4Type() {
|
||||
super("1.9.3 Chunk", Chunk1_9_3_4.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk1_9_3 read(ByteBuf input) throws Exception {
|
||||
public Chunk1_9_3_4 read(ByteBuf input) throws Exception {
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
@@ -29,11 +29,11 @@ public class Chunk1_9_3Type extends Type<Chunk1_9_3> {
|
||||
for (int i = 0; i < blockEntities; i++) {
|
||||
nbtData.add(Type.NBT.read(input));
|
||||
}
|
||||
return new Chunk1_9_3(chunkX, chunkZ, groundUp, primaryBitmask, sections, nbtData);
|
||||
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Chunk1_9_3 chunk) throws Exception {
|
||||
public void write(ByteBuf buffer, Chunk1_9_3_4 chunk) throws Exception {
|
||||
buffer.writeInt(chunk.getX());
|
||||
buffer.writeInt(chunk.getZ());
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3;
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
|
||||
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
@@ -10,8 +10,8 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class Protocol1_9_1_2TO1_9_3 extends Protocol {
|
||||
public static Type<Chunk1_9_3> CHUNK = new Chunk1_9_3Type();
|
||||
public class Protocol1_9_1_2TO1_9_3_4 extends Protocol {
|
||||
public static Type<Chunk1_9_3_4> CHUNK = new Chunk1_9_3_4Type();
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
@@ -56,7 +56,7 @@ public class Protocol1_9_1_2TO1_9_3 extends Protocol {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Chunk1_9_3 chunk = wrapper.passthrough(CHUNK);
|
||||
Chunk1_9_3_4 chunk = wrapper.passthrough(CHUNK);
|
||||
BlockEntity.handle(chunk.getBlockEntities(), wrapper.user());
|
||||
}
|
||||
});
|
||||
@@ -102,9 +102,9 @@ public class Protocol1_9TO1_8 extends Protocol {
|
||||
plugin.getLogger().info("Enabling PaperSpigot patch: Fixes block placement.");
|
||||
Bukkit.getPluginManager().registerEvents(new PaperPatch(), plugin);
|
||||
}
|
||||
if (plugin.getConfig().getBoolean("simulate-pt", true))
|
||||
if (plugin.getConf().isStimulatePlayerTick())
|
||||
new ViaIdleThread(plugin.getPortedPlayers()).runTaskTimer(plugin, 1L, 1L); // Updates player's idle status
|
||||
if (plugin.getConfig().getBoolean("item-cache", true)) {
|
||||
if (plugin.getConf().isItemCache()) {
|
||||
new HandItemCache().runTaskTimerAsynchronously(plugin, 2L, 2L); // Updates player's items :)
|
||||
HandItemCache.CACHE = true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
@@ -30,7 +29,7 @@ public class ViaIdleThread extends BukkitRunnable {
|
||||
private Method handleFlying;
|
||||
|
||||
public ViaIdleThread(Map<UUID, UserConnection> portedPlayers) {
|
||||
USE_NMS = ((ViaVersionPlugin) ViaVersion.getInstance()).getConfig().getBoolean("nms-player-ticking", true);
|
||||
USE_NMS = ViaVersion.getConfig().isNMSPlayerTicking();
|
||||
|
||||
this.portedPlayers = portedPlayers;
|
||||
Class<?> idlePacketClass;
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
@@ -22,7 +23,7 @@ public class DeathListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
Player p = e.getEntity();
|
||||
if (plugin.isShowNewDeathMessages() && checkGamerule(p.getWorld()) && e.getDeathMessage() != null && checkPipeline(p)) {
|
||||
if (ViaVersion.getConfig().isShowNewDeathMessages() && checkGamerule(p.getWorld()) && e.getDeathMessage() != null && checkPipeline(p)) {
|
||||
sendPacket(p, e.getDeathMessage());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -184,9 +184,10 @@ public class EntityPackets {
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
if (tracker.getClientEntityTypes().containsKey(entityID)) {
|
||||
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
|
||||
} else if (!ViaVersion.getConfig().isUnknownEntitiesSuppressed() || ViaVersion.getInstance().isDebug()) {
|
||||
System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
|
||||
metadataList.clear();
|
||||
} else {
|
||||
// Buffer
|
||||
tracker.addMetadataToBuffer(entityID, metadataList);
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -207,8 +208,9 @@ 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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -243,9 +245,6 @@ public class EntityPackets {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// int id = wrapper.read(Type.VAR_INT);
|
||||
// CompoundTag tag = wrapper.read(Type.NBT);
|
||||
// System.out.println(id + " - " + tag);
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
+10
-2
@@ -12,6 +12,8 @@ import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
|
||||
@@ -55,6 +57,7 @@ public class SpawnPackets {
|
||||
int typeID = wrapper.get(Type.BYTE, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityUtil.getTypeFromID(typeID, true));
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,8 +106,8 @@ public class SpawnPackets {
|
||||
List<Metadata> meta = new ArrayList<>();
|
||||
Item item = new Item((short) Material.POTION.getId(), (byte) 1, (short) data, null);
|
||||
ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt
|
||||
|
||||
Metadata potion = new Metadata(5, NewType.Slot.getTypeID(), Type.ITEM, item);
|
||||
// TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS
|
||||
Metadata potion = new Metadata(wrapper.user().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) ? 6 : 5, NewType.Slot.getTypeID(), Type.ITEM, item);
|
||||
meta.add(potion);
|
||||
wrapper.write(Protocol1_9TO1_8.METADATA_LIST, meta);
|
||||
}
|
||||
@@ -129,6 +132,7 @@ public class SpawnPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityType.EXPERIENCE_ORB);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -154,6 +158,7 @@ public class SpawnPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityType.LIGHTNING);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,6 +192,7 @@ public class SpawnPackets {
|
||||
int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityUtil.getTypeFromID(typeID, false));
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -243,6 +249,7 @@ public class SpawnPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityType.PAINTING);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,6 +283,7 @@ public class SpawnPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityType.PLAYER);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ public enum SoundEffect {
|
||||
MOB_HORSE_WOOD("mob.horse.wood", "entity.horse.step_wood", SoundCategory.NEUTRAL),
|
||||
MOB_ZOMBIE_UNFECT("mob.zombie.unfect", "entity.zombie_villager.converted", SoundCategory.HOSTILE),
|
||||
RANDOM_ANVIL_USE("random.anvil_use", "block.anvil.use", SoundCategory.BLOCK),
|
||||
RANDOM_CHESTCLOSED("random.chestclosed", "block.enderchest.close", SoundCategory.BLOCK),
|
||||
RANDOM_CHESTCLOSED("random.chestclosed", "block.chest.close", SoundCategory.BLOCK),
|
||||
MOB_SHEEP_SHEAR("mob.sheep.shear", "entity.sheep.shear", SoundCategory.NEUTRAL),
|
||||
RANDOM_POP("random.pop", "entity.item.pickup", SoundCategory.PLAYER),
|
||||
MOB_BAT_DEATH("mob.bat.death", "entity.bat.death", SoundCategory.NEUTRAL),
|
||||
@@ -85,7 +85,7 @@ public enum SoundEffect {
|
||||
MOB_HORSE_SKELETON_DEATH("mob.horse.skeleton.death", "entity.skeleton_horse.death", SoundCategory.NEUTRAL),
|
||||
AMBIENT_WEATHER_RAIN("ambient.weather.rain", "weather.rain.above", SoundCategory.WEATHER),
|
||||
PORTAL_TRIGGER("portal.trigger", "block.portal.trigger", SoundCategory.BLOCK),
|
||||
RANDOM_CHESTOPEN("random.chestopen", "block.enderchest.open", SoundCategory.BLOCK),
|
||||
RANDOM_CHESTOPEN("random.chestopen", "block.chest.open", SoundCategory.BLOCK),
|
||||
MOB_HORSE_LAND("mob.horse.land", "entity.horse.land", SoundCategory.NEUTRAL),
|
||||
MOB_SILVERFISH_STEP("mob.silverfish.step", "entity.silverfish.step", SoundCategory.HOSTILE),
|
||||
MOB_BAT_TAKEOFF("mob.bat.takeoff", "entity.bat.takeoff", SoundCategory.NEUTRAL),
|
||||
|
||||
+45
-7
@@ -8,7 +8,6 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
@@ -21,7 +20,9 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType;
|
||||
|
||||
import java.util.*;
|
||||
@@ -32,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class EntityTracker extends StoredObject {
|
||||
private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, EntityType> clientEntityTypes = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Integer> vehicleMap = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, BossBar> bossBarMap = new ConcurrentHashMap<>();
|
||||
private final Set<Integer> validBlocking = Sets.newConcurrentHashSet();
|
||||
@@ -87,6 +89,7 @@ public class EntityTracker extends StoredObject {
|
||||
uuidMap.remove(entityID);
|
||||
validBlocking.remove(entityID);
|
||||
knownHolograms.remove(entityID);
|
||||
metadataBuffer.remove(entityID);
|
||||
|
||||
BossBar bar = bossBarMap.remove(entityID);
|
||||
if (bar != null) {
|
||||
@@ -113,7 +116,9 @@ public class EntityTracker extends StoredObject {
|
||||
}
|
||||
|
||||
public void handleMetadata(int entityID, List<Metadata> metadataList) {
|
||||
if (!clientEntityTypes.containsKey(entityID)) return;
|
||||
if (!clientEntityTypes.containsKey(entityID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityType type = clientEntityTypes.get(entityID);
|
||||
for (Metadata metadata : new ArrayList<>(metadataList)) {
|
||||
@@ -138,11 +143,18 @@ public class EntityTracker extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
//ECHOPET Patch
|
||||
if (type == EntityType.HORSE) {
|
||||
// Wrong metadata value from EchoPet, patch since it's discontinued. (https://github.com/DSH105/EchoPet/blob/06947a8b08ce40be9a518c2982af494b3b99d140/modules/API/src/main/java/com/dsh105/echopet/compat/api/entity/HorseArmour.java#L22)
|
||||
if (metadata.getId() == 16 && (int) metadata.getValue() == Integer.MIN_VALUE)
|
||||
metadata.setValue(0);
|
||||
}
|
||||
|
||||
if (type == EntityType.PLAYER) {
|
||||
if (metadata.getId() == 0) {
|
||||
// Byte
|
||||
byte data = (byte) metadata.getValue();
|
||||
if (entityID != getEntityID() && ((ViaVersionPlugin) ViaVersion.getInstance()).isShieldBlocking()) {
|
||||
if (entityID != getEntityID() && ViaVersion.getConfig().isShieldBlocking()) {
|
||||
if ((data & 0x10) == 0x10) {
|
||||
if (validBlocking.contains(entityID)) {
|
||||
Item shield = new Item((short) 442, (byte) 1, (short) 0, null);
|
||||
@@ -154,7 +166,7 @@ public class EntityTracker extends StoredObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == EntityType.ARMOR_STAND && ((ViaVersionPlugin) ViaVersion.getInstance()).isHologramPatch()) {
|
||||
if (type == EntityType.ARMOR_STAND && ViaVersion.getConfig().isHologramPatch()) {
|
||||
if (metadata.getId() == 0 && getMetaByIndex(metadataList, 10) != null) {
|
||||
Metadata meta = getMetaByIndex(metadataList, 10); //Only happens if the armorstand is small
|
||||
byte data = (byte) metadata.getValue();
|
||||
@@ -169,7 +181,7 @@ public class EntityTracker extends StoredObject {
|
||||
Type.VAR_INT.write(buf, 0x25); // Relative Move Packet
|
||||
Type.VAR_INT.write(buf, entityID);
|
||||
buf.writeShort(0);
|
||||
buf.writeShort((short) (128D * (((ViaVersionPlugin) ViaVersion.getInstance()).getHologramYOffset() * 32D)));
|
||||
buf.writeShort((short) (128D * (ViaVersion.getConfig().getHologramYOffset() * 32D)));
|
||||
buf.writeShort(0);
|
||||
buf.writeBoolean(true);
|
||||
getUser().sendRawPacket(buf, false);
|
||||
@@ -181,7 +193,7 @@ public class EntityTracker extends StoredObject {
|
||||
}
|
||||
UUID uuid = getUser().get(ProtocolInfo.class).getUuid();
|
||||
// Boss bar
|
||||
if (((ViaVersionPlugin) ViaVersion.getInstance()).isBossbarPatch()) {
|
||||
if (ViaVersion.getConfig().isBossbarPatch()) {
|
||||
if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
|
||||
if (metadata.getId() == 2) {
|
||||
BossBar bar = bossBarMap.get(entityID);
|
||||
@@ -195,7 +207,7 @@ public class EntityTracker extends StoredObject {
|
||||
} else {
|
||||
bar.setTitle(title);
|
||||
}
|
||||
} else if (metadata.getId() == 6 && !((ViaVersionPlugin) ViaVersion.getInstance()).isBossbarAntiflicker()) { // If anti flicker is enabled, don't update health
|
||||
} else if (metadata.getId() == 6 && !ViaVersion.getConfig().isBossbarAntiflicker()) { // If anti flicker is enabled, don't update health
|
||||
BossBar bar = bossBarMap.get(entityID);
|
||||
// Make health range between 0 and 1
|
||||
float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
|
||||
@@ -251,4 +263,30 @@ public class EntityTracker extends StoredObject {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addMetadataToBuffer(int entityID, List<Metadata> metadataList) {
|
||||
if (metadataBuffer.containsKey(entityID)) {
|
||||
metadataBuffer.get(entityID).addAll(metadataList);
|
||||
} else {
|
||||
metadataBuffer.put(entityID, metadataList);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMetadataBuffer(int entityID) {
|
||||
if (metadataBuffer.containsKey(entityID)) {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser());
|
||||
wrapper.write(Type.VAR_INT, entityID);
|
||||
wrapper.write(Protocol1_9TO1_8.METADATA_LIST, metadataBuffer.get(entityID));
|
||||
MetadataRewriter.transform(getClientEntityTypes().get(entityID), metadataBuffer.get(entityID));
|
||||
handleMetadata(entityID, metadataBuffer.get(entityID));
|
||||
if (metadataBuffer.get(entityID).size() > 0) {
|
||||
try {
|
||||
wrapper.send();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
metadataBuffer.remove(entityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class UpdateListener implements Listener {
|
||||
@@ -14,7 +15,7 @@ public class UpdateListener implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (e.getPlayer().hasPermission("viaversion.update")
|
||||
&& plugin.isCheckForUpdates()) {
|
||||
&& ViaVersion.getConfig().isCheckForUpdates()) {
|
||||
UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId(), plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
name: ViaVersion
|
||||
main: us.myles.ViaVersion.Bungee
|
||||
author: _MylesC
|
||||
version: ${project.version}
|
||||
@@ -38,7 +38,7 @@ tracking-max-warnings: 4
|
||||
tracking-max-kick-msg: "You are sending too many packets, :("
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
# 1.9 CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||
#----------------------------------------------------------#
|
||||
#
|
||||
# No collide options, these allow you to configure how collision works.
|
||||
@@ -48,7 +48,7 @@ prevent-collision: true
|
||||
auto-team: true
|
||||
# When enabled if certain metadata can't be read we won't tell you about it
|
||||
suppress-metadata-errors: false
|
||||
# When enabled 1.9 will be able to block by using shields
|
||||
# When enabled 1.9 & 1.10 will be able to block by using shields
|
||||
shield-blocking: true
|
||||
# Should we enable our hologram patch?
|
||||
# If they're in the wrong place enable this
|
||||
@@ -61,18 +61,13 @@ simulate-pt: true
|
||||
nms-player-ticking: true
|
||||
# Should we patch boss bars so they work? (Default: true, disable if you're having issues)
|
||||
bossbar-patch: true
|
||||
# If your boss bar flickers on 1.9, set this to 'true'. It will keep all boss bars on 100% (not recommended)
|
||||
# If your boss bar flickers on 1.9 & 1.10, set this to 'true'. It will keep all boss bars on 100% (not recommended)
|
||||
bossbar-anti-flicker: false
|
||||
# This will show the new effect indicator in the top-right corner for 1.9 players.
|
||||
# This will show the new effect indicator in the top-right corner for 1.9 & 1.10 players.
|
||||
use-new-effect-indicator: true
|
||||
# Show the new death messages for 1.9 on the death screen
|
||||
# Show the new death messages for 1.9 & 1.10 on the death screen
|
||||
use-new-deathmessages: false
|
||||
# This will suppress the following error: 'Unable to get entity for ID: xxxx'
|
||||
# This error message means one of you plugins is sending bad packets!
|
||||
suppress-entityid-errors: false
|
||||
# Our patch for block breaking issue, if you have issues with block updates then disable this.
|
||||
block-break-patch: true
|
||||
# Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items
|
||||
item-cache: true
|
||||
# Patch the Anti xray to work on 1.9 (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
|
||||
# Patch the Anti xray to work on 1.9 & 1.10 (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
|
||||
anti-xray-patch: true
|
||||
@@ -2,8 +2,8 @@ name: ViaVersion
|
||||
main: us.myles.ViaVersion.ViaVersionPlugin
|
||||
author: _MylesC
|
||||
version: ${project.version}
|
||||
load: startup
|
||||
loadbefore: [ProtocolLib, ProxyPipe, SpigotLib, PacketListenerApi]
|
||||
load: postworld
|
||||
loadbefore: [ProtocolLib, ProxyPipe, SpigotLib, PacketListenerApi, SkinRestorer]
|
||||
commands:
|
||||
viaversion:
|
||||
description: Shows ViaVersion Version and more.
|
||||
|
||||
Reference in new issue
Block a user