Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.3.7 #93

Merged
merged 18 commits into from
Dec 26, 2024
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
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi
dependencies {
labyProcessor()
labyApi("api")
addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.2.0")
addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.2.1")
}

labyModAnnotationProcessor {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")
group = "org.example"
version = providers.environmentVariable("VERSION").getOrElse("1.3.6")
version = providers.environmentVariable("VERSION").getOrElse("1.3.7")

labyMod {
defaultPackageName = "com.rappytv.globaltags" //change this to your main package name (used by all modules)
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi
dependencies {
labyProcessor()
api(project(":api"))
addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.2.0")
addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.2.1")
}

labyModAnnotationProcessor {
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/com/rappytv/globaltags/GlobalTagAddon.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rappytv.globaltags;

import com.rappytv.globaltags.activities.ReferralLeaderboardActivity;
import com.rappytv.globaltags.api.GlobalTagAPI;
import com.rappytv.globaltags.command.GlobalTagCommand;
import com.rappytv.globaltags.config.GlobalTagConfig;
Expand All @@ -15,6 +16,7 @@
import com.rappytv.globaltags.listener.ServerNavigationListener;
import com.rappytv.globaltags.nametag.CustomTag;
import com.rappytv.globaltags.wrapper.GlobalTagsAPI.Agent;
import java.util.concurrent.TimeUnit;
import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.component.Component;
Expand All @@ -26,6 +28,7 @@
import net.labymod.api.client.resources.ResourceLocation;
import net.labymod.api.models.addon.annotation.AddonMain;
import net.labymod.api.revision.SimpleRevision;
import net.labymod.api.util.concurrent.task.Task;
import net.labymod.api.util.version.SemanticVersion;

@AddonMain
Expand Down Expand Up @@ -78,6 +81,13 @@ protected void enable() {
this.labyAPI().interactionMenuRegistry().register(new TagHistoryBulletPoint());
this.labyAPI().interactionMenuRegistry().register(new ToggleBanBulletPoint());
this.registerCommand(new GlobalTagCommand(this));

Task.builder(() -> api.getApiHandler().getReferralLeaderboards(response -> {
if (!response.isSuccessful()) {
return;
}
ReferralLeaderboardActivity.setLeaderboards(response.getData());
})).repeat(5, TimeUnit.MINUTES).build().run();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ public void initialize(Parent parent) {
.addId("input");
String reason = suspension.getReason();
if(reason != null) inputWidget.setText(reason, true);
ComponentWidget boxLabelWidget = ComponentWidget
.i18n("globaltags.context.editBan.appealable")
.addId("appealable-label");
HorizontalListWidget checkboxWrapper = new HorizontalListWidget().addId(
"checkbox-wrapper");
CheckBoxWidget checkBoxWidget = new CheckBoxWidget().addId("check-box");
checkBoxWidget.setState(suspension.isAppealable() ? State.CHECKED : State.UNCHECKED);
ComponentWidget boxLabelWidget = ComponentWidget
.i18n("globaltags.context.editBan.appealable")
.addId("checkbox-label");
ButtonWidget sendButton = new ButtonWidget()
.updateComponent(Component.translatable(
"globaltags.context.editBan.send",
Expand Down Expand Up @@ -108,10 +110,12 @@ public void initialize(Parent parent) {
profileWrapper.addEntry(headWidget);
profileWrapper.addEntry(titleWidget);

checkboxWrapper.addEntry(checkBoxWidget);
checkboxWrapper.addEntry(boxLabelWidget);

content.addChild(inputLabelWidget);
content.addChild(inputWidget);
content.addChild(boxLabelWidget);
content.addChild(checkBoxWidget);
content.addChild(checkboxWrapper);
content.addChild(sendButton);

windowWidget.addContent(profileWrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
@AutoActivity
public class ReferralLeaderboardActivity extends SimpleActivity {

private static Map<ReferralLeaderboardType, List<ReferralLeaderboardEntry>> leaderboards = null;
private final GlobalTagAPI api;
private final VerticalListWidget<ReferralLeaderboardEntryWidget> entries = new VerticalListWidget<>().addId(
"leaderboard-entries");
private final HorizontalListWidget buttonMenu;
private ReferralLeaderboardType selectedLeaderboard = ReferralLeaderboardType.TOTAL;
private Map<ReferralLeaderboardType, List<ReferralLeaderboardEntry>> leaderboards = null;

public ReferralLeaderboardActivity() {
this.api = GlobalTagAddon.getAPI();
this.buttonMenu = new HorizontalListWidget().addId("button-menu");
ButtonWidget totalViewButton = ButtonWidget.i18n(
"globaltags.settings.referralLeaderboards.activity.total");
Expand All @@ -57,10 +59,24 @@ public ReferralLeaderboardActivity() {
this.buttonMenu.addEntry(currentMonthViewButton);
}

public static void setLeaderboards(
Map<ReferralLeaderboardType, List<ReferralLeaderboardEntry>> leaderboards) {
ReferralLeaderboardActivity.leaderboards = leaderboards;
}

private void initializeWithInfo() {
if (ThreadSafe.isRenderThread()) {
this.initializeWithInfo(false);
} else {
Laby.labyAPI().minecraft().executeOnRenderThread(
() -> this.initializeWithInfo(true)
);
}
}

@Override
public void initialize(Parent parent) {
super.initialize(parent);
GlobalTagAPI api = GlobalTagAddon.getAPI();

FlexibleContentWidget container = new FlexibleContentWidget().addId("container");

Expand All @@ -69,38 +85,32 @@ public void initialize(Parent parent) {
container.addContent(scroll);
this.document.addChild(container);

api.getApiHandler().getReferralLeaderboards(response -> {
if (!response.isSuccessful()) {
Laby.labyAPI().minecraft().executeOnRenderThread(
() -> container.addContentInitialized(
ComponentWidget.text(response.getError(), NamedTextColor.RED)
.addId("error-component")
)
);
scroll.setVisible(false);
return;
}
this.leaderboards = response.getData();
this.initializeWithInfo();
});
}

private void initializeWithInfo() {
if (ThreadSafe.isRenderThread()) {
this.initializeWithInfo(false);
if (ReferralLeaderboardActivity.leaderboards == null) {
this.api.getApiHandler().getReferralLeaderboards(response -> {
if (!response.isSuccessful()) {
Laby.labyAPI().minecraft().executeOnRenderThread(
() -> container.addContentInitialized(
ComponentWidget.text(response.getError(), NamedTextColor.RED)
.addId("error-component")
)
);
scroll.setVisible(false);
return;
}
ReferralLeaderboardActivity.leaderboards = response.getData();
this.initializeWithInfo();
});
} else {
Laby.labyAPI().minecraft().executeOnRenderThread(
() -> this.initializeWithInfo(true)
);
this.initializeWithInfo();
}
}

private void initializeWithInfo(boolean initialized) {
this.entries.getChildren().clear();
if (this.leaderboards == null) {
if (leaderboards == null) {
return;
}
for (ReferralLeaderboardEntry entry : this.leaderboards.get(this.selectedLeaderboard)) {
for (ReferralLeaderboardEntry entry : leaderboards.get(this.selectedLeaderboard)) {
if (initialized) {
this.entries.addChildInitialized(new ReferralLeaderboardEntryWidget(entry));
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.rappytv.globaltags.activities;

import com.rappytv.globaltags.api.GlobalTagAPI;
import com.rappytv.globaltags.GlobalTagAddon;
import com.rappytv.globaltags.api.GlobalTagAPI;
import com.rappytv.globaltags.api.Util;
import java.util.UUID;
import java.util.function.Consumer;
import net.labymod.api.Laby;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.event.ClickEvent;
import net.labymod.api.client.component.event.HoverEvent;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.gui.icon.Icon;
import net.labymod.api.client.gui.screen.Parent;
Expand All @@ -15,12 +19,13 @@
import net.labymod.api.client.gui.screen.widget.Widget;
import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget;
import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget;
import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget;
import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget.State;
import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget;
import net.labymod.api.client.gui.screen.widget.widgets.layout.FlexibleContentWidget;
import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget;
import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget;
import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget;
import java.util.UUID;

@Link("input.lss")
@AutoActivity
Expand Down Expand Up @@ -48,6 +53,21 @@ public void initialize(Parent parent) {
TextFieldWidget inputWidget = new TextFieldWidget()
.placeholder(Component.translatable("globaltags.context.placeholder", NamedTextColor.DARK_GRAY))
.addId("input");
HorizontalListWidget checkboxWrapper = new HorizontalListWidget().addId("checkbox-wrapper");
CheckBoxWidget checkBoxWidget = new CheckBoxWidget().addId("check-box");
checkBoxWidget.setState(State.UNCHECKED);
Component boxLabel = Component.translatable(
"globaltags.context.report.checkbox.label",
NamedTextColor.WHITE,
Component.translatable("globaltags.context.report.checkbox.rules")
.color(NamedTextColor.AQUA)
.hoverEvent(HoverEvent.showText(
Component.translatable("globaltags.context.report.checkbox.hover")))
.clickEvent(ClickEvent.openUrl("https://docs.globaltags.xyz/rules"))
);
ComponentWidget boxLabelWidget = ComponentWidget
.component(boxLabel)
.addId("checkbox-label");
ButtonWidget sendButton = new ButtonWidget()
.updateComponent(Component.translatable("globaltags.context.report.send", NamedTextColor.RED))
.addId("send-button");
Expand All @@ -61,13 +81,23 @@ public void initialize(Parent parent) {
.append(Util.getResponseComponent(response))
));
});
inputWidget.updateListener((text) -> sendButton.setEnabled(!text.isBlank()));
Consumer<String> updateButton = (text) -> sendButton.setEnabled(
!text.isBlank() && checkBoxWidget.state() == State.CHECKED
);
inputWidget.updateListener(updateButton);
checkBoxWidget.setActionListener(() ->
updateButton.accept(inputWidget.getText())
);

profileWrapper.addEntry(headWidget);
profileWrapper.addEntry(titleWidget);

checkboxWrapper.addEntry(checkBoxWidget);
checkboxWrapper.addEntry(boxLabelWidget);

content.addChild(labelWidget);
content.addChild(inputWidget);
content.addChild(checkboxWrapper);
content.addChild(sendButton);

windowWidget.addContent(profileWrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ private void initializeWithInfo(PlayerInfo<Component> info, boolean refetched, b
);
}
addEntry.accept(tag);
if (info.getHighestRoleIcon() != null) {
if (info.getRoleIcon() != null) {
addEntry.accept(
new IconWidget(Icon.url(info.getHighestRoleIcon()))
new IconWidget(Icon.url(info.getRoleIcon()))
.addId("staff-icon")
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void render(Stack stack, Entity entity) {
9,
9
);
if(this.info.getHighestRoleIcon() != null) Icon.url(this.info.getHighestRoleIcon()).render(
if(this.info.getRoleIcon() != null) Icon.url(this.info.getRoleIcon()).render(
stack,
this.getWidth() + 0.9F,
-1.2F,
Expand Down
49 changes: 18 additions & 31 deletions core/src/main/resources/assets/globaltags/i18n/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,9 @@
"entries": {
"none": "Kein Icon",
"custom": "Custom",
"android": "",
"apple": "",
"bereal": "",
"crown": "Krone",
"discord": "",
"duolingo": "",
"ebio": "",
"epicgames": "",
"gamescom": "",
"github": "",
"gitlab": "",
"heart": "Herz",
"instagram": "",
"kick": "",
"labynet": "",
"paypal": "",
"pinterest": "",
"playstation": "",
"reddit": "",
"snapchat": "",
"soundcloud": "",
"spotify": "",
"star": "Stern",
"statsfm": "",
"steam": "",
"telegram": "Telegram",
"threads": "",
"tiktok": "",
"twitch": "",
"x": "",
"xbox": "",
"youtube": ""
"star": "Stern"
}
},
"updateSettings": {
Expand All @@ -121,6 +92,17 @@
"name": "Cache leeren",
"text": "Leeren",
"description": "Löscht den Tag-Cache manuell.\nDer Cache wird automatisch alle §b5 Minuten§f geleert.\nDu kannst den Cache auch mit §b/gt cc§f löschen."
},
"referralLeaderboards": {
"name": "Einladungsleaderboards",
"text": "Öffnen",
"activity": {
"total": "Insgesamt",
"current_month": "Diesen Monat",
"open": "laby.net Profil öffnen",
"loading": "Lädt…"
},
"description": "Zeigt Leaderboards der Spieler an, die die meisten Spieler zu GlobalTags eingeladen haben."
}
},
"general": {
Expand Down Expand Up @@ -165,7 +147,12 @@
"report": {
"name": "GlobalTag melden",
"title": "%s melden",
"send": "Meldung senden"
"send": "Meldung senden",
"checkbox": {
"label": "Dieser Tag bricht die %s.",
"rules": "GlobalTags Regeln",
"hover": "Klicke hier, um die GlobalTags Regeln zu öffnen."
}
},
"ban": {
"name": "GlobalTag-Spieler bannen",
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/resources/assets/globaltags/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"total": "Total",
"current_month": "This month",
"open": "Open laby.net profile",
"loading": "Loading..."
"loading": "Loading"
}
},
"showOwnTag": {
Expand Down Expand Up @@ -176,7 +176,12 @@
"report": {
"name": "Report GlobalTag",
"title": "Report %s",
"send": "Send report"
"send": "Send report",
"checkbox": {
"label": "This tag breaks the %s.",
"rules": "GlobalTags rules",
"hover": "Click here to open the GlobalTags rules."
}
},
"ban": {
"name": "Ban GlobalTag player",
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/assets/globaltags/i18n/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"none": "Ningún",
"custom": "Personalizado",
"heart": "Corazón",
"star": "Estrella"
"star": "Estrella",
"crown": "Corona"
}
},
"tag": {
Expand Down
Loading
Loading