Skip to content

Commit f50e425

Browse files
committed
Update Hytale version and progressbar placeholders
Closes #55
1 parent ef035f8 commit f50e425

File tree

17 files changed

+111
-46
lines changed

17 files changed

+111
-46
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,31 @@ jobs:
1717

1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v6
2121

2222
- name: Setup JDK ${{ matrix.java-version }}
23-
uses: actions/setup-java@v4
23+
uses: actions/setup-java@v5
2424
with:
2525
distribution: temurin
2626
java-version: ${{ matrix.java-version }}
2727

2828
- name: Setup Gradle
29-
uses: gradle/actions/setup-gradle@v4
29+
uses: gradle/actions/setup-gradle@v6
30+
with:
31+
cache-provider: basic
3032

3133
- name: Build
3234
run: ./gradlew build
3335

3436
- name: Upload AzLink.jar
35-
uses: actions/upload-artifact@v4
37+
uses: actions/upload-artifact@v7
3638
with:
3739
name: AzLink
3840
path: universal/build/libs/AzLink-*.jar
3941
overwrite: true
4042

4143
- name: Upload AzLink-Legacy.jar
42-
uses: actions/upload-artifact@v4
44+
uses: actions/upload-artifact@v7
4345
with:
4446
name: AzLink-Legacy
4547
path: universal-legacy/build/libs/AzLink-Legacy-*.jar

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,24 @@ This plugin currently supports the following platforms:
1212
* [Velocity](https://velocitypowered.com/)
1313
* [Nukkit](https://cloudburstmc.org/articles/)
1414
* [Hytale](https://hytale.com/)
15+
* [Fabric](https://fabricmc.net/)
16+
* [Forge](https://files.minecraftforge.net/)
17+
* [NeoForge](https://neoforged.net/)
1518

1619
> [!NOTE]
17-
> NeoForge and Fabric versions of the plugin are available in the [dev/mods branch](https://github.com/Azuriom/AzLink/tree/dev/mods).
20+
> Code for Fabric, Forge and NeoForge versions of AzLink is available in the [dev/mods branch](https://github.com/Azuriom/AzLink/tree/dev/mods).
1821
1922
## Setup
2023

21-
### Installation
24+
### Download
2225

23-
The plugin works with the same .jar for all the platforms, except Bukkit/Spigot 1.7.10 which requires the legacy version of the plugin.
26+
The latest version of AzLink for _Minecraft: Java Edition_ can be downloaded on [Modrinth](https://modrinth.com/project/azuriom).
2427

25-
You just need to download the plugin, add it to the `plugins` folder of your server, and restart your server.
28+
For Nukkit and Hytale, you can download the plugin from the [GitHub Releases](https://github.com/Azuriom/AzLink/releases).
29+
30+
## Installation
31+
32+
Download AzLink, add it to the `plugins` or `mods` folder of your server, and restart your server.
2633

2734
## Building
2835

@@ -61,11 +68,14 @@ When the shop and/or vote plugins are installed on your Azuriom website, the int
6168
* `%azlink_vote_top_[position]_votes%`: vote count of player at given position in ranking
6269
* `%azlink_vote_goal_progress%`: number of votes currently counted toward the monthly vote goal
6370
* `%azlink_vote_goal_target%`: total number of votes required to reach the monthly vote goal
71+
* `%azlink_vote_goal_percentage%`: percentage progress toward the monthly vote goal
72+
* `%azlink_vote_goal_progressbar%`: progress bar of recent votes toward the monthly vote goal
6473

6574
### Shop Placeholders
6675
* `%azlink_shop_goal_progress%`: current progress of the shop goal this month
6776
* `%azlink_shop_goal_total%`: total amount of the shop goal this month
6877
* `%azlink_shop_goal_percentage%`: percentage progress of the shop goal this month
78+
* `%azlink_shop_goal_progressbar%`: progress bar of the shop goal this month
6979
* `%azlink_shop_top_[position]_name%`: name of top customer at given position this month
7080
* `%azlink_shop_top_[position]_amount%`: amount spent by top customer at given position
7181
* `%azlink_shop_top_[position]_currency%`: currency of top customer at given position

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
allprojects {
22
group = 'com.azuriom'
3-
version = '1.3.11'
3+
version = '1.3.12'
44
}
55

66
subprojects {

bukkit/src/main/java/com/azuriom/azlink/bukkit/command/BukkitCommandSender.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
package com.azuriom.azlink.bukkit.command;
22

3+
import com.azuriom.azlink.common.chat.AdventureComponentAdapter;
34
import com.azuriom.azlink.common.chat.TextComponent;
45
import com.azuriom.azlink.common.command.CommandSender;
56
import org.bukkit.ChatColor;
67
import org.bukkit.entity.Entity;
8+
import org.bukkit.entity.Player;
79

810
import java.nio.charset.StandardCharsets;
911
import java.util.UUID;
1012

1113
public class BukkitCommandSender implements CommandSender {
1214

15+
private static final boolean ADVENTURE_SUPPORT;
16+
17+
static {
18+
boolean adventureSupport = true;
19+
20+
try {
21+
Class<?> component = Class.forName("net.kyori.adventure.text.Component");
22+
Player.class.getMethod("sendMessage", component);
23+
} catch (ClassNotFoundException | NoSuchMethodException e) {
24+
adventureSupport = false;
25+
}
26+
27+
ADVENTURE_SUPPORT = adventureSupport;
28+
}
29+
1330
private final org.bukkit.command.CommandSender sender;
1431

1532
public BukkitCommandSender(org.bukkit.command.CommandSender sender) {
@@ -37,6 +54,11 @@ public void sendMessage(String message) {
3754

3855
@Override
3956
public void sendMessage(TextComponent message) {
57+
if (ADVENTURE_SUPPORT) {
58+
this.sender.sendMessage(AdventureComponentAdapter.toAdventure(message));
59+
return;
60+
}
61+
4062
sendMessage(message.toMinecraftLegacy());
4163
}
4264

bukkit/src/main/java/com/azuriom/azlink/bukkit/injector/InjectedHttpServer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ public InjectedHttpServer(AzLinkBukkitPlugin plugin) {
3232
public void start() {
3333
// Make sure Netty isn't relocated
3434
if (!HttpDecoder.class.getSuperclass().getName().startsWith("io.")) {
35-
plugin.getLoggerAdapter().error("Injecting HTTP server on server channel is not supported with AzLink legacy.");
35+
this.plugin.getLoggerAdapter().error("Injecting HTTP server on server channel is not supported with AzLink legacy.");
3636
return;
3737
}
3838

3939
if (!Bukkit.getServer().getClass().getSimpleName().equals("CraftServer")) {
40-
plugin.getLoggerAdapter().error("Injecting HTTP server on server channel is only supported on CraftBukkit based servers. You can use an other port for AzLink.");
40+
this.plugin.getLoggerAdapter().error("Injecting HTTP server on server channel is only supported on CraftBukkit based servers. You can use an other port for AzLink.");
4141
return;
4242
}
4343

4444
try {
4545
inject();
4646
} catch (Exception e) {
47-
plugin.getLoggerAdapter().error("Unable to inject HTTP server. Try using a different port for AzLink", e);
47+
this.plugin.getLoggerAdapter().error("Unable to inject HTTP server. Try using a different port for AzLink", e);
4848
}
4949
}
5050

@@ -82,7 +82,7 @@ private void inject() throws Exception {
8282

8383
injectServerChannel((ChannelFuture) item);
8484

85-
plugin.getLoggerAdapter().info("HTTP server successfully injected.");
85+
this.plugin.getLoggerAdapter().info("HTTP server successfully injected.");
8686

8787
return;
8888
}
@@ -96,7 +96,7 @@ public void uninject() {
9696
return; // We are not injected
9797
}
9898

99-
Channel channel = serverChannel.channel();
99+
Channel channel = this.serverChannel.channel();
100100

101101
channel.eventLoop().submit(() -> {
102102
try {
@@ -106,7 +106,7 @@ public void uninject() {
106106
}
107107
});
108108

109-
serverChannel = null;
109+
this.serverChannel = null;
110110
}
111111

112112
private void injectServerChannel(ChannelFuture future) {
@@ -139,9 +139,9 @@ private ChannelHandler createChannelHandler() {
139139
@Override
140140
protected void initChannel(Channel channel) {
141141
try {
142-
channel.eventLoop().submit(() -> channel.pipeline().addFirst(new HttpDecoder(plugin.getPlugin())));
142+
channel.eventLoop().submit(() -> channel.pipeline().addFirst(new HttpDecoder(InjectedHttpServer.this.plugin.getPlugin())));
143143
} catch (Exception e) {
144-
plugin.getLoggerAdapter().error("Unable to init channel", e);
144+
InjectedHttpServer.this.plugin.getLoggerAdapter().error("Unable to init channel", e);
145145
}
146146
}
147147
};

bukkit/src/main/java/com/azuriom/azlink/bukkit/injector/NettyLibraryLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private void loadLibrary(String groupId, String artifactId, String version) thro
6363
}
6464

6565
URL[] urls = {jar.toUri().toURL()};
66-
ClassLoader classLoader = plugin.getClass().getClassLoader();
66+
ClassLoader classLoader = this.plugin.getClass().getClassLoader();
6767
Field classLoaderField = classLoader.getClass().getDeclaredField("libraryLoader");
6868

6969
classLoaderField.setAccessible(true);

bukkit/src/main/java/com/azuriom/azlink/bukkit/placeholders/BasePlaceholderExpansion.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public boolean persist() {
6969
public void start() {
7070
this.providers.put("money", new MoneyPlaceholderProvider());
7171

72-
if (plugin.getConfig().getBoolean("placeholders.shop")) {
73-
this.providers.put("shop", new ShopPlaceholderProvider(plugin));
72+
if (this.plugin.getConfig().getBoolean("placeholders.shop")) {
73+
this.providers.put("shop", new ShopPlaceholderProvider(this.plugin));
7474
this.plugin.getLogger().info("Shop placeholders successfully enabled.");
7575
}
7676

77-
if (plugin.getConfig().getBoolean("placeholders.vote")) {
78-
this.providers.put("vote", new VotePlaceholderProvider(plugin));
77+
if (this.plugin.getConfig().getBoolean("placeholders.vote")) {
78+
this.providers.put("vote", new VotePlaceholderProvider(this.plugin));
7979
this.plugin.getLogger().info("Vote placeholders successfully enabled.");
8080
}
8181
}

bukkit/src/main/java/com/azuriom/azlink/bukkit/placeholders/PlaceholderProvider.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.azuriom.azlink.bukkit.placeholders;
22

3+
import com.google.common.base.Strings;
34
import me.clip.placeholderapi.PlaceholderAPIPlugin;
5+
import org.bukkit.ChatColor;
46
import org.bukkit.OfflinePlayer;
7+
import org.bukkit.configuration.ConfigurationSection;
58

69
import java.time.Duration;
710
import java.time.Instant;
@@ -47,4 +50,14 @@ default String formatDuration(String format, Duration duration) {
4750
.replace("%m", Long.toString(minutes))
4851
.replace("%s", Long.toString(seconds));
4952
}
53+
54+
default String formatProgressBar(double progress, ConfigurationSection config) {
55+
int totalLength = config.getInt("progress-bar.length", 15);
56+
String fill = config.getString("progress-bar.fill", "█");
57+
String separator = config.getString("progress-bar.separator", "&7");
58+
int filled = (int) Math.round(totalLength * Math.max(Math.min(progress, 1), 0));
59+
String sep = ChatColor.translateAlternateColorCodes('&', separator);
60+
61+
return Strings.repeat(fill, filled) + sep + Strings.repeat(fill, totalLength - filled);
62+
}
5063
}

bukkit/src/main/java/com/azuriom/azlink/bukkit/placeholders/ShopPlaceholderProvider.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.azuriom.azlink.bukkit.AzLinkBukkitPlugin;
44
import com.azuriom.azlink.common.http.client.HttpClient;
5-
import com.google.common.base.Strings;
6-
import org.bukkit.ChatColor;
75
import org.bukkit.OfflinePlayer;
6+
import org.bukkit.configuration.file.FileConfiguration;
87
import org.bukkit.scheduler.BukkitTask;
98

109
import java.time.Instant;
@@ -36,6 +35,7 @@ public List<String> availablePlaceholders() {
3635
"%azlink_shop_goal_progress%",
3736
"%azlink_shop_goal_total%",
3837
"%azlink_shop_goal_percentage%",
38+
"%azlink_shop_goal_progressbar%",
3939
"%azlink_shop_top_[position]_name%",
4040
"%azlink_shop_top_[position]_amount%",
4141
"%azlink_shop_top_[position]_currency%",
@@ -81,16 +81,14 @@ private String goalPlaceholder(String type) {
8181

8282
switch (type) {
8383
case "progress":
84-
return String.valueOf(this.goalProgress);
84+
return Double.toString(this.goalProgress);
8585
case "total":
86-
return String.valueOf(this.goalTotal);
86+
return Double.toString(this.goalTotal);
8787
case "percentage":
8888
return String.format("%.2f%%", proportion * 100);
8989
case "progressbar":
90-
int length = 15;
91-
int filled = (int) Math.round(length * Math.min(proportion, 1));
92-
93-
return Strings.repeat("■", filled) + ChatColor.GRAY + Strings.repeat("■", length - filled);
90+
FileConfiguration config = this.plugin.getConfig();
91+
return formatProgressBar(proportion, config.getConfigurationSection("placeholders"));
9492
default:
9593
return null;
9694
}

bukkit/src/main/java/com/azuriom/azlink/bukkit/placeholders/VotePlaceholderProvider.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.azuriom.azlink.common.http.client.HttpClient;
55
import com.google.gson.annotations.SerializedName;
66
import org.bukkit.OfflinePlayer;
7+
import org.bukkit.configuration.file.FileConfiguration;
78
import org.bukkit.entity.Player;
89
import org.bukkit.event.EventHandler;
910
import org.bukkit.event.HandlerList;
@@ -67,7 +68,9 @@ public List<String> availablePlaceholders() {
6768
"%azlink_vote_top_[position]_name%",
6869
"%azlink_vote_top_[position]_votes%",
6970
"%azlink_vote_goal_target%",
70-
"%azlink_vote_goal_progress%"
71+
"%azlink_vote_goal_progress%",
72+
"%azlink_vote_goal_percentage%",
73+
"%azlink_vote_goal_progressbar%"
7174
);
7275
}
7376

@@ -139,30 +142,36 @@ private String userCanPlaceholder(String[] parts, OfflinePlayer player) throws N
139142
return null;
140143
}
141144

142-
private String goalPlaceholder(String action) {
145+
private String goalPlaceholder(String type) {
143146
VoteGoal goal = this.goal;
147+
double proportion = goal != null ? (double) goal.progress / goal.target : 0;
144148

145-
switch (action) {
149+
switch (type) {
146150
case "target":
147151
return goal != null ? Integer.toString(goal.target) : "0";
148152
case "progress":
149153
return goal != null ? Integer.toString(goal.progress) : "0";
154+
case "percentage":
155+
return String.format("%.2f%%", proportion * 100);
156+
case "progressbar":
157+
FileConfiguration config = this.plugin.getConfig();
158+
return formatProgressBar(proportion, config.getConfigurationSection("placeholders"));
150159
default:
151160
return null;
152161
}
153162
}
154163

155164
private String sitePlaceholder(String[] parts) throws NumberFormatException {
156165
if (parts[1].equals("count")) {
157-
return Integer.toString(voteSites.size());
166+
return Integer.toString(this.voteSites.size());
158167
}
159168

160169
if (parts.length < 3) {
161170
return null;
162171
}
163172

164173
int id = Integer.parseInt(parts[1]);
165-
VoteSite site = voteSites.get(id);
174+
VoteSite site = this.voteSites.get(id);
166175

167176
if (site == null) {
168177
return "<unknown>";

0 commit comments

Comments
 (0)