WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 3edef1c

Browse files
committed
Bump API and plugin version for release
1 parent 0c835da commit 3edef1c

File tree

9 files changed

+62
-52
lines changed

9 files changed

+62
-52
lines changed

bukkit/src/main/java/ch/andre601/advancedserverlist/bukkit/objects/PAPIPlaceholders.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ public String onPlaceholderRequest(Player pl, @NotNull String identifier){
9191

9292
ProfileEntry entry = ProfileManager.merge(profile);
9393

94-
if(ProfileManager.checkOption(entry.isExtraPlayersEnabled()))
95-
max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount());
94+
if(ProfileManager.checkOption(entry.extraPlayersEnabled()))
95+
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
9696

9797
GenericServer finalServer = new GenericServerImpl(online, max, host);
9898

9999
return switch(identifier.toLowerCase(Locale.ROOT)){
100-
case "motd" -> ComponentParser.list(entry.getMotd())
100+
case "motd" -> ComponentParser.list(entry.motd())
101101
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
102102
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
103103
.toString();
104-
case "favicon" -> ComponentParser.text(entry.getFavicon())
104+
case "favicon" -> ComponentParser.text(entry.favicon())
105105
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
106106
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
107107
.toString();
108-
case "playercount_hover" -> ComponentParser.list(entry.getPlayers())
108+
case "playercount_hover" -> ComponentParser.list(entry.players())
109109
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
110110
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
111111
.toString();
112-
case "playercount_text" -> ComponentParser.text(entry.getPlayerCountText())
112+
case "playercount_text" -> ComponentParser.text(entry.playerCountText())
113113
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
114114
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
115115
.toString();
@@ -126,7 +126,7 @@ private int resolveProtocol(Player player){
126126
if(plugin instanceof SpigotCore)
127127
return ProtocolLibrary.getProtocolManager().getProtocolVersion(player);
128128

129-
// getProtocolVersion is only in Paper, so this is only called when
129+
// getProtocolVersion is only in Paper, so this is only called when main class isn't SpigotCore
130130
return Bukkit.getUnsafe().getProtocolVersion();
131131
}
132132

bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/SpigotCore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
3535
import ch.andre601.advancedserverlist.spigot.events.LoadEvent;
3636
import com.comphenix.protocol.wrappers.WrappedServerPing;
37+
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
3738
import org.bstats.bukkit.Metrics;
3839
import org.bstats.charts.SimplePie;
3940
import org.bukkit.command.PluginCommand;
@@ -78,7 +79,7 @@ public void loadCommands(){
7879
getPluginLogger().warn("Unable to register command /advancedserverlist");
7980
return;
8081
}
81-
cmd.setExecutor(new CmdAdvancedServerList(this));
82+
cmd.setExecutor(new CmdAdvancedServerList(this, BukkitAudiences.create(this)));
8283
}
8384

8485
@Override

bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/events/ProtocolLibEventWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public void setDefaultFavicon(){
124124

125125
// Not used in ProtocolLib
126126
@Override
127-
public void updateEvent(){}
127+
public void updateEvent(){
128+
event.getPacket().getServerPings().write(0, ping);
129+
}
128130

129131
@Override
130132
public boolean isInvalidProtocol(){

core/src/main/java/ch/andre601/advancedserverlist/core/commands/CommandHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void handle(CmdSender sender){
116116
core.clearPlayerCache();
117117
sender.sendPrefixedMsg("<green>Successfully cleared Player Cache!");
118118

119-
sender.sendErrorMsg("<green>Reload complete!");
119+
sender.sendPrefixedMsg("<green>Reload complete!");
120120
}
121121
}
122122

core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,43 +68,43 @@ public static <F, P extends GenericPlayer> void handleEvent(GenericEventWrapper<
6868
if(entry.isInvalid())
6969
return;
7070

71-
if(ProfileManager.checkOption(entry.isExtraPlayersEnabled())){
72-
max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount());
71+
if(ProfileManager.checkOption(entry.extraPlayersEnabled())){
72+
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
7373
event.setMaxPlayers(max);
7474
}
7575

7676
GenericServer finalServer = new GenericServerImpl(online, max, host);
7777

78-
if(ProfileManager.checkOption(entry.getMotd())){
78+
if(ProfileManager.checkOption(entry.motd())){
7979
event.setMotd(
80-
ComponentParser.list(entry.getMotd())
80+
ComponentParser.list(entry.motd())
8181
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
8282
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
8383
.toComponent()
8484
);
8585
}
8686

87-
boolean hidePlayers = ProfileManager.checkOption(entry.isHidePlayersEnabled());
87+
boolean hidePlayers = ProfileManager.checkOption(entry.hidePlayersEnabled());
8888

8989
if(hidePlayers){
9090
event.hidePlayers();
9191
}
9292

93-
if(ProfileManager.checkOption(entry.getPlayerCountText()) && !hidePlayers){
93+
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers){
9494
event.setPlayerCount(
95-
ComponentParser.text(entry.getPlayerCountText())
95+
ComponentParser.text(entry.playerCountText())
9696
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
9797
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
9898
.toString()
9999
);
100100
}
101101

102-
if(ProfileManager.checkOption(entry.getPlayers()) && !hidePlayers){
103-
event.setPlayers(entry.getPlayers(), player, server);
102+
if(ProfileManager.checkOption(entry.players()) && !hidePlayers){
103+
event.setPlayers(entry.players(), player, server);
104104
}
105105

106-
if(ProfileManager.checkOption(entry.getFavicon())){
107-
String favicon = StringReplacer.replace(entry.getFavicon(), player, server);
106+
if(ProfileManager.checkOption(entry.favicon())){
107+
String favicon = StringReplacer.replace(entry.favicon(), player, server);
108108

109109
F fav = plugin.getFaviconHandler().getFavicon(favicon, image -> {
110110
try{

core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileManager.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static boolean checkOption(Object obj){
9999
return !list.isEmpty(); // Check if list isn't empty
100100
}else
101101
if(obj instanceof String str){
102-
return !str.isEmpty(); // Check if list is not empty
102+
return !str.isEmpty(); // Check if String is not empty
103103
}else
104104
if(obj instanceof NullBool nb){
105105
return nb.getOrDefault(false); // Return NullBool's value
@@ -109,52 +109,52 @@ public static boolean checkOption(Object obj){
109109
}
110110

111111
private static List<String> resolveMOTD(ProfileEntry profile, ProfileEntry defaultProfile){
112-
if(profile == null || !checkOption(profile.getMotd()))
113-
return defaultProfile.getMotd();
112+
if(profile == null || !checkOption(profile.motd()))
113+
return defaultProfile.motd();
114114

115-
return profile.getMotd();
115+
return profile.motd();
116116
}
117117

118118
private static List<String> resolvePlayers(ProfileEntry profile, ProfileEntry defaultProfile){
119-
if(profile == null || !checkOption(profile.getPlayers()))
120-
return defaultProfile.getPlayers();
119+
if(profile == null || !checkOption(profile.players()))
120+
return defaultProfile.players();
121121

122-
return profile.getPlayers();
122+
return profile.players();
123123
}
124124

125125
private static String resolvePlayerCountText(ProfileEntry profile, ProfileEntry defaultProfile){
126-
if(profile == null || !checkOption(profile.getPlayerCountText()))
127-
return defaultProfile.getPlayerCountText();
126+
if(profile == null || !checkOption(profile.playerCountText()))
127+
return defaultProfile.playerCountText();
128128

129-
return profile.getPlayerCountText();
129+
return profile.playerCountText();
130130
}
131131

132132
private static String resolveFavicon(ProfileEntry profile, ProfileEntry defaultProfile){
133-
if(profile == null || !checkOption(profile.getFavicon()))
134-
return defaultProfile.getFavicon();
133+
if(profile == null || !checkOption(profile.favicon()))
134+
return defaultProfile.favicon();
135135

136-
return profile.getFavicon();
136+
return profile.favicon();
137137
}
138138

139139
private static boolean resolveHidePlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){
140-
if(profile == null || !checkOption(profile.isHidePlayersEnabled()))
141-
return defaultProfile.isHidePlayersEnabled().getOrDefault(false);
140+
if(profile == null || !checkOption(profile.hidePlayersEnabled()))
141+
return defaultProfile.hidePlayersEnabled().getOrDefault(false);
142142

143-
return profile.isHidePlayersEnabled().getOrDefault(false);
143+
return profile.hidePlayersEnabled().getOrDefault(false);
144144
}
145145

146146
private static boolean resolveExtraPlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){
147-
if(profile == null || !checkOption(profile.isExtraPlayersEnabled()))
148-
return defaultProfile.isExtraPlayersEnabled().getOrDefault(false);
147+
if(profile == null || !checkOption(profile.extraPlayersEnabled()))
148+
return defaultProfile.extraPlayersEnabled().getOrDefault(false);
149149

150-
return profile.isExtraPlayersEnabled().getOrDefault(false);
150+
return profile.extraPlayersEnabled().getOrDefault(false);
151151
}
152152

153153
private static Integer resolveExtraPlayersCount(ProfileEntry profile, ProfileEntry defaultProfile){
154-
if(profile == null || profile.getExtraPlayersCount() == null)
155-
return defaultProfile.getExtraPlayersCount() == null ? 0 : defaultProfile.getExtraPlayersCount();
154+
if(profile == null || profile.extraPlayersCount() == null)
155+
return defaultProfile.extraPlayersCount() == null ? 0 : defaultProfile.extraPlayersCount();
156156

157-
return profile.getExtraPlayersCount();
157+
return profile.extraPlayersCount();
158158
}
159159

160160
private static List<String> resolveList(ConfigurationNode node, Object... path){

core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileSerializer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public void serialize(Type type, @Nullable ProfileEntry profile, ConfigurationNo
4848
return;
4949
}
5050

51-
node.node("motd").set(profile.getMotd());
52-
node.node("playerCount", "hover").set(profile.getPlayers());
53-
node.node("playerCount", "text").set(profile.getPlayerCountText());
54-
node.node("favicon").set(profile.getFavicon());
55-
node.node("playerCount", "hidePlayers").set(profile.isHidePlayersEnabled());
56-
node.node("playerCount", "extraPlayers", "enabled").set(profile.isExtraPlayersEnabled());
57-
node.node("playerCount", "extraPlayers", "amount").set(profile.getExtraPlayersCount());
51+
node.node("motd").set(profile.motd());
52+
node.node("playerCount", "hover").set(profile.players());
53+
node.node("playerCount", "text").set(profile.playerCountText());
54+
node.node("favicon").set(profile.favicon());
55+
node.node("playerCount", "hidePlayers").set(profile.hidePlayersEnabled());
56+
node.node("playerCount", "extraPlayers", "enabled").set(profile.extraPlayersEnabled());
57+
node.node("playerCount", "extraPlayers", "amount").set(profile.extraPlayersCount());
5858
}
5959
}

docs/api/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
This page lists the recent changes made towards the AdvancedServerListAPI.
44
They are ordered newest to oldest.
55

6+
## v2.1.0
7+
8+
### :octicons-pencil-24:{ .changelog-changed title="Changed" } Changed { #v-changed }
9+
10+
- Turned `ProfileEntry` class into a record
11+
- Former `getX()` methods are now deprecated in favour of the recor's own `x()` methods (i.e. `getMotd()` -> `motd()`)
12+
613
## v2.0.0
714

815
### :octicons-alert-24:{ .changelog-breaking title="Breaking Changes" } Breaking Changes { #v2-breaking }

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
<properties>
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939

40-
<plugin.version>3.0.0-b1</plugin.version>
40+
<plugin.version>3.0.0-b2</plugin.version>
4141
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
4242

43-
<api.version>v2.0.0</api.version>
43+
<api.version>v2.1.0</api.version>
4444

4545
<maven.compiler.source>16</maven.compiler.source>
4646
<maven.compiler.target>16</maven.compiler.target>

0 commit comments

Comments
 (0)