Fix PacketExControlPlayer

This commit is contained in:
ME1312 2022-05-28 05:59:33 -04:00
parent 1521acfc51
commit 307ac43df0
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
41 changed files with 74 additions and 101 deletions

View File

@ -27,8 +27,8 @@
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>22w16a</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -151,7 +151,7 @@ public class ExternalSubLogger extends SubLogger {
if (writer != null) {
PrintWriter writer = this.writer;
this.writer = null;
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
int l = (("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2;
String s = "";
while (s.length() < l) s += '-';
writer.println(s + " LOG END " + s);

View File

@ -174,7 +174,7 @@ public class InternalSubLogger extends SubLogger {
if (writer != null) {
PrintWriter writer = this.writer;
this.writer = null;
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
int l = (("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2;
String s = "";
while (s.length() < l) s += '-';
if (writer != null) {

View File

@ -28,8 +28,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
* @param plugin SubPlugin
*/
public PacketAddServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -26,8 +26,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
* @param plugin SubPlugin
*/
public PacketCommandServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -26,8 +26,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
*/
public PacketDeleteServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -24,8 +24,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
* @param plugin SubPlugin
*/
public PacketDownloadGroupInfo(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
@ -36,8 +35,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
* @param tracker Receiver ID
*/
public PacketDownloadGroupInfo(SubProxy plugin, List<String> groups, UUID tracker) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.tracker = tracker;
if (groups != null) {

View File

@ -26,8 +26,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
* @param plugin SubPlugin
*/
public PacketDownloadHostInfo(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
@ -38,8 +37,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
* @param tracker Receiver ID
*/
public PacketDownloadHostInfo(SubProxy plugin, List<String> hosts, UUID tracker) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.tracker = tracker;
if (hosts != null) {

View File

@ -26,8 +26,7 @@ public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, Packet
* @param plugin SubPlugin
*/
public PacketDownloadPlayerInfo(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
@ -39,8 +38,7 @@ public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, Packet
* @param tracker Receiver ID
*/
public PacketDownloadPlayerInfo(SubProxy plugin, List<String> names, List<UUID> ids, UUID tracker) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.tracker = tracker;
if (ids != null) {

View File

@ -26,8 +26,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
* @param plugin SubPlugin
*/
public PacketDownloadProxyInfo(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
@ -38,8 +37,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
* @param tracker Receiver ID
*/
public PacketDownloadProxyInfo(SubProxy plugin, List<String> proxies, UUID tracker) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.tracker = tracker;
if (proxies != null) {

View File

@ -26,8 +26,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
* @param plugin SubPlugin
*/
public PacketDownloadServerInfo(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
@ -38,8 +37,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
* @param tracker Receiver ID
*/
public PacketDownloadServerInfo(SubProxy plugin, List<String> servers, UUID tracker) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.tracker = tracker;
if (servers != null) {

View File

@ -27,8 +27,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
* @param plugin SubPlugin
*/
public PacketEditServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -72,7 +72,7 @@ public class PacketExControlServer implements PacketObjectIn<Integer>, PacketObj
this.args = new Object[type.getArguments().length];
for (int i = 0; i < type.getArguments().length; ++i) {
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getCanonicalName());
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getTypeName());
args[i] = arguments[i];
}
}

View File

@ -32,8 +32,7 @@ public class PacketExSyncPlayer implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
*/
public PacketExSyncPlayer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -31,8 +31,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubPlugin
*/
public PacketLinkExHost(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -32,8 +32,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubPlugin
*/
public PacketLinkProxy(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -45,8 +45,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubPlugin
*/
public PacketLinkServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -74,7 +74,7 @@ public class PacketOutExEditServer implements PacketObjectOut<Integer> {
this.args = new Object[type.getArguments().length];
for (int i = 0; i < type.getArguments().length; ++i) {
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getCanonicalName());
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getTypeName());
args[i] = arguments[i];
}
}

View File

@ -28,8 +28,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
* @param plugin
*/
public PacketOutExRunEvent(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -27,8 +27,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
*/
public PacketRemoveServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -26,8 +26,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
* @param plugin SubPlugin
*/
public PacketRestartServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -27,8 +27,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
* @param plugin SubPlugin
*/
public PacketStartServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -26,8 +26,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
* @param plugin SubPlugin
*/
public PacketStopServer(SubProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -49,8 +49,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
* @param plugin Event
*/
public DefaultUIHandler(SubPlugin plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
Bukkit.getPluginManager().registerEvents(this, plugin);
}

View File

@ -24,8 +24,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
* @param plugin SubServers.Client
*/
public PacketDownloadLang(SubPlugin plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -1,9 +1,11 @@
package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -14,13 +16,18 @@ import java.util.UUID;
* Player Control Packet
*/
public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private int response;
private UUID tracker;
/**
* New PacketExControlPlayer (In)
*
* @param plugin SubServers.Client
*/
public PacketExControlPlayer() {}
public PacketExControlPlayer(SubPlugin plugin) {
this.plugin = Util.nullpo(plugin);
}
/**
* New PacketExControlPlayer (Out)
@ -48,13 +55,15 @@ public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObj
String command = data.getString(0x0001);
UUID target = (data.contains(0x0002)?data.getUUID(0x0002):null);
CommandSender sender = Bukkit.getConsoleSender();
if (target != null && (sender = Bukkit.getPlayer(target)) == null) {
client.sendPacket(new PacketExControlPlayer(6, tracker));
} else {
Bukkit.getServer().dispatchCommand(sender, command);
client.sendPacket(new PacketExControlPlayer(0, tracker));
}
Bukkit.getScheduler().runTask(plugin, () -> {
CommandSender sender = Bukkit.getConsoleSender();
if (target != null && (sender = Bukkit.getPlayer(target)) == null) {
client.sendPacket(new PacketExControlPlayer(6, tracker));
} else {
Bukkit.getServer().dispatchCommand(sender, command);
client.sendPacket(new PacketExControlPlayer(0, tracker));
}
});
} catch (Throwable e) {
client.sendPacket(new PacketExControlPlayer(2, tracker));
e.printStackTrace();

View File

@ -24,8 +24,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubServers.Client
*/
public PacketLinkServer(SubPlugin plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
* New PacketLinkServer (Out)
@ -34,8 +33,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
* @param channel Channel ID
*/
public PacketLinkServer(SubPlugin plugin, int channel) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.channel = channel;
}

View File

@ -105,7 +105,7 @@ public class SubProtocol extends SubDataProtocol {
registerPacket(0x0070, new PacketInExRunEvent(plugin));
registerPacket(0x0071, new PacketInExReset());
registerPacket(0x0072, new PacketInExReload(plugin));
registerPacket(0x0078, new PacketExControlPlayer());
registerPacket(0x0078, new PacketExControlPlayer(plugin));
}
public static SubProtocol get() {

View File

@ -17,8 +17,8 @@
<dependencies>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>22w11a</version>
<artifactId>GalaxiBase</artifactId>
<version>22w16a</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -25,8 +25,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
* @param plugin SubServers.Client
*/
public PacketDownloadLang(SubPlugin plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -26,8 +26,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubServers.Client
*/
public PacketLinkServer(SubPlugin plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
* New PacketLinkServer (Out)
@ -36,8 +35,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
* @param channel Channel ID
*/
public PacketLinkServer(SubPlugin plugin, int channel) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.channel = channel;
}

View File

@ -236,12 +236,14 @@ public class HTMLogger extends AnsiOutputStream {
} else if (color < 16) {
return ANSI_BRIGHT_COLOR_MAP[color - 8];
} else if (color < 232) {
int r = (int) (Math.floor((color - 16) / 36d) * (255 / 5));
int g = (int) (Math.floor(((color - 16) % 36d) / 6d) * (255 / 5));
int b = (int) (Math.floor(((color - 16) % 36d) % 6d) * (255 / 5));
float x = color - 16;
int r = (int) ((x / 36f) * 51);
x = (x % 36f) ;
int g = (int) ((x / 6f) * 51);
int b = (int) ((x % 6f) * 51);
return ((r >= 16)?"":"0") + Integer.toString(r, 16) + ((g >= 16)?"":"0") + Integer.toString(g, 16) + ((b >= 16)?"":"0") + Integer.toString(b, 16);
} else if (color < 256) {
int gray = (int) ((255 / 25d) * (color - 232 + 1));
int gray = (int) (10.2f * (color - 231));
return ((gray >= 16)?"":"0") + Integer.toString(gray, 16) + ((gray >= 16)?"":"0") + Integer.toString(gray, 16) + ((gray >= 16)?"":"0") + Integer.toString(gray, 16);
} else {
throw new IOException("Invalid 8 Bit Color: " + color);

View File

@ -30,13 +30,13 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>22w11a</version>
<version>22w16a</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUI</artifactId>
<version>22w11a</version>
<version>22w16a</version>
<scope>runtime</scope>
</dependency>
<dependency>

View File

@ -235,7 +235,7 @@ public class SubLoggerImpl {
if (writer != null) {
PrintWriter writer = this.writer;
this.writer = null;
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
int l = (("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2;
String s = "";
while (s.length() < l) s += '-';
if (writer != null) {

View File

@ -64,7 +64,7 @@ public class PacketExControlServer implements PacketObjectIn<Integer>, PacketObj
this.args = new Object[type.getArguments().length];
for (int i = 0; i < type.getArguments().length; ++i) {
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getCanonicalName());
if (!type.getArguments()[i].isInstance(arguments[i])) throw new IllegalArgumentException("Argument " + (i+1) + " is not " + type.getArguments()[i].getTypeName());
args[i] = arguments[i];
}
}

View File

@ -23,8 +23,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
* @param plugin SubServers.Client
*/
public PacketDownloadLang(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -28,8 +28,7 @@ public class PacketExSyncPlayer implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
*/
public PacketExSyncPlayer(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -23,8 +23,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubServers.Client
*/
public PacketLinkProxy(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
* New PacketLinkProxy (Out)
@ -33,8 +32,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param channel Channel ID
*/
public PacketLinkProxy(ExProxy plugin, int channel) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.channel = channel;
}

View File

@ -23,8 +23,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
* @param plugin SubServers.Client
*/
public PacketDownloadLang(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -30,8 +30,7 @@ public class PacketExSyncPlayer implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
*/
public PacketExSyncPlayer(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**

View File

@ -23,8 +23,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubServers.Client
*/
public PacketLinkProxy(ExProxy plugin) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
}
/**
* New PacketLinkProxy (Out)
@ -33,8 +32,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param channel Channel ID
*/
public PacketLinkProxy(ExProxy plugin, int channel) {
Util.nullpo(plugin);
this.plugin = plugin;
this.plugin = Util.nullpo(plugin);
this.channel = channel;
}