Archiviert
1
0

Fix BauLock, 1.15 - 1.20.1 Tablist, Builderserver, BugCommand

Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Lixfel 2024-07-05 10:09:29 +02:00
Ursprung bacf366643
Commit d09f8edfa2
10 geänderte Dateien mit 75 neuen und 21 gelöschten Zeilen

@ -1 +1 @@
Subproject commit e76473e0beffe3df5c6d1c3430f62332b7371579
Subproject commit 1237a699ba244ecfac65478df34e714afbe2366e

Datei anzeigen

@ -184,7 +184,7 @@ UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8.
NOTE_TEAM={0} §e{1} §7received a §e§lnote§7 from §e{2} {3}: §f{4}
#BugCommand
BUG_MESSAGE=§7Your bugreport was saved.
BUG_MESSAGE=§7Please describe the issue in a Discord ticket with the bug ID §e{0} §7further§8.
#IgnoreCommand
IGNORE_YOURSELF=§cHow are you going to ignore yourself?

Datei anzeigen

@ -168,7 +168,7 @@ UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8.
NOTE_TEAM={0} §e{1} §7erhielt von §e{2} {3} §7die §e§lNotiz§7§8: §f{4}
#BugCommand
BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
BUG_MESSAGE=§7Bitte beschreibe das Problem in einem Discordticket genauer und gebe dabei die Bug-ID §e{0} §7an§8.
#IgnoreCommand
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?

Datei anzeigen

@ -214,7 +214,7 @@ public class ServerStarter {
directory = version.getServerDirectory("Builder");
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
worldName = map;
serverNameProvider = port -> map + "";
serverNameProvider = port -> "*" + map;
checkpoint = true;
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback);

Datei anzeigen

