mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 18:15:39 +01:00
Add /viaversion autoteam to toggle auto teaming for 1.8 colliding.
This commit is contained in:
parent
dac616d72c
commit
44907b3e8d
@ -28,6 +28,7 @@ public class ViaVersionCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion()));
|
sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion()));
|
||||||
sender.sendMessage(color("&6Commands:"));
|
sender.sendMessage(color("&6Commands:"));
|
||||||
sender.sendMessage(color("&2/viaversion list &7- &6Shows lists of all 1.9 clients and 1.8 clients."));
|
sender.sendMessage(color("&2/viaversion list &7- &6Shows lists of all 1.9 clients and 1.8 clients."));
|
||||||
|
sender.sendMessage(color("&2/viaversion autoteam &7- &6Toggle automatically teaming to prevent colliding."));
|
||||||
sender.sendMessage(color("&2/viaversion dontbugme &7- &6Toggle checking for updates."));
|
sender.sendMessage(color("&2/viaversion dontbugme &7- &6Toggle checking for updates."));
|
||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("list")) {
|
if (args[0].equalsIgnoreCase("list")) {
|
||||||
@ -54,6 +55,14 @@ public class ViaVersionCommand implements CommandExecutor {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
sender.sendMessage(color("&6We will " + (newValue ? "&anotify you about updates." : "&cnot tell you about updates.")));
|
sender.sendMessage(color("&6We will " + (newValue ? "&anotify you about updates." : "&cnot tell you about updates.")));
|
||||||
}
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("autoteam")) {
|
||||||
|
boolean newValue = !plugin.getConfig().getBoolean("auto-team", true);
|
||||||
|
plugin.getConfig().set("auto-team", newValue);
|
||||||
|
plugin.saveConfig();
|
||||||
|
sender.sendMessage(color("&6We will " + (newValue ? "&aautomatically team players" : "&cno longer auto team players")));
|
||||||
|
sender.sendMessage(color("&6All players will need to re-login for the change to take place."));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public class OutgoingTransformer {
|
|||||||
private final ConnectionInfo info;
|
private final ConnectionInfo info;
|
||||||
private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
private boolean autoTeam = false;
|
||||||
|
|
||||||
private Map<Integer, UUID> uuidMap = new HashMap<Integer, UUID>();
|
private Map<Integer, UUID> uuidMap = new HashMap<Integer, UUID>();
|
||||||
private Map<Integer, EntityType> clientEntityTypes = new HashMap<Integer, EntityType>();
|
private Map<Integer, EntityType> clientEntityTypes = new HashMap<Integer, EntityType>();
|
||||||
@ -550,6 +551,7 @@ public class OutgoingTransformer {
|
|||||||
output.writeBytes(input);
|
output.writeBytes(input);
|
||||||
// send fake team
|
// send fake team
|
||||||
if (plugin.isAutoTeam()) {
|
if (plugin.isAutoTeam()) {
|
||||||
|
autoTeam = true;
|
||||||
sendTeamPacket(true);
|
sendTeamPacket(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -627,7 +629,7 @@ public class OutgoingTransformer {
|
|||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
String name = PacketUtil.readString(input);
|
String name = PacketUtil.readString(input);
|
||||||
if (plugin.isAutoTeam() && name.equalsIgnoreCase(info.getUsername())) {
|
if (autoTeam && name.equalsIgnoreCase(info.getUsername())) {
|
||||||
if (mode == 4) {
|
if (mode == 4) {
|
||||||
// since removing add to auto team
|
// since removing add to auto team
|
||||||
plugin.run(new Runnable() {
|
plugin.run(new Runnable() {
|
||||||
@ -748,21 +750,7 @@ public class OutgoingTransformer {
|
|||||||
}
|
}
|
||||||
output.writeBytes(input);
|
output.writeBytes(input);
|
||||||
}
|
}
|
||||||
private void sendCreateTeam() {
|
|
||||||
ByteBuf buf = info.getChannel().alloc().buffer();
|
|
||||||
PacketUtil.writeVarInt(PacketType.PLAY_TEAM.getNewPacketID(), buf);
|
|
||||||
PacketUtil.writeString("viaversion", buf);
|
|
||||||
buf.writeByte(0); // make team
|
|
||||||
PacketUtil.writeString("viaversion", buf);
|
|
||||||
PacketUtil.writeString("", buf); // prefix
|
|
||||||
PacketUtil.writeString("", buf); // suffix
|
|
||||||
buf.writeByte(0); // friendly fire
|
|
||||||
PacketUtil.writeString("", buf); // nametags
|
|
||||||
PacketUtil.writeString("never", buf); // collision rule :)
|
|
||||||
buf.writeByte(0); // color
|
|
||||||
PacketUtil.writeVarInt(0, buf); // player count
|
|
||||||
info.sendRawPacket(buf);
|
|
||||||
}
|
|
||||||
private void sendTeamPacket(boolean b) {
|
private void sendTeamPacket(boolean b) {
|
||||||
ByteBuf buf = info.getChannel().alloc().buffer();
|
ByteBuf buf = info.getChannel().alloc().buffer();
|
||||||
PacketUtil.writeVarInt(PacketType.PLAY_TEAM.getNewPacketID(), buf);
|
PacketUtil.writeVarInt(PacketType.PLAY_TEAM.getNewPacketID(), buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user