generated from LabyMod/addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from RappyLabyAddons/feat/activities
Add report activity
- Loading branch information
Showing
11 changed files
with
254 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
core/src/main/java/com/rappytv/globaltags/activities/ReportUUIDActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.rappytv.globaltags.activities; | ||
|
||
import com.rappytv.globaltags.GlobalTagAddon; | ||
import net.labymod.api.Laby; | ||
import net.labymod.api.client.component.Component; | ||
import net.labymod.api.client.component.format.NamedTextColor; | ||
import net.labymod.api.client.gui.icon.Icon; | ||
import net.labymod.api.client.gui.screen.Parent; | ||
import net.labymod.api.client.gui.screen.ScreenInstance; | ||
import net.labymod.api.client.gui.screen.activity.AutoActivity; | ||
import net.labymod.api.client.gui.screen.activity.Link; | ||
import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; | ||
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.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("report.lss") | ||
@AutoActivity | ||
public class ReportUUIDActivity extends SimpleActivity { | ||
|
||
private final GlobalTagAddon addon; | ||
private final UUID uuid; | ||
private final String username; | ||
|
||
public ReportUUIDActivity(GlobalTagAddon addon, UUID uuid, String username) { | ||
this.addon = addon; | ||
this.uuid = uuid; | ||
this.username = username; | ||
} | ||
|
||
@Override | ||
public void initialize(Parent parent) { | ||
super.initialize(parent); | ||
FlexibleContentWidget windowWidget = new FlexibleContentWidget().addId("window"); | ||
HorizontalListWidget profileWrapper = new HorizontalListWidget().addId("header"); | ||
IconWidget headWidget = new IconWidget(Icon.head(this.uuid)).addId("head"); | ||
ComponentWidget titleWidget = ComponentWidget.i18n("globaltags.report.title", this.username).addId("username"); | ||
VerticalListWidget<Widget> content = new VerticalListWidget<>().addId("content"); | ||
ComponentWidget reasonWidget = ComponentWidget.i18n("globaltags.report.reason").addId("reason"); | ||
TextFieldWidget textField = new TextFieldWidget() | ||
.placeholder(Component.translatable("globaltags.report.placeholder", NamedTextColor.DARK_GRAY)) | ||
.addId("text-field"); | ||
ButtonWidget button = new ButtonWidget() | ||
.updateComponent(Component.translatable("globaltags.report.send", NamedTextColor.RED)) | ||
.addId("report-button"); | ||
button.setEnabled(false); | ||
button.setActionListener(() -> { | ||
Laby.labyAPI().minecraft().minecraftWindow().displayScreen((ScreenInstance) null); | ||
addon.getApiHandler().reportPlayer(uuid, textField.getText()); | ||
}); | ||
textField.updateListener((text) -> button.setEnabled(!text.isBlank())); | ||
|
||
profileWrapper.addEntry(headWidget); | ||
profileWrapper.addEntry(titleWidget); | ||
|
||
content.addChild(reasonWidget); | ||
content.addChild(textField); | ||
content.addChild(button); | ||
|
||
windowWidget.addContent(profileWrapper); | ||
windowWidget.addContent(content); | ||
this.document.addChild(windowWidget); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
core/src/main/java/com/rappytv/globaltags/context/ReportContext.java
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
core/src/main/java/com/rappytv/globaltags/interaction/ReportBulletPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.rappytv.globaltags.interaction; | ||
|
||
import com.rappytv.globaltags.GlobalTagAddon; | ||
import com.rappytv.globaltags.activities.ReportUUIDActivity; | ||
import com.rappytv.globaltags.util.PlayerInfo; | ||
import com.rappytv.globaltags.util.TagCache; | ||
import net.labymod.api.Laby; | ||
import net.labymod.api.client.component.Component; | ||
import net.labymod.api.client.entity.player.Player; | ||
import net.labymod.api.client.entity.player.interaction.BulletPoint; | ||
import net.labymod.api.client.gui.icon.Icon; | ||
|
||
public class ReportBulletPoint implements BulletPoint { | ||
|
||
private final GlobalTagAddon addon; | ||
|
||
public ReportBulletPoint(GlobalTagAddon addon) { | ||
this.addon = addon; | ||
} | ||
|
||
@Override | ||
public Component getTitle() { | ||
return Component.translatable("globaltags.context.report"); | ||
} | ||
|
||
@Override | ||
public Icon getIcon() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void execute(Player player) { | ||
Laby.labyAPI().minecraft().executeNextTick(() -> | ||
Laby.labyAPI().minecraft().minecraftWindow().displayScreen(new ReportUUIDActivity(addon, player.getUniqueId(), player.getName())) | ||
); | ||
} | ||
|
||
@Override | ||
public boolean isVisible(Player player) { | ||
PlayerInfo playerInfo = TagCache.get(player.getUniqueId()); | ||
return playerInfo != null && playerInfo.getTag() != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
core/src/main/resources/assets/globaltags/themes/fancy/lss/report.lss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.window { | ||
left: 50%; | ||
top: 50%; | ||
width: 300; | ||
height: 180; | ||
alignment-x: center; | ||
alignment-y: center; | ||
# background-color: rgba(20, 20, 20, 0.9); | ||
# border: 1 dark_gray; | ||
|
||
.header { | ||
left: 50%; | ||
width: 100%; | ||
height: 20; | ||
padding: 0 2 0 2; | ||
space-between-entries: 2; | ||
# background-color: rgba(10, 10, 10, 0.4); | ||
|
||
.head { | ||
width: 16; | ||
height: width; | ||
alignment: center; | ||
} | ||
|
||
.username { | ||
alignment: center; | ||
} | ||
} | ||
|
||
.content { | ||
width: 100%; | ||
height: 100%; | ||
alignment-x: center; | ||
alignment-y: center; | ||
overwrite-width: false; | ||
|
||
.reason { | ||
margin-top: 40; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
|
||
.text-field { | ||
margin-top: 6; | ||
width: 200; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
|
||
.report-button { | ||
margin-top: 5; | ||
width: 50; | ||
height: 20; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
core/src/main/resources/assets/globaltags/themes/vanilla/lss/report.lss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.window { | ||
left: 50%; | ||
top: 50%; | ||
width: 300; | ||
height: 180; | ||
alignment-x: center; | ||
alignment-y: center; | ||
# background-color: rgba(20, 20, 20, 0.9); | ||
# border: 1 dark_gray; | ||
|
||
.header { | ||
left: 50%; | ||
width: 100%; | ||
height: 20; | ||
padding: 0 2 0 2; | ||
space-between-entries: 2; | ||
# background-color: rgba(10, 10, 10, 0.4); | ||
|
||
.head { | ||
width: 16; | ||
height: width; | ||
alignment: center; | ||
} | ||
|
||
.username { | ||
alignment: center; | ||
} | ||
} | ||
|
||
.content { | ||
width: 100%; | ||
height: 100%; | ||
alignment-x: center; | ||
alignment-y: center; | ||
overwrite-width: false; | ||
|
||
.reason { | ||
margin-top: 40; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
|
||
.text-field { | ||
margin-top: 6; | ||
width: 200; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
|
||
.report-button { | ||
margin-top: 5; | ||
width: 70; | ||
height: 20; | ||
alignment-x: center; | ||
alignment-y: center; | ||
} | ||
} | ||
} |