@ -93,17 +93,23 @@ public class BauCommand extends SWCommand {
@Validator(value = "teleportTarget", local = true)
public TypeValidator<SteamwarUser> teleportTargetValidator() {
return (sender, value, messageSender) -> {
if (value == null) {
return (sender, owner, messageSender) -> {
if (owner == null) {
messageSender.send("UNKNOWN_PLAYER");
return false;
}
if (sender.user().getId() != value.getId() && BauweltMember.getBauMember(value.getId(), sender.user().getId()) == null) {
SubserverSystem.sendDeniedMessage(sender, value.getUUID());
if (sender.user().getId() != owner.getId() && BauweltMember.getBauMember(owner.getId(), sender.user().getId()) == null) {
SubserverSystem.sendDeniedMessage(sender, owner.getUUID());
messageSender.send("BAU_TP_NOALLOWED");
return false;
}
return !BauLock.checkNotifyLocked(value, sender);
if (BauLock.isLocked(owner, sender.user())) {
messageSender.send("BAU_LOCKED_NOALLOWED");
Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender);
return false;
}
return true;
};
}

Datei anzeigen

@ -30,10 +30,10 @@ public class BugCommand extends SWCommand {
@Register
public void bugMessage(Chatter sender, String... message) {
SWException.log(
int id = SWException.logGetId(
String.join(" ", message),
sender.withPlayerOrOffline(player -> player.getCurrentServer().map(connection -> connection.getServerInfo().getName()).orElse("offline"), () -> "offline") + " " + sender.user().getUserName() + " " + sender.user().getId()
);
sender.system("BUG_MESSAGE");
sender.system("BUG_MESSAGE", id);
}
}

Datei anzeigen

@ -124,7 +124,9 @@ public class TpCommand extends SWCommand {
sender.system("JOIN_PLAYER_BLOCK");
return;
}
} else if (BauLock.checkNotifyLocked(SteamwarUser.get(bauserver.getOwner()), sender)) {
} else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) {
sender.system("BAU_LOCKED_NOALLOWED");
Chatter.of(bauserver.getOwner()).system("BAU_LOCK_BLOCKED", sender);
return;
} else if (!bauserver.getOwner().equals(sender.user().getUUID()) && BauweltMember.getBauMember(bauserver.getOwner(), sender.user().getUUID()) == null) {
SubserverSystem.sendDeniedMessage(sender, bauserver.getOwner());

Datei anzeigen

@ -19,12 +19,14 @@
package de.steamwar.velocitycore.tablist;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.network.Connections;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
@ -205,6 +207,40 @@ public class Tablist extends ChannelInboundHandlerAdapter {
directTabItems.remove(uuid);
}
}
} else if(msg instanceof LegacyPlayerListItemPacket packet) {
if(packet.getAction() == LegacyPlayerListItemPacket.ADD_PLAYER) {
for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) {
entry.setLatency(1).setPlayerKey(null);
if (!Storage.teamServers.containsValue(connection.getServerInfo())) {
entry.setDisplayName(Component.empty());
} else if (entry.getDisplayName() == null) {
entry.setDisplayName(Component.text(entry.getName()).color(NamedTextColor.GRAY));
}
UpsertPlayerInfoPacket.Entry newEntry = new UpsertPlayerInfoPacket.Entry(entry.getUuid());
newEntry.setProfile(new GameProfile(entry.getUuid(), entry.getName(), entry.getProperties()));
newEntry.setDisplayName(new ComponentHolder(player.getProtocolVersion(), entry.getDisplayName()));
newEntry.setListed(true);
synchronized (directTabItems) {
directTabItems.put(entry.getUuid(), newEntry);
}
}
} else if(packet.getAction() == LegacyPlayerListItemPacket.UPDATE_GAMEMODE) {
for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) {
if(!player.getUniqueId().equals(entry.getUuid()) && entry.getGameMode() == 3)
entry.setGameMode(1);
}
} else if(packet.getAction() == LegacyPlayerListItemPacket.REMOVE_PLAYER) {
for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) {
synchronized (directTabItems) {
directTabItems.remove(entry.getUuid());
}
}
} else {
ReferenceCountUtil.release(msg);
return;
}
}
ctx.fireChannelRead(msg);
@ -214,6 +250,23 @@ public class Tablist extends ChannelInboundHandlerAdapter {
if(items.isEmpty())
return;
if(player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_19_3)) {
int legacyAction = LegacyPlayerListItemPacket.REMOVE_PLAYER;
if(action == UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME)
legacyAction = LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME;
else if (action == UpsertPlayerInfoPacket.Action.ADD_PLAYER)
legacyAction = LegacyPlayerListItemPacket.ADD_PLAYER;
sendPacket(player, new LegacyPlayerListItemPacket(legacyAction, items.stream().map(item -> new LegacyPlayerListItemPacket
.Item(item.getProfileId())
.setName(item.getProfile().getName())
.setProperties(item.getProfile().getProperties())
.setDisplayName(item.getDisplayName().getComponent())
.setLatency(item.getLatency())
.setGameMode(item.getGameMode())).toList()));
return;
}
if(action == null) { //REMOVE
sendPacket(player, new RemovePlayerInfoPacket(items.stream().map(item -> item.getProfile().getId()).toList()));
return;

Datei anzeigen

@ -61,10 +61,10 @@ public class TablistManager extends BasicListener {
@Subscribe
public void onJoin(PostLoginEvent event) {
Tablist.sendPacket(event.getPlayer(), createTeamPacket);
synchronized (tablists) {
tablists.put(event.getPlayer(), new Tablist(event.getPlayer()));
}
Tablist.sendPacket(event.getPlayer(), createTeamPacket);
}
@Subscribe

Datei anzeigen

@ -34,8 +34,7 @@ public class BauLock {
owner.system("BAU_LOCKED_" + state.name());
}
public static boolean checkNotifyLocked(SteamwarUser owner, Chatter sender) {
SteamwarUser target = sender.user();
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
if (owner.getId() == target.getId())
return false;
@ -62,12 +61,6 @@ public class BauLock {
locked = false;
}
if(locked) {
sender.system("BAU_LOCKED_NOALLOWED");
Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender);
}
return locked;
}
}