Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

bug/UCA-809-player-list-sorting-fails-if-player-list-is-not-called-with-tab-key #810

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import com.rettichlp.unicacityaddon.base.teamspeak.TeamSpeakAPI;
import com.rettichlp.unicacityaddon.controller.DeadBodyController;
import com.rettichlp.unicacityaddon.controller.GuiController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import com.rettichlp.unicacityaddon.controller.ScreenshotController;
import com.rettichlp.unicacityaddon.controller.SoundController;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.TransportController;
import com.rettichlp.unicacityaddon.controller.WorldInteractionController;
import com.rettichlp.unicacityaddon.core.generated.DefaultReferenceStorage;
Expand Down Expand Up @@ -149,6 +149,10 @@ public DeadBodyController deadBodyController() {
return controller().getDeadBodyController();
}

public PlayerListController playerListController() {
return controller().getPlayerListController();
}

public ScreenshotController screenshotController() {
return controller().getScreenshotController();
}
Expand All @@ -157,10 +161,6 @@ public SoundController soundController() {
return controller().getSoundController();
}

public TabListController tabListController() {
return controller().getTabListController();
}

public TransportController transportController() {
return controller().getTransportController();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.rettichlp.unicacityaddon.badge;

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.config.tablist.TabListConfiguration;
import com.rettichlp.unicacityaddon.base.config.playerlist.PlayerListConfiguration;
import com.rettichlp.unicacityaddon.base.registry.annotation.UCBadge;
import net.labymod.api.client.entity.player.badge.renderer.BadgeRenderer;
import net.labymod.api.client.gui.icon.Icon;
Expand Down Expand Up @@ -32,8 +32,8 @@ public void render(Stack stack, float x, float y, NetworkPlayerInfo player) {

@Override
public boolean isVisible(NetworkPlayerInfo player) {
TabListConfiguration tabListConfiguration = this.unicacityAddon.configuration().tablist();
return this.unicacityAddon.utilService().isUnicacity() && tabListConfiguration.enabled().get() && tabListConfiguration.afk().get() && Optional.ofNullable(player.getTeam())
PlayerListConfiguration playerListConfiguration = this.unicacityAddon.configuration().playerlist();
return this.unicacityAddon.utilService().isUnicacity() && playerListConfiguration.enabled().get() && playerListConfiguration.afk().get() && Optional.ofNullable(player.getTeam())
.map(ScoreboardTeam::getTeamName)
.map(s -> s.equals("nopush"))
.orElse(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import com.rettichlp.unicacityaddon.base.config.message.MessageConfiguration;
import com.rettichlp.unicacityaddon.base.config.nametag.DefaultNameTagConfiguration;
import com.rettichlp.unicacityaddon.base.config.nametag.NameTagConfiguration;
import com.rettichlp.unicacityaddon.base.config.playerlist.DefaultPlayerListConfiguration;
import com.rettichlp.unicacityaddon.base.config.playerlist.PlayerListConfiguration;
import com.rettichlp.unicacityaddon.base.config.reinforcement.DefaultReinforcementConfiguration;
import com.rettichlp.unicacityaddon.base.config.reinforcement.ReinforcementConfiguration;
import com.rettichlp.unicacityaddon.base.config.sloc.DefaultSlocConfiguration;
import com.rettichlp.unicacityaddon.base.config.sloc.SlocConfiguration;
import com.rettichlp.unicacityaddon.base.config.tablist.DefaultTabListConfiguration;
import com.rettichlp.unicacityaddon.base.config.tablist.TabListConfiguration;
import com.rettichlp.unicacityaddon.base.config.teamspeak.DefaultTeamSpeakConfiguration;
import com.rettichlp.unicacityaddon.base.config.teamspeak.TeamSpeakConfiguration;
import net.labymod.api.addon.AddonConfig;
Expand Down Expand Up @@ -96,7 +96,7 @@ public class DefaultUnicacityAddonConfiguration extends AddonConfig implements U

@SwitchSetting
@SpriteSlot(y = 2)
private final DefaultTabListConfiguration tablist = new DefaultTabListConfiguration();
private final DefaultPlayerListConfiguration playerlist = new DefaultPlayerListConfiguration();

@SwitchSetting
@SpriteSlot(x = 1, y = 2)
Expand Down Expand Up @@ -190,8 +190,8 @@ public TeamSpeakConfiguration teamspeak() {
}

@Override
public TabListConfiguration tablist() {
return this.tablist;
public PlayerListConfiguration playerlist() {
return this.playerlist;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import com.rettichlp.unicacityaddon.base.config.join.PasswordConfiguration;
import com.rettichlp.unicacityaddon.base.config.message.MessageConfiguration;
import com.rettichlp.unicacityaddon.base.config.nametag.NameTagConfiguration;
import com.rettichlp.unicacityaddon.base.config.playerlist.PlayerListConfiguration;
import com.rettichlp.unicacityaddon.base.config.reinforcement.ReinforcementConfiguration;
import com.rettichlp.unicacityaddon.base.config.sloc.SlocConfiguration;
import com.rettichlp.unicacityaddon.base.config.tablist.TabListConfiguration;
import com.rettichlp.unicacityaddon.base.config.teamspeak.TeamSpeakConfiguration;
import net.labymod.api.configuration.loader.property.ConfigProperty;

Expand Down Expand Up @@ -63,7 +63,7 @@ public interface UnicacityAddonConfiguration {

TeamSpeakConfiguration teamspeak();

TabListConfiguration tablist();
PlayerListConfiguration playerlist();

ConfigProperty<Boolean> despawnTime();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rettichlp.unicacityaddon.base.config.tablist;
package com.rettichlp.unicacityaddon.base.config.playerlist;

import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
import net.labymod.api.configuration.loader.Config;
Expand All @@ -8,7 +8,7 @@
/**
* @author RettichLP
*/
public class DefaultTabListConfiguration extends Config implements TabListConfiguration {
public class DefaultPlayerListConfiguration extends Config implements PlayerListConfiguration {

@SwitchSetting
@ParentSwitch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.rettichlp.unicacityaddon.base.config.tablist;
package com.rettichlp.unicacityaddon.base.config.playerlist;

import net.labymod.api.configuration.loader.property.ConfigProperty;

/**
* @author RettichLP
*/
public interface TabListConfiguration {
public interface PlayerListConfiguration {

ConfigProperty<Boolean> enabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*/
@Nullable
@Referenceable
public abstract class TabListController {
public abstract class PlayerListController {

public abstract void orderTabList(UnicacityAddon unicacityAddon);
public abstract boolean isKeyPlayerListDown();

public abstract void orderPlayerList(UnicacityAddon unicacityAddon);
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ public void onKey(KeyEvent e) {

UnicacityAddonConfiguration configuration = this.unicacityAddon.configuration();
if (state.equals(KeyEvent.State.PRESS) && this.unicacityAddon.utilService().isUnicacity()) {
if (key.equals(Key.TAB) && !Laby.references().chatAccessor().isChatOpen() && configuration.tablist().enabled().get() && configuration.tablist().sorted().get()) {
boolean isKeyPlayerListDown = this.unicacityAddon.playerListController().isKeyPlayerListDown();
if (isKeyPlayerListDown && !Laby.references().chatAccessor().isChatOpen() && configuration.playerlist().enabled().get() && configuration.playerlist().sorted().get()) {
this.unicacityAddon.utilService().debug("Sorting tab list");
this.unicacityAddon.tabListController().orderTabList(this.unicacityAddon);
this.unicacityAddon.playerListController().orderPlayerList(this.unicacityAddon);
return;
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/main/resources/assets/unicacityaddon/i18n/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,14 @@
"name": "Support-Channel-betreten Nachricht"
}
},
"tablist": {
"name": "Tabliste",
"playerlist": {
"name": "Spieler-Liste",
"sorted": {
"name": "Sortierte Tabliste",
"description": "Sortiert die Tabliste nach Duty-Fraktionen, UC's, Buildern und aktiven Reports"
"name": "Sortierte Spieler-Liste",
"description": "Sortiert die Spieler-Liste nach Duty-Fraktionen, UC's, Buildern und aktiven Reports"
},
"afk": {
"name": "AFK Tag in Tabliste",
"name": "AFK Tag in Spieler-Liste",
"description": "Zeugt hinter AFK Spielern ein Icon an"
}
},
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/resources/assets/unicacityaddon/i18n/en_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,11 @@
"name": "Join support channel message"
}
},
"tablist": {
"name": "Tab list",
"playerlist": {
"name": "Player List",
"sorted": {
"name": "Sorted Tab List",
"description": "Sorts the tab list by duty factions, UC's, builders and active reports"
"name": "Sorted Player List",
"description": "Sorts the player list by duty factions, UC's, builders and active reports"
},
"afk": {
"name": "AFK Tag",
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/resources/assets/unicacityaddon/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,11 @@
"name": "Join support channel message"
}
},
"tablist": {
"name": "Tab List",
"playerlist": {
"name": "Player List",
"sorted": {
"name": "Sorted Tab List",
"description": "Sorts the tab list by duty factions, UC's, builders and active reports"
"name": "Sorted Player List",
"description": "Sorts the player list by duty factions, UC's, builders and active reports"
},
"afk": {
"name": "AFK Tag",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.tab.TabPrefix;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import net.labymod.api.Laby;
import net.labymod.api.client.gui.screen.key.Key;
import net.labymod.api.client.network.ClientPacketListener;
import net.labymod.api.client.network.NetworkPlayerInfo;
import net.labymod.api.models.Implements;
Expand All @@ -17,20 +18,28 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
* @author RettichLP
*/
@Singleton
@Implements(TabListController.class)
public class VersionedTabListController extends TabListController {
@Implements(PlayerListController.class)
public class VersionedPlayerListController extends PlayerListController {

@Inject
public VersionedTabListController() {
public VersionedPlayerListController() {
}

@Override
public void orderTabList(UnicacityAddon unicacityAddon) {
public boolean isKeyPlayerListDown() {
int playerListKeyCode = Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode();
return Optional.ofNullable(Laby.references().keyMapper().getKeyByKeyCode(playerListKeyCode))
.map(Key::isPressed).orElse(false);
}

@Override
public void orderPlayerList(UnicacityAddon unicacityAddon) {
ClientPacketListener clientPacketListener = Laby.labyAPI().minecraft().getClientPacketListener();
Collection<NetworkPlayerInfo> networkPlayerInfos = clientPacketListener != null ? clientPacketListener.getNetworkPlayerInfos() : Collections.emptyList();
assert Minecraft.getMinecraft().world != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.tab.TabPrefix;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import net.labymod.api.Laby;
import net.labymod.api.client.network.ClientPacketListener;
import net.labymod.api.client.network.NetworkPlayerInfo;
Expand All @@ -22,15 +22,20 @@
* @author RettichLP
*/
@Singleton
@Implements(TabListController.class)
public class VersionedTabListController extends TabListController {
@Implements(PlayerListController.class)
public class VersionedPlayerListController extends PlayerListController {

@Inject
public VersionedTabListController() {
public VersionedPlayerListController() {
}

@Override
public void orderTabList(UnicacityAddon unicacityAddon) {
public boolean isKeyPlayerListDown() {
return Minecraft.getInstance().options.keyPlayerList.isDown();
}

@Override
public void orderPlayerList(UnicacityAddon unicacityAddon) {
ClientPacketListener clientPacketListener = Laby.labyAPI().minecraft().getClientPacketListener();
Collection<NetworkPlayerInfo> networkPlayerInfos = clientPacketListener != null ? clientPacketListener.getNetworkPlayerInfos() : Collections.emptyList();
assert Minecraft.getInstance().level != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.tab.TabPrefix;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import net.labymod.api.Laby;
import net.labymod.api.client.network.ClientPacketListener;
import net.labymod.api.client.network.NetworkPlayerInfo;
Expand All @@ -22,15 +22,20 @@
* @author RettichLP
*/
@Singleton
@Implements(TabListController.class)
public class VersionedTabListController extends TabListController {
@Implements(PlayerListController.class)
public class VersionedPlayerListController extends PlayerListController {

@Inject
public VersionedTabListController() {
public VersionedPlayerListController() {
}

@Override
public void orderTabList(UnicacityAddon unicacityAddon) {
public boolean isKeyPlayerListDown() {
return Minecraft.getInstance().options.keyPlayerList.isDown();
}

@Override
public void orderPlayerList(UnicacityAddon unicacityAddon) {
ClientPacketListener clientPacketListener = Laby.labyAPI().minecraft().getClientPacketListener();
Collection<NetworkPlayerInfo> networkPlayerInfos = clientPacketListener != null ? clientPacketListener.getNetworkPlayerInfos() : Collections.emptyList();
assert Minecraft.getInstance().level != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.tab.TabPrefix;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import net.labymod.api.Laby;
import net.labymod.api.client.network.ClientPacketListener;
import net.labymod.api.client.network.NetworkPlayerInfo;
Expand All @@ -22,15 +22,20 @@
* @author RettichLP
*/
@Singleton
@Implements(TabListController.class)
public class VersionedTabListController extends TabListController {
@Implements(PlayerListController.class)
public class VersionedPlayerListController extends PlayerListController {

@Inject
public VersionedTabListController() {
public VersionedPlayerListController() {
}

@Override
public void orderTabList(UnicacityAddon unicacityAddon) {
public boolean isKeyPlayerListDown() {
return Minecraft.getInstance().options.keyPlayerList.isDown();
}

@Override
public void orderPlayerList(UnicacityAddon unicacityAddon) {
ClientPacketListener clientPacketListener = Laby.labyAPI().minecraft().getClientPacketListener();
Collection<NetworkPlayerInfo> networkPlayerInfos = clientPacketListener != null ? clientPacketListener.getNetworkPlayerInfos() : Collections.emptyList();
assert Minecraft.getInstance().level != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.tab.TabPrefix;
import com.rettichlp.unicacityaddon.controller.TabListController;
import com.rettichlp.unicacityaddon.controller.PlayerListController;
import net.labymod.api.Laby;
import net.labymod.api.client.network.ClientPacketListener;
import net.labymod.api.client.network.NetworkPlayerInfo;
Expand All @@ -22,15 +22,20 @@
* @author RettichLP
*/
@Singleton
@Implements(TabListController.class)
public class VersionedTabListController extends TabListController {
@Implements(PlayerListController.class)
public class VersionedPlayerListController extends PlayerListController {

@Inject
public VersionedTabListController() {
public VersionedPlayerListController() {
}

@Override
public void orderTabList(UnicacityAddon unicacityAddon) {
public boolean isKeyPlayerListDown() {
return Minecraft.getInstance().options.keyPlayerList.isDown();
}

@Override
public void orderPlayerList(UnicacityAddon unicacityAddon) {
ClientPacketListener clientPacketListener = Laby.labyAPI().minecraft().getClientPacketListener();
Collection<NetworkPlayerInfo> networkPlayerInfos = clientPacketListener != null ? clientPacketListener.getNetworkPlayerInfos() : Collections.emptyList();
assert Minecraft.getInstance().level != null;
Expand Down
Loading