Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Add /viaversion autoteam to toggle auto teaming for 1.8 colliding.
Dieser Commit ist enthalten in:
Ursprung
dac616d72c
Commit
44907b3e8d
@ -28,6 +28,7 @@ public class ViaVersionCommand implements CommandExecutor {
|
||||
sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion()));
|
||||
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 autoteam &7- &6Toggle automatically teaming to prevent colliding."));
|
||||
sender.sendMessage(color("&2/viaversion dontbugme &7- &6Toggle checking for updates."));
|
||||
} else if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("list")) {
|
||||
@ -54,6 +55,14 @@ public class ViaVersionCommand implements CommandExecutor {
|
||||
plugin.saveConfig();
|
||||
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 ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||
private boolean cancel = false;
|
||||
private boolean autoTeam = false;
|
||||
|
||||
private Map<Integer, UUID> uuidMap = new HashMap<Integer, UUID>();
|
||||
private Map<Integer, EntityType> clientEntityTypes = new HashMap<Integer, EntityType>();
|
||||
@ -550,6 +551,7 @@ public class OutgoingTransformer {
|
||||
output.writeBytes(input);
|
||||
// send fake team
|
||||
if (plugin.isAutoTeam()) {
|
||||
autoTeam = true;
|
||||
sendTeamPacket(true);
|
||||
}
|
||||
return;
|
||||
@ -627,7 +629,7 @@ public class OutgoingTransformer {
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
String name = PacketUtil.readString(input);
|
||||
if (plugin.isAutoTeam() && name.equalsIgnoreCase(info.getUsername())) {
|
||||
if (autoTeam && name.equalsIgnoreCase(info.getUsername())) {
|
||||
if (mode == 4) {
|
||||
// since removing add to auto team
|
||||
plugin.run(new Runnable() {
|
||||
@ -748,21 +750,7 @@ public class OutgoingTransformer {
|
||||
}
|
||||
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) {
|
||||
ByteBuf buf = info.getChannel().alloc().buffer();
|
||||
PacketUtil.writeVarInt(PacketType.PLAY_TEAM.getNewPacketID(), buf);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren